390 likes | 902 Views
Software Engineering Modern Approaches. Eric Braude and Michael Bernstein. Chapter 21: Advanced and Emerging Methods in Software Design. Planning. Maintenance. Learning Goals of This Chapter How is the design process affected when engineers are geographically distributed?
E N D
Software Engineering Modern Approaches Eric Braude and Michael Bernstein
Chapter 21: Advanced and Emerging Methods in Software Design
Planning Maintenance • Learning Goals of This Chapter • How is the design process affected when engineers are geographically distributed? • In what ways can aspect-oriented programming help software engineering? • How does a UML framework like UMLsec help with designing for security? • What are the main goals of Model-Driven Architecture? • What is a formal design process in the B language? Testing The Software Development Lifecycle Requirements analysis Implementation Design Phase most relevant to this chapter is shown in bold © 2010 John Wiley & Sons Ltd.
Design Tools for Distributed Development (IBM) • License distributed teams requirement • Seek flexible license model response • Apply service-oriented architecture • Model process flow with UML • Build in Web Services from inception • Communicate design to all engineers • Use UML models • Make Web-viewable http://www3.software.ibm.com/ibmdl/pub/software/rational/web/guides/GC34-2500-00.pdf
Tools for Distributed Design • Web-based development environments • E.g., Google Code, SourceForge • Wikis • Track changes to designs • Web-based whiteboards • Graphic elements visible to all • Conference calls • Aural discussions of designs • Hyperlinked UML diagrams http://www3.software.ibm.com/ibmdl/pub/software/rational/web/guides/GC34-2500-00.pdf
The Idea of Aspect-Oriented Programming Aspects Class Model • Transaction management A • Efficiency G • Security C B D E F • Business logic • - domain specific • e.g., “financial” • “logistical,”etc.
Runtime Aspects: Decorating a Core Process Get order information Paths without security or persistent aspects Process invalid id/password else Order valid … Execute order … …. Security aspect Store order Persistence aspect
sales «fair exchange» Sell product Example of Security Requirement in Use Case Imposes mandate on use case specifics Buy product customer vendor Adapted from Jurjens p 16 © 2010 John Wiley & Sons Ltd.
«fairexchange»in a Derived Activity Diagram Buy product «fair exchange» start={Pay} stop={Reclaim, Obtain} Request product “… must reach one of these.” Pay Customer Vendor “Processing that gets here ...” Wait until delivery due time Deliver Reclaim Obtain Adapted from Jurgens p 54 © 2010 John Wiley & Sons Ltd.
Goals of Model-Driven Architecture • Portability • Platforms, languages, middleware • Interoperability • Reusability of designs [1]http://www.omg.org/docs/omg/03-06-01.pdf
Means of Model-Driven Architecture • Design independent of implementation and environment • Generate code as automatically as possible from designs • Uses models as the primary means of “understanding, design, construction, deployment, operation, maintenance, and modification.”[1] • Specified and organized by OMG [1]http://www.omg.org/docs/omg/03-06-01.pdf
Generating Skeleton Code From UML class Customer { public int getCreditRating { return 0; } } Customer +getCreditRating(): int VideoCustomer +getNumDVDsRented(): int DVD class VideoCustomer extends Customer { DVD dvd; public int getNumDVDsRented { return 0; } } class DVD { }
Design Requirements analysis Round-Trip Engineering 4 Regenerate class model from code base 1 Create class model 5 Augment class model 2 Generate skeleton code 3 Augment skeleton code Coding Testing © 2010 John Wiley & Sons Ltd.
The MDA Concept Application Middle- ware 1 Perva- sive svce 1 Application UML model Middle- ware 3 Middle- ware 2 Perva- sive svce 2 Middleware description Application Pervasive service description (example) Application Adapted from http://www.omg.org/mda/ © 2010 John Wiley & Sons Ltd.
The MDA Concept: Annotated Target applications (select middleware & pervasive services Core design Common to many app’s (explained later) middleware http://www.omg.org/mda/ © 2010 John Wiley & Sons Ltd.
Main MDA Artifacts • Platform-independent Model (PIM) Design independent of platform • Platform-Specific Models (PSM) • Code implementing PSM’s 1. PIM 2. PSM1 PSM2 PSM3 (Standard) description of platform #1 Code2 Code3 Code1 3.
MDA Example VideoCustomer PIM Video customer E.R.D. VideoCustomer “PSM bridge” -- relates customer objects to table records Relational PSM Java PSM “code bridge” Relational code Java code
Uses of OCL • To specify invariants on classes and types in the class model • To describe pre- and post conditions on operations and methods • To describe guards (“if <guard>”) • As a navigation language • To specify constraints on operations i.e., limits http://lcm.csa.iisc.ernet.in/soft_arch/OCL.htm
Relational expression score > 8.3 value <= next.value Logical expression score > 8.3 and score <= 9.4 p implies q p1 <> p2 implies p1.name <> p2.name Primary expression MyClass::myMethod(myArgument) if expression if name = ‘JohnSmith' then score > 8.3 endif Set: Set { 1 , 2 , 5 , 88 } Set { 'apple' , 'orange', ‘peach' } Sequence: Sequence { 1, 3, 45, 2, 3 } Sequence { 'ape', 'nut' } Sequence { 10..24 } Examples of OCL Syntax adapted from http://www.csci.csusb.edu/dick/samples/ocl.html#Glossary © 2010 John Wiley & Sons Ltd.
PIM Example with Approximate OCL invariant: 0< name.length()<= 20 VideoCustomer +name: String +numRented: int 0..10 Rental +year: String 0..1 customer getFine(daysLate: integer): float initially: 0 precondition: daysLate==1 or daysLate== 2
Example of a PIM / PSM / Code Transformation Video Store PIM PIM - to - Relational transformation PIM - to - Web transformation PIM - to - EJB Components transformation Relational PSM EJB Component PSM Web PSM Code generation Code generation Code generation SQL source code EJB source code JSP source code
PSM Java/UML Example VideoCustomer -name: String -numRented: int -rentals: Set Rental -year: String -videoCustomer: Set getYear(): int setYear(year: int) getFine(daysLate: integer): float … getName(): String setName(name: String) …
PIM / PSM / Transformation Example with Communications PIM level Video Store PIM PSM level Relational PSM EJB Component PSM Web PSM Communications Communications Code level Communications Communications SQL source code EJB source code JSP source code
MOF Specification of UML: A Part “every class is an element composed of zero or more attributes and methods.” UML Element 0..* 0..* Method Attribute Class
Application of the MOF MOF Meta-language is specified via … is specified via … input Transformation definition input Model language 1 Model language 2 is specified via … is specified via … uses Transformation program PIM a PSM
The Parts of a B Specification • MACHINE Identifies part; has parameters • CONSTRAINTS On parameters & constants • VARIABLES Like those of a class • INVARIANT Respected by all operations • INITIALIZATION Carried out automatically • OPERATIONSLike methods in a class
Lookup Example in B -- 1 Parameters of the entire machine MACHINE table( lowest, highest ) CONSTRAINTS lowest NAT‡⋀highest NAT⋀ 0< lowest ⋀lowest highest VARIABLES ….. INVARIANT …… .. on parameters and constants; includes types ‡ NAT = the natural numbers continued © 2010 John Wiley & Sons Ltd.
Lookup Example in B -- 2 Only names are lists (type specifications are part of the invariant); at least 2 letters MACHINE table( lowest, highest ) CONSTRAINTS … VARIABLES min, max, Pred, found, xx INVARIANT minNAT⋀maxNAT⋀ min lowest ⋀ max highest ⋀ [ Pred ( min..(max-1) BOOL ) ]⋀foundBOOL⋀xxNAT Pred maps each natural number between min andmax-1onto true or false. e.g., Pred(3)==false continued © 2010 John Wiley & Sons Ltd.
Lookup Example in B -- 3 INITIALIZATION /* Not used in this example */ OPERATIONS Search =def IF ii ( ii min..(max-1) ) ⋀ ( Pred(ii) = true ) THEN found=true⋀ ANY jj WHERE ( jj min..(max-1) ) ⋀ ( Pred(jj) = true ) THEN xx >= jj END ELSE (found=false)⋀ (xx = max) END 1 2 3 4 5 6 7 8 “The following specifies Search” “If an indexexists where Pred is true” “jj is any index where Pred is true” Adapted from Monin p108 © 2010 John Wiley & Sons Ltd.
Refinement Example (Database Query) Requirement: “The top DVD rentals in each category are present on the monitor.” Refinement 1: variable topRental = VERY_LOW_RENTAL “For each category, display category name For each rental if( rental frequency > topRental frequency ) topRental := rental display topRental”
Refinement of Lookup (“table”) Example 1 of 2 Every part of table applies REFINEMENT tableR1(Low, Hi) REFINES table VARIABLES min1,max1, Pred1, xx1 INVARIANT min1 = min max1 = max Pred1 = Pred xx1 = xx min1 xx1 xx1 max1 ( xx1 = max1 found = false ) INITIALIZATION /* none applied */ Variables additional to table. Connects the variables of table and table1 To honor table’s invariant continued © 2010 John Wiley & Sons Ltd.
Refinement of Lookup Example 2 of 2 OPERATIONS Search =def IF ii ( ii min1..(max1-1) ) ( Pred1(ii) = true ) THEN ANY jj WHERE ( jj min 1..(max-1) ) ( Pred(ii) = true ) THEN xx1 := jj END ELSE xx1 := max1 END END END Refined definition of Search Still somewhat non-deterministic; needs further refinement Less deterministic because of these assignments Less deterministic because of these assignments © 2010 John Wiley & Sons Ltd.