I was reading a post by Perci Reyes (spanish link) inspired by a Coding Horror post about understanding code. After reading it and all related links (Joel's thoughts and Peter Hallam's post) I have something to add that it seems nobody thought about...
I agree we all of the authors about the current developer's activities statistics... and maybe it's true that we spend a lot of time trying to understand code. By default, programmers are so narcissist that they need to feel they created something, so they are prone to change anything they don't understand to a more suitable and personal solution, under their point of view. Everybody seems to argue about this narcissism and programmers willing to rewrite instead of understanding but I have some doubts about it being a programmer's problem instead of a code problem...
I mean... is the code too complex to understand it? Maybe it is. I've personally seen thousand of lines of code impossible to read and understand because the chosen architecture, data or business layers, presentation model or even UI layer where poorly and improperly designed, or even not present at all. That adds lot of complexity, but you should agree it's not related to the programmer modifying that code. It's related to the code itself. That code was once written by a developer that thought it was the best solution to the business problem (or maybe it was the best suitable solution possible that could be written with the project, developer and solution constraints present at that time; or maybe related to a lack of experience or knowledge in the side of the developer on how to write that code)
I guess that if a team of peers are developing a solution they do it the best way they can, using known patterns, decoupling code and user interface, and refactoring classes and methods. Following some simple rules you should be unable to find something like a 400 lines method or a class with only one method and 2000 lines of code. And I swear this kind of code exists, I've seen it lot of times.
In that case I would obviously replace and rewrite the smelly code. Not because I prefer it my way, just because it's so poorly designed that it will drive us mad while developing the solution; but most important, it will frustrate working hours of future developers maintaining that code.
So, my point about all that thread of posts was simply to include that developer's are narcissist but they are also able to read understandable code. The problem is introduce by poorly designed software, that actually is pretty common to find anywhere. We need to have in mind that any software we develop will hit production sometime, and it will be supported by a team of developers (maybe not the same team who wrote it) that will need to understand it.
So, my personal advice is (and this is what I actually do when I wrote code in a project) that every developer out there should write the code the best way possible but always making it perfectly readable and understandable. The code must talk by itself, not through the use of code comments, and you should refactor and simplify it until you get something readable and understandable by mere humans. It's not that hard. There are lot of practices to achieve this goal and it will also, under my point of view, make you a better developer; but my favorite statement about this is:
"if you feel the need to add a comment, just refactor your code so it the comment seems superfluous; this way your code will be simpler and easier to understand"
posted on Saturday, December 16, 2006 4:07 AM
Feedback
# re: Why should I rewrite code?
12/22/2006 7:29 PM |
Hi Miguel, I've just found your post and it make me smile because I've commented about a very similar topic recently on my blog.
I've never thought about the developer's narcissisms idea but I'm not sure narcissism were one of the main motivations to refactor code. The fact is, sadly, most people rarely refactor and they should because of the reasons you gave, not because of narcissism.
# re: Why should I rewrite code?
3/4/2007 11:53 PM |
thanks
# re: Why should I rewrite code?
4/23/2007 12:48 PM |
Good ! thank the author.
# re: Why should I rewrite code?
6/6/2007 9:31 AM |
I think code rewriting is a good thing if the base code is not too big.
Only when the project is finished you have the whole view and can make it better.
# re: Why should I rewrite code?
6/26/2007 3:23 PM |
hi! nice site!
# re: Why should I rewrite code?
8/13/2007 3:50 AM |
ghgh
# re: Why should I rewrite code?
9/11/2007 10:38 AM |
Good blog! intresting work.
11/1/2007 10:25 AM |
JHVJ
# re: Why should I rewrite code?
11/18/2007 10:21 PM |
thxx
# re: Why should I rewrite code?
12/8/2007 6:36 PM |
We offer the largest collection of polyphonic ringtones, monophonic ringtones, mobile videos, color wallpapers, color screensavers, real sounds.
# re: Why should I rewrite code?
12/12/2007 10:32 PM |
Really good blog.
# re: Why should I rewrite code?
12/12/2007 10:34 PM |
Nice site
# re: Why should I rewrite code?
12/19/2007 9:47 PM |
If you are looking for the replica watch and information about it, you came to the right place.
# re: Why should I rewrite code?
1/6/2008 12:25 PM |
Nice work. Thanks for sharing
# re: Why should I rewrite code?
2/13/2008 10:32 PM |
tskler
3/24/2008 8:09 PM |
thank youuuu
# re: Why should I rewrite code?
6/6/2008 8:46 AM |
Hi,
Thanks for this good blog text..
We miss your text.
6/7/2008 11:54 PM |
gelinlik resimleri
# re: Why should I rewrite code?
6/22/2008 7:55 AM |
Hi,
Thanks for this good blog text..
We miss your tx.
# re: Why should I rewrite code?
6/27/2008 4:38 AM |
Thanks for this good blog text.. oyuntan hugo oyunlari
# re: Why should I rewrite code?
6/28/2008 6:32 AM |
Thanks for this good blog text.. oyuntan zeka oyunlari
# re: Why should I rewrite code?
6/28/2008 9:43 PM |
Thanks for this good blog text.. komik oyunlar
# re: Why should I rewrite code?
6/29/2008 8:08 AM |
Thanks for this good blog text.. bebek oyunlari
# re: Why should I rewrite code?
7/1/2008 1:02 AM |
Thanks for this good blog text.. oyunvar varmisin yokmusun
# re: Why should I rewrite code?
7/2/2008 5:10 AM |
Thanks for this good blog text.. hugo oyunlari
# re: Why should I rewrite code?
7/3/2008 8:01 AM |
Thanks for this good blog text.. kantir
# re: Why should I rewrite code?
7/5/2008 8:09 PM |
Thanks for this good blog text.. dövüs oyunlari
# re: Why should I rewrite code?
7/10/2008 6:21 AM |
Thanks for this good blog text.. en güzel oyunlar
# re: Why should I rewrite code?
7/16/2008 7:41 PM |
nedir olay anlamdadim.
# re: Why should I rewrite code?
7/25/2008 8:25 PM |
very very nice
# re: Why should I rewrite code?
7/25/2008 9:19 PM |
very very nice
# re: Upgrading from MCAD to MCPD Web Developer with exam 71-551
7/30/2008 11:55 PM |
very goods, thanks
# re: Why should I rewrite code?
8/13/2008 9:20 PM |
yaeg
# re: Why should I rewrite code?
9/14/2008 12:17 PM |
Thanks so much.
# re: Why should I rewrite code?
10/10/2008 6:26 AM |
Thank you very much for this information
# re: Why should I rewrite code?
10/27/2008 4:46 PM |
Two kids from a small town accidentally stow away aboard an airplane owned by the mob.
# re: Why should I rewrite code?
10/30/2008 2:28 AM |
The drama revolves around Tristan Price (Jesse Metcalfe), a young guy who has it all: plenty of money, a loving family, a gorgeous girlfriend, a promising future —and complete boredom! Once at the cub, the thrill-seeking guy meets and forges an unlikely friendship with his former college mate Sebastian Cole (Corey Large), a charismatic but sleazy drug dealer who ensnares him into the sordid underworld of drugs, sex and murder. Tristan soon comes to realize that his newfound friend is really an insidious enemy who seeks to exploit his contacts with Tristan’s upper crust friends and family.
# re: Why should I rewrite code?
1/6/2009 11:37 AM |
Alot of great stuff to read on this site, thanks.
1/10/2009 2:04 AM |
thank youm
1/10/2009 2:05 AM |
thanks baby
# re: Why should I rewrite code?
1/14/2009 4:29 PM |
Thanks, interesting.
1/20/2009 6:12 AM |
thanks
1/20/2009 6:13 AM |
thanks
# re: Why should I rewrite code?
1/20/2009 6:14 AM |
thanks
1/20/2009 6:15 AM |
thanks
# Играть в игры для детей
2/5/2009 11:03 PM |
Good!
# re: Why should I rewrite code?
2/7/2009 5:25 PM |
Sohbet Odalari
# re: Why should I rewrite code?
2/21/2009 10:16 AM |
Thank You
# re: Why should I rewrite code?
3/1/2009 10:24 AM |
thanks
3/17/2009 9:25 PM |
interesting
# re: Why should I rewrite code?
3/17/2009 9:26 PM |
thanks
# re: Why should I rewrite code?
3/19/2009 9:19 AM |
Thank You
# re: Why should I rewrite code?
3/19/2009 9:20 AM |
Thank You
# re: Why should I rewrite code?
3/19/2009 11:31 AM |
Thanks for that article. I read all of them.
# re: Why should I rewrite code?
3/21/2009 8:22 PM |
Thanks For BLog..
# re: Why should I rewrite code?
3/25/2009 5:46 PM |
thank you.
4/3/2009 10:37 PM |
thank you very good site
4/3/2009 10:38 PM |
thank you very good site
4/3/2009 10:38 PM |
thank you very good site
4/21/2009 9:55 PM |
Tbaks
4/23/2009 6:36 AM |
thanks for post
4/23/2009 6:37 AM |
thanks
# re: Why should I rewrite code?
4/30/2009 7:42 AM |
v
# re: Why should I rewrite code?
4/30/2009 7:43 AM |
thank you
# re: Why should I rewrite code?
4/30/2009 7:43 AM |
thank you
# re: Why should I rewrite code?
5/3/2009 3:58 PM |
It's not that hard. There are lot of practices to achieve this goal and it will also, under my point of view, make you a better developer.
# re: Why should I rewrite code?
5/3/2009 5:15 PM |
Tristan soon comes to realize that his newfound friend is really an insidious enemy who seeks to exploit his contacts with Tristan’s upper crust friends and family.
# re: Why should I rewrite code?
5/12/2009 3:45 AM |
thank
# re: Why should I rewrite code?
5/17/2009 12:20 AM |
thank you
very good your comments
# re: Why should I rewrite code?
5/23/2009 8:43 AM |
Nice post, simple but work very well
# re: Why should I rewrite code?
5/27/2009 12:02 AM |
thanks.
# re: Why should I rewrite code?
6/4/2009 9:15 AM |
thank you
very good your comments
# re: Why should I rewrite code?
6/8/2009 1:19 AM |
Thank you very much. Exactly I needed this information.
# re: Why should I rewrite code?
6/8/2009 5:27 AM |
thank you okey oyna
# re: Why should I rewrite code?
6/8/2009 5:28 AM |
thank you bedava okey
# re: Why should I rewrite code?
6/8/2009 5:29 AM |
thank you ücretsiz okey
# re: Why should I rewrite code?
6/8/2009 5:29 AM |
thank you okey
# re: Why should I rewrite code?
6/8/2009 5:30 AM |
thank you canli okey
# re: Why should I rewrite code?
6/8/2009 5:31 AM |
thank you okey salonlari
# re: Why should I rewrite code?
6/9/2009 5:50 AM |
As a developing "hacker", I couldn't agree more. I think too many developers use comments and their own familiarity as a crutch versus taking the time to view their code as a living document that needs to be comprehensible to outsiders.
# re: Why should I rewrite code?
6/13/2009 9:26 PM |
nice article
thank you