# OOAD Lab 9, 10 (04/20)
###### tags: `OOAD`
---
[TOC]
---
## 9. How to Find Classes and Objects?
- **Jacobson’s Three Types**
- **Entity Objects**: things in the users’ real world
- **Concrete objects**: Employee, Product, Tool, etc.
- **Conceptual objects**: Corporation, strategy, membership, approval, etc.
- **Event and State objects**: Purchase, delivery, arrival, ownership, status, etc.
- **Interface Objects**: To encapsulate the details of GUIs, communication protocols, and the like.
- **Control Objects**: To carry complex methods that don’t have a class they obviously belong in.
- **The KRB Seven-Step Method**:
1. **Candidate Classes**: find ***nouns***
- *Just find all the names!*
- **Entity** objects:
- Client Interviews
- Nouns from the Documentation
- Brainstorming
- **Interface** objects:
- User interface
- Data Communications Interfaces
- Real-world systems to control or monitor
2. **Define Classes**: check for the ***meaning*** the users attach to each noun
- Each Candidate Class must undergo three checks:
1. A Real-World **Identifier**
- to distinct from each other
2. A **Definition**
- a sentence to describe this class
3. Sample **Attributes** and **Behaviors**
3. **Establish Associations**: checking how these things ***interact***
- An association is an **interaction** between instances of two classes
- Represented by a **verb**.
- *“Object verb Object”*
- The **Verb**, and The **Multiplicity**.
4. **Expand Many-to-Many Associations**: generates much discussion and ***more classes***.
- Bads:
- likely to run out of room!
- The data is recorded in two places, which is not good design, since it will get out of step (Murphy’s Law)
- Add attributes to associations
- Check the strings - **the M:M is now 2 x 1:M** !!
5. **Attributes**: keep ***about*** each thing
6. **Normalization**
7. **Operations**:
- Six techniques for Finding Operations
1. By Inspection
2. Basic CRUD
3. Use Cases
4. Statechart Diagram
5. CRC Cards
6. CRUD Revisited
- Find the similarity (in behaviors) and construct **inheritance** hierarchy
- Make sure there are association linked to base classes (a.k.a **polymorphism**)
- **RUP**: Rational Unified Process
## 10. An Overview of UML
- **The objectives of OOAD**
- create codes in good architecture, easily maintainable
- create reusable codes (via inheritance)
- **modeling software before building it**
- **減少摸石頭過河過程中錯誤所帶來的金錢與時間延遲**
- **Model v.s. Module**
- **Model: 模型**
- **Module: 模組**
- Building **prototypes** and **models**
- ***Idea ---> Requirement and Spec ---> Modeling and Design ---> Coding***
- **UML**: Unified Modeling Language
- **Type of Models**:
- 軟體工程到目前為止沒有一種標準的開發工程圖
- Model that is **not rigid**
- Some UML models like class diagram
- ERD models
- Model that is **executable**
- State chart in UML, can be applied to tools such as simulation
- Model that is **rigid**
- Can be applied to tools such as verification
- **Model process**:
- modeling process is a **design and analysis process**
- Through the process, you will understand, research, and consider your problem carefully. Therefore, **avoid fatal error** in your problem
- 也就是說你還保持著你的概念的完整性
- **What can you do to a model? (UML)**:
- Translate it into templates, allow programmers to add codes
- Simulation – if the type of model is executable
- Use it as document (Software Visualization)
- Use it as a communicating tools
- Check consistency:
- The major risk of design and analysis is omit specification
- **UML**:
- It is not only used in OOAD but can be used in other software applications where programs are not OO( 可視為軟體的工程圖標準(不見得只是對物件導向程式有用)
- 由物件導向學界的三位巨頭成果結合而成(3 amigos)
- Grady Booch (Rational Software)
- Jim Rumbaugh (GE)
- Ivar Jacobson
- UML is just a tool, like OOPL,not a methodology
- You understand UML X=> you know OOAD (知道UML語言,不代表你會OOAD)
- Just like a mechanic can understand a blueprint but does not mean he can design one. (正如同懂OOPL不代表你會寫出真正的OO程式)
- 軟體工程唯一不變的東西就是一直變
- UML history:
- OOPSLA (Object-oriented programming, systems, languages, and applications)
- OMG (object management group)
- Smalltalk (Simula)
- key methodologists protest standardization
- OOPSLA 94: Booch and Rumbaugh merge their method
- **UML**:
- UML define a notation and a meta-model
- Communication:
- Natural language is too imprecise
- code is precise but too detailed
- use UML to highlight important details
- OO: *"Object languages allow advantages but don’t provide them."* by Tom Hadfield
- **Stability**:
1. Other Interfaces
2. Outputs
3. User Interface
4. Object Behavior
5. Object Attributes
6. Object Classes
- 物降導向分析就是不斷的把變動往上推,藉由多型之類的
- **Control Objects**:
- These methods **don’t easily fit** or **don’t logically belong** in any of our **entity classes** or **interface classes**.
- **Abstract Classes**:
- “artificial” superclass
- To make use of some common attributes or behavior
- **分析**:
- 分析的目的是為了要讓程式碼寫出來能夠充分的應付**未來的變化**。讓程式能夠順利的演化
- **技術債**:流了很多難改的程式
- **好的分析!=好的效能**
- **成功的分析就是要能夠嗅出未來軟體可能演化的部分與方向。**
- **UML intro**:
- No single diagram are capable of describing software. ( 軟體工程幾十年的重要體認就是我們沒有辦法用單一種的圖像來表示軟體)
- There are several aspects of software. Must be dealt by several kind of diagrams. (軟體有許多面向,需要以不同的圖形表示方式來解決)
- Use case diagrams
- Class diagrams
- Object diagrams
- Sequence diagrams
- Collaboration diagrams
- Statechart diagrams
- Activity diagrams
- Component diagrams
- Deployment diagrams