Deep understanding: single entry, MVC, ORM, CURD, ActiveRecord concepts

Source: Internet
Author: User
This article provides a detailed analysis of the concepts of single entry, MVC, ORM, CURD, and ActiveRecord. For more information, see MVC

MVC is a design pattern that forcibly separates the input, processing, and output of an application. MVC applications are divided into three core components:Model (M), View (V), Controller (C)And they process their own tasks.

View: View is the interface on which the user sees and interacts with it. For older Web applications, a view is an interface composed of HTML elements. in new Web applications, HTML still plays an important role in the view, however, some new technologies have emerged, including Adobe Flash and some identification languages and Web services such as XHTML, XML/XSL, and WML. How to process the application interface becomes increasingly challenging. One major benefit of MVC is that it can process many different views for your applications. In fact, there is no real processing in the view. whether the data is stored online or an employee list, as a view, it is just a way to output data and allow users to manipulate it.

Model: Model indicates enterprise data and business rules. Among the three components of MVC, the model has the most processing tasks. For example, it may use component objects such as EJBs and ColdFusion Components to process databases. The data returned by the model is neutral, that is, the model has nothing to do with 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, code duplication is reduced.

Controller: The controller accepts user input and calls models and views to fulfill user requirements. Therefore, when you click a hyperlink on a Web page and send an HTML form, the controller does not output anything or process anything. It only receives the request and determines which model component is called to process the request, and then determines which view is used to display the data returned by the model for processing.

Now Let's summarize the MVC processing process. First, the controller receives user requests and decides which model should be called for processing. then, the model uses the business logic to process user requests and return data, finally, the controller uses the corresponding view to format the data returned by the model and presents it to the user through the presentation layer.

OOP

Object-oriented programming (Object Oriented Programming(OOP) is a computer programming architecture. One basic principle of OOP is that a computer program is composed of a single unit or object that can act as a subroutine. OOP has achieved three main objectives of Software Engineering: reusability, flexibility, and scalability. To achieve the overall operation, each object can receive, process, and send information to other objects. OOP has the following concepts and components:

Components-Data and functions are units formed in running computer programs. components are the basis of modules and structures in OOP computer programs.

Abstraction-the program has the ability to ignore some aspects of the information being processed, that is, the ability to focus on the main aspects of information.

Encapsulation-Information encapsulation: ensures that components do not change the internal status of other components in an unpredictable manner. only those components that provide the internal status change method can, to access its internal status. Each type of component provides an interface for contacting other components and specifies the method for calling other components.

Polymorphism-The reference and class assembly of components involve many other different types of components, and the result of the reference component must be based on the actual call type.

Inheritance-Subclass components can be created based on existing components, which unify and enhance polymorphism and encapsulation. Typically, classes are used to group components, and new classes can be defined as extensions of existing classes, so that classes can be organized into a tree or mesh structure, this reflects the versatility of the action.

Because of abstraction, encapsulation, reusability, and ease of use, component-based programming has become particularly popular in scripting languages.

ORM

Object-link ing (Object/Relation Mapping, AbbreviationORM) Is generated with the development of object-oriented software development methods. Object-oriented development is the mainstream development method in today's enterprise-level application development environment. relational databases are the mainstream data storage systems that permanently store data in enterprise-level application environments. Objects and relational data are two forms of business entities. business entities are represented as objects in the memory and relational data in the database. Objects in the memory have associations and inheritance relationships. in the database, relational data cannot directly express many-to-many associations and inheritance relationships. Therefore, object-link ing (ORMSystems generally exist in the form of middleware, mainly to map program objects to Relational database data.

Object-oriented development is based on the basic principles of Software Engineering (such as coupling, aggregation, and encapsulation), while Relational databases are developed from mathematical theories. The two sets of theories have significant advantages.Differences. To solve this mismatch, the object link ing technology emerged.

CURD

CURDIt is a acronym in database technology. The basic functions of various parameters in project development are as follows:CURD. It indicates that (Create), Update (Update), Read (Read) And delete (Delete.CURDDefines basic atomic operations for processing data. The reasonCURDTo a high level of technical difficulty is to complete a task involving multiple database systems.CURDThe performance of activities related to the summary of operations may vary greatly with the changes in data relations.

CURDThe create, update, read, and delete methods are not necessarily used in specific applications, but their functions are consistent. For example, ThinkPHP uses the add, save, select, and delete methods to represent the model.CURDOperation.

ActiveRecord

ActiveRecordAlso belongsORMLayer, which was first proposed by Rails and follows the standardORMModel: A table is mapped to a record, a record is mapped to an object, and a field is mapped to an object property. In combination with the naming and configuration conventions, the model operations can be quickly implemented and easy to understand.

ActiveRecordThe main idea is:

1. each database table creates a class, and each object instance of the class corresponds to a row of records in the table in the database. Generally, each Field of the table has a corresponding Field in the class;

2.ActiveRecordAt the same time, we are responsible for making ourselves persistentActiveRecordEncapsulates access to the database, that isCURD;;

3.ActiveRecordA Domain Model encapsulates some business logic;

ActiveRecordApplicable:

1. the business logic is relatively simple. when your class is basically one-to-one with the tables in the database,ActiveRecordIs very convenient, that is, most of your business logic is to operate on a single table;

2. when a cross-table operation occurs, the Transaction Script is often used together to promote the cross-table Transaction to the Transaction Script;

3.ActiveRecordIt is simple and intuitive. A class includes data access and business logic. it is more convenient to use with the code generator;

These advantages makeActiveRecordIt is particularly suitable for rapid WEB development.

Single Portal

A single Portal usually refers to a project or application with a unified (but not necessarily unique) Portal file. that is to say, all function operations of the project are performed through this portal file, in addition, the entry file is usually executed in the first step.

The advantage of a single portal is that the project is relatively standardized as a whole, because the same portal usually has the same rules between different operations. In addition, the advantage of a single portal is that the control is more flexible, because the interception is convenient. for example, some permission control and user logon judgment and operations can be handled in a unified manner.

Or some people may worry that all websites will be accessed through an entry file, which may put too much pressure on them. in fact, this is a worrying idea.

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.