File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data consistency & class design

 
Shivani Chandna
Ranch Hand
Posts: 380
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given 4 classes:



My question is - User and Role - both entities can have attributes linked to them,. So they have an instance of AttributeSet - which has list of attributes and operations to be performed on them defined.

But Attribute - have their own existence as well - they can exist independently of other entities and it can have some more behaviours defined - which may not be applicable when it is linked to any of the Entity.


How do I capture this in a class design?.

If I keep a reference of those attributes which are linked to the enity inside the entity class then - I have a problem of updating the "TOTAL" set when the individual attribute linked to the entity changes...

Or I do not keep attributes linked to the entity inside the entity class.,... but instead keep all of the attributes in AttributeSet class only...

Thanks !
Shivani.
[ August 04, 2006: Message edited by: Shivani Chandna ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I understand the problem. Perhaps it would help if you showed us more code?
 
Shivani Chandna
Ranch Hand
Posts: 380
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

User and Role are linked to attributes. But attribute can exist without the linkage also. Should the User or Role class "HAve" an instance of AttributeSet in them or not?

Or can we make AttributeSet have all the Attributes (Those linked to User and Role as well?) and make it responsible for any queries related to any attributes linked or not to any User or Role. In this case we get:

[ August 04, 2006: Message edited by: Shivani Chandna ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic