The main features of "OOAD" oop

Source: Internet
Author: User
Tags dashed line

Aggregation "virtual inclusion" ambiguous
The combination of "real inclusion" explicit

Abstraction (abstract)
Abstraction: Abstraction is the process of forming a concept after extracting common features through a particular instance. It emphasizes the main characteristics, ignoring the secondary features. An object is an abstraction of an entity in the real world, a class is an abstraction of a set of objects, an abstraction is a single description that emphasizes the characteristics associated with the application and discards irrelevant features.

The process of ignoring the details of an object or entity and focusing only on its main characteristics;
simplify functions and formats;
Helps users interact with objects.

Package (encapsulation)
Encapsulation (encapsulation)-Hide internal implementations
Hide data and implementations;
Provide public methods for user invocation function;
Two views of objects
External view: What the object can do
Inner view: How an object finishes its work
Benefits:
Good encapsulation can reduce coupling;
The implementation within the class can be freely modified;
The class has a clear external interface. (public)

Encapsulation (encapsulation) is an important principle of an object. It has two levels of meaning:
First, the object is an indivisible whole which is formed by the close combination of all its properties and all the services;
Second, the object is an opaque black box, and the data that represents the state of the object and the code that implements the operation are encapsulated in a black box. When you use an object, you only need to know the form of the interface it provides to the outside world, without having to know its data structure details and the algorithm that implements the operation. Invisible from the outside, it is more impossible to directly modify the object's private properties from the outside.
Encapsulation is a unit of related concepts that are then referenced by a name. Object-oriented encapsulation is the encapsulation of data and data-based operations into a whole object, and access to or modification of the data can only be done through interfaces provided externally by the object.

Inheritance, generalization, generalized relationships (inheritance, generalization)
Inheritance (inheritance)-Reusing existing code
A mechanism for defining new types through existing types;
There is usually a relationship of "is a" or "kind of" between the two types;
Through inheritance, code reuse can be realized, and inheritance is also the basis of polymorphism.
such as Apple "is a" fruit.

Do not inherit, if you want to modify the function, you have to modify in all the repeated methods, the more code, the more likely the error, and the advantage of inheritance is that all subclasses of the public part of the parent class, so that the code has been shared, which avoids duplication, in addition, Inheritance can make it easier to modify or extend inherited implementations.

Generalization (generalization)-Example
Generalization (generalization) generalize refers to the inheritance relationship between classes.
The inheritance relationship is represented by a hollow triangle + solid line.

Polymorphic (polymorphism)
Polymorphic (polymorphism)-Overwrite object behavior

A name, multiple forms;
Inheritance-based polymorphism;
When the method is called, different processing methods are chosen according to the different objects.
such as Football-play (): Use the foot to complete
Basketball-play (): Use Hand to complete
Give a specific football or basketball, the user automatically know who to use the way to perform play ()

Polymorphic (polymorphism)-Example 1
Polymorphism is a method that allows you to define the same operation or property name in multiple classes, and can have different implementations in each class. Polymorphism allows a property or variable to represent a non-homogeneous object at different times.

, rectangle and Circle are inherited from shape, and for shape there is a getarea () operation. It is clear, however, that the implementation of the Rectangle and Circle Getarea () methods is completely different, which embodies the polymorphic characteristics.

Polymorphic (polymorphism)-Example 2


Virtual methods and methods overrides
In order for an instance of a subclass to completely replace a class member from a parent class, the parent class must declare the member as virtual. This is done by adding the virtual keyword before the return type of the member.
Subclasses can choose to use the Override keyword to replace the parent class implementation with its own implementation, which is the method override override, or method overwrite.
The declaration of this object must be a parent class, not a subclass, and a different object can perform the same action, but it is executed by their own implementation code.
The instantiated object is a subclass, which enables polymorphism.
The principle of polymorphism is that when a method is called, no matter whether the object is converted to its parent class, only the method implementation at the end of the object's inheritance chain is called. That is, a virtual method is called dynamically by its run-time type, not by the compile-time type.
Not learning design patterns, so many pairs of state, and even to the object-oriented understanding is mostly superficial and one-sided.

Association (Association)
A way of referencing when interacting between objects;
When an object uses another object's service or operation through a reference to another object, there is an association between the two objects;
There is an association between person using Computer,person and computer.

Association (association)-Example
When a class ' knows ' another class, it can be associated (association).
The association relationship is represented by a solid arrow.

Aggregation, aggregation (aggregation)
One of the related relationships in which an object becomes part of another object;
is a strong correlation;
There is a "has a" relationship between two objects, an object that exists as a property of another object that can be specified by the client with its associated internal object when the external object is produced;
such as automobiles and tires, tires as a part of the car, it and the car can be produced separately after the use of the Assembly, but the car can be replaced by new tires, tires can also be unloaded to other cars to use.

Aggregation (aggregation)-Example
Aggregation represents a weak ' owning ' relationship, which indicates that a object can contain a B object, but that the B object is not part of a object.
The aggregation relationship is represented by a hollow diamond + solid arrow.
Aggregation refers to the relationship between the whole and the part, which is common between entity domain objects

Combination (composition)
When an object contains another object, the external object is responsible for managing the life cycle of the internal objects;
One of the strongest associations in the relationship;
The creation of an internal object is controlled by the external object itself;
The inner object cannot exist when the external object does not exist;
such as televisions and monitors.

Combination (composition)-Example
Synthesis (composition, also translated into ' combination ') is a strong ' ownership relationship ' that embodies a strict part-to-whole relationship, part and whole life cycle.
Synthetic relationships are represented by solid Diamond + solid arrows.

Dependency (Dependency)
Dependency (Dependency), denoted by a dashed arrow.

Implementation (Realization)
Implementation (realization): A dashed line with a hollow arrow;

Cohesion and coupling (cohesion&coupling)
Cohesion: A measure of the ability of a class to accomplish a task independently
Coupling: Measuring the complexity of dependencies within a system or between systems
Design principles: increased cohesion, reduced coupling (cohesion, low coupling)

The coupling degree of the program is reduced by encapsulation, inheritance and polymorphism.
The design pattern makes the program more flexible, easy to modify, and easy to reuse. (maintainable, reusable, scalable, flexible)

"Statement and thanks"
This article, on the shoulders of many giants, draws on and cites many other works or writings that others have copyrighted, and is here to thank the former people for their contributions. And at the same time publish the quoted content, the original author or source (some of the content from the Internet can not be traced to the source, deeply regret).

"References"
Design mode-the basis of reusable object-oriented software author: [US] Erich gamma/richard Helm/ralph johnson/john vlissides Translator: Li Yingjun/Ma Xiaoxing/Cai Min/Liu Jianzhong and other machinery industry press
Refactoring-Improving the design of existing code author: Martin Fowler Translator: China Power Press, HOU-jie
"Agile software Development-principles, patterns and practices" Author: Robert C. Martin Tsinghua University Press
"Programmer's path to cultivation-from small to expert" by Andrew hunt/david Thomas Electronics Press
Head First design mode author: Freeman translator: O ' Reilly Taiwan company China Power Press
"Zen of Design Pattern" Author: Qin Xiaobo Machinery Industry Press
MSDN Webcast "C # Object-oriented design mode discussion on" lecturer: Li Jianzhong
Liu wei. design mode. Beijing: Tsinghua University Press, 2011.
Liu wei. Design pattern Training Tutorial. Beijing: Tsinghua University Press, 2012.
"Big Liar design Mode" Author: Geoscience Tsinghua University Press
C # Illustrated Tutorial Author: Solis Translator: Surin/Zhu Ye People's post and telecommunications press
"You must know. NET" Author: Wang Tao
. NET in Project author: Li Tianping Electronics Press
The Microsoft. NET Enterprise Application Architecture Design Author: (US) Esposito and other translators: Chen Lifu
http://www.dofactory.com/Patterns/Patterns.aspx. NET Design Patterns
Http://www.cnblogs.com/zhenyulu Blog Lu Zhenyu
Http://www.cnblogs.com/terrylee Blog Li Huijun
http://www.cnblogs.com/anlyren/Blog Anlyren
Http://www.cnblogs.com/idior Blog Idior
Http://www.cnblogs.com/allenlooplee blog Allen Lee
HTTP://BLOG.CSDN.NET/AI92 Blog ai92
http://www.cnblogs.com/umlonline/Blog Zhang
http://www.cnblogs.com/lovecherry/Blog Lovecherry

The main features of "OOAD" oop

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.