اصول و قراردادهای نامگذاری در داتنت
شنبه 28 اردیبهشت 1392اصول و قراردادهای نامگذاری در داتنت <br/> نامگذاری (Naming) اشیا یک برنامه شاید در نگاه اول دارای اهمیت بالایی نباشه، اما تجربه نشون داده که در پروژههای بزرگ که با کمک چندین مجموعه به انجام میرسه نامگذاری صحیح و اصولی که از یکسری قواعد کلی و مناسب پیروی میکنه میتونه به پیشبرد اهداف و مدیریت راحتتر برنامه کمک بسیاری بکنه.
1
|
FirstName |
1
|
firstName |
1
2
|
strFirstName lblFirstName |
1
|
<Company>.<Technology|Produt|Project>[.<Feature>][.<SubNamespace>] |
1
2
3
|
Microsoft.Reporting.WebForms Kara.Support.Manager.Enums Kara.CSS.HQ.WebUI.Configuration |
1
2
|
PackageManager , PacakgeConfigGenerator Circle , Utility , Package |
1
2
|
CreateConfig , classdata CManager , ClsPackage , Config_Creator , Config1389 |
1
|
CenterCollection , PackageCollection |
1
2
|
public delegate void Logger ( string log); public delegate void LoggingCallback ( object sender, string reason); |
1
|
AddEventArgs , EditEventArgs , DeleteEventArgs |
1
|
Adding , Add , Added |
1
|
public delegate void EventHandler ( object sender, <EventName>EventArgs e); |
1
|
public event EventHandler Adding; |
1
|
DisplayNameAttribute , MessageTypeAttribute |
1
2
3
|
IComponent (اسم) IConnectionProvider (موصوف) ICloneable (صفت) |
1
2
3
4
|
public enum FileMode { Append, Read, … } |
1
2
3
4
5
6
|
[Flag] public enum KeyModifiers { Alt = 1, Control = 2, Shift = 4 } |
1
2
3
4
5
|
public enum OperationState { DoneState, FaultState, RollbackState } |
1
|
AddDays , Save , DeleteRow , BindData , Close , Open |
1
|
Radius , ReportType , DataSource , Mode , CurrentCenterId |
1
|
public CenterCollection Centers { get ; set ; } |
1
2
3
4
5
|
if (list.Contains(item)) if (regularExpression.Matches(text)) if (stream.CanSeek) if (context.Created) if (form.Enabled) |
1
2
3
4
5
|
if (list.IsContains(item)) if (regularExpression.Match(text)) if (stream.Seekable) if (context.IsCreated) if (form.IsEnabled) |
1
|
public Color Color { get ; set ; } |
1
|
firstName , e , id , packageId , centerName , name |
1
2
|
public static MyType operator +(MyType left, MyType right) public static bool operator ==(MyType left, MyType right) |
1
|
public static MyType operator ++(MyType value) |
1
|
public static MyType operator /(MyType dividend, MyType divisor) |
1
|
public static MyType operator -(MyType d1, MyType d2) // incorrect! |
1
|
Area , DataBinder , PublicCacheName |
1
2
3
|
_centersList _firstName _currentCenter |
1
|
parameterType , packageOperationTypeId |
1
2
3
|
lblName (Label) txtHeader (TextBox) btnSave (Button) |
1
|
ArgumentNullException , InvalidOperaionException |
1
|
System.Data |
1
2
|
<Company>.<Component>.dll <Company>.<Project|Product|Technology>.<Component>.dll |
1
|
Microsoft.CSharp.dll , Kara.CSS.Manager.dll |
1
2
|
public int IComparer<T> {…} public delegate bool Predicate<T> (T item) |
1
2
3
4
|
public int ISessionChannel<TSession> {…} public delegate TOutput Converter<TInput, TOutput> (TInput from) public class Nullable<T> {…} public class List<T> {…} |
1
2
3
|
ArgumentExceptionIllegalCharacters ArgumentExceptionInvalidName ArgumentExceptionFileNotFound |
Pascal Casing |
camel Casing |
Wrong |
Callback |
callback |
CallBack |
BitFlag |
bitFlag |
Bitflag / bitflag |
Canceled |
canceled |
Cancelled |
DoNot |
doNot |
Donot / Don’t |
|
|
|
Endpoint |
endpoint |
EndPoint / endPoint |
FileName |
fileName |
Filename / filename |
Gridline |
gridline |
GridLine / gridLine |
Hashtable |
hashtable |
HashTable / hashTable |
Id |
id |
ID |
Indexes |
indexes |
Indices |
LogOff |
logOff |
Logoff / LogOut ! |
LogOn |
logOn |
Logon / LogIn ! |
SignOut |
signOut |
Signout / SignOff |
SignIn |
signIn |
Signin / SignOn |
Metadata |
metadata |
MetaData / metaData |
Multipanel |
multipanel |
MultiPanel / multiPanel |
Multiview |
multiview |
MultiView / multiView |
Namespace |
namespace |
NameSpace / nameSpace |
Ok |
ok |
OK |
Pi |
pi |
PI |
Placeholder |
placeholder |
PlaceHolder / placeHolder |
UserName |
username |
Username / username |
WhiteSpace |
whiteSpace |
Whitespace / whitespace |
Writable |
writable |
Writeable / writeable |
1
2
3
4
5
|
public class Color { … public static Color FromArgb(…) { … } } |
- C#.net
- 1k بازدید
- 1 تشکر