Download presentation
Presentation is loading. Please wait.
Published byMeryl Robbins Modified over 9 years ago
1
Software Engineering for Digital Home 單元 3 :軟體設計 Chapter 3-6 – Specifying Interfaces
2
Software Engineering for Digital Home Outline Introduction Interface specification –Identifying missing attributes and operations –Specifying type, visibility and signature –Specifying contracts Discussions and Exercises 2
3
Software Engineering for Digital Home Software lift cycle 3 Software life cycle Development cycle Design ImplementationTesting Maintenance Requirements Engineering System design Object design Analysis Model (Class diagrams) Requirements Elicitation Analysis SRS Subsystem (Class diagram)
4
Software Engineering for Digital Home Use case Use case name 建立作業 Participating actors Initiated by 老師 Flow of events 1. 老師要建立作業. 2. 老師輸入作業的名稱 (50 字元 ), 作業的要求 (2000 字元 ), 截止日期 ( 日 期格式 ). 3. 系統檢查輸入的作業名稱, 作業的要求, 截止日期是否正確. 4. 如果正確, 系統就建立作業. Exceptions 3.1 如果所輸入的資料不正確, 系統要求使用者重新輸入. Entry condition 老師己登入教學網站. Exit conditions 老師在教學網站上建立了一個新的作業. 4
5
Software Engineering for Digital Home Class diagram 5 AssignmentForm createAssignment() set( name, context, due ) AssignmentControl checkdata() Assignment name context duedate
6
Software Engineering for Digital Home Interface specification 6 Identifying missing attributes and operations Object Design Document Specifying type, Visibility and signature Specifying Contracts Class interfaces Class diagrams Analysis Subsystem decomposition Refine class using design pattern
7
Software Engineering for Digital Home Identifying missing attributes and operations 分析後得到的 class diagrams 常常會漏掉很多 attribute 與 operation ,因為我們只把 use cases 轉成 class diagram 僅描述 系統功能 7 AssignmentForm createAssignment() setData( name, context, due ) AssignmentControl checkdata() Assignment name context duedate
8
Software Engineering for Digital Home Identifying missing attributes and operations 使用文字來說明作業內容學生不易於了解作業需 求 一般人對於圖片和範例等表現方式比較容易了其 意義 提供作業附件功能方便學生能夠藉由附件更了解 作業內容 8
9
Software Engineering for Digital Home Identifying missing attributes and operations 9 AssignmentForm createAssignment() setData( name, context, due, file ) AssignmentControl checkdata() uploadAttachment(file) Assignment name context duedate attachment AssignmentForm createAssignment() setData( name, context, due ) AssignmentControl checkdata() Assignment name context duedate
10
Software Engineering for Digital Home Type, Visibility and Signature Type (Attributes) –Name: string –maxNumPlayers: int –Start: date Visibility (Attributes and Operations) –Private: - –protected: # –public: + Signature (Operations) –acceptPlayer(Player): void –getMaxNumPlayers(void): int 10
11
Software Engineering for Digital Home Specifying type, visibility and signature Specifying the range of each attribute. ( 首先確定我們需要什麼類型及範圍的型態 ) We determine which types provided by the development environment. ( 接著看開發環境上有什麼型態符合我們第一步找出的需求類型及範圍 ) 11 AssignmentForm +createAssignment() +set( name, context, due, file ) AssignmentControl +checkdata():bool +uploadAttachment(file) Assignment +name:String +context:String +duedate:Date +attachment:File
12
Software Engineering for Digital Home Contracts Invariant –Specifying consistency constraints among class attributes. ( 凡屬於 class 的所有 instances 都要符合的限制 ) Precondition –Specifying constrains that a class user meet before calling the operation. (new 了一個 class 後,要使用它的 operation 前必須符合的限制 ) Postcondition –It’s a predicate that must be true after an operation is invoked. ( 執行了 operation 後必定會成立的條件 ) 12
13
Software Engineering for Digital Home Contract Notation OCL, Object Constraint Language [OMG, 1998]. A constraint is expressed as a boolean expression returning the value True or False. ( 描述限制的式子回傳值皆為 boolean 型態 ) 13 context AssignmentControl inv: //Condition (s) Keyword: contextClass or Operation AssignmentControl AssignmentControl ::checkdata() Constraint type inv > pre > post > Expression self.getSize(f) < 3145728
14
Software Engineering for Digital Home Specifying contracts 14 AssignmentControl +checkdata():bool +uploadAttachment( file: File):boolean -getLength(data:String): int -getSize(f:File): int -checkType(f:File): boolean -isCourseExist(id:int):boolean -isAttachmentUpload(f:File):boolean Public class AssignmentControl{ /* The Course exist at all times.*/ context AssignmentControl inv: isCourseExist(id) context AssignmentControl::uploadAttachment(file) pre: checkType(f) and getSize(f) < 3145728 context AssignmentControl::uploadAttachment(file) post: isAttachmentUpload(f) … }
15
Software Engineering for Digital Home Exercises – 每一個 operation 都有 precondition 以及 postcondition 嗎 ? – 試以教學網站的 analysis model 設計 class interface. 15
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.