Tuesday, January 29, 2013

When your code's names are running afoul of ReSharper, it has a reason

Why ReSharper keep on suggesting to name the SocialFeedBOVM as SocialFeedBovm, PersonID as PersonId?


Following Microsoft guidelines, any acronyms more than two characters should be treated as a word in their own right.


XmlWriter instead of XMLWriter. System.Web.Mvc instead of System.Web.MVC.

LaserSword instead of LASERSword. Y'know, laser is an acronym http://en.wikipedia.org/wiki/Laser


Two letter acronyms should be written in all uppercase, e.g.:

IOWriter, not IoWriter. TRSocialFeedAI, not TrSocialFeedAi

LaserAI, not LaserAi. AILaserIOSword, not AiLaserIoSword

System.Data.DBConcurrencyException, not System.Data.DbConcurrencyException



Id is not an acronym, it's an abbreviation, so it should be PersonId, not PersonID.


For the ajax technology name, Microsoft invented XMLHttpRequest, they can be forgiven on that. XML was the vogue by the turn of the century, it should stand out on your marketing materials, library's naming conventions, etc. XML was good on the resume too, and so was JAVA (name derived from Java coffee, it's not an acronym. Just Another Vague Acronym is just a retronym) ^_^ Y'know JAVA will stand out as one of your skills when it is written in all uppercase, I digress.




But I think Microsoft was drunk when they made the rules for ID/Id:



ID
System.Runtime.InteropServices._Activator.GetIDsOfNames()
System._AppDomain.GetIDsOfNames()
System.Runtime.InteropServices._Attribute.GetIDsOfNames()
System.Type.GetTypeFromProgID()
System.Threading.Thread.ThreadID
System.Threading.Thread.GetDomainID()
System.Runtime.Serialization.ObjectHolder.ContainerID
System.Globalization.Calendar.ID
System.Globalization.CultureInfo.InvariantCultureID
System.Web.UI.Control.ClientID
System.Web.UI.Control.UniqueID

Id
System.AppDomain.GetCurrentThreadId()
System.AppDomain.GetIdForUnload()
System.AppDomain.IsDomainIdValid()
System.AppDomain.GetId()
System.Attribute.TypeId
System.TypeLoadException.ResourceId
System.Reflection.AssemblyAlgorithm.AssemblyAlgorithmAttribute.AlgorithmId
System.Runtime.Remoting.Lifetime.Lease.GetNextId()
System.Xml.Xpath.XPathNavigator.UniqueId
System.Data.OleDb.DBPropSet.PropertyId





Microsoft is drunk on DB acronym too. Following their own naming guidelines, they got the OLE right, it's a three letter acronym, hence should be written as Ole, but why on earth Microsoft written DB as Db? It should be written as System.Data.OleDB

Hmm.. I think we can't criticize them on those stuff, they called it naming guidelines, not naming rules. On things like this, there are no hard and fast rules, there are only guidelines (that was somehow being broken liberally), programming is being elevated to an art form :p





Sources:

http://msdn.microsoft.com/en-us/library/ms229043.aspx

http://10rem.net/articles/net-naming-conventions-and-programming-standards---best-practices

No comments:

Post a Comment