This is an alternate profile for the Observer pattern where the Observer class hierarchy is collapsed into a single Observer object. This profile can be used when there is no need for an abstract Observer class. The difference in the profile compared to the first one is in the stereotype definition, OCL constraints, and multiplicities of stereotypes connected to the Observer class.
Profile download (Rational Rose model)
context Observer inv: not self.isAbstract context ObservedSubject inv: self.treeTop implies (self.isAbstract and self.sOS->size() = 1 and self.oSS->size() = 0 and self.attachOp->size() > 0 and self.detachOp->size() > 0 and self.notifyOp->size() > 0 and self.subjectState->size() = 0) inv: not self.treeTop implies (self.getStateOp->size() > 0 and self.setStateOp->size() > 0) inv: self.isAbstract implies (self.specialization->size() > 0 and self.specialization->forAll (c | c.child.oclIsKindOf (ObservedSubject))) inv: not self.isAbstract implies (self.oSS->size() > 0 and self.sOS->size() = 0 and self.subjectState->size() > 0) context aSubjectObserver inv: self.sOO.isNavigable and not self.sOS.isNavigable context aObserverSubject inv: self.oSS.isNavigable and not self.oSO.isNavigable
The incorrect instance diagram in this case is the correct instance of the original Observer profile with a class hierarchy for the Observer class. It is essentially the same class diagram with "2" appended to all class names to avoid namespace conflicts with the correct instance of this alternate profile. The tool will report errors at the association multiplicity (graphical constraint) level because of the changes to them for this alternate profile. MyObserver2 also violates the first OCL constraint for Observer but the tool does not check it until the graphical constraints are fixed, and in this case the user should realize that the profile does not have a class hierarchy for Observer.