Saturday, March 05, 2005

Read the code, bro's

Artists study the work of others to improve their skill with the brush. Writers read each other's novels and MCs/DJs(I don't know which word fits here, altough each of my schoolmates could tell....I really dont know) listen to each other's groove. Looking at the list above, we clearly see that most creative workers look at each other's work to improve.
But coders? Do they look at each others stuff too? Can they? Would they?
A few years ago, most source codes were considered confidential, only accessible to employees of the company that owned the program.
Dick Gabriel once said that coding is one of the few creative professions in which writers are not allowed to read each other's work(quote from:code reading by Diomidis Spinellis).
While opensource movements have improved the coder's situation, PalmOS programmers always had a huge advantage. Palm's SDK contained the sources for the core apps of the pilot. Maybe this openness inspired other coders. The PalmOS programmer can access hundreds of sources(e.G. www.palmopensource.com) for different kinds of applications. Nice code, clear code, buggy code, code with dynamic UI...
Now, you may wonder why a skill as simple as code reading warrants an article of its own. Many programmers(including myself) haven't yet understood the potential that lies before them. Why always reinvent the wheel? Even if you can't copy the code 1:1 for licence reasons, looking at it will save you looking up API and algorithms. And even if you don't need the stuff today, it may just save your a$@ another day.
So, lets bring this to an end. Look at open-source code for ideas. If you need a button-press trap, look at traps from other programs (McPhling, thanks to Ben Combee for the tip). Don't feel bad about looking at other's code-it is a smart way to save time. And no developer has too much of that!
Tell us your oppinion-feel free to comment(anonymously)!

6 Comments:

Blogger Ron said...

Even "professional" developers, in house, don't look at each other's code. There are a couple of reasons for this:

1. The person who wrote the code originally wasn't a computer professional and the code "works" but is very poorly written and definately not something that you'd want to reuse.

2. The person who needs to do something is not a computer professional and it seems so them that the time it would take to understand the code is greater than doing it themselves.

12:20 AM  
Anonymous Steven Fisher said...

I'd be really hesitant to look at the ROM applications code. I've found a number of problems with it, all of which aren't encountered by end users because it is running from ROM (mostly to do with resource locks).

5:13 AM  
Anonymous marc said...

I am kind a confused...
Sorry, Tam:
The same person who has written one of the most restrictive licensee agreements(see your LEDManagers licensee agreement, e.g.) encourages others to browse and use available sourcecodes for themselves (and to alter them in a way not to get into licensee issues?)
imho these are double moral standards you are promoting here...
What about giving some openess back to the community by yourself?
How much "time have you saved the smart way" by using "available" code in your applications?
Open source does not mean free by no means! Hope, you have not harmed any xGPL-variants with your purchasable software...
I dont know what kind of profession you have as a software developer, but I can say, that I had never enough time in software projects to walk through others sources.
It is already pretty difficult to go through foreign source codes when you have to (e.g. for optimizing/error reasons)...
You may think about your attitude!

6:33 PM  
Blogger Tam Hanna said...

Hi you all,
indeed-I didn't mean verbatim copying. I just mean to look at the programs of others in order to gather ideas on how to handle sth.
And something to Mark: TamsPalm is indeed filled with Source Codes every now and then-these are of course available publicly. Also, Tamoggemon.com is scheduled to host a copy of the Sony Clie resources from middle of march!
If you feel concerned by a specific part of the LedManager licence, feel free to email me and we can then tailor a special lixcence out just for you. And sometzing else-I won't attack anyone for loading the program in RSRCedit-its only crackers that should be deferred!
Best regards
Tam Hanna

7:17 PM  
Blogger Tom Frauenhofer said...

I'll give you an even better reason why we don't read each others code: we are not taught to read others code!

When we learn programming, we are taught about operators and precedence, looping structures, variables, functions, etc. We're taught basic algorithms and told to write programs to solve problems (towers of hanoi, etc.). Name me a single programming class or book that teaches you how to read code!

Now I listen to discussions about how people don't read code because it's not written well or they don't want to take the time to understand existing code. While there is some truth here, there is also a discomfort at reading something that's not in your style. I think this is one of the leading contributors to the "not invented by me" syndrome and leads software developers to rewrite existing programs, sometimes with disasterous results (anybody remember the dBase database program?).

(In fact, that is a project that I am undertaking - I've started to write a book on how to read code. I'm hoping to finish it sometime this year. I think that this is a skill we need to encourage to improve the overall quality of software products and decided that I have to take the initiative.)

1:22 AM  
Blogger Tam Hanna said...

Hi Tom,
this is an interesting insight. I would be glad to help you with your book, e.G: proofreading, etc if you want.
However-please keep in mind that there already is a book available about just that by Diomidis Spinellis. nhere uis a link to its amazon web page:
http://www.amazon.com/exec/obidos/tg/detail/-/0201799405/qid=1110744259/sr=8-1/ref=pd_csp_1/002-6485101-3026458?v=glance&s=books&n=507846
Best regards
Tam Hanna

9:05 PM  

Post a Comment

<< Home