How do you do modular development in c / C ++?

I can handle only the simplest case when there are only 2 modules A and B

A depends on B , so I'm building B as a library and include the header file B . A , also refer to a library B to create A .

This will not work if A and B are interdependent and even worse when the number of modules increases.

So, what is the general way to perform modular development in c/c++?

UPDATE

Sorry, it seems that my title is incompatible, the rephrased version: how can I split the module into many .hand .cppfiles (none)?

+5
source share
4 answers

If A and B are interdependent, you cannot deploy them separately. Therefore, you practically have one module, not two. (You can reorganize your modules to extract common material into the third module C, thereby making both A and B dependent on C, but not on each other.)

A well-designed project should not contain cyclic dependencies of modules. This ensures that there is always a normal build order between its modules.

Update

How can I split a module into many .h and .cpp files (not one)?

: . @Felix : . @kotlinski Larman .

, , :-) ++ . , , (, ) , . ( ), .

(/) ( header/cpp). ( ) cpp. () , .

+5

, .

1) C,

2) I, A B I, .

#pragma # include/# ifndef protection:

?

#include ?

+5

, , ... I.e. A B, , B A. , , .

, " ++" .

+4

, Model-View-Controller - MVC.

Model-View-Controller (MVC) is a software architecture; 1 is currently considered an architectural pattern used in software development. The template isolates the "domain logic" (application logic for the user) from input and presentation (UI), allowing independent development, testing and maintenance of each of them.

alt text

0
source

All Articles