theKindOfMe

December 30, 2008

Debugging Tightly Coupled Code(Rant)

Filed under: Uncategorized — Tags: , — yasi8h @ 6:26 pm

I love OO for a reason. i don’t go around saying that i love OO so that everybody think i know a thing or two about software architecture. but because it have dividends. when you have a good design in your software, things become easy. some planning and some structure can make a lot of things very easy. if you follow OO principals you will have better and simple code. its very simple! you don’t follow OO principals, or any other principal(that have some acceptance, or that you knows to work well) you will end up with UGLY CODE! it might be easy to write ugly code. it might feel very ‘efficient’, ‘high performence’, ‘robust’ code at first. but in the end you will not have much performance gains(well may be about 0.001%, because you decided not to use setters and getters, to save method calls!!!). it will only make thing look bad an ugly. and that’s not all. i can assure you that your code will end up so complicated and full with ‘booby trap type bugs’ waiting to surface and explode.

believe me i know that gut feeling you get when you are writing ugly, unstructured code. 🙂 when you are writing stuff your mind will be ‘hot enough’ to handle all the complications that arise. so you will be able to wire up things, and put a few FLAGS! here are there and get things working smoothly. and you might feel smart too! but think for a minute. you are not supposed to write code to show how deep the ‘stack of your brain’s cache’ is. it will be hard to understand in the future for your self. and what about others who look in to it? do you really think they want to read complicated code? it is not good to write complicated code. source code is supposed to be human friendly. you don’t need to become a machine. we have more than enough machine’s! think in a higher level people! we have enough processors/RAM and shit! brains are more precious than that stuff!

wow you want to write micro code? no i am not talking about short and straight forward code. i am talking about micro code! why would to want to write something in one line if it takes 2 minutes for someone to understand it, while the same thing could be written in 2 lines, making it easy for people to read. i mean sure it will be the same for the machine(in a given context). i think you should write code that is readable. making it too short while compromising human readability is bad.

every tiny nano/1000000000 second that you TRY to save for your compiler will cost the programmers 5 mins. think about it. is it worth it?

so now all of you(who are stupid and jobless to read this! :D) know that this is a rant. now why i am ranting like this? well today i had to do some debugging in a project whose code was ‘tightly coupled’. yeah like really tight!!! the bug was in the UI layer, but i had to go thought the custom controller code(UI), UI code that uses the controllers, business logic… to understand how the “UI” works! the business class that was related to this incident had a property setter that was there just to support a certain feature in UI :O i am so shocked! this is so tightly coupled. but what can i do. i got to debug it anyways 🙂

huh… if you have to debug tightly coupled code my advice to you is… first of all claim down. and tell your self that sometimes you got to do things that you don’t like. and start debugging.

Advertisements

Blog at WordPress.com.