Oop thought and design

Source: Internet
Author: User
Tags php framework switch case
oop--object-oriented programming. Oop idea refers to the idea of object-oriented itself. The OOP design does not mean that the code is encapsulated into classes. Because, if that's the case, it only refers to object-oriented programming.

oop--Object-oriented programming is just a practice. The idea of OOP is fundamental. What is important is not the practice, but the actual goal to be achieved.

The Java language is always able to achieve the most object-oriented goals. The reason is quite simple. That's because of the limitations of the language itself.

Everything in Java needs to be in a class. A separate function outside the class is not allowed. Design patterns, that is, because of the generation of Java. From this point, Java has changed the mind of the software world.

The goal of OOP is to make the code conform to the solid principle. These principles are introduced at the beginning of all works that explain design patterns.

But this is a theoretical goal. The actual goal is to answer, why do we do it. Because, we are always unknown to the future. We don't know what will happen to demand. We may be able to offer only one simple version today, for a limited time. But it must be expanded in the future. What we have done may have covered everything today, but one day we will find that there is another component that is not considered.

If there is no object-oriented, then we are done with the simplest switch case structure. Because of this, we have to re-modify our core code. However, if our code conforms to the solid principle, then all we have to do is add a new class for the existing code.

It is not difficult to find: plug-in ideas, derived from OOP. So, at this point, if we look at OOP again, it's not just a matter of encapsulating scattered code into classes.

We need to follow the solod principle, what is abstract and what is concrete. Although we only provide limited code for specific problems, they all depend on the overall abstraction. There are new and specific problems of the same kind, and we just add classes. This is the core of the idea of design patterns.

OOP design is far from the case. Code readability, maintainability, and content in the document. On the surface, this is not an important detail. But the reality is extremely important. Especially for the design of a core module of a problem, or design a PHP development framework. The readability of a table of contents, or whether it conforms to OOP, largely determines the speed with which people understand it, and the degree to which they are willing to accept it. For example, Sysmfony directory structure is not very good. Although it is old, the early occupation of the market is larger. But the market is still being carved up by some new frameworks. In retrospect, the code was not designed to be quite good, for example, Kohana,ci was quite easy to accept, and about its directory structure. This is also the reason that some domestic frameworks can be accepted by users. is not a single because, it is Chinese version of.

Thus, the idea of OOP design is not just in terms of code, but in architecture and design.

The vast majority of PHP framework problems are due to the open source system, which has not really experienced a large project with enough experienced people as an architect. This is quite excusable. However, if an enterprise does open source, and after many years of operation, the larger the system, the more complex it is, the more complicated it is, the more difficult it is to have a clear and easy-to-maintain architecture.

Some say these companies can make use of this to make money for customers who need to develop two times. In fact, earning such money is always limited. Because, a good core architecture, will bring real software industrialization. And will save a lot of money.

In fact, to put it back, the development framework is actually quite simple stuff. Simple enough to be summed up in one or two sentences: one is to provide a different class library for users to call, so that users write less code. The second is to allow users to easily add their own needs of the plug-in, reduce user development. This is actually a shut down system that calls each other. In the MVC system, the pure OOP framework, the latter is the code that the framework calls the user. In this respect, the most prominent is the user interface components. PHP in a lot of this kind of framework. But it's all very elementary. No one can compare with FCS in Java, or Typestry. Some beginners can also release a 200KB tag engine. Without looking at the code, you can imagine that there is no design pattern, and it is impossible to follow the solid principle. Then, the extension, maintenance will be quite a big problem.

So we thought, how many internet companies, their website is PHP, on the surface, PHP seems to reduce costs, but can reduce to how much? The key is that from OOP code to OOP architecture, the level of OOP architecture determines the efficiency and cost of technical department development.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.