上游充通大学 2.1 State of the Art of Model-based Software SHANGHAI JIAO TONG UNIVERSITY Engineering The Vision During object design we would like to implement a system that realizes the use cases specified during requirements elicitation and system design. The Reality Different developers usually handle contract violations differently. Undocumented parameters are often added to the API to address a requirement change. Additional attributes are usually added to the object model,but are not handled by the persistent data management system, possibly because of a miscommunication. Many improvised code changes and workarounds that eventually yield to the degradation of the system. Software Engineering
Software Engineering 2.1 State of the Art of Model-based Software Engineering The Vision • During object design we would like to implement a system that realizes the use cases specified during requirements elicitation and system design. The Reality • Different developers usually handle contract violations differently. • Undocumented parameters are often added to the API to address a requirement change. • Additional attributes are usually added to the object model, but are not handled by the persistent data management system, possibly because of a miscommunication. • Many improvised code changes and workarounds that eventually yield to the degradation of the system
上游充通大学 2.2 Model transformations SHANGHAI JIAO TONG UNIVERSITY Forward engineering Refactoring Model transformation Reverse engineering Model space Source code space Software Engineering
Software Engineering 2.2 Model transformations Source code space Forward engineering Refactoring Reverse engineering Model space Model transformation
上克通大¥2.3 Model Transformation Example SHANGHAI JIAO TONG UNIVERSITY Object design model before transformation LeagueOwner Advertiser Player +email:Address email:Address +emai1 Address Object design model after transformation: User +email:Address LeagueOwner Advertiser Player Software Engineering
Software Engineering 2.3 Model Transformation Example Object design model before transformation Object design model after transformation: Advertiser +email:Address Player +email:Address LeagueOwner +email:Address LeagueOwner Advertiser Player User +email:Address
上通大Refactoring Example:Pull Up Field SHANGHAI JIAO TONG UNIVERSITY public class User private String email; public class Player extends public class Player User private String email; //... //... 3 3 public class LeagueOwner public class LeagueOwner extends User private String eMail; //... //... 3 3 public class Advertiser public class Advertiser extends User private String //... email_address; 3 //... } Software Engineering
Software Engineering Refactoring Example: Pull Up Field public class Player { private String email; //... } public class LeagueOwner { private String eMail; //... } public class Advertiser { private String email_address; //... } public class User { private String email; } public class Player extends User { //... } public class LeagueOwner extends User { //... } public class Advertiser extends User { //... }
上游充通大学 Refactoring Example:Pull Up Constructor SHANGHAI JIAO TONG UNIVERSITY Body public class User public class User private String email; public User(String email) this.email email; public class Player extends User 3 public class Player extends User public Player(String email){ this.email email; public Player(String email){ super(ema11); publ ic class LeagueOwner extends 3 eagueOwner(String Usert publ ic class LeagueOwner extends this.email email; User t 3 mieagueOwner(String 3 super(email); public class Adyertiser 3 extendsUser{ iAdvertiser(String this.email email; publ ic class Advertiser extends User t 3 dvertiser(String super(email); Software Engineering
Software Engineering Refactoring Example: Pull Up Constructor Body public class User { private String email; } public class Player extends User { public Player(String email) { this.email = email; } } public class LeagueOwner extends User{ public LeagueOwner(String email) { this.email = email; } } public class Advertiser extendsUser{ public Advertiser(String email) { this.email = email; } } public class User { public User(String email) { this.email = email; } } public class Player extends User { public Player(String email) { super(email); } } public class LeagueOwner extends User { public LeagueOwner(String email) { super(email); } } public class Advertiser extends User { public Advertiser(String email) { super(email); } }