On Saturday, 16 June 2018 at 19:20:30 UTC, FromAnotherPlanet wrote:
- Interface segregation principal: Essentially breaking the program up into smaller interfaces. Sometimes only consistent of one or two methods/properties (can feed into 'S' of SOLID quite nicely).

- Dependency inversion principle: Things should depend on abstractions not concretions. Strongly enables dependency injection.

D seems to have all of the features *required* to make this happen, but I guess the real question is the last two, and more specifically the last one.

Then D supports everything you need (and even better, just look at interface with contracts: https://dlang.org/spec/interface.html)

Interface segregation example: https://run.dlang.io/gist/6aa1710dd5a8327f20e605b0ac3b978f

Keep in mind that D doesn't support multiple inheritance, so if you want to follow DRY principle, you need to use interfaces + template mixins to make it happen (so in this point D is way better than the plain Java, because D's templates mixins are like traits).

Dependency injection is also supported. However, D doesn't supply any DI containers in its standard library, so you have to rely on 3rd-party components, or implement it on your own.

Look at this page: https://wiki.dlang.org/Dependency_Injection_Containers The most popular and actively maintained are "aedi" and "poodinis".

Reply via email to