In an OOP world, what's the best way to handle a lot of sequential code?
April 16, 2008 10:19 AM
Subscribe
Design-pattern (programming) question.
I'm working on a huge app (many thousand lines of code), and one of the most complex parts of it is the initialization logic. There's a ton of code that needs to run sequentially and only once.
Currently, I'm handling all of this with singletons, but I wonder if there's a better way.
Here's the basic framework now (in pseudocode).
MainInit.getInstance().init();
/* inside MainInit's init() method... */
DataManager.getInstance().init();
CommandManager.getInstance().init();
GraphicsManager.getInstance().init();
... etc ... //maybe 40 more calls like this
This seems pretty straightforward and easy to maintain. I don't have any real problems with it. But it's sort of off-the-top-of-my-head. I've never worked on an app that needs so much initializing before.
Since it's not really about objects -- it's just about tons of code running in sequential order -- I'm not sure of the best, tried and true method of breaking it up into manageable chunks. And I can't find much about it in my Design Pattern books.
I'm cool with non design-pattern solutions, too. I know patterns aren't for everything. I just need a really good way of organizing this sort of code.
posted by grumblebee to computers & internet (41 comments total)
2 users marked this as a favorite
posted by grouse at 10:28 AM on April 16, 2008