2
我正在嘗試爲學生和教師創建一個社交網絡應用程序。 我目前在設計用戶賬戶模塊如何在系統中設計兩種類型的帳戶
我還以爲這兩種方法的
方法1
Public class Account
{
public string AccountId{get;set;}
public string AccountName{get;set;}
.
.
.
}
public class Student : Account
{
public Course[] Courses {get; set;}
//other student properties
.
.
.
}
public class Teacher : Account
{
//other teacher properties
}
方法2
Public class Account
{
public string AccountId{get;set;}
public string AccountName{get;set;}
public AccountType AccountType {get;set;} //AccontType is enum having student and teacher
.
.
.
}
public class User
{
public string UserId { get;set;}
public string UserName {get;set;}
public Account Account {get;set;}
}
public class Student : User
{
public Course[] Courses {get; set;}
//other student properties
.
.
.
}
public class Teacher : User
{
//other teacher properties
}
有什麼比這些方法更好的方法?
你有沒有遇到過這樣的場景......並且有沒有關於這個的任何標準實踐... – 2011-06-12 08:17:12