----- Original Message -----
From: "Sacha Chua" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 03, 2001 9:06 PM
Subject: Re: [plug] Interesting small Math problem


> On 03 Dec 2001 01:43:57PM +0800, fooler ([EMAIL PROTECTED]) said:
>
> > iterative:
> >     double factorial;
> >     if (n < 2) {
> >         factorial = 1;
> >     }else {
> >         for (factorial = n ; n != 2; factorial = factorial * --n);
> >     }
>
> I don't know about you, but I'd have written the iterative factorial as:
>
> int factorial = 1;
> for (i = 1; i <= n; i++)
>     factorial *= i;
>
> cleaner, you think? ;)

or do it this way

for (factorial = 1; n > 1; factorial *= n--);

i intentionally make the iterative code previously more rude so that the
recursive looks more clean and elegant :-> <grin>

> Clean and elegant code has its uses. Maintainability is pretty
> important. =) Of course it all depends on the needs of your application
> - sometimes a quick hack is called for, sometimes a mission-critical app
> must be written -

agree.

> but it doesn't hurt to make sure that the next
> programmer who looks at your code can understand it.

well this is another dimension. if it is a team programming, i usually
enforce *comments* and *hungarian notation*. but hey, dont get impres that i
am still a programmer. yes i am seven years ago :->

>
> Plus, things are easier to debug when you understand it - you know what
> a pain spaghetti code can be...

true!


> But in this particular context, a quick, brute-force solution is easy to
> write. =) That's why an elegant solution would be interesting.

yes if time permit.


> I've spent time thinking of designs to try and then sketching them out
> in code. I've also thrown away code and started all over again a few
> times. I've even rm -rf'd my project directories in a fit of frustration.
;)

thats ok :-> what you felt is what i felt before and we all do i think :->


> Then again, there are times when I just shoehorn things into existing
> programs, and most of the time I still understand what's going on.. =)
>
> It's not a perfect process, but I feel like I learn a lot with
> each iteration. I don't know if I work acceptably quickly. When I have a
> clear picture of what is needed, like the online project submission
> system I'm doing for my school, then I can put together something pretty
> quickly. It took me a day to put that together. Of course it took me a
> week and a lot of help to figure out that the one bug delaying
> deployment was a _browser_ problem! GRRRRR. It works in IE, Mozilla,
Galeon.. anything but Lynx, Links and Opera. <grumble!>

hahahaha thats life sacha :-> i did experienced that too that the problem is
not part of what you are doing. :-> what i did is to back-off, take a rest,
and sing to the tune of "saan ako nagkamali" and later on come back. solve!.
:->


> I don't know. I've never worked for money, and you have. You know what
> it's like in the real world. <shrug> As far as I've seen, speed, size,
> correctness, robustness and neatness aren't mutually exclusive, although

patience sacha.. someday you will work for a money for a living. :-> unless
you found a rich handsome man will take care of you :-> <grin> we have the
same attitude that our technical work must be at par excellence. every clock
ticks on the code must be considered... one clock tick difference is
considered a bad code. :-> but this is only true for technical sense but on
the other hand..  a technical guy must not only have a technical sense but
also have a business sense... for example, why put all the features if you
can put it one at time for the next version release? now you see why
microsoft got rich? :->


> I've seen code written by Gino and William, and they really try to
> make their code neat. It's clean enough for me to understand. =)

baka nag pa pa impress yan sa iyo :-> bachelor pa ba ang dalawa yan? hehehe


> I'd like to be an expert programmer. (See extensive literature on
> novice and expert programmer). According to some studies, expert
> programmers write code roughly an order of magnitude faster _and_
> smaller _and_ neater than novice programmers in a tenth of a time.
> (Wow!)
>
> Of course these are probably some pretty old studies, but cool goals,
> you think? I have much to learn.

balance is the key here... if you think the code is part of the
initialization or sometimes called then you can optimize it thru size or
make it robust but if it is the heart or the main code and frequently called
then optimize it thru speed.

> I don't know much about software in the real world, I have to admit. I
> love programming, and I'd like to do that for the rest of my life - in
> addition to doing research and learning about all sorts of cool stuff,
> of course. But if the software industry here doesn't care about things
> like readability and maintainability, if all that I read in books
> and magazines about good software practices are just concerns of geeks
> in America and elsewhere - what should I do?

programming is a sacred.. programming is an art... find a company who
understand these two.

> I don't know. I want to learn more. I want to practice thinking,
> problem-solving, doing.. I want to make writing good code so natural
> that I don't have to think about it. Is this at all possible, or am I
> chasing a pipe dream?

we share the same dreams... during the time when i was a student like you,
im planning to write a program that the program will turn into a programmer.
but unfortunately, it didnt push thru due to lack of support. :-<

fooler.

_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]

To subscribe to the Linux Newbies' List: send "subscribe" in the body to 
[EMAIL PROTECTED]

Reply via email to