Pain of codes (from Java to C++)
I never thot that cleaning up the codes is so painful. I'm supposed to repackage a piece of code, making to more presentable. But it brought me pain. I never thought that Java could make harm to C++ coding... I often see code segments like...
(object) obj = new object(param1,param2,param3);
(object *) objectArrary =
new (object *)[someSize];
if (objectArray == NULL) {
cout << "ERROR" << endl;
exit(1);
}
:
:
:
delete obj;
delete [] objectArray;
while the code can be written nicely as...
object obj (param1,param2,param3);
(object *) objectArrary[someSize];
I often see variable names like... noOfBindingSites, motifLength.... which I renamed it to num_binding_sites, motif_len... more C++ friendly.
I'm still trying to clear up all this "style of writing C++" to somthing I feel more comforatable... But I'll need to break up a function of 400++ lines into different functions (methods) that are described in a paper by 6 different EM functions. That's the most painful part. Then when I asked why lump all into one? The answer is (justifiable), "because putting into different methods make it *slow*,....", how slow? .... Then I stop asking, I'll do it *MY WAY*.
mr blog
mr blow should know cos he C tutor? - PM
By Anonymous, at 5/25/2004 04:53:10 PM
errr note that I'm a C tutor, not C++ or Java. So i dunno the latter 2 lor.
Mr Blow
By schemer, at 5/27/2004 01:50:15 AM
Actually, splitting it up into different methods makes it *FASTER*. Because it increases code locality, magnifying the effect of the fast L1/L2 caches.
Charles Leicerson gave us a seminar about this several years back, and he had some data in which I recall there were significant performance improvements when loop unrolling was turned *OFF*.
By Anonymous, at 5/27/2004 11:30:30 PM
Rhandeev,
Thanks for the comment. I totally agree with you, although I didn't thought of that in the first place. But I don't think I'll comment further about his code. *sigh*
By HonL, at 5/27/2004 11:34:04 PM
<< Home