5 ms·
I'm admittedly not proficient in C++, but I can't see what's beatiful about the code. Looking at the specific example you linked to... inconsistent formatting a
by V-2 7y ago
I'm admittedly not proficient in C++, but I can't see what's beatiful about the code. Looking at the specific example you linked to... inconsistent formatting and "magic values" aside, what's the point of, say:
if( !relaunched ) {
printf( "Relaunch failed\n" );
setSignal( "relaunchFailed" );
}
else {
printf( "Relaunched... but did not exit?\n" );
setSignal( "relaunchFailed" );
}
Instead of simply:
if( !relaunched ) {
printf( "Relaunch failed\n" );
}
else {
printf( "Relaunched... but did not exit?\n" );
}
setSignal( "relaunchFailed" );
?
Such copy-pasta style redundancy does count as somewhat sloppy in my book.
And do C++ books or tutorials recommend cramming over 20 KLOC in a single file? https://github.com/jasonrohrer/OneLife/blob/master/gameSource/LivingLifePage.cpp https://github.com/jasonrohrer/OneLife/blob/master/gameSourc...
I don't have any bone to pick with the guy, whom I don't know and who I'm sure may be very talented.
I only fail to see why code quality, beauty even, would be considered a forte of this particular project.
- kabwj 7y agoIt’s probably a mistake done after refactoring. The guy is only human you know.
- V-2 7y agoMagic strings and numbers all over the place are less likely to be refactoring artifacts. Of course he's only human, but it wasn't me who picked this little (80 LOC) file, of all the codebase, as an example of code being like "out of a book or tutorial" :) And what about stuff such as 20 KLOC in a single file? This is spaghetti, no matter how you spin it. I wouldn't want to work with such codebase.
- smolder 7y agoJust because there are many lines of code doesn't necessarily mean it's badly organized, hard to navigate, or spaghetti like. People have this idea that high LOC files = bad. It's really complexity of mental model of code and difficulty of navigation that is bad. Repetitive code isn't elegant but it it's often more obvious.
- s_m_t 7y agoIt isn't really clear that splitting up your code into a bunch of files is always a good thing. Sometimes it becomes harder to search, for some people switching files incurs a sort of mental cost (like walking through a doorway), it can make compilation slower, and depending on your editor you might have to do some extra configuration to work well with your directory structure.
- daemin 7y agoThis is not so much C++ as it's C with some C++ syntax. From the look of the bits of code I've seen is that it's written pretty much on demand. Not building an engine or library, just only the code that is needed and nothing more.
- userbinator 7y agoI'd say it's pretty mundane code, like perhaps 90% of what I usually see. If I were trying to reduce redundancy, it would become more like this: printf("Relaunch%s", relaunched? "ed... but did not exit?\n" : " failed\n" ); setSignal("relaunchFailed");