Re-arrange C++ classes and name spaces #2523
Replies: 9 comments 1 reply
-
I think the main reason for messiness is lack of a description of naming convention of the files. Otherwise, C++ isn't Java, having closely related classes in a single file is completely acceptable and improves compile performance. Also, having everything in a single directory makes opening files much simpler at the CLI. |
Beta Was this translation helpful? Give feedback.
-
Personally, I think that Code Maintainability is better than save a couple of milliseconds in build time. Will a PR for this be accepted? |
Beta Was this translation helpful? Give feedback.
-
I'm personally not against organised structures for files and directories etc. |
Beta Was this translation helpful? Give feedback.
-
I won't accept a PR that puts every class in it's own file, but I would accept one that splits th_gfx in a simpler way e.g.merges all the code in th_gfx_sdl with the files / classes they belong in and then splits th_gfx by functionality or major classes. Splitting bitmap and freetype font IMO doesn't help with maintainability, but I welcome opposing views. Putting all the th_lua_* classes in their own directory (and possibly namespace) makes some sense. I've considered doing that before. I wouldn't split any of the current classes out of th_map. Not sure what else you were thinking? |
Beta Was this translation helpful? Give feedback.
-
I disagree. When i'm programming in my favourite IDE (VS Code or IntelliJ IDEA), i like to search by File. Having 1 class -> 2 files (.h and .cpp) would make the code more maintainable. Currently i'm constantly doing a search all to find the classes i want and it's a mess and exhausting. But this is my view, and i'm very picky with code maintainability. |
Beta Was this translation helpful? Give feedback.
-
There's probably an area of compromise here. For keeping neatness in general I usually find @Alberth289346 does give good insight. And as pointed out below by himself:
I don't touch the C++ of things so from most points of view I can't actually contribute much there. Going back to the wiki page though it looks like the C++ standard is to be followed at most for CorsixTH. I'm not sure what if anything it says about this topic. But if there is some local changes to C++ conventions then make sure the wiki gets it documented too I guess. |
Beta Was this translation helpful? Give feedback.
-
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rnr-lots-of-files |
Beta Was this translation helpful? Give feedback.
-
Currently i feel like C++ code is a bit messy. I suggest putting each class into separate files to make it cleaner.
e.g.:
Src/gfx/sdl/render_target.h
Src/font.h
Src/font/bitmap_font.h
Beta Was this translation helpful? Give feedback.
All reactions