Part 1:
Basic Principles of Java Programming 2
I. Opening and closing principle
The simple point is that the new open, the change is closed. And should try to do without changing the module's source code, you can change the behavior of the module.
Ii. The principle of dependency inversion
The principle is to rely on abstraction rather than on detailed implementations.
third, the principle of interface isolation
The principle is not to use generic interfaces. Instead, different interfaces are used for different users.
iv. principle of substitution
The principle is that subclasses should be able to replace the parent class and appear wherever the parent class is now available.
Part 2:
Basic experience in class design
one, the class to be single
The meaning of the design of the class function to be single, a class should be descriptive of a class of extremely relevant properties and methods.
second, strengthen the cohesion, loose coupling
meaning means a class. Can be implemented within their own internal implementation, not to tune other classes, to minimize the dependency on other classes.
Three, good encapsulation
It means that the part that does not have to be opened is open to the outside. Suppose that the property of the class is set to private when the attribute permission is not determined, and then it is opened again when it is used.
Four, the granularity of the class should be reasonable
That means The Java specification suggests that a class should not be larger than 1000 rows, and that the size of a method should not exceed 100 rows.
the implementation class cannot rely on its use class
This means that a class is dependent (used or called) and has a class. Then there is one class that cannot, in turn, rely on the current class.
Vi. flexibility should be considered. Which is configurable, maintainable
meaning that the user's needs will be constantly changing, the late changes and maintenance is inevitable. Therefore, software development should consider flexibility.
Vii. Consider performance and scalability
The idea is to weigh the relationship between speed and resource consumption, and consider that software can be scaled within a certain range.
consider possible future changes, i.e. scalability
This means that extensibility means that the application can easily add new functionality.
Nine, to consider a reasonable re-use
It means to consider reuse as much as possible, but not to consider reuse. You can't throw away all the other design principles.
10, to reasonably consider the use of interfaces and abstract classes
The idea is to use the interface first, assuming that you want to constrain the behavior of the subclass and provide the public function for the subclass, using abstract classes.
11. Minimizing the number of interactions and interactions between classes and collaboration classes
This means that the class should not be called repeatedly, do not pass very much data each time.
12, the parent class should not know the information of the child class, the subclass must know the information of the parent class
13, access to the object must pass through the interface. You can't bypass the interface and go directly to the interview.
Read the full text of the copyright notice: This article for Bo Master original article, without Bo Master agreed not to reprint.
Report
- This article has been included in the following column:
- Java Learning Log
0Article comments
-
-
-
Related articles recommended
-
Java Design Ideas (1) Preface: The next thing to learn is what's important in Java. is also a very abstract thing. There is just a sense of inexpressible feeling, but not so magical, to believe that the code good. None of this is a cinch. Just design ideas need to be constantly learning, constant understanding. Talent is better ...
- u011459262
- 2015-08-17 23:53
- 1594
-
Java design Ideas of the factory implementation scenarios and problems? Java Program development emphasizes interface-oriented programming. You need to hide the detailed implementation class. How to solve the problem.
This time we need to use the "interface?" Factory?? Implementation class "----iron triangle. To help us solve the problem the first class is our client. ...
- Story__struggle
- 2016-07-24 18:27
- 294
-
Java design idea value object scenarios and issues in Java development. Need to exchange large amounts of data back and forth. For example, to pass in a number of parameters for a method. You also get the return value of the method. The main writing with step 1, write a class. Implement serializable (assuming that later data is stored in the database, you can not serialize, ...
- Story__struggle
- 2016-07-27 14:09
- 136
Java design ideas about Java
-
design ideas? Finally Copyright: JDram314 if reproduced please post the source!
?????????? Java's three major features should be known as programmers of Java. is encapsulation, polymorphism and inheritance. Suppose this is not known. So please ...
- JDream314
- 2011-09-29 20:37
- 3169
-
The design idea of Java Decoration Class----------------------asp.net+unity development. NET training, look forward to communicating with you!
----------------------outlines one of the JAVA23 design patterns in English called de ...
- u013999337
- 2014-03-16 23:59
- 867
-
The design idea in java/android ① the single Duty principle SRP (a Responsibility Principle)?? The so-called "single duty" principle is. A class should have only one reason to cause it to change.
Multiple duties, that is, a class has many of the original that caused it to change ...
- Changcsw
- 2016-08-03 14:42
- 327
-
Java design mode thought Command mode: The first thing to have a command class is a detailed operation method, such as attacking a certain force. Then you have to have a detailed command interface, which has the Run method execute (). Then there is the recipient, which implements the command interface. At the same time there are command classes ...
- u014491545
- 2015-07-03 12:02
- 280
Brief introduction to design thought brief introduction
-
to the design idea ofbiz the security group to associate permissions with users.
There are several kinds of permissions in the system, such as the permissions of the system presets, the user's own defined permissions, the permissions of the resources, the permissions of the operation, and so on.
- u014191011
- 2014-03-18 13:15
- 48
-
Rsic Design thought Rsic design thought mainly by the following four design criteria to realize???? The 1 instruction set--rsic processor reduces the type of processing instructions.
The rsic instruction type simply provides a simple operation. is a cycle to be able to run an instruction. The length of each instruction is fixed. Agree flow ...
- z1179675084
- 2012-12-17 17:38
- 229
-
A good design idea in C + + 1, now found in C + + has a similar approach to Delphi design ideas. Really benefited!
So together to share with everyone under that is the idea of control in Delphi, the idea of control is very good, so the implementation of the small module can be through the control ...
- Fishmai
- 2016-09-01 12:48
- 255
-
-
learning is like feeling. There is nothing to gain but to pay for it. + Focus
-
Original
-
-
Fans
-
-
Like
-
0
- about the certificate---convert a p7b format certificate to a CER format certificate.
- GraphicsMagick + im4java picture processing
- Regular expressions that are often used
- properly solve MySQL Chinese garbled problem, so willful
many other articles
Online Courses
-
-
"Live" computer vision principle and actual combat-Professor Qu
-
-
"Package" Spark+scala Course Package--Chen Chao
- folder
-
- like to cancel like
- Collection
- share Weibo QQ
Collection Assistant Bad news report