[Soft Exam - Notes on Essential Knowledge Points for Software Designers] Chapter 7 Object-Oriented Technology

Preface

Since the notes copied to CSDN have invalid styles, I don’t have the energy to completely check and set the styles again. Those with points can download the word, pdf, and Youdao cloud note versions.
It should be noted that the downloaded content is consistent with the content shared in this article. The only difference is the style [for example, the key memory and frequently tested content have colors, font sizes, weights, etc., and the directory structure is more complete. Tables are not pictures, etc.]

Download address of this chapter:
https://download.csdn.net/download/chengsw1993/85835830

If you find that the article has reading differences, abnormal display, etc., please let us know in the comment area so that we can modify it. This should be caused by CSDN's markdown syntax.

Series of articles

Previous article:[Soft Exam - Notes on Essential Knowledge Points for Software Designers] Chapter 6 System Development and Operation

Next article:[Soft Exam - Notes on Essential Knowledge Points for Software Designers] Chapter 8 Algorithm Analysis and Design

Object-oriented basics

basic concept

Object: The basic running entity is an instance of a class, encapsulating the entirety of data and behavior, such as real entities such as students and cars. Objects have clear boundaries, well-defined behavior, and extensibility.

Message: A construct for communication between objects is called a message.

Class: It is an abstraction of objects, defining a group of generally similar object structures, and defining data and behavior. Including entity classes (classes used to model information that must be stored and related behaviors, classes that need to be saved for a long time and always exist), boundary classes (classes that model interactions between business protagonists inside the system and outside the system) , Control class (a class used to model the control behavior unique to one or several use cases, and a specific behavior that appears passively during the execution of the use case). The domain class model will involve attributes and operations that describe the situation of the class itself, as well as describe the association between classes, but there will be no object-level content.

Inheritance: The mechanism for sharing data and methods between parent and child classes. It is a relationship between classes.

Polymorphism: Different objects have completely different reactions when receiving the same message. It includes four types: parametric polymorphism (different types of parameters and multiple structure types), inclusion polymorphism (parent-child type relationship), overloaded polymorphism (similar to overloading, one name has different meanings), and forced polymorphism (forced type conversion). Polymorphism is supported by the inheritance mechanism.

Overwriting/rewriting: Based on the original parent class interface, the subclass replaces the corresponding implementation in the parent class with an implementation suitable for its own requirements. That is, redefine a method in the subclass with the same name and parameters as the parent class.

Function overloading: To be distinguished from overwriting, function overloading has nothing to do with the subclass and parent class, and the function has the same name but different parameters.

Encapsulation: An information hiding technology whose purpose is to separate the users and producers of objects, that is, other developers do not need to understand the internal working mechanism of the software components they want to use, but only need to know how to use the components.

Static typing means that the type of an object is determined at compile time;

Dynamic typing means that the object type can only be determined at run time.

Static binding (static allocation) is based on static type, and the method has been bound before the program is executed;
Dynamic binding is based on dynamic type, and the variables are determined at runtime The actual referenced object type determines which method is called, and dynamic binding supports polymorphism.

object-oriented analysis

Object-oriented analysis: is to determine the problem domain and understand the problem.

It contains five activities: identifying objects (identifying objects according to naturally existing entities), organizing objects (analyzing object relationships and abstracting them into classes), interaction between objects (describing the relationship between objects in the application system), and determining object operations. (Operations, such as creation, addition, deletion, etc.), defining the internal information (properties) of the object.

Object-oriented design: It is the design of analysis model and implementation of corresponding source code. This source code can be executed in the target code environment. Design solutions to problem domains.

Object-oriented programming: Use object-oriented programming language to implement design solutions. See software design in the afternoon for details.

Object-oriented testing: No different than normal testing steps.

It can be divided into four levels: algorithm layer (testing each method defined in the class, similar to unit testing), class layer (testing the interaction of all methods and attributes in the same class, unique module testing), template layer (testing The interaction between a group of classes that work together, similar to integration testing), system layer (similar to system testing).

UML

UML is a unified modeling language and has nothing to do with programming languages.

There are three elements of UML: the basic building blocks of UML, the rules that govern how these building blocks are placed together, and some common mechanisms that apply to the entire language.

The basic building blocks of UML include: things (abstraction of the most representative components in the model), relationships (combining things together), and diagrams (aggregating related things).

thing

There are four types of things in UML:structural things, behavioral things, grouping things, and annotation things.

Structural things: static parts of the model, such as classes, interfaces, use cases, components, etc.; as shown in the following figure:
Insert image description here

Behavioral things: The dynamic parts of the model, such as interactions, activities, and state machines.
Insert image description here

Group things: Organizational parts of a model, such as packages.

Annotation: The explanatory part of a model, a simple symbol attached to an element or a set of elements that constrains or explains it.
Insert image description here

relation

Dependence: The semantics of one thing change depending on the change of the semantics of another thing

Association: It is a structural relationship that describes a set of chains. Chains are connections between objects. Divided into combination and aggregation/aggregation, both are relationships between parts and wholes, among which the relationship between combined things is stronger. The association between two classes is actually an association between the roles played by the two classes. Therefore, there can be multiple associations between two classes identified by different roles.

Generalization: general/special relationship,Relationship between subclass and parent class

Implementation: One class class specifies a contract that another class class guarantees to enforce.
Insert image description here

picture

Class diagram (static diagram)

Class diagram: Static diagram is a static design view of the system, showing a set of objects, interfaces, collaborations and the relationships between them. The UML class diagram is as follows:
Insert image description here

Multiplicity: 1...* means 1 or more, 1 means 1
Attributes
Operations
Relationship

Object graph (static graph)

Object diagram: Static diagram, showing a group of objects and the relationship between them at a certain moment, which is a snapshot of the class diagram.
Without a class diagram, the object diagram is a static design view, as follows:
Insert image description here

Use case diagram (static diagram)

Use case diagram: A static diagram that shows a set of use cases, actors, and the relationships between them.

The actors in a use case diagram are the roles that people, hardware, or other systems can play; a use case is a series of operations completed by the actors.

The relationship between use cases:Inclusion, extension, generalization.
Insert image description here

Sequence diagram (dynamic diagram)

Sequence diagram: namely sequence diagram, dynamic diagram. It is a graphical representation of a scene that describes the interactions between objects organized in time sequence.

YesSynchronization message (making a blocking call, the caller suspends execution, waits for control to return, and needs to wait for a return message, use a solid triangular arrow Represented), Asynchronous message (continues execution after sending the message, does not cause the caller to block, and does not wait for the return message, represented by the hollow arrow), (indicated by the dashed arrow from right to left) Three types. As shown in the picture:Return message
Insert image description here

Communication diagram (dynamic diagram)

Communication diagram: Dynamic diagram, also known as collaboration diagram, is another representation method of sequence diagram. It is also a diagram composed of objects and messages, but it does not emphasize the time sequence, but only emphasizes the communication between events, and There are no fixed drawing rules. and sequence diagrams are collectively called interaction diagrams. As follows:
Insert image description here

State diagram (dynamic diagram)

State diagram: A dynamic diagram that shows a state machine describing the behavior of a single object in multiple use cases, including simple states and combined states.

conversion can be triggered by an event trigger. After the event is triggered, the corresponding monitoring conditions will be checked. Transitions and states in the state diagram are two independent concepts, as follows:The boxes in the figure represent states, the arrows represent trigger events, and the solid dots are the starting point and end point.

Insert image description here

Activity diagram (dynamic diagram)

Activity diagram: Dynamic diagram is a special type of state diagram that shows the flow from one activity to another in the system.

The active bifurcation and confluence line is a thick horizontal line.

Nouns and meanings such as concurrent bifurcation, concurrent convergence, guardian expression, branch, and stream. The number of branches for each fork represents the number of threads that can run simultaneously. What can be executed in parallel in an activity diagram is the activities on the branches under a thick branch line.
Insert image description here

Component diagram (static diagram)

Component diagram (component diagram): Static diagram, a static implementation view of the system, showing the organization and dependencies between a set of components. as follows:
Insert image description here

Deployment diagram (static diagram)

Deployment diagram: Static diagram, which is a static deployment view of the system. The deployment diagram is the node distribution of physical modules. It is related to the component diagram, usually a node contains one or more components. Its dependency relationship is similar to package dependency, so the dependency between deployed components is one-way and similar to the inclusion relationship. As follows:
Insert image description here

Design Patterns

Each design pattern describes a recurring problem around us and the core of the solution to that problem. This way, you can use the solution again and again without duplication of effort. The core of design patterns is to provide solutions to related problems, making it easier and more convenient for people to reuse successful designs and architectures.

The four basic elements of a design pattern are: pattern name, problem (when the pattern should be used), solution (content of the design), and effect (the effect of the pattern application).

is divided into three categories, creative mode mainly deals with creating objects, structural mode< /span>Mainly describes the interactive behavior of classes or objects, as follows (Memory keywords in bold red indicate those that must be remembered for regular exams):Behavioral patternMainly deals with the combination of classes and objects,

Insert image description here
Insert image description here
Insert image description here

Observer mode: Listener, Event
Decorator mode: Wrapper, Decorator
Adapter mode: HandlerAdatper executes different Handlers according to Handler rules
Spring design pattern summary

Guess you like

Origin blog.csdn.net/chengsw1993/article/details/125537502