🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #75489

Re: Java needs "goto" (was Re: hi)

#75489
From: ah
Date: Sun, 11 Mar 2007 07:33
315 lines
12635 bytes
Vance I. de Souza, C.A.S. wrote:
> In article <6uto94-3np.ln1@zoogz.gregorie.org>, Martin Gregorie
> <martin@no.known.address> wrote:
>>Lew wrote:
>>> Gordon Beaton wrote:
>>>> I'm with you on this. I find that readability is improved if
>>>> declarations are collected at the start of the method, rather than
>>>> interspersed with code statements.
> 
> Plus, and don't forget about this,
> otherwise you'll end up spending lifetimes
> to fix your program in case there is error.
> 
> If variables are declared at the top of the methods,
> then all the error conditions and variable values
> could be seen if you set a breakpoint in correct place
> cause they won't go out of scope.
> 
> Especially if you have the exceptions in that method,
> as if they are hit, you are COMPLETELY out to lunch,
> and it would take you lifetimes to figure out WHY
> that exception was hit if you are using declarations
> deep inside the method. I even avoid using things like
> 
>     for (int nInd = 0; nInd < limit; nInd++)
> 
> Instead, i do
> 
>     int nInd;
> 
>     for (int nInd = 0; nInd < limit; nInd++)
>     {
>         ...
>     }
> 
> So, if i have an error condition inside for loop,
> i can see which exact element caused it,
> even if i am thrown out of the scope of the loop
> by some exception.
> 
>>> I would accept your formatting in a code review
> 
> I absolutly hate "code reviews".
> It simply means that there is some smart ass,
> sitting on the top of a bunch of dummies,
> telling them how screwed up they are,
> and all it produces at the end
> is guilt, leading to fear
> to lose onse skin.
> 
> Instead of those stupid "code reviews",
> you just work within a group and maintain
> a constant feedback and exchange the ideas.
> 
>>> if you said start of the
>>> block, rather than start of the method. Engineering rules trump
>>> formatting rules, so a "declare at the top" style should still yield to
>>> scope limitation.
> 
> I know plenty of those rules. But as far as end product goes,
> those "rules" do not cover about the most subtle issues,
> and especially the maintainability and future code modifications.
> Long subject.
> 
>>> I distinguish between rules I follow and rules I want others to follow.
> 
> I know, I know.
> 
> :---}
> 
> It is called scitsophrenia.

ITYM "schizophrenia"

HTH


> In one situation you think like this,
> and in another situation you think like that.
> 
> No wonder...
> 
>>> I believe we all should limit the scope of variables,
> 
> Yep. I like those "shoulds",
> the byproducts of a rigid mind.
> 
> Now, on what basis should we limit the scope of variables?
> What does it improve?
> Not that I do not see what you mean,
> but you need to be able to put the WHOLE thing
> in perspective, and not only in terms of your
> ideology, but the debugging process, code extensibility,
> maintenance issues, code simplicity and readability
> and all sorts of other things.
> 
> The rules of:
> 
> THOU SHALT LIMIT THE SCOPE OF YOUR VARIABLES
> is simply incomplete of a statement.
> There are no ifs and buts in it.
> So, it is not programming.
> It is totalitarian dictatorship
> of black and white.
> 
> Programming is a pure logic,
> as THAT is where all the intricacies come in.
> 
> If you use this black and white model,
> your program will be the most oppressive thing there is.
> To the user, to the programmer and the rest of them
> mortals that come its way.
> 
>>> and I personally
>>> declare variables inline with use,
> 
> Uhu.
> 
> And what happens if you hit an exception
> during debugging?
> 
> Ever thought?
> 
> Can you look at those variables inside some loop
> and see what EXACTLY happened?
> 
> How long will it take you to fix bugs with this approach?
> How many times you would have to recompile
> and how many source files you'd have to go thru
> to see where is the error?
> 
> You see, looking at the source is not the same thing
> as looking at the state of your program and variables
> in RUN time.
> Cause what you THOUGHT MUST be happening,
> for some strange reason, do not happen.
> And, usually, it is the simpliest things imaginable
> that break your royal code.
> 
>>> but I wouldn't ask you to move your
>>> declarations in line.
> 
> Which is about the most foolish thing to do.
> Just recently, i was lazy enoug to declare my
> variables in one lengthy operation where a number
> of files are opened and, in some cases, a single
> statement would cause the entire file load and parsing.
> The error would happen after tens of minutes of operation
> and, once the exception was hit, i did not have a SLIGHTEST
> clue what exactly was the reason for that exception.
> 
> Once i moved the declaration on the most outside scope
> of method, i could see that error within seconds.
> 
> Hows THAT for lesson in programming?
> 
>>> I happen to believe that readability is improved with variables declared
>>> near their use, diametrically opposite to your viewpoint.
> 
> It all depends.
> Sure, you are guaranteed a better memory dealocation
> and sure, you may avoid some subtle bugs if you initialize
> the variables on the most outside scope and, later on,
> use them when they were not properly set in the inner levels,
> and, instead of compile time errors, you get run time exceptions.
> No question about it.
> But this is just the BEGINNING of a story,
> and not the end.
> 
>>>I also do not
>>> see any objective evidence that either of us is correct.
> 
> Well, BOTH are correct
> and both are wrong.
> 
> Because you need to specify ALL the conditions
> and ALL the tradeoffs.
> 
>>> I do see
>>> evidence that declaring variables in the narrowest scope provides
>>> stability and other engineering benefits.
> 
> To general to even consider.
> I doubt you have enough evidence for stability,
> and i do not even attempt to figure out what those
> "engineering benefits" are in specific terms.
> 
>>> If I worked in a group that said "declare at the top of the block", I'd
>>> follow their rule except where engineering considerations override.
> 
> "declare at the top of the block" dictates
> are no different then "use bracess this way" dictate.
> You can hit me with a sledge hammer,
> but i will still use the braces on the next line,
> and i have a REASON for it, you see,
> and the reason is simple enough to a mere mortal to comprehend.
> 
> If you use braces at the end of a line,
> you can never be certain if you put them in the
> right scope, especially in nested "if else" clauses.
> 
>>I'm happy with either approach and would go with either project standard
>>without argument. I used to declare variables at the top of a block in
>>the Algols and do like the scope limitation that provides: I guess that
>>too much C has stopped me using it. I must try harder.
> 
> First of all, if you declare variables at the very beginning
> of you method, you can review that code and see if some
> variables and, therefore, some operations are simply overkill,
> or you are doing some extra work on a method level that would
> not have to be done if your code was more structured.
> 
> So, by sheer fact that you have some variables,
> it indicates that you do some operations that NEED those
> variables, and you can see that you might be using several
> variable to carry the same exact information except in
> a slightly different context, and so you can fix that code.
> 
> As far as memory management goes, it is true that the memory
> deallocation may improve if you declare those variables
> on the deepest scope possible as in that case,
> the deallocation is pretty much automatic.
> 
> But again, that is just a beginning of the story,
> and not the end.
> 
>>The layout standard I've seen that I really don't like is the custom of
>>declaring class-level variables after the methods. Why reverse the
>>standard used inside blocks and methods other than sheer perversity?
> 
> Well, i must be a pervert then.
> I agree with you that it is better to move it in front,
> generally speaking, but some methods have so much stuff
> attached to them that it takes you quite some time
> before you see the constructor code, which is about
> the FIRST thing i want to see.
> 
> Then, after contructor code, i like to put the highest,
> possibly thread level methods, such as start, stop, run,
> Terminator (ever heard of such an animal), and things
> like that.
> 
> Then, I'd like to see the main method, starting the
> whole operation.
> 
> Then, after it, i like to see the more fine grained
> methods.
> 
> And, about the LAST thing i want to see, is the even
> handler code. That comes as just about the LAST thing
> in that class, and the beauty of it, i know EXACTLY
> where i can find it, even if i do not remember the
> exact name of some variable or method,
> which is an art on its own.
> 
> I can remember just about every single method or
> variable in a pretty complex program, just because
> of naming convention i use.
> 
> I can see what the methods do simply by looking
> at the variable names those methods use.
> 
> And, the LAST thing i want to see is...
> 
> Tada!
> 
> The VARIABLES, in bulk.
> But even there, they are all nicely sequenced
> and the first in order come those of the most
> outer scope and meaning, the MAJOR variables,
> that could correspond to entire complex classes,
> frames, etc.
> 
> Then comes the file level variables, file names,
> handles, etc.
> 
> Then come the groups of related variables describing
> some logically related operations or constructions.
> 
> Then comes the miscellaneous stuff, which i periodically
> look at to see what kind of garbage is there
> as there should be none on the first place as just about
> all the variables should be decleared on more local
> scope, otherwise you have a database consistency issue,
> when several different methods access the same global,
> and, in some cases, one hand does not know what the other
> is doing.
> 
> As a general rule, I use as little globals as I can manage.
> So far, my stuff runs, compiles, extends, and maintains
> like a tank. Try to kill it. Even if you unplug the power
> cord, in the middle of a file operation, I'll recover,
> as long as operating system can recover the damaged file.
> 
> :--}
> 
> 
> 
> 
> 
> 
> 
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> "[The Palestinians are] beasts walking on two legs."
> 
> --- Menahim Begin,
>     speech to the Knesset, quoted in Amnon Kapeliouk,
>     "Begin and the Beasts".
>     New Statesman, 25 June 1982.
> 
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> This is just a reminder.
> It is not an emergency yet.
> Were it actual emergency, you wouldn't be able to read this.
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Technical Details
Message-ID: <45f3aeb8$0$30429$8f2e0ebb@news.shared-secrets.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!post01.iad01!news.shared-secrets.com!not-for-mail
References: <1170226439.643463.93880@j27g2000cwj.googlegroups.com> <1170245478.964647.118450@v45g2000cwv.googlegroups.com> <XLOdneZMhuRVDF3YnZ2dnUVZ_r2onZ2d@comcast.com> <op.tm3trwrjaynfek@laptop32.home.inter-corporate.com> <4ebe94-rrd.ln1@zoogz.gregorie.org> <YcednVZR_pOcdVjYnZ2dnUVZ_sfinZ2d@comcast.com> <g0lj94-jf7.ln1@zoogz.gregorie.org> <45c818de$0$24619$8404b019@news.wineasy.se> <hPWdnbmDpr0GmFTYnZ2dnUVZ_tijnZ2d@comcast.com> <6uto94-3np.ln1@zoogz.gregorie.org> <5854FBA4.27BA3F5C@hotmail.com>

Show Full Headers
Complete Article Headers
Message-ID: <45f3aeb8$0$30429$8f2e0ebb@news.shared-secrets.com>
Subject: Re: Java needs "goto" (was Re: hi)
Date: Sun, 11 Mar 2007 03:33:53 -0400
From: ah <splifingate@gmail.com>
References: <1170226439.643463.93880@j27g2000cwj.googlegroups.com> <1170245478.964647.118450@v45g2000cwv.googlegroups.com> <XLOdneZMhuRVDF3YnZ2dnUVZ_r2onZ2d@comcast.com> <op.tm3trwrjaynfek@laptop32.home.inter-corporate.com> <4ebe94-rrd.ln1@zoogz.gregorie.org> <YcednVZR_pOcdVjYnZ2dnUVZ_sfinZ2d@comcast.com> <g0lj94-jf7.ln1@zoogz.gregorie.org> <45c818de$0$24619$8404b019@news.wineasy.se> <hPWdnbmDpr0GmFTYnZ2dnUVZ_tijnZ2d@comcast.com> <6uto94-3np.ln1@zoogz.gregorie.org> <5854FBA4.27BA3F5C@hotmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!post01.iad01!news.shared-secrets.com!not-for-mail
Organization: happy
User-Agent: Mariozilla/3.5a (Nintendo64; U; WaveRunner m20478; en-US;
MIME-Version: 1.0
Newsgroups: news.groups, alt.slack, alt.config, news.software.nntp, alt.usenet.kooks
 alt.usenet.kooks
In-Reply-To: <5854FBA4.27BA3F5C@hotmail.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Lines: 315
X-Complaints-To: abuse@shared-secrets.com