views:

441

answers:

4

In a C++ project, compilation dependencies can make a software project difficult to maintain. What are some of the best practices for limiting dependencies, both within a module and across modules?

+11  A: 
luke
As would Clooney say: "What else" ??? Anyway, I find the "Abstract Interface" link out of topic in a C++ case: No exemple of a C++ interface and its derived implementation...
paercebal
+2  A: 

I think you need to be very careful and considerate about this. Generally, you can limit dependencies by separating the code and using abstract interfaces (eg: function pointers or an object equivalent), but separation generally adds fragility. For example, you can call a module through a generic abstract interface to reduce the dependency on the actual object implementation, but you have to update the interface in sync with the object itself, or the code will fail at run-time.

I would say it's important to structure large projects in modules with a well-defined hierarchy, but within each module don't go overboard with breaking apart code to limit dependencies. If you're going for improved maintenance, you have to balance reducing dependencies with reducing code fragility.

Nick
+5  A: 
jwfearn