Model and layer-3 Structure

Source: Internet
Author: User

The model is also called an entity class, which may not be well layered.

I used to understand this as follows: Ui <--> Model <--> BLL <--> Model <--> Dal, in this case, the model serves as a bridge for data transmission between layers. But here, we don't want to make things simple, but to make things complicated. What is model? It's nothing! It is dispensable in a three-tier architecture. It is actually the most basic thing in Object-Oriented Programming: class. A table is a class, a news is also a class, Int, String, double is also a class, it is just a class. In this way, the location of the model in the three-tier architecture is the same as that of the int, string, and other variables. It has no other purpose and is only used for data storage, it only stores complex data. Therefore, if the objects in your project are very simple, you can build a three-tier architecture by directly passing multiple parameters without using the model. So why do we need a model? What are its advantages. The following is what I think of when I think about a problem. Put it here: Can model play a major role in parameter passing at each layer?

When passing parameters between layers, you can: adduser (userid, username, userpassword ,...,) You can also use the adduser (userinfo) method.

Obviously, it must be much better than the second one.

When can I use the common variable type (INT, String, guid, double) to pass parameters between layers? What can I do with model?

The following methods:

Selectuser (INT userid)

Selectuserbyname (string username)

Selectuserbyname (string username, string password)

Selectuserbyemail (string email)

Selectuserbyemail (string email, string password)

It can be summarized as follows:

Selectuser (userid)

Selectuser (User)

Here, the "user" model object includes four combination modes of the three parameters "username, password, and email. Userid can also be merged into the user, but other bll in the project implements interfaces with the ID parameter, so this item is also retained here. If userinfo is passed in, how can this problem be solved? This should be done in a specific order.CodeDecide. In this order, we will first check whether username and password are available at the same time, then check whether there is both email and password, then check whether there is username, and then check whether there is email. Processing in sequence. In this way, if you add a new member card (number), you do not need to change the interface. You only need to add support for number in the Dal code, then, you can add a membership card to the front-end to display and process the content.

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.