Monthly Archives: March 2013

Coding Practice: Unit Test Coverage

Coding   Practice: How much code should I expect to cover with my unit tests? This is another one of those   questions where the answer is “it depends”.  A hard fast rule of thumb   is that you should … Continue reading

Posted in Software Architecture | Tagged , | Leave a comment

Coding Practice: Unit Testing – Arrange, Act, Assert

Coding Practice: How should I layout my unit tests? Just as you   would when working with any code, your objective is readability and ease of   comprehension.  A coding layout for unit tests that achieves this   objective is … Continue reading

Posted in Software Architecture | Tagged , | Leave a comment

Coding Practice: Unit Test Execution Time

Coding   Practice: What do I do when my unit tests take more than 6 seconds to run? Unit tests should take less than   1 second to run per test.  When recently looking at a leading open source eCommerce project, … Continue reading

Posted in Software Architecture | Tagged , | Leave a comment

Coding Practice: Analyzing Code Clones

Coding Practice: Why doesn’t someone make a tool to help you detect code duplication and opportunities for refactoring? Someone does.  In fact, it is built into Visual Studio 2012 (Ultimate and Premium editions) under the Analyze menu > Analyze Solution … Continue reading

Posted in Software Architecture | Tagged , | Leave a comment

Coding Practice: Unit Test to Code Ratio

Coding Practice: What should I do if my lines of unit test code is greater than the lines of code being tested? This is a good sign.  You should expect to have a code-to-test ratio of 1:2 (i.e. twice as … Continue reading

Posted in Software Architecture | Tagged , | Leave a comment

Coding Practice: LINQ Complexity

Coding Practice: Which has higher cyclomatic complexity, a one line LINQ query or 20 lines of code? Well, it depends.  Take the single line of code below as an example: This one line LINQ query has a cyclomatic complexity of … Continue reading

Posted in Software Architecture | Tagged , | Leave a comment

Coding Practice: YAGNI

Coding   Practice: What is the minimum code needed to do a task? There is this concept of calling YAGNI (You Aren’t Gonna Need It) on a chunk of code that you have written to do something above and beyond … Continue reading

Posted in Software Architecture | Tagged , | Leave a comment

Coding Practice: Dependency Injection

Coding Practice: Why is using “new” a bad thing? The usage of “new” in a class can be an indicator of tight coupling, which can lead to code that is difficult to test and easily broken by change. Consider how … Continue reading

Posted in Software Architecture | Tagged , | Leave a comment

Coding Practice: Feature Envy

Coding   Practice: What is feature envy? A method in Class A seems way   too interested in the workings and data fields of Class B. The feature envy   from Class A to Class B is an indication of … Continue reading

Posted in Software Architecture | Tagged , , | Leave a comment

Coding Practice: Commenting Out Code

Coding Practice: When should I check in commented code? Code that is commented out should not be checked into TFS. Quote: “When you see commented-out code, delete it! Don’t worry; the source code control system still remembers it. If anyone really … Continue reading

Posted in Software Architecture | Tagged , | Leave a comment