Tutorial at Caise'2003, Velden, Austria
Total Page:16
File Type:pdf, Size:1020Kb
CAiSE 2003 Tutorial 23-April-2003 This presentation is based on: Developing Maintainable Systems – This presentation is based on: Roundtrip Engineering with Metrics Maciaszek, L.A. (2001): Requirements Analysis and System Design. Developing Information Systems with UML, Addison-Wesley, 378p. {translated to Chinese, Russian and Italian} forthcoming 2nd edition of the above: Tutorial Maciaszek, L.A. (2004): Requirements Analysis and The 15th Conf. on Advanced Information Systems Engineering CAiSE’03 Systems Design, 2nd ed., Addison-Wesley, ~500p. Velden, Austria, 17-June-2003 forthcoming new textbook: Leszek A. Maciaszek, Bruc Lee Liong Maciaszek, L.A. Liong, B.L. and Bills, S. (2004): Macquarie University, Sydney, Australia Practical Software Engineering. A Case-Study Approach, Addison-Wesley, ~600p. © L.A.Maciaszek, B.L.Liong & Addison-Wesley © Addison-Wesley CAiSE 2003 Tutorial 2 Topics The tutorial themes Application design objectives - PCMEF “Applications come and go. Databases stay for ever.” Tutorial case study – Email Management System Bob Epstein, Sybase (quoted from memory) Dependency management “Enterprise applications often have complex data – Generic architectural patterns and lots of it – to work on, together with business Architectural patterns for business objects rules that fail all tests of logical reasoning.” The supportability metrics “The architectural pattern I like the most is that of Conclusions layers…” Martin Fowler (in “Patterns of Enterprise Information Architecture”) © Addison-Wesley CAiSE 2003 Tutorial 3 © Addison-Wesley CAiSE 2003 Tutorial 4 Application design objectives MVC a hierarchical layering of software modules that reduces complexity and enhances Application Program understandability of module dependencies by disallowing direct object View intercommunication between non- Database and Web Services neighboring layers, and Model an enforcement of programming standards Persistent that make module dependencies visible in Data compile-time program structures and that Controller forbid muddy programming solutions utilizing just run-time program structures © Addison-Wesley CAiSE 2003 Tutorial 5 © Addison-Wesley CAiSE 2003 Tutorial 6 © L.A.Maciaszek, B.L. Liong & Addison- Wesley 1 CAiSE 2003 Tutorial 23-April-2003 PCMEF application packages <<layer>> Meaning of P-C-M-E-F presentation The Presentation package • classes that define UI objects <<layer>> The Control package control • classes responsible for the program’s logic, algorithmic solutions, and main computations The Mediator package <<layer>> • creates a level of independence between entity and foundation domain and between control and foundation PCMEF entity mediator • responsible for object caching Database and Web The Entity package Services • classes representing “business objects” <<layer>> Persistent The Foundation package foundation Data • responsible for all communications with the persistent data store © Addison-Wesley CAiSE 2003 Tutorial 7 © Addison-Wesley CAiSE 2003 Tutorial 8 Consider non-PCMEF design ...and PCMEF design CControl EEntity CControl MMediator PPresentation MMediator PPresentation EEntity FFoundation FFoundation © Addison-Wesley CAiSE 2003 Tutorial 9 © Addison-Wesley CAiSE 2003 Tutorial 10 PCMEF principles PCMEF+ Downward Dependency Principle (DDP) Upward Notification Principle (UNP) Neighbor Communication Principle (NCP) Explicit Association Principle (EAP) Cycle Elimination Principle (CEP) Class Naming Principle (CNP) Acquaintance Package Principle (APP) © Addison-Wesley CAiSE 2003 Tutorial 11 © Addison-Wesley CAiSE 2003 Tutorial 12 © L.A.Maciaszek, B.L. Liong & Addison- Wesley 2 CAiSE 2003 Tutorial 23-April-2003 Tutorial case study Display email messages EM – Email Management system • part of an Electronic Document Management System • capture, indexing, classification and retrieval of all email business correspondence Composing and emailing of messages stored in the database and scheduled to be sent to contacts (customers) • a Java application that accesses an Oracle database via JDBC • upon employee’s login to the database, the application can retrieve from the database and display the list of messages to be emailed to contacts • the employee can then email chosen messages • after a successful email, the database is updated accordingly • the employee can create, update, delete messages • messages can be sorted and filtered © Addison-Wesley CAiSE 2003 Tutorial 13 © Addison-Wesley CAiSE 2003 Tutorial 14 Update email message Email received © Addison-Wesley CAiSE 2003 Tutorial 15 © Addison-Wesley CAiSE 2003 Tutorial 16 Conceptual class model Relational database model © Addison-Wesley CAiSE 2003 Tutorial 17 © Addison-Wesley CAiSE 2003 Tutorial 18 © L.A.Maciaszek, B.L. Liong & Addison- Wesley 3 CAiSE 2003 Tutorial 23-April-2003 Class Let’s slow down and revisit… model for EM Architectural design is an exercise in managing module dependencies • Module A depends on module B if changes to module B may necessitate changes to module A It is important that dependencies do not cross dependency firewalls (Martin, 2003) • In particular, dependencies should not propagate across non-neighboring layers and must not create cycles © Addison-Wesley CAiSE 2003 Tutorial 19 © Addison-Wesley CAiSE 2003 Tutorial 20 Proactive and reactive approach Packages Architectural design takes a proactive approach to dependency relationship B owns X A depends on B managing dependencies in software. • This is a forward-engineering approach – from design to Package B Package E implementation. Package A Class X • The aim is to deliver a software design that minimizes dependencies by imposing an architectural solution on + package with no members revealed programmers. circle-plus notation Package F Proactive approach must be supported by the Package C E owns F reactive approach that aims at measuring F owns Y and Z dependencies in implemented software. Package D + • This is a reverse-engineering approach – from implementation to design. • The implementation may or may not conform to the Class Y Class Z desired architectural design. C owns D © Addison-Wesley CAiSE 2003 Tutorial 21 © Addison-Wesley CAiSE 2003 Tutorial 22 Cycles between packages Eliminating cycles between packages Package A Package B Package A Package B circularly-dependable Package A2 elements of Package A extracted into Package A2 Package C Package D Package E Package C Package D Package E circularly-dependable Package C2 elements of Package C extracted into Package C2 © Addison-Wesley CAiSE 2003 Tutorial 23 © Addison-Wesley CAiSE 2003 Tutorial 24 © L.A.Maciaszek, B.L. Liong & Addison- Wesley 4 CAiSE 2003 Tutorial 23-April-2003 <<layer>> <<layer>> Layer Layer 1 Layer 1 Package A Package B dependencies Package A Package B Class X Class Y Layer 1 Package A depends on depends on Package B because Class Layer 2 X depends on ClassY <<layer>> Layer 2 Class <<layer>> Layer 2 Layer 1 depends on Layer 2 because Class X Package C Package D depends on Class Y depend- Package C Package D encies Class Z Package E Package E © Addison-Wesley CAiSE 2003 Tutorial 25 © Addison-Wesley CAiSE 2003 Tutorial 26 Method dependencies Method dependencies and delegation control control public class EOutMessage { EEmployee emp; CActioner CActioner p ubl ic void d o2() { emp.do3(); do1() entity } public class EOutMessage { EOutMessage EEmployee emp; do1() } public void do2() { public class CActioner { emp.do3(); 0..1 EEmployee emp; do2() } public void do1() { } emp.do3(); } public class EEmployee { public class CActioner { entity } EEmployee MBroker brk; EEmployee emp; public void do3() { public void do1() { brk.do3(); do3() } emp.do3(); Act Emp EOutMessage 0..1 mediator } } } do2() MBroker 0..n OutEmp do3() foundation EEm ployee public class MBroker { public class FUpdater { FUpdater upd; FUpdater public void do3() { 0..n public void do3() { // code for do3 do3() upd.do3(); do3() } } } } © Addison-Wesley CAiSE 2003 Tutorial 27 © Addison-Wesley CAiSE 2003 Tutorial 28 Interfaces UML notations In the UML 2.0, interface is a declaration of a set of features that is not directly instantiable, i.e. no objects of it can be directly created. The object that implements interface provides “a public façade that conforms to the interface specification” (UML, 2002, p.123). <<Interface>> In UML 2.0 interface can declare attributes, not just Interface1 Interface3 operations. Interface2 • By contrast, in Java an interface can contain data members but they must be constants (defined as static and final). An abstract class is a class that contains at least one method, which is not (or cannot be) implemented by that class, and therefore it cannot be instantiated. • A class is a class is a class. In languages that support only single AbstractClass1 Class1 implementation inheritance, like Java, a class can only extend one base class (abstract or concrete), but it can implement multiple interfaces. This is a huge practical difference. • The related difference is that interfaces allow passing objects typed as interfaces in method calls. © Addison-Wesley CAiSE 2003 Tutorial 29 © Addison-Wesley CAiSE 2003 Tutorial 30 © L.A.Maciaszek, B.L. Liong & Addison- Wesley 5 CAiSE 2003 Tutorial 23-April-2003 Implementation dependency Usage dependency This is permitted in UML 2.0, but not in Java, which only allows extension inheritance between interfaces public interface Interface1 { private int a1; Interface1 Interface2 public void o1(); a1 a2 } Interface1 <<uses>> Interface2 o1() o2() a1 a2 public class Class1