Objective:
1. Understand and master the object-oriented concepts and methods.
2. Use UML.
3. complete object-oriented analysis and design.
4. Understand the OO design principles and some typical design patterns
What Is Object-Oriented?
- Object-orientation (OO) is a system modeling technology.
- Object-Oriented Programming (OOP) is a process of developing programs according to the OO methodology.
- Describes or models A system by analyzing the interaction of objects in the system.
- The interaction objects are finally organized in the form of classes.
- The OO method consists of three parts: process, identifier, and rule.
Object
- It is an objective and unique entity.
- It is the starting point and basis for analyzing and solving problems in the process of object-oriented programming.
- Has its own identity, data, and behavior.
- It can be simple or complex.
- Can be abstract or specific.
- In Oop, it is a dynamic instance of a class.
- For example, student-ID, name, age (attribute)
-- Setname, getname, countscore (methods)
-- New student ()
Class
- Class is the object template.
- Objects are generated by class instantiation.
- One class can create multiple objects
OOAD
OOAD (Object Oriented Analysis and Design), object-oriented analysis and design.
OOAD is a process of analyzing and designing software systems based on OO methodology.
-- OOA
Analysis Phase
-- OOD
Design Phase
DefinitionOOAPhase
- The analysis phase mainly solves the following problems:
-- Create a clear view of business problem domains.
-- List the core tasks that must be completed by the system.
-- Create a public vocabulary for the problem domain.
-- List the best solutions for this problem.
2. What
Do ?"
DefinitionOODPhase
1. the design phase mainly solves the following problems:
--
How to solve specific business problems.
--
Introduce the supporting elements required for system work.
--
Define system implementation policies
2. How
Do ?"
OOPMain features
1. Abstract)
2. Encapsulation)
3. Inheritance)
4. polymorphism (polymorphism)
5. Association)
6. Aggregation)
7. Composition)
8. Cohesion and coupling (cohesion &
Coupling)
Abstraction
- Ignore the details of an object or entity and focus only on its essential features.
- Simplified functions and formats.
- Helps users interact with objects.
Encapsulation
- Hide data and implementations.
- Provides public methods for users to call.
- Two views of an object.
-- External view: the work that an object can do.
-- Internal view: How the object completes its work.
Inheritance
- Define a New Type through an existing type.
- There is usually a relationship like "is a" or "kind of" between two types.
- Code can be reused through inheritance, and inheritance is also the basis of polymorphism.
For example, Apple "is a" fruit.
Polymorphism
- A name in multiple forms.
- Inheritance-based Polymorphism
- When calling a method, select a different processing method based on the given object.
- For example, football-Play (): complete with a script.
Basketball-Play (): complete by hand.
5. Give a specific football or basketball. The user automatically knows who to use to execute play ().
Association
- A reference method for interaction between objects.
- When an object uses the service or operation of another object through the reference of another object, the two objects are associated.
- For example, if a person uses a computer, there is an association between the person and the computer.
Aggregation
- An association. An object is an integral part of another object.
- Is a strongly correlated relationship.
- There is a relationship like "has a" between two objects. An object exists as an attribute of another object. When an external object is produced, the internal object associated with it can be specified by the client.
- For example, an automobile and a tire are an integral part of an automobile. They can be assembled and used after production respectively, but the automobile can be replaced with a new tire and can be unloaded for use by other cars.
Combination
- When an object contains another object, the external object is responsible for managing the lifecycle of the internal object.
- The most intense Association.
- Internal creation is controlled by external objects.
- Such as televisions and monitors.
Domain Model
- The domain model is object-oriented. In object-oriented terms, a domain model can also be called a design model. The domain model consists of the following:
-- Domain objects with statuses and Behaviors
-- Relationship between domain objects.
- · Association
- · Dependency
- · Focus
- · Generalization)
Relationship between domain objects
- · Association)
- · Dependency)
- · Aggregation)
- · Generalization)
Association
Customer
<---------------------- Order [Customer: Customer]
Multi-to-one association from order to customer
Customer [Orders: Set] ----------------- à order
One-to-multiple unidirectional Association from customer to order
Customer [Orders: Set] orders ------------ à order [Customer: Customer]
One-to-multiple bidirectional Association from customer to order
Dependency
BusinessService --------- à customer
BusinessService class depends on customer class
The method used to access the customer class in the businessService class,
Create a customer instance.
Clustering relationship
Clustering refers to the relationship between the whole and the part, which is common among object domain objects.
Person {set
Aggregation relationship between the person class and the hand class
General Relationship
General relationships refer to the inheritance relationships between classes.
Cohesion and Coupling
- Cohesion: measure the ability of a class to complete a job independently.
- Coupling: measure the complexity of dependencies within or between systems.
- Design Principle: increase cohesion and reduce coupling (High Cohesion and low coupling ).
Development Process Overview
1. Traditional development process-Waterfall Model
2. Unified Software Development Process (usdp)
Traditional development process (Waterfall Model)
Requirements à analysis à design à implementation à Test
OOADDevelopment Process
- Major projects are divided into subprojects.
- Use UML tools
- Unified Software development is an iterative and incremental development process.
Iterative and incremental project lifecycle
- Projects are iterative and incremental.
- Iteration refers to a step in the lifecycle.
- Iteration leads to "increasing" or the growth of the entire project.
- Major projects are divided into subprojects.
- In each iteration stage, we should do the following:
-- Select and analyze related Use Cases
-- Design Based on the selected Architecture
-- Design at the component level
-- Verify that the component meets the needs of the use case
6. When an iteration meets the target, the development enters the next iteration cycle.
Inception-start up
Elaboration-refine
Construction-Implement
Transition -- Promotion
7. Each cycle contains one or more iterations.
8. The end of a stage is called "Milestone" (milestone)
Initialization phase
The increment of this phase is concentrated in:
-- Start the project
-- Establish business
-- Define business problem domains
-- Identify major risk factors
-- Define the extension of project requirements
-- Create instructions for business problem domains
Refinement stage
-- High-level Analysis and Design
-- Establish the basic framework of the Project
-- Main risk factors of Supervision
-- Formulate a creation plan to achieve the project objectives
Build phase
The increment in this phase is concentrated in
-- Code and function implementation
Handover phase
The increment in this phase is concentrated in
-- Publish a product to a user
-- Beta test
-- Perform performance tuning, user training, and Acceptance Testing
Workflow contained in each stage
· Each increment is composed of five workflows.
-- Requirement and initial analysis
-- Analysis
-- Design
-- Implementation
-- Test
-- The depth of the workflow executed in each iteration is different.
-- Early iterations cover the initial workflow in depth, while later iterations cover the later workflow in depth.
-- 80/20 Principle
Advantages of iteration and incremental Lifecycle
· Reduce costs
· Easy to maintain the project progress
· Facilitates collaborative development by teams
· To adapt to the dynamic changes of user needs