-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split up "god" classes, big source files #49
Comments
mainmenu.c has multiple functionality
|
To help refactoring, check out some call-graph visualisation tools: http://stackoverflow.com/a/517797/2038264 |
There's lots of separate game loops implemented which follow the same pattern:
And they are interspersed throughout all the game screen functions. The game loops should be refactored into a common loop with game screens. So far the game loops are in:
which all happen to be large files. |
A better metric would be to use LOC from the ohloh analysis. Currently the top offenders are:
|
Map is a big source file that actually contains different classes, which are used by things other than the map:
There are also other concepts here that whilst closely related to map, may be higher level than it:
|
Updates:
New top offenders:
|
ai.c has been split up; due to the addition of coop AI, some common utilities (such as getting closest enemy) have been moved to ai_utils.c, and coop only AI is in ai_coop.c. ai.c would eventually only contain code for the "classic" AI. ai.c: 476 (-56) |
Refactor menu to remove campaign type (#49)
Due to recent editor refactors, cdogsed.c has shrunk but it created a new monster file - editor_ui.c, which creates all the UI elements. ai.c: 480 (-52): many utility functions migrated to ai_utils.c New top offenders (500 LOC or greater): Top 10: |
Static map editing has been added, so despite some code being split from editor_ui.c to editor_ui_static.c, the former has still grown to over 2k lines! UI specifications are verbose by nature so I'm reluctant to refactor that further. Maybe more splits are in order. editor_brush.c: 609: code for every tool; splitting it up will also clear up the multitude of large switches New top offenders (500 LOC or greater): Top 10: |
A large number of refactors and polishing this time around, with little effect on LOC counts. editor_ui.c 2150 (+116) some editor enhancements and a huge file gets a bit bigger still. shikata ga nai New top offenders: bullet_class.c 792 The big development this time round is the split of the previously-huge objs.c into this. Bullet class encapsulates bullets (everything that weapons shoot) and objs.c gets the scraps, which includes the non-moving TObject. There is hope for this getting smaller again, as the recent weapons refactor seeks to move all the bullet definitions into an external data file. Top 10: |
There are a few source files that are >10kb in size, which is highly suspect. No module should need to be this big. They may be big because they contain large, hand-coded data structures (which can be separated from logic), or they have multiple functionality.
Currently the following source files exceed 10kb in size:
This is almost half of all the source files. Given that CDogs is a fairly big game for the number of source files, this is somewhat expected.
This will be a big ongoing issue. Keep updating this issue with findings such as:
The text was updated successfully, but these errors were encountered: