News for hackers. Stuff that matters.
Re:Are software engineering “best practices” just developer ... by bitwize on Thursday September 30, 2021 @01:36PM (#28708915)
> The language allows you to simply make a class. You're not required to make an interface and then make a class that implements it, and yet, Java programmers do it anyways and then criticize the language for being verbose.

That's the 'D' in SOLID -- dependency inversion. An object's dependencies should be defined in terms of abstract interfaces, not concrete classes. The verbosity is just boilerplate, and it would appear in any statically typed language if you're following SOLID principles.

> Getters and Setters? You probably don't need them. Classes can have public member variables.

Getters and setters are part of the JavaBeans spec for being able to load and configure arbitrary beans. If you're writing JavaBeans, as many EJB or Spring application developers are, you'll use getters and setters.

Re:Are software engineering “best practices” just developer ... by goto11 on Friday October 01, 2021 @04:02AM (#28715843)
> That's the 'D' in SOLID -- dependency inversion. An object's dependencies should be defined in terms of abstract interfaces, not concrete classes

DI does not talk about the interface keyword in Java. It talks about interface as the public surface of an object or system.

Programming to a Java interface declaration does not guarantee the code is depending on higher-level abstractions - this depends on how the interface is defined. An interface which just replicate the public surface of a class (a "header interface") is on the exact same abstraction level as the class, it just introduce needless boilerplate.

Re:Are software engineering “best practices” just developer ... by gpderetta on Friday October 01, 2021 @06:57AM (#28716815)
I.e. (together with the S and I) this implies that the interface should be defined by its immediate consumer and should consist of all and only the methods required to implement the functionality in the most straightforward way (i.e. the consumer shouldn't have to deal with the idiosyncrasies of the provider).

On most languages this requires a lot of boilerplate and indirections though.