Scott Allen in his plural sight video makes these 10 recommendations for writing quality software
- Keep classes small.
- Keep methods short. Ideally a method should sit on one screen. If its bigger than that, break it up into smaller methods.
- Except for API documentation comments (the one that goes on top of a method with ///) avoid comments. Good code with meaningful method names, is so readable and intention revealing that it does not need comments.
- Avoid multiple exit points (multiple returns) from a method. That is bad for code readability. Have just one exit at the bottom of the method.
- Encapsulate complex expressions.Instead of having an if condition with many checks, replace it with a method call.
- Set up your project build warning level to 4 and set "Treat warnings as errors" to All.
- Avoid having more than 3 parameters to a method. If it needs 4 or more parameters, it should be one parameter which is an instance of a class that has those 4 parameters as properties.
- Avoid using boolean parameters to a method, because they reduce the code readability.
- Do not use exceptions for jumping around in the code.Use exceptions for errors only.
- Avoid using regions in code. According to Scott if your code is well organized using appropriately sized classes (a class that is NOT a swiss army knife) then you do not need regions.
No comments:
Post a Comment
Comments will appear once they have been approved by the moderator