Preface: The next study is very important in Java, is also very abstract things, a kind of imaginative achievement here inexpressible feeling, but not so mysterious, to believe that the code is good, these are nothing to plug. However, design ideas need to be constantly learning, continuous understanding, to better understand the design ideas.
One, the component
Below through a picture of the abstract understanding under:
This is a "component" package design idea, the diagram of the component (1~K) is clearly a component, and the module (1~M), the subsystem (1~N) can also be seen as a component, and the system may be a component, if a large software, then this part of the system is only a corner of the project.
II. Basic principles of Java Programming 1
Part1:
1. Interface-oriented programming: This is the first principle universally acknowledged in Java programming; An interface is an important feature: encapsulation isolation; An interface is the appearance of a function block or package block.
2. Prioritize using object combinations instead of class inheritance
3, layered (most typical three-layer structure: Presentation Layer--------------data layer)
4. Basic principles of inter-layer interaction
The ① layer invokes the logical layer, and the logical layer calls the data layer, which cannot be reversed.
② inter-tier interactions should also be called through an interface to ensure that the implementation of each layer changes independently.
Part2:
1. Interface-oriented programming idea
① interfaces and related mechanisms have the most basic function: the same behavior of unrelated classes can be implemented through interfaces, without having to consider the hierarchical relationships between these classes. Depending on the interface, you can understand the interface of an object without needing to know which class the object belongs to.
② object-oriented programming to "improve cohesion, loose coupling", then the different program modules how to access each other, is through the interface, that is, the interface is the external unified appearance of each part. The idea that interfaces embody in Java programming is encapsulation isolation, because interfaces simply describe a unified behavior, so developers do not care about specific implementations when programming for interfaces.
③ interface plays an important role in object-oriented Java programming. In fact, one of the most important tasks in the design phase is to design the interface of each part and then form the basic framework of the program through the combination of interfaces.
Note: For behavioral models, interfaces are preferred and abstract classes are used sparingly
It is not only to constrain the function of subclasses, but also to provide some common functions, it chooses abstract class
2. Interface-oriented programming in Components
Three or three-layer structural design pattern
The three-tier structure has the following functions:
① Presentation Layer function: Display data, human-computer interaction, collect parameters call the logical layer.
② Logic Layer function: Carries on the logical check of the data, carries on the logic judgment, realizes the business function, processes the related function, processes the subsequent process, organizes the data to return to the performance layer.
③ data-tier capabilities: Enables bidirectional mapping of data persistence, implementation of objects, and persisted data.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java Design Ideas (1)