軟件需求分析英文課件:Chap 8-Design to Code_第1頁(yè)
軟件需求分析英文課件:Chap 8-Design to Code_第2頁(yè)
軟件需求分析英文課件:Chap 8-Design to Code_第3頁(yè)
軟件需求分析英文課件:Chap 8-Design to Code_第4頁(yè)
軟件需求分析英文課件:Chap 8-Design to Code_第5頁(yè)
已閱讀5頁(yè),還剩41頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論