From: Nick Keighley on 20 May 2010 03:39 On 20 May, 08:00, Nick <3-nos...(a)temporary-address.org.uk> wrote: > Richard Heathfield <r...(a)see.sig.invalid> writes: > > Lie Ryan wrote: > > <snip> > > >> If I'm searching for all cells whose sprite size is 56 pixels (e.g. > >> 7x8), do I create a list of all integers in the program? > > > If sprite size matters to you, it makes sense to have a list of > > (probably pointers to) sprites, sorted by sprite size. Instead of > > searching cell by cell, you find the sprites that are the right size, > > and then look at where they're displayed. That will be a darn sight > > faster than iterating over your entire screen checking every pixel. > > Except, of course, as we all really know, there will be times when you > just occasionally need to do something - perhaps when printing debugging > information - that you otherwise have no need to. > > Creating multiple indexes on every field in a complex tree of structures > for example, just in case you ever want to check any one of them for any > particular value, even when written out in Sanskrit, seems overkill to > me. put it in a database and let the DBMS decide when it needs additional indexes
From: Daniel T. on 21 May 2010 20:33 James Dow Allen <jdallen2000(a)yahoo.com> wrote: > On May 19, 7:42�pm, "bart.c" <ba...(a)freeuk.com> wrote: > > James Dow Allen wrote: > > > > > > Another grown man felt the need to post flowchart > > > comparisons that blithely ignored that (A && B) > > > is more "complicated" than (B). �If it isn't clear what > > > I'm driving at then run this code through your "tool": > > > � � �A = B ? C : D; > > > > > � � �if (B) > > > � � � � �AA = C; > > > � � �else > > > � � � � �AA = D; > > > If your tool tells you the first form above is simpler, > > > would you agree the tool is flawed? > > > > AA? > > ??? Yourself! > The (irrelevant) use of an alternate name was just > so no smart-aleck would argue that the first > statement gets optimized out! > > > Whether A or AA, this potentially complex term has to be repeated. This form > > also encourages you to spread it over 4 lines instead of 1, which can have > > the effect of expanding the surrounding statement or function enough to make > > it harder to take in at a glance. > > You miss the point. Of course I am *NOT* arguing against the simpler > expression here, just pointing out that a conditional is a conditional > whether it uses the keystrokes "if", "?:" or even "&&". > > I was rebutting another poster who claims that his *more* complicated > code is, instead *equally* complicated just because *his tool* treats > (A && B) > and > (B) > as *equally* complicated*, even though the tool recognizes "if" as > complicating. > > I hope my point isn't too ... er ... complicated :-) I think the point though is that his tool (i.e., cyclometric complexity) is meant to measure the number of unique paths through the code in question. If neither 'A' nor 'B' have side effects, then A && B isn't any more complex than B (based on the definition of complexity presented.)
From: Lie Ryan on 21 May 2010 23:13 On 05/22/10 10:33, Daniel T. wrote: > James Dow Allen <jdallen2000(a)yahoo.com> wrote: >> You miss the point. Of course I am *NOT* arguing against the simpler >> expression here, just pointing out that a conditional is a conditional >> whether it uses the keystrokes "if", "?:" or even "&&". >> >> I was rebutting another poster who claims that his *more* complicated >> code is, instead *equally* complicated just because *his tool* treats >> (A && B) >> and >> (B) >> as *equally* complicated*, even though the tool recognizes "if" as >> complicating. >> >> I hope my point isn't too ... er ... complicated :-) > > I think the point though is that his tool (i.e., cyclometric complexity) > is meant to measure the number of unique paths through the code in > question. If neither 'A' nor 'B' have side effects, then A && B isn't > any more complex than B (based on the definition of complexity > presented.) Great, now I have the proof that this construction is the simplest, most readable construction as it possibly can be: for (int i = 0; i < foo && foo2 > i || func(foo, i) ? foo3 << i < foo4 >> 33 > 0 : foo3 > 10 || foo ; foo++, foo2--, foo3 += 10) { }
From: Helmut Meukel on 22 May 2010 19:55 "Leigh Johnston" <leigh(a)i42.co.uk> schrieb im Newsbeitrag news:EIOdnQHlmcFTj07WnZ2dnUVZ8h-dnZ2d(a)giganews.com... > > > "Daniel T." <daniel_t(a)earthlink.net> wrote in message > news:daniel_t-DBCC13.11141024042010(a)70-3-168-216.pools.spcsdns.net... >> Ali Karaali <alicpp(a)gmail.com> wrote: >> >>> I use goto to break nested for loops and I can't see a >>> reason to ban goto. >> >> I'll give you a reason to ban goto. This is a line of BASIC code: >> >> 90 x = 5 >> >> Now, I ask you, where is the line that was previously executed? Is it >> directly above line 90, is it directly below it, or could it be anywhere >> in the program? Because of the goto statement, simply because an >> unstructured "goto" is possible in the language, you have to analyze the >> entire program to know the answer. If we ban the use of "goto", we can >> confidently know exactly what line of code comes before line 90. > > This channel is about C++ not BASIC, you do not have to analyze the entire > program in C++ as goto can only jump within the same function so comparisons > with BASIC is silly. > > /Leigh Hmm, I just re-read Page 155 of BASIC Language Reference (copyright 1989) and it states: "A GOTO statement can branch only to another statement at the same level within a program. You cannot use GOTO to enter or exit a SUB or FUNCTION procedure or multiline DEF FN function." This was Microsoft Basic Version 7.0, but the same was true for the earlier versions of QuickBasic (4.0 and 4.5). Don't know about Quickbasic 3.0, never used this one. But I remember a BASIC 2.0 (from IBM) that had no SUBs or FUNCTIONs and one program written in this flavour of Basic which I tried to convert to QuickBasic and that I never ever could straighten out some of the spaghetti knots caused by excessive use of GOTOs and GOSUBs. (No comments within the code and no other documentation). I finally dumped some not essential functionality of the program so I was able to add my enhancements without causing problems with the existing code. Helmut.
From: Leigh Johnston on 22 May 2010 21:39
"Helmut Meukel" <Helmut_Meukel(a)NoProvider.de> wrote in message news:ht9qtj$ti1$1(a)news.eternal-september.org... > "Leigh Johnston" <leigh(a)i42.co.uk> schrieb im Newsbeitrag > news:EIOdnQHlmcFTj07WnZ2dnUVZ8h-dnZ2d(a)giganews.com... >> This channel is about C++ not BASIC, you do not have to analyze the >> entire program in C++ as goto can only jump within the same function so >> comparisons with BASIC is silly. >> >> /Leigh > > > Hmm, > > I just re-read Page 155 of BASIC Language Reference (copyright 1989) > and it states: > "A GOTO statement can branch only to another statement at the same level > within a program. You cannot use GOTO to enter or exit a SUB or FUNCTION > procedure or multiline DEF FN function." > > This was Microsoft Basic Version 7.0, but the same was true for the > earlier > versions of QuickBasic (4.0 and 4.5). Don't know about Quickbasic 3.0, > never > used this one. > > But I remember a BASIC 2.0 (from IBM) that had no SUBs or FUNCTIONs > and one program written in this flavour of Basic which I tried to convert > to > QuickBasic and that I never ever could straighten out some of the > spaghetti knots > caused by excessive use of GOTOs and GOSUBs. (No comments within the code > and no other documentation). I finally dumped some not essential > functionality of > the program so I was able to add my enhancements without causing problems > with > the existing code. > > Helmut. > I was only considering old BASICs such as Sinclair BASIC, I am sure the new fangled modern BASICs are better (but I still wouldn't touch them with a barge pole). /Leigh |