• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

More about the domain objects in the domain layer

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are domain objects only suppose to have getters and setters or can they have methods as well ??
Example Student domain object would be getters and setters for private variables RollNo,GPA,ContactNo however can it have other methods related to student such as GetResultFromDB() etc ??
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you assign other responsibilities to a domain object like fetching from db, then you are violating Single responsibility principle and the design becomes less cohesive.
 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mohamed Sanaulla wrote:If you assign other responsibilities to a domain object like fetching from db, then you are violating Single responsibility principle and the design becomes less cohesive.


I completely agree with that. A couple of question come to mind regarding this issue
1-An application theoretically contains domain,service,business and service layer are other layers allowed to access the domain objects or is the service layer only allowed to access them to provide services to other layers

 
Mohamed Sanaulla
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rajesh Khan wrote:

Mohamed Sanaulla wrote:If you assign other responsibilities to a domain object like fetching from db, then you are violating Single responsibility principle and the design becomes less cohesive.


I completely agree with that. A couple of question come to mind regarding this issue
1-An application theoretically contains domain,service,business and service layer are other layers allowed to access the domain objects or is the service layer only allowed to access them to provide services to other layers


I dont know about this, but ideally the layer should communicate with the layer above it or below it and not across other layers. For example you can consider the OSI model of computer networks. If there is a dependency across different layers than changing one of the layers might lead to change in lot of other layers and also it would be not so easy to identify which other layers it would communicate to. I might be wrong, but I drew these conclusions by comparing the concept of layered architecture.

This might partly answer your other query here.
 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my opinion i think other layers can also access domain objects. Suppose the buisness object wanted to create new domain object so it must be able to access that class. Thats my opinion please correct me if i am wrong..
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mohamed's right about adding methods like data access to the domain objects. But what about domain logic? That's a more philosophical question. Classical Object-Oriented methods would put most of the domain logic in the domain objects. But Service Oriented approaches tend to avoid that - they use what I've heard call an "anaemic domain model", where you restrict domain objects to the basics and have all the domain logic provided by your services. Both are valid approaches.

It's also a bit of a philosophical question as to whether you expose the domain objects. In a layered architecture you just need to make sure that all dependencies go downwards - lower layers don't call upper layers. But there's also the concept of a strict layered architecture, where each layer is supposed to depend only on the layer immediately below. It gives you the advantage of reduced coupling (so if you want to replace a layer you only have to consider the one above) at the cost of more infrastructure. I would suggest that updating the domain objects should be forced to go through the service layer, though.

So "it depends" .
 
Mohamed Sanaulla
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Matthew, that was quite a lot informative
 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks you Matthew and Mohammed
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic