In the last chapter, we describe the problem in a simplified example, where the thoughts that were triggered at the time are recorded.
1, interface with a different implementation, as if there is such a design pattern called "strategy" mode. The general idea is to define an interface called Criteriaprovider, which can be written in this way:
Java code
Public interface criteriaprovider{
boolean ispass (Student Student);
}
Then according to the two sets of standards to do different implementation.
This is the problem that can be solved in the project, but because the original judgment in the code many scattered and many changes in the fault is not resolved. If the design of the beginning to consider the criteria may be changed, do such an interface can be, but now the project has been quick, and then do this kind of processing some outweigh the gains,
2, for the characteristics of decentralization, think of AOP programming. The original hard-coded way of dispersion has two characteristics, one is from the breadth of the scattered wide, fine count, there are more than 10 places. Second, from the level of scattered wide, not only the action is judged, DAO implementation also has a similar judgment. Does this kind of "dendrite" not just cater to the characteristics of AOP? Do an AOP reconfiguration, how?
Looks a little gorgeous.
The concept of AOP knows that it has been configured with spring's own AOP, but it would be a bit of a shame to implement it with the existing business logic.
The idea of thinking about pass away, but now look back, but also see an opportunity to realize their own AOP, also have the mind to think of the future if there is time to do a small implementation of the first practice practicing.
3, all the data is obtained through hibernate from the database, can you use Hibernate interceptor,loadeventlistener or filter? If it can be achieved, it solves the problem from the root, and the province makes so many changes in the code.
With this idea, I combed through the relevant techniques in the next hibernate.
The biggest difficulty is similar to AOP, oneself see in Hibernate have this kind of concept but oneself also have no use once, even small experiment also did, now suddenly get project to use, the risk is too big. Casually say, at that time to see these concepts in Hibernate, exclamation hibernate design and powerful, in the heart also talk about their fear hurry also use this high-level Dongdong. With that in mind, the idea of an experiment is gone. Now it seems that this opportunity has stimulated me to deepen my understanding of these advanced usages.
4, start with the original source database. Since the hibernate technology can do, that in the database does not do more thorough? My idea is this, add a sign to the student table and use a trigger to determine whether it is up to par when a record is added or altered.
This idea is even more impossible, the table is not to be arbitrarily add the field, trigger also did not write.
In this way, to the first question, from a shallow to deep thinking about the possibility of these articles. Around this thinking process, there are some key words jumped in: the database to achieve business logic, now the program and shortcomings of the project, the beauty of the program design. This article can not be written, see the next article