Variable Conventions
Variable Convention Definition:
Proper use of Method scoped variables in Methods and the effect on Run-time performance
Variable Convention Justification:
Understanding of the proper use standards for declared fields as private variables inside of Methods is essential for maintaining the stability of action methods. Proper use will help to maintain good performance at run-time
Variable Convention Standards:
Method Variables must conform to the following standards:
-
Naming convention is Camel Casing
-
User the var keyword always when the Declaring Type is Clearly Defined with the declaration statement. This reduces Page Code Noise and leads to better understanding of the Intent of the Underlying Software Entity
-
Assign the Variable closest to its consumptions
-
Do not create Temporary Variables (TempVars). A Temp Variable is a variable that is used ONLY once and then disposed. Copy the content of the variable and use it where the variable is consumed to prevent unnecessary Garbage Collector activities.
-
Do not use Public Properties as Method Variables. It opens the possibility of outside Entity corruption. Use a private backing field if required.
The Primary Purpose of Method Variables …
… Encapsulate Method Data Completely within a Single Responsibility Class Method
Useful ReSharper Quick Tip:
Use the var keyword to have ReSharper decide the Type of a Return when calling a Class Method.
You can then have ReSharper replace the var keyword with the return type. You will then know the Type
The following two tabs change content below.
I am a Principal Architect at Liquid Hub in the Philadelphia area specializing in Agile Practices as a Certified Scrum Master (CSM). I use Test Driven Development (TDD) and Acceptance Test Driven Development (ATDD) with Behavior Driven Development (BDD) as my bridge to Agile User Stories Acceptance Criteria in a Domain Driven Design (DDD) implementing true RESTful services
Latest posts by Brad Huett (see all)
- DevOps: A Bridge to Your DevOps Culture - March 25, 2016
- Embracing Test Driven Development (TDD) - March 25, 2016
- DevOps: Delivering Agile Projects - March 25, 2016