I currently work on a lightweight Dependency Injection framework. While I find it quite handy, I was unhappy with the boilerplate involved in writing constructors.
Inspired by features like Constructor Property Promotion in PHP/Hack and Parameter Properties in TypeScript, I've written something similar for D, except that it works the other way round.
Code sample
// regular way
class Service {
private {
Database db;
Logger logger;
}
public this(
Database db,
Logger logger,
) {
this.db = db;
this.logger = logger;
}
}
becomes:
class Service {
private @dependency {
Database db;
Logger logger;
}
mixin DependencyAssignmentConstructor;
}
Basically something also available in funkwerk-mobility's boilerplate but much more targeted at the DI use-case.
If you had to come up with a fancy name in the spirit of the PHP, TypeScript etc. counterparts, how would you name the concept applied here?