[Tutor] Re: Coding philosophy
Andrei
project5 at redrival.net
Fri Apr 30 17:48:51 EDT 2004
firephreek wrote on Fri, 30 Apr 2004 10:28:59 -0700:
> Is it 'wrong' to add fucntions to your program that only make the code
> 'easier' to read and write?
It's wrong NOT to add them and make your program hard to read and maintain
because of it. :)
> For example, I'm working on that wxPython program, and rather than
> create a different name for each 'row' in the notebook layout, or even a
> numbered array, I 'enumerated' a dictionary so that I can reference a
> row by the name I give it.
I'm not sure the change in this particular case will save you a lot of time
or maintenance worries, but I don't think it's wrong.
> The idea (imo-head) was that each time I wanted to add or remove a 'row'
> of stuff, I could just add the name to the caller, and not worry about
> typing everything out.
The reason I don't think it will make much of a difference is that IMO the
function you wrote could do a little bit more work :). As it stands, it
just creates the rows and then you still have to do all that manual work of
adding labels, sizers, etc. to them. You could devise a system which lets
you pass certain parameters to the function and then creates the rows with
all appropriate contents already in place. In that way, when you need to
add new rows, you just modify the one function call and are done.
> I figured it'd make my code more readable and make more sense. Is that
> 'ethical'? Silly question I suppose, but I guess it's kinda in my head
> that I shouldn't waste resources just so I can be lazy. So sue me, I'm
> an american. Hah.
Waste computer resources all you like when it saves human resources :). As
long as the result doesn't perform badly from a human's POV (and humans
really are quite slow, they'll never notice a few microseconds at startup),
there's really no point in worrying over performance.
In fact, you can fool humans into thinking something is fast when it's not
by distracting their attention with shiny objects, like splash screens,
dynamic progress bars and labels with captions changing too quickly for us
to read :).
--
Yours,
Andrei
=====
Real contact info (decode with rot13):
cebwrpg5 at jnanqbb.ay. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
gur yvfg, fb gurer'f ab arrq gb PP.
More information about the Tutor
mailing list