Object-Oriented Methodology for Review of Introduction to Software Engineering

1. Key points and advantages of object-oriented methodology

main points:

① Think that the objective world is composed of various objects, everything is an object, and complex objects can be composed of simpler objects in a certain way. The object-oriented approach replaces the functional decomposition of the traditional approach with object decomposition.

② Divide all objects into various object classes, and each class defines a set of data and a set of methods.

③According to the relationship between the subclass (or called the source class) and the parent class (or called the base class), several object classes are formed into a hierarchical system (also called class hierarchy).

④ Objects can only communicate with each other by passing messages.

advantage:

① Consistent with the way of thinking that humans are used to

② Good stability

③ Good reusability

④Easier to develop large-scale software products

⑤Good maintainability

2. Object-oriented basic concepts

  1. Object: An object is an abstract representation of an individual or thing in the real world, and it is an encapsulation of its attributes and related operations.
  2. Class: A class is a description of one or more objects that have the same properties and behavior.
  3. Instance: A concrete object described by a particular class
  4. Message: A specification that requires an object to perform an operation defined in the class in which it is defined
  5. Method: The operation that the object can perform, that is, the service defined in the class
  6. Attribute: the data defined in the class, the abstraction of the properties of the objective world entity
  7. Encapsulation: When using an object, you only need to know the form of the interface it provides to the outside world, without knowing the internal details
  8. Inheritance: It is a mechanism for subclasses to automatically share the data structure and methods of the parent class, which is a relationship between classes
  9. Polymorphism: means that the same operation or function process can act on multiple types of objects and obtain different results
  10. Overloading: Function overloading means that several functions with different parameter characteristics in the same scope can use the same function name; operator overloading means that the same operator can be applied to different types of operands   

 3. Class Diagram

 Usually, use the class diagram provided by UML to build the object model. A class diagram describes the static relationship between classes, which is the basis for creating other UML. A system can be represented by multiple class diagrams, and a class can also appear in several class diagrams.

(1) Composition of classes

① Class name : descriptive, concise and unambiguous

②Attribute : Describes the characteristics of the thing (that is, object) represented by the class in the software system. The class can have any number of attributes or no attributes. The syntax of the class attribute in UML is:

Visibility attribute name: type=initial value

Visibility: Public (Public) "+" All classes are visible; Private (Private) "-" This class and its descendants are visible;

Protected (Protected) "#" is only visible to the class itself; if it is not declared, it means that it has not yet been defined

··The attribute name is composed of nouns or noun phrases that describe the characteristics of the class to which it belongs, and the first letter of the rest of the words except the first word should be capitalized

Attribute type: simple type, integer type, floating point type, Boolean type, ... other custom classes in the system

The initial value of the attribute: protect the integrity of the system and prevent the integrity of the system from being missed or damaged by illegal values

③Operation : The abstraction of the transactions that objects of a class can do. A class can have any number of operations or no operations at all. The
return type, name and parameters are called the operation signature. In UML, the syntax of a class operation is:

Visibility operation name (parameter list): return value type

The visibility of the operation is the same as that of the property

··Operation Name: A verb or verb phrase used to describe the behavior of the class to which it belongs. Naming rules are the same as attributes

··Parameter table: Some attributes in order define that the input of the operation is optional, that is, the operation does not necessarily have to have parameters, the syntax is "parameter name: type = default value" (the default value is used when no actual parameter is provided)

Return type: is optional, that is, the operation does not necessarily have to have a return type

 (2) Relationship between classes

①Association : Indicates that there is a certain semantic connection between objects of two classes. For example, when a student uses a computer, there is in the class diagram:

The multiplicity at both ends of the line indicates how many objects of the class are connected to one object of the other

②Aggregation : Aggregation is a special case of association, which means that the relationship between classes is the relationship between the whole and the part.

Shared aggregation: Objects at the part side can participate in the formation of multiple objects at the whole side at the same time, for example, a project team consists of multiple team members, and each team member can also be a member of other project teams

 ··Combined aggregation: the part and the whole coexist, and if the whole does not exist, the part will disappear with it. For example, a window is composed of text boxes, etc. When the window is closed, each component will also disappear

 ③Generalization (inheritance) : a classification relationship between general elements and specific elements

 ④ Dependency : Describe the semantic relationship between two model elements. If A is independent, B is not independent, and B depends on A, B will be affected when A changes, such as animals drinking water

 ⑤ Refinement : When the same thing is described at different levels of abstraction, there is a refinement relationship between these descriptions. For example, A and B describe the same thing, and B is a more detailed description on the basis of A. It is said that B refines A, or A becomes B.

 4.  Use case diagram

 A use case diagram contains model elements such as system, use cases, actors and the relationships among use cases

  1. System: Think of it as a black box that provides use cases, represented by a box. The internal working implementation is not important for establishing the use case model.
  2. Actor: A person or other system that interacts with the system, on behalf of an external entity
  3. Use case: A complete function of the system that can be experienced by actors. In UML, a use case is defined as a series of actions completed by the system. Characteristics of a use case: represents visible functionality, achieves some goal; is initiated by an actor; must be complete
  4. Relationship between use cases:  ①Extended relationship: Adding some actions to a use case constitutes another use case, which inherits some behaviors of the former, and the latter is usually called an extended use case ②Usage relationship: One use case uses another use case

5. Three models established by object-oriented technology

To develop software with the object-oriented method, it is usually necessary to establish three types of models, which are the object model describing the system data structure , the dynamic model describing the system control structure and the function model describing the system function.

Object Model: Represents the static, structured "data" nature of the system. It is a mapping of the objects that simulate the entities of the objective world and the relationship between objects, and describes the static structure of the system. The object model is always the most important and fundamental, laying the foundation for the other two models

Dynamic Model: Represents the "controlling" properties of a transient, behavioral system. It specifies the legal sequence of changes to objects in the object model

Functional Model: Represents the "functional" nature of the changing system, which specifies what the system should "do" and thus more directly reflects the user's needs for the target system.

Guess you like

Origin blog.csdn.net/weixin_46516647/article/details/124989008