M
mike3
Why would you need examples?
K-PEX-ians would likely say that any inelligent being is well capable of
telling right from wrong -- you even demonstrated it in the initial message,
so all you lack is self-confidence. ;-)
What are "K-PEX-ians"?
You see the noise and repetition caused by mis-application of a method. So
just think the alternatives and chose the one that has least of those
problems.
What if one of the alternatives that looks good is something often
considered
"bad"? Like a global, or a goto?
Write alternatives and read them back. Ot show them for review.
You mean write the code and then read it to yourself? Write a method,
sniff it with your own nose?
And no, you can't have a general solution for the concrete problems. No
silver bullets. You must think alternatives for every particular case.
I didn't think so. I was looking more for just what needs to be
considered.
Just like the three blind guys go into "contradictions" describing the
elephant...
So does this mean the positions "use only exceptions" and "mix error
codes with exceptions" and "use only error codes" are not as
contradictory as they seem?
Heh, is there a point in that discussion? It should be vwell known, that you
can have only two kinds of C code: the incorrect and the unreadable.
Exactly due to the lack of sensible centralized error handling, and
auto-cleanup. So any code that actually checks the return codes (that in C
have no realistic good alternatives) will be infested with all the checks
and cleanup actions. To a level you can't see what should go on.
Does this mean that C sucks?
Did you try the 'five whys' method?
Sure they have some point. Dig out what it is, and you can decide whetherit
applies to your case or not.
So then you should ask "why? why? why?" to ALL these rules -- use
only exceptions, use exceptions only when "exceptional" with error
codes
for everything else, use only error codes, never make a method more
than
X long (20 lines, one screen, etc.), never use a global, never use a
goto,
avoid singleton, etc.?
Probably more dependent on the patricular situation. The same event can be
exceptional in one program and exceptional in another.
Hell yes. ;-) The Master thought to tell the good tree by the good
fruits.
IMO the stuff for which some objective answer exists is pretty rare.
Huh. Did you ever hear people saying that any guideline is only as good as
you understand its rationale?
I met a plenty of those "NO" guys, asked the 5 whys, most started to sweat
blood right at the first, or didn;t even understand what "why" means and if
he supposed to provide some answer.
Isn't that a BIG problem if "most" fail to understand these reasons?
Does this mean I should get to work spending a lot of time memorizing
rationale? Where can I find detailed rationale for all these rules --
no long method,
no global, no goto, exceptions vs error codes, etc. so as to be able
to know
enough rationale to pass the "5 whys test"?