I recently read duwamish7, Asp.net forums, and dottext from several excellent open-source (Microsoft official) projects.
For the reason of the current technical level, I think these projectsProgramIs more concerned with the specific implementation
Second, Architecture
My first concern is the implementation of the entity layer of the three projects. Below we use a simpleCodeTo compare several projects
And then make some simple comparisons, limited to personal level is limited, can not do in-depth analysis, but also
Please comment on prawns!
Implementation Code:
I. Asp.net forums:
Implementation of object classes:
Public Class User
{
Private String _ Username = String . Empty;
Private String _ Userpassword = String . Empty;
Public String Username
{
Get {Return_ Username ;}
Set {_ Username=Value ;}
}
Public String Userpassword
{
Get {Return_ Userpassword ;}
Set {_ Userpassword=Value ;}
}
}
Collection class implementation:
Public Class Usercollection: arraylist
{
Public Usercollectionofarraylist (): Base () {}
Public Usercollectionofarraylist (icollection C ): Base (C) {}
}
2. dottext:
Implementation of object classes: basically the same as above. The main difference lies in the implementation of collection classes.
Collection class implementation:
Public Class Usercollection: collectionbase
{
Public Int Add (user value)
{
Return This. List. Add (value );
}
Public Bool Contains (user value)
{
Return This. List. Contains (value );
}
Public Int Indexof (user value)
{
Return This. List. indexof (value );
}
Public Void Insert ( Int Index, user value)
{
List. insert (index, value );
}
Public Void Remove (user value)
{
List. Remove (value );
}
// Public new keywordcollectionenumerator getenumerator ()
// {
// Return new keywordcollectionenumerator (this );
// }
//
// Public class keywordcollectionenumerator: ienumerator
// {
// // This class is used to iterate a set of classes. For example, you need to implement this interface when using foreach to traverse a set, saving Columns
// // For specific implementation, refer to the implementation method of dottext.
// }
}
Iii. duwamish7
This project is officially released by Microsoft, so the implementation of the entity layer is implemented using the ADO. NET technology pushed by Microsoft.
Entity classes and collection classes are implemented in one piece:
Public Class Usercollection: Dataset
{
Public Usercollectionofdataset ()
{
This. Builddatatables ();
}
Private Void Builddatatables ()
{
Datatable table = New Datatable ( " Usercollection " );
Datacolumncollection Columns = Table. columns;
Columns. Add ( " Username " , Typeof (System. String ));
Columns. Add ( " Userpassword " , Typeof (System. String ));
This . Tables. Add (table );
}
}
Simple analysis:
I. There is nothing to say about the Asp.net forums object class, mainly because the collection class is implemented by inheriting the arraylist.
Collection class. This implementation method is the simplest and quickest, but there will be some loss in performance, because when using this set,
Requires constant boxing and unboxing operations;
2. The dottext object class and Asp.net forums are basically the same, but the collection class is implemented through collectionbase
To achieve, the implementation is more complex and requires more code, but its implementation of the Collection class is a strong type of object
In use, boxing and unboxing operations are not required, so the performance is better
Optimal Implementation of Asp.net forums
3. duwamish7 uses a typed dataset to implement the entity layer. dataset is usually a resource-consuming method.
it is generally considered that collection can provide better performance when there is a small amount of data, the performance of using dataset for large data volumes is relatively good
, but most of the time, we read data from the database when developing applications, generally, paging queries are performed in the
stored procedure. only part of the data is selected. This can be said to be a small amount of data. If you only choose from the performance perspective
, typed Dataset is not the best choice
welcome tiles and flowers