Complexity: A physician, a civil engineer, and a computer scientist were arguing about what was the oldest profession in the world. The physician remarked, "Weil, in the Bible, it says that God created Eve from a rib taken out of Adam. This clearly required surgery, and so I can rightly claim that mine is the oldest profession in the world. "The civil engineer interrupted, and said, "But even earlier in the book of Genesis, it states that God created the order of the heavens and the earth from out of the chaos . This was the first and certainly the most spectacular application of civil engineering. Therefore, fair doctor, you are wrong: mine is the oldest profession in the world. "The computer scientist leaned back in her chair, smiled, and then said confidently, "Ah, but who do you 1 From: Object-Oriented Analysis and Design with Applications by Grady Booch
41
Embed
C#, .NET, Java - General Naming and Coding Conventions
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Complexity:A physician, a civil engineer, and a computer scientist were arguing about what was the oldest profession in the world.
The physician remarked, "Weil, in the Bible, it says that God created Eve from a rib taken out of Adam. This clearly required surgery, and so I can rightly claim that mine is the oldest profession in the world.
"The civil engineer interrupted, and said, "But even earlier in the book of Genesis, it states that God created the order of the heavens and the earth from out of the chaos. This was the first and certainly the most spectacular application of civil engineering. Therefore, fair doctor, you are wrong: mine is the oldest profession in the world.
"The computer scientist leaned back in her chair, smiled, and then said confidently, "Ah, but who do you think created the chaos?"
1From: Object-Oriented Analysis and Design with Applications by Grady Booch
• Types (Classes and Structs) are made of members: methods, properties, events, constructors, and fields. The following sections describe guidelines for naming type members.
Naming Conventions and Style
21
Naming Conventions and Style
• Give methods names that are verbs or verb phrases.
public class String { public int CompareTo(...); public string[] Split(...); public string Trim();}
public static class Console{
public static void Write(string format, object arg0)public static void WriteLine(char value);public static void SetWindowSize(int width, int height);public static void SetWindowPosition(int left, int top);public static void ResetColor();public static Stream OpenStandardError(int bufferSize);
}
22
Naming Conventions and Style
• Names of Properties: Unlike other members, properties should be given noun phrase or adjective names. That is because a property refers to data (object state), and the name of the property reflects that.
• Always use PascalCasing to name properties.
• DO name properties using a noun, noun phrase, or adjective.• DO NOT have properties that match the name of "Get"
public string TextWriter { get {...} set {...} } public string GetTextWriter(int value) { ... }
This above pattern typically indicates that the property should really be a method.
23
Naming Conventions and Style
• Names of Properties: Name the collection properties with a plural phrase describing the items in the collection instead of using a singular phrase followed by "List" or "Collection."
• Names of Properties: Name Boolean properties with an affirmative phrase (CanSeek instead of CantSeek). Optionally, you can also prefix Boolean properties with "Is," "Can," or "Has," but only where it adds value.
public class Control { public Color Color { get {...} set {...} }}
27
Naming Conventions and Style
• Name source files according to their main classes. Exceptions: file names with partial classes reflect their source or purpose, e.g. designer, generated, etc.
int Cutomer_Name;int CustName;int CSTMR-NM;int empName;int intDrvrCde;int drvrcode;int d; //elapsed time in daysint tempId; //not sure Temperature or Template