Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java beans and oo

 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are Java beans non-OO because they have no behaviour.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, because of a simple, but common misunderstanding: Java Beans can have behaviour.

Ok, so is a Java Bean without behaviour non-OO?

Well, I couldn't tell. OOD/P isn't about the structure of isolated classes, it is about managing the dependencies between the classes inside a system.

Well designed systems may still contain classes with only data and no behaviour - DTOs are an example. You should be wary if you have many of those, though, as they are an indication of an Anemic Domain Model.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, because of a simple, but common misunderstanding: Java Beans can have behaviour.


Right but I hardly see it. Entity beans are another example which is nothing but a class get/set and lifecycle methods.

Anemic Domain Model.


What is that ? Thanks Ilja for your reply.
 
Vagner Freitas
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Anemic Domain Model is an anti-pattern published for Martin Fowler.

Vagner
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic