IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Somewhat related: Borland Builder-IDE "style" issue.
So, you went with the silly-language one in stead of Delphi, eh? :-)

Sorry I was too late to the party to be of any direct use... But the guys probably found that one quicker and better than I would have been able to; C/C++ isn't my favourite language. (Oh, really?!? You could *never* have guessed! So, what else is totally new and unexpected? :-)

But, if I may comment on another issue, "coding style"...? From this snippet:
//\n// Calculate Normalization factor from entered value.\n//\nfloat NORM1;  // overflows 32-bit INT if m is too large.\nint m = StrToInt(fmRefOsc->edM1->Text);\n\nfmRefOsc->edM1->Text = m;  /* Show/read the fitting interval */\nfmRefOsc->edInterval1->Text = 2*m + 1;\n\nNORM1 = (m * ((4 * m * m) - 1) * (2 * m + 3) * (m + 1) / 3);\n\n/* Show the calculated normalizing factor. */\n\nfmRefOsc->edNORM1->Text = NORM1;
...the first and perhaps most important characteristic isn't immediately obvious: Is this code situated in the actual fmRefOsc.cpp file, or somewhere else? And if it is in some other "math routines library" file, it still gets called from fmRefOsc.cpp, for instance by a button-click event handler, right? (Though at a guess, I'd wager this is the actual button-click event handler.)

Anywhichway, I think my point -- a small one, but hopefully one you'll find useful if you continue to work in "Delphi-style" IDEs, with their forms, components, properties, and events -- goes for both cases. It is this: the way you refer to components and their properties, as in "fmRefOsc->edM1->Text", is actually too precise; this can turn out to be a hindrance when later you try to re-use the code, or even if you just decide to alter your naming convention and re-name the form. Practice has shown that it is usually better (especially if this code does belong to the form itself) to use just "edM1->Text"; or, alternatively, (if you want to be anal about "precision and clarity" :-) "this->edM1->Text". But if this is a method of the form object itself, components it owns (like edM1) are visible to the method without the this-> self-reference, so adding it truly is "anal"... (What, no, what does me often doing it anyway have to do with this?!? :-)

Why, you ask? Well, simply: Because if you later change the form's name, you have to go through all these lines where you've referred to it by name, and change those to use the new name. Or, if you decide to expand your program and create multiple instances of this form... then you'll be waaay fucked, when whichever window your users click the button in, stuff only happens to one of them -- quite correctly, in the sense of doing what you ordered, not what you thought you ordered; the one your code is explicitly referring to! -- and you haven't the faintest idea what is wrong! (Listen carefully; this is the voice of experience talking... ;^[ )

The same -- only perhaps even more so -- goes for the case where you have this as a routine in a separate cpp file, with the intention of re-using this in other projects in the future.

HTH!


   [link|mailto:MyUserId@MyISP.CountryCode|Christian R. Conrad]
(I live in Finland, and my e-mail in-box is at the Saunalahti company.)
Resident [link|http://z.iwethey.org/forums/render/content/show?contentid=119792|zIWETHEY pilkunnussija]
New Well, I'm trying to reuse some earlier code.
Hi CRC,

So, you went with the silly-language one in stead of Delphi, eh? :-)

The code I'm modifying is already in Builder, so I'm trying to get it working the way I like without having to become an expert. No slight intended. :-)

Is this code situated in the actual fmRefOsc.cpp file, or somewhere else?

Unfortunately, it's in the form source file (which is called ProcSher5d.cpp at the moment - yes, it's confusing as hell.) :-( It works the way you suspect. The coding style is taken from the existing code - I have no experience with this stuff so I'm just trying to modify it (my only addition is trying to comment it clearly so that I can understand what it's doing).

Early on I tried to put my changes in a new unit, but I couldn't figure out how to tie it in to the existing form. And when I tried to rename the existing form (from fmRefOsc) and eliminate the fmRefOsc form/unit, I couldn't get the program to build even after making the name changes in the source (because fmRefOsc wasn't there - I even checked the .h files.). :-( When I get some time I really need to go through a tutorial or similar to figure out how changes /additions /deletions /modification to existing code should be done, but the things I've seen so far don't seem very helpful.

The code I'm modifying is rather general purpose. It consists of some plotting routines, some data collection routines for some instrumentation, and some data analysis routines. It's all pretty modular and generally works very well. I'm trying to improve the data analysis code without breaking everything else. :-)

Thanks very much for the pointers! I'm sure those issues will bite me very shortly.

Cheers,
Scott.
New Dude....
Watch it...Bub!

;-)
jb4
"There are two ways for you to have lower Prescription-drug costs. One is you could hire Rush Limbaugh's housekeeper ... or you can elect me President."
John Kerry
     Newbie C++ Builder problem with overflow. - (Another Scott) - (25)
         Re: Newbie C++ Builder problem with overflow. - (deSitter) - (19)
             Second paragraph in deS msg explains it - (Arkadiy) - (1)
                 Thanks! That did it. - (Another Scott)
             You're speaking over my head. - (Another Scott) - (16)
                 Re: You're speaking over my head. - (deSitter) - (15)
                     Thanks for the tips. Greatly appreciated. -NT - (Another Scott)
                     Actually, Ross... - (jb4) - (13)
                         Re: Actually, Ross... - (deSitter) - (12)
                             Hrm? - (jb4) - (11)
                                 Re: Hrm? - (deSitter) - (10)
                                     So what iron is that running on? - (jb4) - (9)
                                         Re: So what iron is that running on? - (deSitter)
                                         Also 12 on HPQ Presario 5831 (500 MHz Athlon)/gcc 2.95.4 -NT - (scoenye) - (7)
                                             Re: Also 12 on HPQ Presario 5831 (500 MHz Athlon)/gcc 2.95.4 - (jb4) - (6)
                                                 Re: Also 12 on HPQ Presario 5831 (500 MHz Athlon)/gcc 2.95.4 - (deSitter) - (5)
                                                     Sorry Ross: No Sale - (jb4) - (2)
                                                         Re: Sorry Ross: No Sale - (deSitter) - (1)
                                                             Please stand by... - (jb4)
                                                     Doesn't compile here - (pwhysall) - (1)
                                                         Gotta add -lm for math library -NT - (deSitter)
         Somewhat related: Borland Builder-IDE "style" issue. - (CRConrad) - (2)
             Well, I'm trying to reuse some earlier code. - (Another Scott)
             Dude.... - (jb4)
         NORM1 is a float, but - (jb4) - (1)
             Thanks! - (Another Scott)

More left-wing than Stalin!
50 ms