File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Stereotype Vs constraint Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Stereotype Vs constraint" Watch "Stereotype Vs constraint" New topic
Author

Stereotype Vs constraint

Poornachandran R
Ranch Hand

Joined: Sep 11, 2002
Posts: 47
Hai all,
Can anyone explain when to use stereotype and when to use constraints ? I think it is worth knowing the difference.
Poorna
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Stereotypes result in a logical classification of classes in your system - they create sort of buckets.. By tagging a class as a particular sterotype, you are documenting a common behavior, responsibilities and restrictions on all classes belonging to that stereotype. For instance, by tagging a class as a <<SingleThreadModel>>, you are saying everything that is true for a SingleThreadModel are true for this class too.
Constraints on the otherhand, can be very specific to a particular object state or variation of a class. It is a sort of a global rule on all objects of that class, sometimes referred to as "covariants". They can be used with or without stereotypes, but when used in conjunction with stereotypes, they act as subqualifiers ie., add more qualifications. For instance, a class can have a stereotype of <<DependentObject>> and can have a constraint that says AccountBalance > 1550. As you can see, constraints almost always are applied on attributes, and hence has an implicit reference to the object state.
It is a good idea to use stereotypes, but be careful when using constraints and avoid them if possible. You should not use constraints unless they are applicable to all instances ie., you should be able to pick an instance of the class at random and should be able to evaluate the constraint. From a cosmetic point of view, they tend to clutter the class diagram, espcially when the model evolves during the course of time and you end up adding more and more constraints....


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Poornachandran R
Ranch Hand

Joined: Sep 11, 2002
Posts: 47
Thanks a lot Ajith.
Then, for abstract class, how is abstract defined as a constraint {abstract} ?
Poorna
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
<<abstract>>
Kuan Fan
Ranch Hand

Joined: Jan 25, 2002
Posts: 48
Perfect explaination for Stereotype and Constraint
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stereotype Vs constraint