Over a million developers have joined DZone.

How I Learned to Stop Worrying and Love the Coding Conventions

· Agile Zone

Learn more about how DevOps teams must adopt a more agile development process, working in parallel instead of waiting on other teams to finish their components or for resources to become available, brought to you in partnership with CA Technologies.

Can you spot the difference between the following two code snippets?

Exhibit #1:

public class MyClass
public int MyFunc(int x, int y)
return x + y;

Exhibit #2:

public class MyClass{
public int MyFunc(int x, int y){
return x + y;


If you have some programming experience you might recognize the two styles. One of which common in your projects and the other looks strange and might even cause you a slight discomfort or bad feeling at the pit of your stomach. Some software developers have been arguing about which is better for as long as I can remember and to tell the truth I was one of them until recently.

I work mostly in C# and the majority of projects/demos/tutorials out there use the first convention. I used to argue that it’s better because it makes the code more readable and besides that’s the Visual Studio default and if it’s good enough for Microsoft it’s good enough for me. Then I got to my current employer where the official coding standard defines option number 2 as well as other conventions and it was hard. Each time I glanced at my code I had the urge to re-format, it made me feel “dirty”. After a while I got used to the new curly brackets location but it still felt wrong to me. One of my responsibilities is to make sure that all of the teams projects follows the official company’s coding specifications some of which I don’t fully agree with.

I’m a fan of this developer’s life podcast and yesterday I heard the latest show Obsession where Scott and Rob talk to several developers about their obsessions and than it hit me – the feeling I have whenever I see code that formatted “wrong” is my little OCD (obsessive compulsive disorder), it’s one of the obsessions I picked up on the way, I need to code to be “right”, similar behavior can be found when developers argue what is better – camel-case or Pascal-case, spaces or tabs, VB.NET or C# and so on. Many of these arguments are valid but sometimes we just miss the point, just because we feel good/bad with something doesn’t mean that it’s right it just mean we’re more comfortable with it and that’s ok.

As for coding standards there is a valid reason  they’re in place – we want all of the company’s source code to follow the same rules. An important goal – even at the price of making you feel good about how the code looks.

One final note – this can only go so far, if the rules make the code less readable and the developers less effective – you should make an effort to change them.

Happy coding…


Discover the warning signs of DevOps Dysfunction and learn how to get back on the right track, brought to you in partnership with CA Technologies.


Published at DZone with permission of Dror Helper, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}