PHP basic Knowledge "OOP/MVC/ORM/AOP"

Source: Internet
Author: User
Tags html form

Oop

Object-oriented programming is a computer programming architecture. One of the basic tenets of OOP is that a computer program is composed of a single unit or object that can act as a subroutine. OOP achieves the three main goals of software engineering: reusability, flexibility, and extensibility. To achieve the overall operation, each object can receive information, process data, and send information to other objects. OOP mainly has the following concepts and components:
components -data and functions in a running computer program formed in a unit, the component in the OOP computer program is a modular and structured basis.
Abstraction -The program has the ability to ignore certain aspects of the information being processed, namely the ability to focus on the main aspects of the information.
Encapsulation -also known as information encapsulation: Ensure that components do not change the internal state of other components in an unpredictable way, and that only those components that provide an internal state change method can access their internal state. Each type of component provides an interface that is associated with other components and specifies the method by which other components are called.
Polymorphism-component references and class sets involve many other components of different types, and the result of referencing a component depends on the type of actual invocation.
Inheritance -Allows child class components to be created on the basis of existing components, which unifies and enhances polymorphism and encapsulation. Typically, a class is used to group components, and it is possible to define a new class as an extension of an existing class, so that the class can be organized into a tree or mesh structure, which embodies the versatility of the action.
Component-based programming has become particularly popular in scripting languages due to the reasons for abstraction, encapsulation, reusability, and ease of use.

Mvc

MVC is a design pattern that makes it mandatory to separate the input, processing, and output of an application. Using an MVC application is divided into three core parts: Model (M), view (V), Controller (C), each of which handles its own tasks. MVC is a method of separating the logical and presentation layers of an application.
views: A view is an interface that the user sees and interacts with. For older Web applications, views are an interface of HTML elements, and in modern Web applications, HTML still plays an important role in the view, but new technologies are emerging, including Adobe Flash and Elephant xhtml,xml/xsl, Some identity languages and Web services, such as WML. How to handle an application's interface becomes increasingly challenging. One big benefit of MVC is that it can handle many different views of your application. There is really no real processing happening in the view, whether the data is stored online or an employee list, as a view, it is simply a way to output data and allow the user to manipulate it.
Model: models represent enterprise data and business rules. Of the three parts of MVC, the model has the most processing tasks. For example, it may use artifact objects such as EJBS and ColdFusion to process the database. The data returned by the model is neutral, meaning that the model is independent of the data format, so that a model can provide data for multiple views. Because the code applied to the model can be reused by multiple views only once, it reduces the repetition of the code.
Controller: The controller accepts the user's input and invokes the model and view to complete the user's needs. So when you click a hyperlink in a Web page and send an HTML form, the controller itself does not output anything and do any processing. It simply receives the request and decides which model component is called to process the request, and then determines which view to use to display the data returned by the model processing.
Now we summarize the process of MVC, first the controller receives the user's request and decides which model should be called to process it, then the model uses the business logic to process the user's request and return the data, and finally the controller formats the data returned by the model with the corresponding view and renders it to the user through the presentation layer.

Orm

Object-relational mapping is a result of the development of object-oriented software development methods. The object-oriented development method is the mainstream development method in the enterprise application development environment, and the relational database is the mainstream data storage system which is stored permanently in the enterprise-level application environment. object and relational data are two representations of business entities, and business entities behave as objects in memory and behave as relational data in the database. There are associations and inheritance relationships between objects in memory, and in a database, relational data cannot directly express many-to-many associations and inheritance relationships. Therefore, object-relational mapping (ORM) system usually exists in the form of middleware, which mainly realizes the mapping of program object to relational database data.
Object-oriented is developed from the basic Principles of software engineering (such as coupling, aggregation, encapsulation), and the relational database is developed from the mathematical theory, and the two sets of theories have significant differences. In order to solve this mismatch, object-relational mapping technology emerged.

Aop

AOP, aspect-oriented programming, can be said to be the complement and refinement of OOP. OOP introduces concepts such as encapsulation, inheritance, and polymorphism to create an object hierarchy that simulates a collection of public behavior. When we need to introduce public behavior to scattered objects, oop seems powerless. In other words, OOP allows you to define relationships from top to bottom, but it is not appropriate to define left-to-right relationships. such as logging capabilities. Log code is often spread horizontally across all object hierarchies, and has nothing to do with the core functionality of the objects it spreads to. This is true for other types of code, such as security, exception handling, and transparent persistence. This irrelevant code scattered around is called crosscutting (cross-cutting) code, and in OOP design, it leads to a lot of duplication of code, rather than the reuse of individual modules. AOP, on the contrary, uses a technique called "crosscutting" that splits the encapsulated object interior and encapsulates public behavior that affects multiple classes into a reusable module, called "Aspect", which is the facet. The so-called "aspect", in a nutshell, is to encapsulate the logic or responsibility that is not related to the business, but for the common invocation of the business module, to reduce the duplication of code in the system, to reduce the coupling between modules, and to facilitate future operability and maintainability. AOP represents a horizontal relationship, if the "object" is a hollow cylinder, which encapsulates the properties and behavior of the object, then the aspect-oriented programming approach is like a razor that cuts through the hollow cylinders to get inside the message. The cut-off aspect is the so-called "facet". Then it hands the cut-off slices with a clever capture of the heavens, leaving no traces.
Using "crosscutting" techniques, AOP divides software systems into two parts: core concerns and crosscutting concerns. The main process of business process is the core concern, and the part that has little relation is the crosscutting concern. One feature of crosscutting concerns is that they often occur in many of the core concerns and are essentially similar everywhere. such as permission authentication, logging, transaction processing. The role of AOP is to separate the various concerns in the system, separating the core concerns from the crosscutting concerns. As Avanade's senior program architect Adam Magee says, the core idea of AOP is "separating the business logic in the application from the generic services that support it." ”

PHP basic Knowledge "OOP/MVC/ORM/AOP"

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.