3 ms·
As far as I understand it, it's more of a "Bottom/Top" versus "Top/Bottom" thinking. Personally, looking at: void checkCloseWorkshop() { if ( noMoreElv
by d0m 14y ago
As far as I understand it, it's more of a "Bottom/Top" versus "Top/Bottom" thinking. Personally, looking at:
void checkCloseWorkshop() {
if ( noMoreElves() ) {
fireAllReindeer();
}
}
is enough, I don't need to look more precisely. But, for someone who is more "Bottom/Top", the second version is a headache because they need to jump everywhere and keep 10 different files/functions open all the time.
An anecdote of this, I once worked with a programmer who was "Bottom/Top" and really hated functions. (1500+ lines function was the way to go for him). He would then refactor my code like this:
void checkCloseWorkshop() {
bool noMoreElves() {
return elfCount == 0;
}
void fireAllReindeer() {
for (int i = 0; i < reindeerCount; ++i) {
delete reindeerArray[i];
}
delete reindeerArray;
}
if ( noMoreElves() ) {
fireAllReindeer();
}
}
I.e. Pasting my functions into the other functions he needed.. rather than just calling mine or moving them in another file. Obviously, there was no tests or frameworks used by this company. This is a true example of "Bottom/Top" thinking.
Last note, I understand your point but there's a way to mix both strategies by using high-level strategies. For instance, fireAllReindeer is deleting an array while noMoreElves is checking for emptiness. Good C++ programmers would use boost or the STD functors/SmartPointers rather then manually reinventing the wheel every time.