DEV Community

Discussion on: It’s all about the abstractions baby

Collapse
 
birdayz profile image
Johannes Brüderl

the moment when classes with behavior are considered the "least good abstraction"...after all Java is an objected oriented language.

I suggest to read martinfowler.com/bliki/AnemicDomai... .

Collapse
 
qm3ster profile image
Mihail Malo

Are you suggesting the database be hardcoded into the objects, or passed to the constructor?
Storage is not a concern of the business object "MyObject".

Collapse
 
birdayz profile image
Johannes Brüderl

no. it's a statement against shallow data classes without behavior.

Thread Thread
 
qm3ster profile image
Mihail Malo

I don't see why you'd assume MyObject doesn't have rich methods and doesn't protect its invariants.

Thread Thread
 
kritner profile image
Russ Hammett

Sorry maybe I'm missing something the purpose of this and your original comment, can you elaborate?

I didn't think there was really any model type classes in this post; save the undefined MyObject. I'm not saying that classes with behavior are bad, I meant more as if it's implementing an interface, then the consumers can work with the interface, rather than the concrete. This, at least in my opinion, is a better high level design, and makes it easier on consumers/callers to understand a system, rather than getting bogged down in the details of implementation.