2008年7月25日 星期五

Naming Convention

撰寫程式時,對於又臭又長的名稱,有的同事一定不喜歡吧。

例如, InvoiceActionHistory 代表著 發票動作歷史,記載著誰在什麼時間,對該張發票做過哪些事情。

但是,名字有點長,19個字元長,因此,有的同事就會改成 InvActHstry 之類的縮寫。

可是,這樣需要猜一猜原來的意思。有時候很難想像。

看看下面的圖表,微軟的 .net framework 的 type name, 也是這麼長哦! 最長使用的長度是 16。

所以,不要太杏嗇了。

資料來源見 http://blogs.msdn.com/mwinkle/archive/2008/05/01/proving-a-point-with-linq-or-the-longest-type-names-in-the-net-framework.aspx 

 

 

Histogram of Type Name Sizes

image

 

Top 100 Longest Type Names

Rank Length Name Version
1 54  AttachedPropertyBrowsableWhenAttributePresentAttribute   v3.0
2 53  ListViewVirtualItemsSelectionRangeChangedEventHandler   v2.0
3 52  ServiceModelEnhancedConfigurationElementCollection`1   v3.0
4 50  DataGridViewCellContextMenuStripNeededEventHandler   v2.0
5 50  ListViewVirtualItemsSelectionRangeChangedEventArgs   v2.0
6 49  DataGridViewRowContextMenuStripNeededEventHandler   v2.0
7 49  WorkflowServiceAttributesDynamicPropertyValidator   v3.5
8 48  DataGridViewColumnDividerDoubleClickEventHandler   v2.0
9 47  DataGridViewCellContextMenuStripNeededEventArgs   v2.0
10 47  DataGridViewCellStyleContentChangedEventHandler   v2.0
11 47  ReadOnlyActiveDirectorySchemaPropertyCollection   v2.0
12 47  ExtendedWorkflowRuntimeServiceElementCollection   v3.5
13 46  IDataGridColumnStyleEditingNotificationService   v2.0
14 46  DataGridViewRowContextMenuStripNeededEventArgs   v2.0
15 46  UpdateProgressAssociatedUpdatePanelIDConverter   v3.5
16
46
 SharedConnectionWorkflowCommitWorkBatchService 
 v3.0
17 46  DispatcherUnhandledExceptionFilterEventHandler   v3.0
18 45  DataGridViewColumnDividerDoubleClickEventArgs   v2.0
19 45  DataGridViewCellToolTipTextNeededEventHandler   v2.0
20 45  DataGridViewEditingControlShowingEventHandler   v2.0
21 45  DataGridViewRowDividerDoubleClickEventHandler   v2.0
22 45  NamedServiceModelExtensionCollectionElement`1   v3.0
23 45  StandardBindingOptionalReliableSessionElement   v3.0
24 45  X509CertificateTrustedIssuerElementCollection   v3.0
25 45  X509ScopedServiceCertificateElementCollection   v3.0
26 45  InitiatorServiceModelSecurityTokenRequirement   v3.0
27 45  RecipientServiceModelSecurityTokenRequirement   v3.0
28 45  DataContractSerializerMessageContractImporter   v3.0
29 45  ClientWindowsAuthenticationMembershipProvider   v3.5
30 45  IClientFormsAuthenticationCredentialsProvider   v3.5
31 45  AttachedPropertyBrowsableForChildrenAttribute   v3.0
32 44  DataGridViewCellStyleContentChangedEventArgs   v2.0
33 44  DataGridViewColumnDesignTimeVisibleAttribute   v2.0
34 44  CodeParameterDeclarationExpressionCollection   v2.0
35 44  ReadOnlyActiveDirectorySchemaClassCollection   v2.0
36 44  ServiceModelConfigurationElementCollection`1   v3.0
37 44  UseManagedPresentationBindingElementImporter   v3.0
38 44  WS2007FederationHttpBindingCollectionElement   v3.0
39 43  KeyContainerPermissionAccessEntryCollection   v2.0
40 43  KeyContainerPermissionAccessEntryEnumerator   v2.0
41 43  DataGridViewAutoSizeColumnsModeEventHandler   v2.0
42 43  DataGridViewCellErrorTextNeededEventHandler   v2.0
43 43  DataGridViewRowHeightInfoNeededEventHandler   v2.0
44 43  DataGridViewRowHeightInfoPushedEventHandler   v2.0
45 43  PerformanceCounterPermissionEntryCollection   v2.0
46 43  TypeUniqueIdentifierSchemaImporterExtension   v2.0
47 43  IRemoteArgumentDictionaryEnumeratorContract   v2.0
48 43  ForeignKeyReferenceAlreadyHasValueException   v3.5
49 43  SecurityPackageContextConnectionInformation   v2.0
50 43  PrintSystemObjectPropertiesChangedEventArgs   v3.0
51 43  IssuedTokenClientBehaviorsElementCollection   v3.0
52 43  IssuedTokenParametersEndpointAddressElement   v3.0
53 43  X509ServiceCertificateAuthenticationElement   v3.0
54 43  TransportConfigurationTypeElementCollection   v3.0
55 43  ClientFormsAuthenticationMembershipProvider   v3.5
56 43  ServiceDescriptionFormatExtensionCollection   v2.0
57 43  DispatcherUnhandledExceptionFilterEventArgs   v3.0
58 42  DataGridViewCellToolTipTextNeededEventArgs   v2.0
59 42  DataGridViewEditingControlShowingEventArgs   v2.0
60 42  DataGridViewAutoSizeColumnModeEventHandler   v2.0
61 42  DataGridViewColumnStateChangedEventHandler   v2.0
62 42  DataGridViewRowErrorTextNeededEventHandler   v2.0
63 42  DataGridViewRowDividerDoubleClickEventArgs   v2.0
64 42  ToolStripItemDesignerAvailabilityAttribute   v2.0
65 42  EdmRelationshipNavigationPropertyAttribute   v3.5
66 42  BehaviorServiceAdornerCollectionEnumerator   v2.0
67 42  DirectoryServicesPermissionEntryCollection   v2.0
68 42  ForestTrustRelationshipCollisionCollection   v2.0
69 42  X509ClientCertificateAuthenticationElement   v3.0
70 42  ServiceControllerPermissionEntryCollection   v2.0
71 42  DatabaseNotEnabledForNotificationException   v2.0
72 42  DesignTimeResourceProviderFactoryAttribute   v2.0
73 41  CryptographicUnexpectedOperationException   v2.0
74 41  DataGridPreferredColumnWidthTypeConverter   v2.0
75 41  IDesignTimeResourceProviderFactoryService   v2.0
76 41  SiteMapDesignerHierarchicalDataSourceView   v2.0
77 41  WindowsUserNameSecurityTokenAuthenticator   v3.0
78 41  PrintSystemObjectPropertyChangedEventArgs   v3.0
79 41  ConnectionOrientedTransportBindingElement   v3.0
80 41  SecurityContextSecurityTokenAuthenticator   v3.0
81 41  SecureConversationSecurityTokenParameters   v3.0
82 41  X509CertificateInitiatorServiceCredential   v3.0
83 41  X509CertificateRecipientServiceCredential   v3.0
84 41  RecordDescriptionToTypeReferenceConverter   v3.0
85 41  BlobMessageEncodingBindingElementImporter   v3.0
86 41  DistributedTransactionPermissionAttribute   v2.0
87 41  CompositeActivityDesignerLayoutSerializer   v3.0
88 41  SqlPersistenceWorkflowInstanceDescription   v3.0
89 41  AttachedPropertyBrowsableForTypeAttribute   v3.0
90 40  DataGridViewAutoSizeColumnsModeEventArgs   v2.0
91 40  DataGridViewCellErrorTextNeededEventArgs   v2.0
92 40  DataGridViewCellStateChangedEventHandler   v2.0
93 40  DataGridViewRowHeightInfoNeededEventArgs   v2.0
94 40  DataGridViewRowHeightInfoPushedEventArgs   v2.0
95 40  ListViewItemSelectionChangedEventHandler   v2.0
96 40  DesignerSerializationVisibilityAttribute   v2.0
97 40  TypeSmallDateTimeSchemaImporterExtension   v2.0
98 40  SchemaImporterExtensionElementCollection   v2.0
99 40  ProtectedConfigurationProviderCollection   v2.0
100 40  DirectoryAttributeModificationCollection   v2.0

沒有留言:

Share with Facebook