Advice on how to remember so many of your own classes and functions?

I'm at the point in my program where I wouldn't be surprised if I've reached my 500th class (though some are very small, I still need to remember them), and I don't even want to estimate how many functions there are. Though I'm very interested in continuing (finishing?) the program, I find that I'm often writing duplicate classes or functions only to later (sometimes much later) realize that I've already written it (and then taking the new ones out and replacing with the old only invites more bugs, so I keep them even though it makes everything less elegant). And when I vaguely remember that I've written a class or function that already does what I need, I have a hard time finding it (i.e. remembering its name) or remembering how I used it even if I do find it, wasting time and causing even more frustration.

Any advice on this general problem? I'm at the point where I'm considering starting a new project even though I really want to finish the current one simply because I'm too overwhelmed by the responsibility with the current one.
Last edited on
1) Maybe you ar making too much classes? Are they all have their own invariants, behavior and purpose, or they are simply stateless structs?

2) Write documentation. Be it Javadoc or simple file describing entities, their purpose, arguments and return values, post and preconditions.

3) Separate your classes and functions into libraries depending on their purpose. Do the same with their dicumentation. If you have 500 classes and only 5 of them are related to date manipulation, you are less likely to forget about some of the date classes if they are in separate group.
The canonical mechanism to handle large numbers of things is not try and remember each and every one of them simultaneously at every point in time. Instead remember a small number of (hierarchically organised) places where they can be found.

For instance, how many items are there in your house? More than five hundred?
Or, how many files are there on your laptop?

In C++, we have namespaces. If we place custom allocators (or their using declarations) in utility::memory::allocators and special purpose containers in utility::containers we wouldn't have too much trouble in locating what we want.

Note that a namespaces may span multiple components and libraries; a library can use entities from different namespaces. Namespaces provide a logical arrangement; libraries provide a physical grouping of functionality for distribution and deployment.

To make it easier to remember how components are used, strive for consistency across the entire code base - consistency in naming, consistency in use of idioms, and consistency in the way things are done. The standard containers library is a good example of consistency in naming and idiomatic usage.
What's the scope of this project? 500 custom classes seems excessive for most small to medium projects. Are you sure that you're not just overreaching\suffering from feature creep?
Last edited on
just out of interest how many years have you been working on this project?
I define roughly 10 new classes every day on average (because there is a lot of polymorphism in the project and new derived types are born everyday), and have been at it for about a year now, so somewhere between 300 to 500 different classes. Often special groups of data need to be stored and passed around, so I conveniently create structs to hold them (but the convenience is only when I use them frequently, until I've stopped using them for some time and then forget I even defined it). I often make revisions just to improve the maintainability of the project, thus creating new functions and sometimes classes just for that (remembering my functions is a much bigger challenge than remembering my classes). Namespaces is something I do need to create more of though.

Though I use both Visual Studio and GCC for compiling, I've gotten used to using DevC++ solely for the editor, which I like except it often cannot find for me which file holds the original definition of a certain class when I need to look it up (assuming I found the name for the class even).
Last edited on
because there is a lot of polymorphism in the project and new derived types are born everyday
Is there really need for polymorfism? Won't composition work for it? Do you represent in code what is better be made as data?

Often special groups of data need to be stored and passed around
How large and how special data is? Won't pair/tuple work for it?

It looks like classes are created to plug holes in underdesigned project architecture.
As other have said, use namespaces and libraries to organize your code.

I have close to 100 separate projects that share the same libraries with probably about 500 classes across these libraries. These libraries are organized into a small number of DLLs. Each DLL is made up of a number of static libraries. Each DLL as a definitive purpose:
- OS interface (platform specific)
- Utility classes (platform independent)
- SQL interface (platform specific)
- Miscellaneous (catch-all to combine a number of small libraries, date handling, tracing, tokenization, etc)
- Compiler framework
- Communications framework (TCP/IP)
- XML handling

Each DLL is a Visual Studio solution. Each static library is a project within Visual Studio.
classes->project->library->DLL->solution
Haven given a fair bit of thought to the organization of these libraries, I find I seldom have to change them.

Topic archived. No new replies allowed.