My design ideas for multiple types of users ......

Source: Internet
Author: User

Preface

Recently, I was working on a project. I talked about it from the customer, requirement analysis, system design, coding, and all-inclusive. The first time I did this,

Depressed, it's not a few days before the delivery, and there are still some unclear ideas, so I will post my thoughts and let you bloger make bricks

Requirement

Here we only write out the relevant part, that is, the user processing part. As required, the system will have five types of users. The three representative descriptions are listed as follows:

1. Instructor user (Teacher): When registering, you can register as a Teacher as an independent identity, or you can choose to associate with a School)

2. School user (SchoolUser): two departments will be generated during registration. One user and the other is a school, and the user will exist as the school administrator. The school information can be used by teachers.

User Selection

3. Expert user (Expert): cannot be directly registered. It must be added by the Administrator in the background

Design

The following describes my ideas based on the entity, data layer, data operation layer, and web layer.

1. entity Layer Design

The entity layer includes user interfaces and other related objects. To facilitate code writing, use fields

No more attributes

Public abstract IUser

{

Public string Username;

Public string Password;

}

Public class Teacher: IUser

{

Public int SchoolID;

}

Public class Expert: IUser

{

// No new attributes

}

Public class SchoolUser: IUser

{

Public School MySchool;

}

Public class School

{

Public string SchoolName;

Public int AreaID;

}

The relationships between entities are shown in the following UML diagram (the first time you draw UML, you don't know if you can understand it). The entity is replaced by an interface and the code is replaced by an abstract class. The meaning is the same.

 

2. Data Layer

Write the CRUD method for each object separately.

3. Data operation layer

Example of registering a user:

Public class Users

{

Public static void Register (IUser user, UserType userType) // user type Enumeration

{

// Write the judgment logic here, which is also the worst place I think

Switch (userType)

{

// Call the corresponding methods at the data layer here to complete registration tasks for various types of users.

}

}

}

4. web layer call

Take registered school users as an Example

School school = new School ()

// The school initialization code is omitted, the same below

SchoolUser user = new SchoolUser ();

....

User. School = school;

Users. Register (user, UserType. SchoolUser );

 

I started to shoot bricks ......

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.