Do you space out your code so there are line breaks between the pieces of logic? Why do you think this is necessary? Typically this is done to separate chunks of logic so that they can be easily distinguished. If it is a complicated enough chunk, then it may even make sense to put a comment at the top of the chunk. At this point, the Agile police will jump on you and tell you to turn your comment into a method name and perform an Extract Method refactoring. This is great practice (fellow Agile police member here!) and it makes a lot of sense since it abstracts the concept and makes the code more self describing.
But let's think back to those line breaks again ... if it needed the line breaks, then there is code smell. If your code needs whitespace in the method to make it cleaner to read then it is probably doing too much. Of course, this is very subjective and easy to argue (heck - our team can't fully agree on this either!) but think carefully the next time you find yourself adding extra whitespace to your code and think:
- Is this code as simple as it should be?
- Does this logic all belong here or could it be broken out into other methods/classes?
Jonathan Cogley is the CEO and founder of Thycotic Software, a .NET consulting company and ISV in Washington DC. Our product, Secret Server is an enterprise password management system for teams to secure their passwords. Where do you keep your passwords or do you use the same password everywhere?