Subscribe to Martyr2's Programming Underground        RSS Feed
***** 1 Votes

Don't Be Afraid To Occasionally Hack

Icon 7 Comments
To hack or not to hack, that is certainly the question! Many programmers who are learning a language tend to follow the structure laid out in a book or provided by a class they took. This is a good thing given that the book/class teaches at least some kind of reasonable coding conventions… which most do. These conventions then tend to be adopted by the programmer and follows them for their rest of their career in some form or another. Once they get enough experience under their belt however, they turn into one of two types of programmers. One type is regimented “this is how it must be done” type of programmer that writes great code but only their way. They usually are the ones that also like to have a full out plan before one line is even written. The other type of programmer is the “cowboy” coder who just opens an editor, starts coding something with little to no plan and see where things take them leading some imaginative solutions. They often get in trouble and can end up with some pretty patched together buggy code not suitable for industrial applications.

Now neither direction is wrong or better than the other in my opinion. When I work at the office I like to have a full plan. But at other times I am not afraid to be a cowboy coder. I have opened up an IDE with a vague idea of what I am going to write and just went to town, coming up with something amazing. Perhaps it is inspired by something I saw someone else do. Maybe I wanted to see how something worked and plunked a function down and tried to wire it up to some test code. Either way, I think every programmer needs to do a little bit of hacking to keep their mind sharp and open to new ideas.

Have you ever found yourself on the phone and while talking to someone you started a doodle on a piece of paper? In the beginning you were just drawing a circle over and over again, tracing over lines you had done before and not really thinking about it. Then next thing you know, as you get off the phone, you drew the next Da Vinci and are kicking yourself that you did it on a napkin or post it note instead of something you could frame. Hacking can be the same thing. Start out with a line of code, add a little more, make it a function, generalize it, maybe refactor it, mold it into something that can handle a specific task or do something it didn’t before. Next thing you know you have a great utility class that will serve you for years. The occasional hack can do that for you!

Of course there are limitations to this and you probably should have a plan if you are working on a major project or getting paid to write a company’s next CMS. Have a plan when it counts and hack when it doesn’t. If you don’t find yourself doing both regularly, you are doing something wrong.

One last thing I can say about this is that with hacks you are going to fail a lot. Heck, most of the time you will. That is perfectly ok. Over the years I have had hundreds of hacks that just didn’t work out. But that is the beauty of hacking… when you fail, who really cares? That doodle you drew while on the phone, most of the time no one will ever see it unless you show them. Happy hacking and thanks for reading!


If you want more blog entries like this, check out the official blog over on The Coders Lexicon. There you will find more code, more guides and more resources for programmers of all skill levels!

7 Comments On This Entry

Page 1 of 1

Sergio Tapia Icon

07 January 2013 - 10:59 AM
You learn more from screwups than from successes.
6

Martyr2 Icon

07 January 2013 - 12:08 PM
You are absolutely correct Sergio. :)
1

Anarion Icon

07 January 2013 - 01:30 PM
I always screw things up and learn stuff from them... which are never put to use :huh:
0

opwernby Icon

08 January 2013 - 10:08 AM
Don't be afraid to hack occasionally...
0

Jstall Icon

08 January 2013 - 10:14 AM
Good article! I find that I am sort of in the middle between regimented and cowboy. I usually like to do a bit of planning just with a very general idea of how things should work and I figure out the implementation on the fly. I do plan a bit more when doing database design, I like to sketch out a quick ERD with the tables and how they related to each other. I absolutely agree that you can learn allot from your failures, they tend to stick in your mind more than your successes and that makes you much less likely to make the same mistake twice :)
2

Martyr2 Icon

08 January 2013 - 12:12 PM
Good call Jstall, but remember one thing about database design, if you go into it hacking along too much you may not realize your problem until you are really neck deep in your coding and then suddenly you are staring at a brick wall of a problem. I try to plan the best I can for database design. Poor database design tends to hide its ugly head a bit easier I find and then it is usually harder to correct.

Thanks for the reply. :)
0

DahDoctow Icon

09 January 2013 - 05:29 PM
I do a lot of cowboy coding, gets me into lots of messes haha. However, usually when I failed I figured out a new way to go about doing it.

Interesting blog post, great stuff.
0
Page 1 of 1