-
Notifications
You must be signed in to change notification settings - Fork 0
Coding Standards
Sandesh Kota edited this page Mar 4, 2019
·
2 revisions
- One Language per File. Ex: Do not include HTML content in Javascript and Javascript content into HTML file
- SOLID : SRP, OCP, LSP, ISP, DIP
- DRY : Don't Repeat Yourself
- YAGNI : You Ain't Gonna Need It
- Variable name should be a Property of the object & Function name should be an action
- Do not catch and eat an exception
- Minimize throwing Generic Exception (to Zero)
- Ensure that curly braces are added for if-else, foreach etc..
- Use Enum / Constant wherever possible
- Minimize logic in Constructor as the Dependency Injector creates object and calls the constructor.
- Method name to start with Capital letter
- Remove un-used Constraints
- Use No count for better perf
- Naming
- MethodName_StateUnderTest_ExpectedBehavior (isAdult_AgeLessThan18_False)
- MethodName_ExpectedBehavior_StateUnderTest (isAdult_False_AgeLessThan18)
- test[Feature being tested] (testIsNotAnAdultIfAgeLessThan18)
- Feature to be tested (IsNotAnAdultIfAgeLessThan18)
- Should_ExpectedBehavior_When_StateUnderTest (Should_ThrowException_When_AgeLessThan18)
- When_StateUnderTest_Expect_ExpectedBehavior (When_AgeLessThan18_Expect_isAdultAsFalse)
- Given_Preconditions_When_StateUnderTest_Then_ExpectedBehavior (Given_UserIsAuthenticated_When_InvalidAccountNumberIsUsedToWithdrawMoney_Then_TransactionsWillFail)