From: Kristian Nielsen Date: July 2 2009 6:08am Subject: Re: MySql coding style: Request for deprecation of UPPERCASE typedefs List-Archive: http://lists.mysql.com/internals/37061 Message-Id: <87skhf4nx8.fsf@knielsen-hq.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Konstantin Osipov writes: > Inclusion with #include is a stronger dependency than inclusion > with a forward declaration. Especially in C++, where > your component becomes aware of such intricate parts of the > included component as private members of classes. > This is why forward declarations are preferred. > > Most C++ engineers I met found this fact more or less > self-evident. > However, if you are really interested in the subject > I warmly recommend "Large-Scale C++ Software Design" > by John Lakos. This books represents the viewpoint > of no-unnecessary-dependencies camp very well. Reducing dependencies is definitely a good thing. However, merely using forward dependencies does not really do any good in this respect, as in C++ you need the full definition to do anything except pass the pointer around. It also does not help me as a developer to know anything about how a type is used in a file to see the forward declaration. The presense of a forward declaration does not tell me that this type is not used with full definition (from some #include). Nor does the absense of a forward declaration tell me that the type is not used in the file. Even the absence of the #include of the definition tells me nothing, as it could be pulled in by another #include. So that is why I asked what the purpose of encouraging forward declarations is, and with the answers I received this is now clear, thanks! *Changing* the code so that it is possible to replace the #include of a definition with a forward declaration in some files _does_ help reduce dependencies, and can be a very good thing of course. - Kristian.