File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Data consistency & class design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Data consistency & class design" Watch "Data consistency & class design" New topic

Data consistency & class design

Shivani Chandna
Ranch Hand

Joined: Sep 18, 2004
Posts: 380
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 !
[ August 04, 2006: Message edited by: Shivani Chandna ]

/** Code speaks louder than words */
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
I'm not sure I understand the problem. Perhaps it would help if you showed us more code?

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Shivani Chandna
Ranch Hand

Joined: Sep 18, 2004
Posts: 380

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 ]
I agree. Here's the link:
subject: Data consistency & class design
It's not a secret anymore!