You became a programmer anarchist. What are some conventions that you don't want to follow along?

Started by
26 comments, last by RLS0812 11 years, 6 months ago
Conventions are put in place so that others will know what were defined correctly. All is good when one follows the conventions. But what if one doesn't? Surely, if there's a good side, there has to be a bad side.

Seeing a giant switch..case code? Convert them all to if...elsif...else. Or replace all if...else to using a ternary operator.
See a function returning an integer? #define that integer as FUNCTION_RETURNING_VALUE, and set that in place.
See a small method? Add meaningless code that does nothing inside the method, to make it look like it's done professionally. (Works nicely with VS C++ compiler, as they optimize code upon building the codes. All meaningless codes will be erased from build.)
Have a meeting? Be a badass. :D

Defying the conventions sounds fun, but intrusive to the industry. So, the inner child of me have mixed feelings about this.
Advertisement
When you're working with multiple people on the same code, standardized coding conventions are a good way to boost team productivity.

When you're writing code which needs to be maintained months or years down the road, having a coding standard and consistency is a good thing!

There is a good reason for having and following conventions :) I think coding used to be a rather chaotic discipline and from that chaos, via the forces of evolution, emerged the best conventions and practices we use today. To return to the chaos would seem counter-productive...
The bad side of conventions is fanatics following them when they're not appropriate or simply obsolete. Or people arguing over brace style conventions, seriously, just pick one already, rand() % 2 if you need to! (Allman ftw, scraping lines to get more code on the screen is so 20th century, lol)

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

I used to work at a place that had extremely strict commenting conventions, where every single function had to be commented with... the name of the function, the date it was added, and the original author... and optionally what it does.
During a crunch period I got sick of it and started writing code like:
/*--------------------------------------
* Function: DrawShadows
* Date: 12/34/56
* Author: Hodgman
* Comment: This actually erases the save games, it's just really badly named. No, really. don't call this to draw shadows.
*------------------------------------*/
void DrawShadows()
{
...code to draw shadows...
}
If you want to be an anarchist...

Make sure you adhere to no naming convention... use getName(), name(), Name() interchangeably
Use var, mVar, m_var,m_Var and various Hungarian things interchangeably, preferably within the same class
Refuse to use source control
Refuse to wait for code review or testing, throw your changes ad-hoc onto live systems and of course don't document it
I do not follow capitalization conventions in Java.
Any useless variable, that is mandatory to have in code, is named "X" ( Such as in LSL )
Python purists have a fit every time they read my code examples, as I tend to compact code and throw the entire Python Mantra out the window.

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me.

~ Ralph Waldo Emerson


If you want to be an anarchist...

Make sure you adhere to no naming convention... use getName(), name(), Name() interchangeably
Use var, mVar, m_var,m_Var and various Hungarian things interchangeably, preferably within the same class
Refuse to use source control
Refuse to wait for code review or testing, throw your changes ad-hoc onto live systems and of course don't document it


Don't forget to use different types of white space and following whitespace.

Add comments above, below, before, after, and sometimes in the middle of lines of code, but never following any set standard.

[source lang="csharp"]
//Why would someone do this?
public void /*because...*/ somefunction(blah blahblah) // fuck you!
//... that's why.
[/source]
I don't like this

if(..) {
}

I prefer

if(..)
{
}

Looks more structured to me.

I also don't like white space everywhere. Like

if ( bla ) {
do ( bla );
}

I also don't like white space everywhere.


if((doSomething(stuff,moreStuff)&&!didSomethingAlready)||(didSomethingAlready&&noNeedToDoMore&&overrideAlreadyDidSomething(manager.name.c_str())))

Yup, much nicer. Seriously, I have seen stuff like this in code. And yet they wondered why so often bugs appear. Being an anarchist and breaking all rules may be fun to do for a bit, trying to get up with a working program that abuses operator overloading like mad and consists of code that when you look at it looks like a pacman made of code and whitespace. But mostly guidelines are there for a reason. Of course, they are guidelines for a reason as well, break them if you have to, but you need to be able to defend your decision to break them.

I don't like this

if(..) {
}

I prefer

if(..)
{
}


Been there... done it... got used it... makes no difference to me anymore...


I also don't like white space everywhere. Like

if ( bla ) {
do ( bla );
}



Yup, much nicer. [...]

Yes, I do agree, white spaces are YOUR FRIEND! However, liking this (i.e. the stated example

if ( s == o ) {
}

) is just WRONG! (ok, ok, it's all about opinions...) But, this is just something that *every single* coding convention I have ever used with agrees with (including the "official" Java and C# styleguides). The only people (at the place I work) that write like this are mathematicians that should not touch the code. PERIOD!!! (yes, I am getting carries away, but it's the truth!) It's got to look like this:

if (foo == bar) {
// there's what do do if foo equals bar
}

(and yes, I've seen very f'ed up coding conventions... ;) )


...

And, to stay on topic (although, I don't quite get it)... this is something evil to do:

#define TRUE FALSE //Happy debugging suckers

Some fun (most will already now it, but I like to read it once in a while): http://stackoverflow...ver-encountered


// way too many edits... time to go to bed...

This topic is closed to new replies.

Advertisement