Interpretation of ObjectiveSQL source code - factory mode

To understand design patterns, you must combine specific cases, and it is difficult to truly grasp design methods through pure theoretical study. In fact, after you really see through the design patterns, when you find that the logic you need to depend on is in an unstable state, abstraction will be created. The so-called design pattern is an inherent form of some unstable dependencies. The pattern, after systematic theoretical arrangement, has formed the design pattern that can be seen today.

The factory pattern series is mainly to encapsulate the process of constructing an instance. There are two main purposes of encapsulation: 1) The process of constructing an instance is more complicated, and the construction process will be reused; 2) The construction process will generate different instances according to different parameters . The factory mode in ObjectiveSQL is used more, mainly because the uncertainty of the usage scenario is relatively large, and the processing logic of JDBC and SQL is relatively flexible, so ObjetivSQL needs to fully adapt to such flexibility and provide more logical abstractions interface.

Query and Persistence encapsulate the logic of query and persistence, and abstract the behavior in the way of ObjectiveSQL .

QueryFactory and PersistenceFactory encapsulate the construction of abstract Query and Persistence, mainly because Query and Persistence will change in different application systems, for example: Query does not necessarily hit the database every time, in some cases, the query may hit Redis or Other in-memory databases, so ObjectiveSQL needs to adapt to this change. In such a scenario, the factory pattern is the best choice. As an abstract technical framework, ObjectiveSQL provides sufficient extension features for different scenarios in the application system and encapsulates the logic that is repeatedly used in different application systems. This is the value of ObjectiveSQL.

Such a design is only a part of the foundation of ObjectiveSQL design, and more design methods and theoretical practices will be introduced in the future.

 

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324121567&siteId=291194637