OCUP 2 Intermediate study materials
OCUP 2 Intermediate study resources

OCUP 2 Intermediate: Improving Upon Other Models

OCUP 2 Intermediate · Work through your exam, one topic at a time.

All guide sections

Improving Upon Other Models

What the domain tests

This domain asks you to improve an existing model without breaking its semantics: refactoring, pattern application, profiles and stereotypes, OCL constraints, consistency checks, traceability, and controlled transformation.

Core rules

  • Refactorings such as Extract Superclass, Pull Up Property, Replace Inheritance with Delegation, and Rename must preserve behavior and update all references, imports, redefinitions, and substitutions.
  • A Profile defines Stereotypes that extend metaclasses; a stereotype may carry tagged values. Applying a stereotype without its profile is invalid.
  • OCL invariants add precision (context Order inv: self.customer->notEmpty()). Use OCL for domain rules, not for metamodel rules already enforced by UML.
  • Model smells include duplicate attributes, ambiguous multiplicities, orphan classes, cyclic package dependencies, and associations that should be composite.

Worked example

A model stores Order.shippingAddress: String and Customer.address: String, while Warehouse uses a separate Address class. Improve it by introducing Address, replacing both strings with associations, and adding {unique} to Order.customer. If an address cannot be shared and dies with its owner, use composite aggregation. Reasoning: one concept, one type; multiplicities become explicit; lifecycle is stated. Check that existing imports still resolve.

Traps

Do not replace an association with an attribute unless you accept losing navigability and multiplicity. Do not use OCL to restate a metamodel rule. Do not rename an element without updating imports and redefinitions. Do not apply a stereotype that has no profile. Do not treat package merge as a refactoring shortcut.