I-order
In the whole ancient, with the improvement of the level of material productivity, in the process of the original social and slave society, three social divisions have emerged: the first social division is the separation of agriculture and animal husbandry, as well as the original population Differentiation into agricultural tribes and nomadic tribes; the second social division is the separation of handicrafts and agricultural and animal husbandry, as well as the formation of professional handicrafts; the third social division is separation in the field of commercial and material production, as well as special business people's class form. Based on the three social division of labor, the separation of urban and rural areas has formed material production and spiritual production, physical labor and mental labor, and physical workers and mental workers, the basic division of labor.
Social division has had a huge impact on human society. The separation of responsibility is an important thinking.
Contact the software industry, how is the responsibility separation guides us for development? Let us look at the technology from the thoughts of responsibility.
For the software industry, from procedural language to object-oriented language is undoubtedly a huge change.
II object-oriented and design patterns
From the process of the model transforms the object-oriented object, what changes have happened?
The completion of a function is no longer a good one, but through a collaboration between one object, send a message to each other to complete a complex task. Look, this process seems to be more complicated, but the same human society Division, each individual has fully played their respective roles, focusing on their own tasks, separating the complexity of the outside world, improving efficiency, also bringing us to have a reusable software. Remember << Design Patterns >> Subject of the book? Elements of Reusable Object-Oriented Software
The design pattern has fully utilized the idea of responsibility separation. Take a look at this book Classification: Creational Patterns, Structural Patterns, Behaviooral Patterns, this classification is based on the principle of responsibility separation, the creation, organization and behavior of the object Interaction is separated from three aspects to talk about how to use objects.
Let's take a few specific patterns, Visitor mode can be convenient for the original object to expand new features. This will better organize object responsibilities, some of the important responsibilities that are closely related to themselves, and some Some responsibilities that are not tight or in the future will be done with other objects to complete through Visit.
Bridge mode is even more responsible to extract a new one, which is to complete the part of the responsibility. Why is this? Because some responsibility is changeable, there are many ways to complete. Separation of responsibility can make each object There is less concern, and it is more easily controlled and managed, which is not much different from the division of labor of human society.
Talking about the design pattern is not talked about the principles of some design. The principle of a single responsibility can see it and this article, each object is focused on a responsibility. This is the most ideal situation, the most convenient management. It seems that the principle of relying on the inversion It can't be connected to the liability separation, but in the following article, you will see how dependent on the principle is to separate the responsibility.
The most hot ORM in the open source field, set up a bridge III ORM for the world and relational database of contact reality
In today's software, object-oriented technology is in the world, penetrates to almost all software design areas, application areas and engineering areas. At the same time, in the database domain, although the relational database occupies most of the market share, Oracle, DB2, SQL Server, Infomix becomes the dominant in the database, but the relational database is still a storage method of data, it does not belong Object-oriented domain. When the relationship database is a data storage method, there is a serious "impedance mismatch" between the relationship concept and the object-oriented concept. In order to solve this problem, object-oriented technology and database technology have naturally began to communicate and combine, and the upper-oriented object-oriented requirements penetrate into the database, even the bottom of the database, and begin to affect the development of future databases.
The development of modern technology has made us have to keep learning. We must not only learn knowledge-oriented, UML, design patterns, etc., but also need to learn SQL Server, ADO.NET, DATASET, DATAREADER and other knowledge. In actual development, it is its unique business function for customers. The current status is that we spend a lot of time in writing data access, Crud method, including the later BUG lookup, maintenance, etc. It is quite a number of times on the data processing. That is to say, we have been wasted at all non-business incidents that do not create value in actual development. After using ORM, we will not need to waste too much time on the ADO.NET and SQL statements. The ORM framework has turned a database into our familiar objects, we will only need to understand the development of database applications for object-oriented development.
Separate business modeling and data storage responsibilities, you can make us more attention to what we need to pay attention to. Each development change is that the business model changes rather than data storage, business modeling makes us need to pay attention .
Separation of responsibility allows business developers to reduce the code that needs to be written, obtain higher development efficiency, and handle ORM to professional developers who are more lineful to the database, and improve data access performance, speed and quality. This is the biggest benefit that the responsibility can be brought to us.
The AOP after OOP has brought me any new thing.
IV AOP
Now consider a simple MVC application. We have a very simple, clear, single design requirement, that is, when a state of the Model class changes, all registered View classes are notified (in some way) to this change. . In general, in a typical implementation, you may see a large number of nonifyobservers () in the method of the MODEL class management status change. Model's responsibility should only be manipulated, but now it is responsible for notifying View, this responsibility should be separated, otherwise there will not be so many NotifyobServers () calls, which is not convenient for the maintenance and modification of the program (for example, you want to put NotifyObservers () Change to notify ()).
At this time, AOP will appear, it can make a cross cut on the Model status, then insert NotifyObservers (). It is the implementation of the idea of responsibility to a higher realm. OOP There is no way, and AOP is Provide possibilities to achieve responsibility separation in more situations.
The authority management, log record, management management, these responsibilities should be detached from business objects, the biggest purpose of AOP is to achieve responsibility separation in this case. The benefits and ORM has a completely similar effect. Current more It is relying on J2EE to help us do these things, and there may be more from Spring Jboss, etc.
AOP has a feature to achieve complete dependencies. We can rely on inversions to some extent under current OOP. For example, A-> i <- b, we achieve the dependence of A to B by I -> Go to B. The dependence on A. However, under AOP we can achieve real A-> B as a <- B.
If you apply this feature of AOP to ORM, what kind of results can you imagine? We can completely leave the database, just use our business objects directly like there is no database, and the current ORM is not the same. ?