上通大Implement Application domain classes SHANGHAI JIAO TONG UNIVERSITY To collapse or not collapse:Attribute or association? Object design choices: Implement entity as embedded attribute Implement entity as separate class with associations to other classes Associations are more flexible than attributes but often introduce unnecessary indirection. Software Engineering
Software Engineering Implement Application domain classes To collapse or not collapse: Attribute or association? Object design choices: • Implement entity as embedded attribute • Implement entity as separate class with associations to other classes Associations are more flexible than attributes but often introduce unnecessary indirection
上游充通大学 Optimization Activities:Collapsing Objects SHANGHAI JIAO TONG UNIVERSITY Every student receives a number at the first day in in the university. Matrikelnumber Student ID:String Student Matrikelnumber:String Software Engineering
Software Engineering Optimization Activities: Collapsing Objects Student Matrikelnumber ID:String Student Matrikelnumber:String Every student receives a number at the first day in in the university
上游充通大 To Collapse or not to Collapse? SHANGHAI JIAO TONG UNIVERSITY Collapse a class into an attribute if the only operations defined on the attributes are Set() and Get(). Software Engineering
Software Engineering To Collapse or not to Collapse? Collapse a class into an attribute if the only operations defined on the attributes are Set() and Get()
上浒充通大Design Optimizations(continued) SHANGHAI JIAO TONG UNIVERSITY Store derived attributes Example:Define new classes to store information locally (database cache) Problem with derived attributes: Derived attributes must be updated when base values change. There are 3 ways to deal with the update problem: Explicit code:Implementor determines affected derived attributes (push) Periodic computation:Recompute derived attribute occasionally(pull) Active value:An attribute can designate set of dependent values which are automatically updated when active value is changed(notification,data trigger) Software Engineering
Software Engineering Design Optimizations (continued) Store derived attributes • Example: Define new classes to store information locally (database cache) Problem with derived attributes: • Derived attributes must be updated when base values change. • There are 3 ways to deal with the update problem: • Explicit code: Implementor determines affected derived attributes (push) • Periodic computation: Recompute derived attribute occasionally (pull) • Active value: An attribute can designate set of dependent values which are automatically updated when active value is changed (notification, data trigger)
上游究通大学 Optimization Activities:Delaying Complex SHANGHAI JIAO TONG UNIVERSITY Computations Image filename:String data:byte[] width() height() paint( Image filename:String width() height() paint() image ImageProxy 0..1 RealImage 1 filename:String data:byte[l width() width() height() height() paint( paintO Software Engineering
Software Engineering Optimization Activities: Delaying Complex Computations Image filename:String width() height() paint() Image filename:String width() height() paint() RealImage width() height() paint() data:byte[] data:byte[] ImageProxy filename:String width() height() paint() image 1 0..1