软件需求分析英文课件:Chap 8-Design to Code_第1页
软件需求分析英文课件:Chap 8-Design to Code_第2页
软件需求分析英文课件:Chap 8-Design to Code_第3页
软件需求分析英文课件:Chap 8-Design to Code_第4页
软件需求分析英文课件:Chap 8-Design to Code_第5页
已阅读5页,还剩41页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Elaboration Iteration 1- Design to CodeCh19. Designing for VisibilityCh20. Mapping Designs to CodeCh21.Test-Driven Development and Refactoring1Chapter 17. Designing for VisibilityObjectivesIdentify four kinds of visibility.Design to establish visibility.2Visibility Between Objects Visibility is the

2、ability of one object to see or have reference to another.The designs created for the system operations (enterItem, and so on) illustrate messages between objects.For a sender object to send a message to a receiver object, the sender must be visible to the receiver.the sender must have some kind of

3、reference or pointer to the receiver object.3Example4Visibility from the Register to ProductCatalog is requiredWhat is Visibility?There are four common ways that visibility can be achieved from object A to object B:Attribute visibility B is an attribute of A.Parameter visibility B is a parameter of

4、a method of A.Local visibility B is a (non-parameter) local object in a method of A.Global visibility B is in some way globally visible.5Attribute Visibility6Parameter Visibility7Parameter to attribute visibility8Local Visibility9Global VisibilityGlobal visibility from A to B exists when B is global

5、 to A. It is a relatively permanent visibility because it persists as long as A and B exist. It is the least common form of visibility in object-oriented systems.One way to achieve global visibility is to assign an instance to a global variablewhich is possible in some languages, such as C+but not o

6、thers, such as Java.The preferred method to achieve global visibility is to use the Singleton pattern , which is discussed in a later chapter.10Chapter 20. Mapping Designs to CodeObjectivesMap design artifacts to code in an object-oriented language11Implementation ModelOOD artifacts as inputInteract

7、ion diagrams Design Class Diagrams Source code Database definitions JSP / XML / HTML pages12Programming and Iterative, Evolutionary DevelopmentThe creation of code in an OO language is not part of OOA/D, its an end goal. The artifacts created in the Design Model provide some of the information neces

8、sary to generate the code.A traceable end-to-end roadmap Use case - requirements OOAD - logical solution, blueprints OOP - running applications 13Mapping Designs to CodeCode Changes are inevitable CASE Tools, and Reverse-Engineering Implementation in an object-oriented language requires writing sour

9、ce code forclass and interface definitionsmethod definitions14Creating Class Definitions from DCDsDCDs depict a basic element of class definition Class or interface nameSuperclassesOperation signaturesAttributes of a classFrom the DCD, a mapping to the attributes (Java fields) and method signatures

10、is straightforward15Defining a Class with Method Signatures and Attributes16SalesLineItem in JavaReference AttributeSimple AttributeCreating Methods from Interaction DiagramsThe sequence of the messages in an interaction diagram translates to a series of statements in the method definitions.17The en

11、terItem interaction diagramThe Register.enterItem Method18The Register class19The Register.enterItem MethodThe enterItem methodCollection Classes in CodeOne-to-many relationships are commonImplemented with a collection objectThe choice of collection class depends on requirements Eg, key-based lookup

12、 requires the use of a Map, a growing ordered list requires a List, or simple array , and so on.Guideline: If an object implements an interface, declare the variable in terms of the interface, not the concrete class2021Adding a collectionDefining the Sale.makeLineItem Method22Sale.makeLineItem metho

13、dOrder of Implementation23Summary of Mapping Designs to CodeThere is a translation process from UML class diagrams to class definitions, and from interaction diagrams to method bodies. The basic translation process looks straightforward, sometimes can be done by a CASE tool There is still lots of ro

14、om for creativity, evolution, and exploration during programming work.24Introduction to the NextGen POS Program SolutionA sample domain layer of classes in Java for this iteration.The main point of this listing is to show that there is a translation from design artifacts to a foundation of code.This

15、 code defines a simple case; it is not meant to illustrate a robust, fully developed Java program with synchronization, exception handling, and so on.2526Eclipse project for NextGen POS 27282930313233Chapter 21. Test-Driven Development and RefactoringObjectivesIntroduce these two important developme

16、nt practices in the context of the case studies34Test-Driven Development (TDD)An excellent practice promoted by the iterative and agile XP method , also known as test-first developmentIn OO unit testing TDD-style, test code is written before the class to be tested, and the developer writes unit test

17、ing code for nearly all production codeAdvantagesThe unit tests actually get writtenProgrammer satisfaction leading to more consistent test writingClarification of detailed interface and behaviorProvable, repeatable, automated verificationThe confidence to change things35TDD (cont.)The most popular

18、unit testing framework is the xUnit family JUnit for java, NUnit for .NET, and so forth. Example: using JUnit and TDD to create the Sale class.Before programming the Sale class, we write a unit testing method in a SaleTest class that does the followingCreate a Sale Add some line items to it with the

19、 makeLineItem method Ask for the total and verify that it is the expected value Each testing method follows this patternCreate the fixture.Do something to it (some operation that you want to test).Evaluate that the results are as expected.36TDD Example3738IDE Support for TDD and xUnitRefactoringCont

20、inuously refactoring code is another XP practice and applicable to all iterative methods A structured, disciplined method to rewrite or restructure existing code without changing its external behavior .Applying small transformation steps combined with re-executing tests each step. The essence of ref

21、actoring is applying small behavior preserving transformations (each called a refactoring), one at a time .After each transformation, the unit tests are re-executed to prove that the refactoring did not cause a regression (failure).39The Activities and Goals of RefactoringThey are simply the activities and goals of good programming Remove duplicate code Improve clarity Make long methods shorter Remove the use of hand-coded literal constants And more Some code smells include: Duplicated code Big method Class with many instance variables Class with lots of code Strikingly simila

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论