Object-Oriented Methodology 1

I. Overview

(1) It is believed that the objective world is composed of various objects, everything is an object, and complex objects can be composed of relatively simple objects in some way.
(2) All objects are divided into various object classes (referred to as classes, Class), and each object class defines a set of data and a set of methods.
(3) According to the relationship between the subclass (or the derived class) and the parent class (or the base class), several object classes are organized into a hierarchical system (also known as class level).
(4) Objects can only communicate with each other through messages.

Object-oriented=object+class+inheritance+message communication

The object-oriented method is to use both objects and mechanisms such as classes and inheritance, and the objects can only communicate with each other by passing messages.

2. Concept

1. Class :
A group of objects with the same data and the same operation;

2. Instance :
a specific object described by a class;

3、消息Message:
= object_ID. method_ID (parameter(s));

4. Method :
The operations that the object can do, also known as service and response, the corresponding code must be defined in the class;

5. Attribute :
the inherent data of the object;

6. Encapsulation :
It combines the properties and services of the object into an independent system unit, and hides the internal details of the object as much as possible.

7. Inheritance :
Subclasses automatically share the attributes and methods of the parent class without having to repeat definitions.

8. Polymorphism : Classes at
different levels can share a method name, but implement this method in their own way.

9. Overloading :
There are two types of overloading: function overloading means that several functions in the same scope with different parameter characteristics can use the same function name; operator overloading means that the same operator can be applied to different The type of operand above. Of course, when the parameter characteristics are different or the type of the operand is different, the semantics of the algorithm or operator that implements the function is different.

Three, object-oriented modeling

Modeling

  • An abstraction made for things in order to understand things is an unambiguous written description of things.
  • The model consists of a set of graphic symbols and the rules for organizing these symbols, and use them to define and describe the terms and concepts in the problem domain.

Three types of models :

  • Object model describing system data structure
  • Dynamic model describing system control structure
  • Functional model describing system functions

A model is a complete abstraction of a system.

Fourth, the object model

UML?
Unity : A universal standard.
Modeling : Establish a model of the software system.
Language : Indicates that it is a set of symbol systems composed according to specific rules and patterns. It is defined by a semi-formal method, that is, it is defined by a combination of graphic symbols, natural language and formal language.

Nine UML diagrams:
Use Case Diagram,
Class Diagram,
Object Diagram,
Sequence Diagram,
Collaboration Diagram,
Statechart Diagram,
Activity Diagram, and
Component Diagram (Component Diagram)
Deployment Diagram (Deployment Diagram)

Class Diagram:

  1. Defining
    a class The graphic symbol that represents a class is a rectangle, which is divided into three areas, upper, middle, and lower. The upper area writes the class name, the middle area is the class attribute, and the lower area is the operation (ie service) of the class.

Insert picture description here
2. Naming A
class name is the name of a class of objects.
Specifically, the following guidelines should be followed when naming classes:
(1) Use standard terminology
(2) Use nouns with precise meanings
(3) Use noun phrases as names when necessary

  1. Describe the properties of the class

Select attributes:
● The attributes of the class should be able to describe and distinguish each object of the class;
● Only those features that the system needs to use should be extracted as the attributes of the class;
● The purpose of system modeling should be fully considered when selecting attributes.

Descriptive attributes:

  • The grammatical format of UML describing attributes is as follows:
    visibility attribute name: type name = initial value {character string}
  • The attribute name and type name must be present.
  • The visibility (that is, accessibility) of attributes is usually divided into three types: public, private and protected, which are represented by plus sign (+), minus sign (-) and pound sign (#) respectively.
  • If there is no symbol in front of the attribute name, it means that the visibility of the attribute has not been defined.
  • UML has no default visibility.
    Insert picture description here
  1. Describe the operation of the class
    Select operation:
    Operation is used to retrieve, modify the properties of the class or perform certain actions.
    ● The operation is set around the processing required for the attribute data of the class, and operations that have nothing to do with these data are not set;
    ● Only those operations that the system needs to use are extracted as operations of the class;
    ● The user’s needs should be fully considered when selecting operations demand.

Describe the operation:

  • The syntax format of UML description operation is:

Visibility operation name (parameter list): return value type {character string}

  • Among them, visibility and operation name are indispensable.

  • The meaning of operation visibility is the same as the meaning of attribute visibility.

  • The parameter table consists of several parameters separated by commas (,). The syntax format of writing parameters is as follows:

     参数名:参数类型名=缺省值
    

Insert picture description here

Graphical symbols representing relationships

1. Association relationship (the most common)
Association relationship indicates that there is a semantic connection between two types of objects, that is, there is a relationship of interaction and mutual dependence between the objects.
Usually the relationship between the two types of objects is subdivided into three basic types: one-to-one (1:1), one-to-many (1:M), and many-to-many (M:N). The types are based on The number of objects participating in the association.
Insert picture description here
2. Gather

  • Shared gathering
  • Combinatorial aggregation

3. Generalization (inheritance) relationship
4. Dependence and refinement

Five, dynamic model

The dynamic model describes the interaction relationship between the objects supported by the system, including sequence diagrams, collaboration diagrams, state diagrams and activity diagrams .

Six, functional model

The functional model represents the "functional" nature of the changing system. It specifies what the system should "do", and therefore more directly reflects the user's needs for the target system.

The functional model consists of a set of data flow diagrams.

The use case diagram provided by UML is a powerful tool for requirement analysis and establishment of functional models. In UML, the system model established by the use case diagram is called the use case model.

A use case is a sequence of operations performed by the system, the result of which will produce an observable result value for a specific operator.

A use case is a sequence of text describing the interaction process performed by an actor using a function of the system.

The use case model includes four parts: operators, use cases, relationships, and system boundaries.

  • Operator: things or use the system roles played by people
  • Use case: description of the interaction between the operator and the system
  • Relationship: the meaningful connection between the operator and the use case and between the use case and the use case
  • System Boundary: A box surrounding the use case, indicating the boundary of the system being modeled

Guess you like

Origin blog.csdn.net/weixin_44366125/article/details/106094591