As is usually the case with this situation. For example, an object may need to do very specific things:
class Human { public: void eat(Food food); void drink(Liquid liquid); String talkTo(Human human); }
Say that this is what this class should do, but actually it can lead to functions with more than 10,000 lines. That way you break them. The problem is that many of these helper functions should not be called by anything other than the function they serve. This makes the code confusing. For example, chew (food); eat () will be called, but should not be called by the user of this class, and probably should not be called anywhere.
How these cases are treated as a whole. I looked at some classes from a real video game that looked like this:
class CHeli (7 variables, 19 functions) Variables list CatalinaHasBeenShotDown CatalinaHeliOn NumScriptHelis NumRandomHelis TestForNewRandomHelisTimer ScriptHeliOn pHelis Functions list FindPointerToCatalinasHeli (void) GenerateHeli (b) CatalinaTakeOff (void) ActivateHeli (b) MakeCatalinaHeliFlyAway (void) HasCatalinaBeenShotDown (void) InitHelis (void) UpdateHelis (void) TestRocketCollision (P7CVector) TestBulletCollision (P7CVectorP7CVectorP7CVector) SpecialHeliPreRender (void) SpawnFlyingComponent (i) StartCatalinaFlyBy (void) RemoveCatalinaHeli (void) Render (void) SetModelIndex (Ui) PreRenderAlways (void) ProcessControl (void) PreRender (void)
They all look like pretty high-level functions, which means that their source code should be quite long. What's good is that at a glance it is very clear what this class can do, and the class looks easy to use. However, the code for these functions can be quite large.
What should a programmer do in these cases; which is good practice for such situations.
source share