---
# System prepended metadata

title: 軟工期末大抄
tags: [NTUT, SE]

---

# 軟工期末大抄

[toc]

###### tags: `SE` `NTUT`
## UML 加減看
[Class Diagram - part1](https://spicyboyd.blogspot.com/2018/07/umlclass-diagram-introduction.html)
[Class Diagram - part2](https://spicyboyd.blogspot.com/2018/07/umlclass-diagram-relationships.html)
[Sequence Diagram](https://dotblogs.com.tw/wasichris/2016/03/17/232341)

## ch6
### Architectural design
- The design process for identifying the sub-systems making up a system and the framework for sub-system control and communication.
- Taxonomy(分類) of Architectural styles：
    - Data centred architectures
    - Data flow architectures
    - Call and Return architectures
    - Object Oriented architecture
    - Layered architecture
### Software Architecture
- Software architecture is the process of converting software characteristics such as flexibility, scalability, feasibility, reusability, and security into a structured solution that meets the technical and the business expectations.
    - extendable, modular and maintainable
    - performance and low fault tolerance, scalability and reliability
    - the feasibility
### Software Architecture Patterns
- MicroServices, Serverless, Layered, Event-Driven Pattern

### Software Design
- The software design is responsible for the code level design such as, what each module is doing, the classes scope, and the functions purposes, etc.
- Design principle：
    - Modularity (low coupling, high cohesion, functional independence)
    - Abstraction (data, function)
    - Top-down design strategy
- SOLID principles：

    | Initial | Stands for |     Name     | Concept                                                                                                                              |
    |:-------:|:----------:|:------------:|:------------------------------------------------------------------------------------------------------------------------------------ |
    |    S    |    SRP     | Single responsibility principle | 每個物件，不管是類別、函數，負責的功能，都應該只做一件事。|
    |    O    |    OCP     | Open-Close principle | 藉由增加新的程式碼來擴充系統的功能，而不是藉由修改原本已經存在的程式碼來擴充系統的功能。|
    |    L    |    LSP     | Liskov substitution principle | 當實作繼承了 interface 或 base-class的 sub-class，那麼在程式中，只要出現該 interface 或 base-class 的部份，都可以用 sub-class 替換。 |
    |    I    |    ISP     | Interface segregation principle | 針對不同需求的用戶，開放其對應需求的介面，提拱使用。可避免不相關的需求介面異動，造成被強迫一同面對異動的情況。|
    |    D    |    DIP     | Dependency inversion principle | 高階模組不應該依賴於低階模組，兩者都該依賴抽象介面。|

### Architectural abstraction
- You can design software architecture at two levels of abstraction：
    - Architecture in the small is concerned with the architecture of individual programs.
    - Architecture in the large is concerned with the architecture of complex enterprise systems that include other systems, programs, and program components.
### Advantages of explicit architecture
- Architecture may be used as a focus of discussion by system stakeholders.
- Analysis of whether the system can meet its nonfunctional requirements is possible.
- The architecture may be reusable across a range of systems
- Product-line architectures may be developed
### Architectural representations(表述)
- Simple, informal block diagrams showing entities and relationships are the most frequently used method for documenting software architectures.
- Lack semantics, do not show the types of relationships  between entities nor the visible properties of entities in  the architecture.
- Depends on the use of architectural models. The requirements for model semantics depends on how the models are used
### ~~Use of architectural models~~
- ~~As a way of facilitating discussion about the system design~~
- ~~As a way of documenting an architecture that has been designed~~
### Architectural design decisions
- Architectural design is a creative process so the process differs depending on the type of system being developed, the background and experience of the system architect, and the specific requirements for the system .
- However, a number of common decisions span all  design processes and these decisions affect the non-functional characteristics of the system.
### Architecture reuse
- You have to decide what your system and broader application classes have in common and decide how much knowledge form these application architectures you can reuse
- The architecture of a system may be designed around one of more architectural patterns. 
### Architecture and system characteristics
- Performance
    - Localise critical operations and minimise communications. Use large rather than fine-grain components to reduce the numbers of communication. Consider runtime system organization that allows system to be replicated and executed on different processor.
- Security
    - Use a layered architecture with critical assets in the inner layers.
- Safety
    - Localise safety-critical features in a small number of sub-systems to reduce safety validation cost.
- Availability
    - Include redundant components and mechanisms for fault tolerance.
- Maintainability
    - Use fine-grain, replaceable components. Separate data consumer from data producer. Avoid shared data structure.
### 4 + 1 view model of software architecture
- A logical view, which shows the key abstractions in the system as objects or object classes.
- A process view, which shows how, at run-time, the system is composed of interacting processes
- A development view (implementation view), which shows how the software is decomposed for development.
- A physical view (deployment view), which shows the system hardware and how software components are distributed across the processors in the system
- Illustrate the architecture using use cases or scenarios(+1) -- use case view
### Conceptual view
- An abstract view of the system that can be the basis for decomposing high-level requirements into more detailed specifications
### Architectural patterns
- An architectural pattern is a stylized description of good design practice, which has been tried and tested in different environments.
### The Model-View-Controller (MVC) pattern
- Description：將應用程式劃分為三種組件，模型 - 視圖 - 控制器（MVC）設計定義它們之間的相互作用。
- When used：Used when there are multiple ways to view and interact with data.
- Advantages：Allows the data to change independently of its representation and vice versa.
- Disadvantages：Can involve additional code and code complexity when the data model and interactions are simple
<!-- - ![](https://i.imgur.com/vqKAKmn.png) -->
- ![](https://i.imgur.com/3Fbiij7.png)
<!--### The Layered pattern/architecture
- Description：Organizes the system into layers with related functionality associated with each layer.A layer provides services to the layer above it so the lowest-level layers represent core services that are likely to be used throughout the system
- When used：Used when building new facilities on top of existing systems.
- Advantages：Allows replacement of entire layers so long as the interface is maintained.
- Disadvantages：In practice, providing a clean separation between layers is often difficult and a high-level layer may have to interact directly with lower-level layers rather than through the layer immediately below it
- ![](https://i.imgur.com/HZktFwX.png)
### The Repository pattern/architecture
- Description：All data in a system is managed in a central repository that is accessible to all system components.
- When used：have a system in which large volumes of information are generated that has to be stored for a long time
- Advantages：Components can be independent, do not need to know of the existence of other components.
- Disadvantages：The repository is a single point of failure so problems in the repository affect the whole system.
- ![](https://i.imgur.com/0uz74OP.png)
### The Client–server pattern/architecture
- Description：In a client–server architecture, the functionality of the system is organized into services, with each service delivered from a separate server.
- When used：Used when data in a shared database has to be accessed from a range of locations
- Advantages：The principal advantage of this model is that servers can be distributed across a network
- Disadvantages：Each service is a single point of failure so susceptible to denial of service attacks or server failure
- ![](https://i.imgur.com/uNJxi1S.png)
### Application architectures
- Application systems are designed to meet an organisational need.
- As businesses have much in common, their application systems also tend to have a common architecture that reflects the application requirements
- A generic application architecture is an architecture for a type of software system that may be configured and adapted to create a system that meets specific requirements
-->
### The Clean Architecture 
- ![](https://i.imgur.com/AY1CsIn.png)
## ch7
### 5 key activities in an object-oriented design process：
- Class：定義一件事物的抽象特點，像是它能夠做到的、包含哪些屬性等。
- Object：是 class 的例項，定義具體的事物，而它的屬性也是具體的。
- Method：定義一個類別可以做，但不一定會去做的事。
- Inheritance：在某些情況下，一個類別會有「子類別」，子類別會比原本的類別更加具體化，而透過繼承可以讓 programmer 減少寫重複程式碼。
- Encapsulation：透過限制只有特定物件可以存取特定類別的成員，通常利用介面實作訊息的傳入傳出。
### Context and interaction models
- A system context model is a structural model that demonstrates the other systems in the environment of the system being developed
- An interaction model is a dynamic model that shows how the system interacts with its environment as it is used
### Approaches to identification - Object class
- Use a grammatical approach based on a natural language description of the system.
- Base the identification on tangible things in the application domain
- Use a behavioural approach and identify objects based on what participates in what behaviour
- Use a scenario-based analysis. The objects, attributes and methods in each scenario are identified
### Design models
- Structural (static) models describe the static structure of the system in terms of object classes and relationships.
- Dynamic models describe the dynamic interactions between objects
- Examples of design models
    - Subsystem model shows how the design is organised into logically related groups of objects
    - Sequence models show the sequence of object interactions that take place
    - State diagrams are used to show how objects respond to different service requests and the state transitions triggered by these requests
### Design patterns
- A design pattern is a way of reusing abstract knowledge about a problem and its solution.
### A UML model of the Observer pattern
- Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically
- ![](https://i.imgur.com/NKC99ug.png)
### Domain-Driven Design (DDD)
- DDD is an approach to software development for complex needs by connecting the implementation to an evolving model
- DDD Building Blocks
    1. Entity: An object that is identified by its consistent thread of continuity, as opposed to traditional objects, which are defined by their attributes.
    2. Value Object: An immutable (unchangeable) object that has attributes, but no distinct identity
    3. Domain Event: An object that is used to record a discrete event related to model activity within the system.
    4. Aggregate: A cluster of entities and value objects with defined boundaries around the group.
    5. Service: Essentially, a service is an operation or form of business logic that doesn’t naturally fit within the realm of objects.
    6. Repositories: is a service that uses a global interface to provide access to all entities and value objects that are within a particular aggregate collection.
    7. Factories: DDD suggests the use of a factory, which encapsulates the logic of creating complex objects and aggregates, ensuring that the client has no knowledge of the innerworkings of object manipulation.
### Configuration management
- 是一個建立系統工程的過程，用來建立與維持一個產品，讓這個產品的效能、功能，以及它所要求的物理特性，在它的生命週期中，都能保持穩定與一致性。
- activities
    - Version management, where support is provided to keep track of the different versions of software components.
    - System integration, where support is provided to help developers define what versions of components are used to create each version of a system.
    - Problem tracking, where support is provided to allow users to report bugs and other problems, and to allow all developers to see who is working on these problems and when they are fixed.
    - Release management, where new versions of software system are released to customers.
- ![](https://i.imgur.com/icy430i.png)

## ch8
### Program testing
- Testing is intended to show that a program does what it is intended to do and to discover program defects before it is put into use. 
### Program testing goals
- To demonstrate to the developer and the customer that the software meets its requirements.
<!--     - For custom software, this means that there should be at least one test for every requirement in the requirements document.
    - For generic software products, it means that there should be tests for all of the system features, plus combinations of these features, that will be incorporated in the product release. -->
### Testing process goals
- Validation testing
    - To demonstrate to the developer and the system customer that the software meets its requirements.
- Defect testing
    - To discover faults or defects in the software where its behaviour is incorrect or not in conformance with its specification
### Verification vs Validation(V&V)
- Verification：The software should conform to its specification.
    > *"Are we building the product right”.*
- Validation：The software should do what the user really requires.
    > *"Are we building the right product”*
### V & V confidence
- Software purpose
    - The level of confidence depends on how critical the software is to an organisation.
- User expectations
    - Users may have low expectations of certain kinds of software
- Marketing environment
    - Getting a product to market early may be more important than finding defects in the program
### Inspections and testing
- Software inspections Concerned with analysis of the static system representation to discover problems. (static verification)
- Software testing Concerned with exercising and observing product behaviour. (dynamic verification)
- ![](https://i.imgur.com/k6a05qv.png)
### Advantages of inspections
- inspection is a static process, you don’t have to be concerned with interactions between errors.
-  Incomplete versions of a system can be inspected without additional costs.
- inspection can also consider broader quality attributes of a program, such as compliance with standards, portability and maintainability.
### A model of the software testing process
- ![](https://i.imgur.com/n7z28Yi.png)
### Stages of testing
- Development testing：where the system is tested during development to discover bugs and defects.
    - Unit testing：Unit testing should focus on testing the functionality of objects or methods
    - Component testing：Component testing should focus on testing component interfaces
    - System testing：System testing should focus on testing component interactions
- Release testing：where a separate testing team test a complete version of the system before it is released to users.
- User testing：where users or potential users of a system test the system in their own environment.
### Testing strategies
- Partition testing：where you identify groups of inputs that have common characteristics and should be processed in the same way.
- Guideline-based testing：where you use testing guidelines to choose test cases.
### Test-driven development
- is an approach to program development in which you inter-leave testing and code development
- ![](https://i.imgur.com/f5ICx9W.png)
### Benefits of test-driven development
- Code coverage
- Regression testing
    - One of the most important benefits of TDD is that it reduces the costs of regression testing
- Simplified debugging
- System documentation
### Release testing
- The primary goal of the release testing process is to convince the supplier of the system that it is good enough for use.
### Types of user testing
- Alpha testing
- Beta testing
- Acceptance testing
### The acceptance testing process
- ![](https://i.imgur.com/LMniTfA.png)
## ch9
### Refactor and reengineering
- reengineering 是對於架構上的改良,
- refactoring 則是針對 project 中 bad smell 的部份進行改進
### Cose Smell
- 充滿壞味道的程式，通常不是好程式。當你在閱讀程式碼時，若感覺某段寫法令人不悅，彷彿飄出一股臭味，甚至使人作嘔，通常就意味著該思考是否要重構消毒除臭一番。發線程式碼有壞味道後馬上進行適當的重構，培養自身撰寫程式的好習慣及使用能查找壞味道的程式。
- Duplicate code 
- Long methods
- Large class
- Data clumping
- Feature envy
### Advantages of reengineering
- Reduced risk
- Reduced cost
### Reengineering process activities
- Source code translation
- Reverse engineering
- Program structure improvement
- Program modularisation
- Data reengineering