Re: Programming style...



If you are coding if blocks within if blocks more than three or so levels
deep, you need to reconsider your algorithms and design. It is not
necessary. It leads to bad results since the code becomes far more
difficult to debug, understand, and maintain. Most bad code can be fixed
with better algorithms and a redesign. That 'do once' block helps limit the
depth to which you must nest 'if' statements. Version 1.0 of most programs
and drivers can and should be discarded for a better design later.
Commercial pressures make most of us keep the old code, so then you just
have to improve it block at a time as you have the time or you need to
modify or fix a particular area.

"Wan-Hi" <WanHi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:837701A9-C56D-43B6-90AD-8414314E84D8@xxxxxxxxxxxxxxxx
>i understand your point of viewas a professional, but you should consider
>the
> possibility that there are some amateurs among the professional majority.
> i
> for myself deal with the field of device io just for fun and know no
> senior
> programmer i can ask.
>
> coding in a clean style is not the problem. what bothers me are cases like
> if blocks in if blocks in if blocks and so on, just because the api
> function
> i call *might* return a failure code (i assume in some cases this could
> only
> happen if i passed a nullpointer for example). but for the sake of
> robustness
> i live with the thousand ifs in ifs because i can never be sure if a
> different circumstance causes a failure.
>
> i think it's good to hear different point of views from the pros to weight
> the arguments and find an own way how to deal with things.
>
> "David J. Craig" wrote:
>
>> ... If you can't code it clean and easy to follow, you need to go back to
>> school
>> or find something other than a programming job. No one will live
>> forever,
>> much less stay in the same job, so be nice to those who follow and write
>> maintainable code.
>> ...


.



Relevant Pages

  • Re: Is top-down design feasible for a coffee-break roguelike?
    ... fundamental design decisions should be settled before doing coding.. ... is strongly linked to the game mechanics itself. ... but simply because it assumes diagonal movement is disallowed. ...
    (rec.games.roguelike.development)
  • Re: [PROPOSAL/PATCH] Fortuna PRNG in /dev/random
    ... was good not to rely *entirely* on the ahsh algorithms. ... The point is that the current random.c design DOES NOT ... RELY on the security of the hash function. ... plaintext that's not one of the two. ...
    (Linux-Kernel)
  • Re: simple math question
    ... computer science, algorithms and math, let alone crypto, should NOT be ... Each design incorporated a new design idea, from SPNs to feistels, ... differential cryptanalysis, linear cryptanalysis, etc, papers you're ...
    (sci.crypt)
  • Re: truly-optimized coding styles & design patterns in C#?
    ... grokking design patterns but try to find practical examples of each pattern ... apps you've written and seek out the simplest and most elegant ways to ... creating a small utility app vs coding something that has to fit into ... > exceptions classes, none of that. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Commenting the source code.
    ... > Do you comment your source code while coding or after coding. ... break down the design to be more specific ... write, document, compile and debug debug fuctions. ... Whereas successfull means dedect bugs, ...
    (comp.lang.c)