Discover object oriented design and patterns 2nd edition, include the articles, news, trends, analysis and practical advice about object oriented design and patterns 2nd edition on alibabacloud.com
horizontal direction, the system functions should be distributed as much as possible. That is, according to the design, the top-level classes should share work in a unified manner. P30
(13)Do not create all-powerful classes/objects in your system. Be especially careful about the classes whose names include driver, Manager, system, and susystem. P30
Plan an interface instead of implementing an interface.
number of access methods in public interfaces. A large number of access methods mean that related data and behaviors are not stored in a centralized manner.
(15) Be careful with classes that contain too many non-communication behaviors.
Another manifestation of this problem is that many get and set functions are created in the public interfaces of classes in your application.
(16) In an application composed of an object-
frameworks rather than reusable components when creating an inheritance hierarchy.
(55) If you use multiple inheritance in the design, first assume that you have made a mistake. If you do not make a mistake, try to prove it.
(56) as long as inheritance is used in object-oriented design, I have two questions: (1) i
the design.
(13) do not create all-powerful classes/objects in your system. Be especially careful about the classes whose names include driver, Manager, system, and susystem.
Plan an interface instead of implementing an interface.
(14) Be careful with classes that define a large number of access methods in public interfaces. A large number of access methods mean that related data and behaviors are not stored in a centralized manner.
(15) Be c
of access methods in the public interface. A large number of access methods means that the relevant data and behavior are not centrally stored.
(15) Be more careful with classes that contain too much communication behavior.
Another manifestation of this problem is the creation of many get and set functions in the public interface of the classes in your application.
(16) In an application composed of an object-ori
of access methods in the public interface. A large number of access methods means that the relevant data and behavior are not centrally stored.
(15) Be more careful with classes that contain too much communication behavior.
Another manifestation of this problem is the creation of many get and set functions in the public interface of the classes in your application.
(16) In an application composed of an object-ori
Single principle of responsibilityIn fact, developers often say, "high cohesion, low coupling"In other words, each class should have only one responsibility, and only one function can be provided externally, and the cause of the class change should only be the same. In design mode, all design patterns follow the principleOpening and closing principleThe core idea
When we first came into contact with object-oriented thinking, I think the first concept we came into contact with should be"
Class ", We have been discussing profound issues such as how to design classes and how to implement classes, but have we ever thought about what is called" classes "and what is the essence of classes ?. According to the introduction in mo
When using the object-oriented idea for system design, our predecessors summarized seven principles:
1. Single Responsibility Principle (SRP)
The core idea of a single responsibility principle is that every object in the system should have only one independent responsibility, and all objects focus on the fulfillment of
change should be closed for the module he designed. He must first guess the most likely types of changes, and then construct an abstraction to isolate those changes.Take action immediately when changes occur.
When we first wrote the code, we assumed that the change would not happen. When a change occurs, we create an abstraction to isolate similar changes that occur later.In the face of requirements, changes to the program are made by adding new Code, rather than changing the existing code.We h
model the dynamic semantics of classes. If you try to use a static semantic relationship to model dynamic semantics, the type will be switched during runtime.
(50) do not convert the class object into a derived class. Be careful with any Derived classes that only have one instance.
(51) If you think you need to create a new class at runtime, take a step back to recognize that you want to create an object
direction as much as possible, that is, the top-level classes should share work in a unified manner according to the design.
(13) do not create all-powerful classes/objects in your system. Be especially careful about the classes whose names include driver, Manager, system, and susystem.Plan an interface instead of implementing an interface.
(14) Be careful with classes that define a large number of access methods in public interfaces. A large num
switched during runtime.(50) do not convert the class object into a derived class. Be careful with any Derived classes that only have one instance.(51) If you think you need to create a new class at runtime, take a step back to recognize that you want to create an object. Now, we can generalize these objects into a class.(52) it should be illegal to overwrite the methods in the base class by using an empty
the dynamic semantics of a class by inheriting relationships. Attempting to model dynamic semantics with a static semantic relationship causes the type to be switched at run time.(50) Do not turn the object of the class into a derived class. Be careful with any derived class that has only one instance.(51) If you feel you need to create a new class at run time, step back to see what you are creating. Now, generalize these objects into a class.(52) It
Good questions about object-oriented analysis and design. it may take some time for the younger brother to get in touch with object-oriented design. every time you design a new system,
Today, I have posted all the five object-oriented design principles (SRP, OCP, LSP, dip, and ISP) that I have organized some time ago. I hope they will help you, I also hope to have more exchanges with you.
General principles (from: Design Patterns explained ):
1.
Object-Oriented design method: The basic idea of Java object-oriented programming is to solve problems by constructing and organizing objects. Objects are good, and any object can be considered an
modification of the situation to expand the system function To meet the requirements of open and closed principle. The dependency inversion principle is one of the basic principles behind the technologies and frameworks of COM, CORBA, EJB, and spring.4. Combination/Aggregation multiplexing principleThe combination/aggregation multiplexing principle, also known as the synthetic multiplexing principle, is to use some existing objects in a new object by
===================================== Another versionWhat are design principles?
Design principles are basic tools. applying these rules can make your code more flexible, easier to maintain, and easier to expand.Basic Principles
Encapsulation change Encapsulate what varies.
It is intended for interface programming rather than implementing Code to an interface rather than to an implementation.
Combinat
1. An important experience for Object-Oriented Design:
Anyone who owns the data provides external operations on the data.
2. Object-oriented refining experience:
Term refining method.
Case:1. Draw circles on the blackboard
Through this sentence, it is easy to think of the ob
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.