Esqueletos
Autor: LG | Publicado: 2012-04-26T14:55:00-03:00

Eu gosto de usar esqueletos, ou seja, aqueles arquivos de modelo. Eles me ajudam a lembrar de coisas que normalmente precisamos e também deixam o código com uma cara homogênea.

Mas eu não gosto de esqueletos mortos, daqueles que estão estáticos e não podem ser mudados, ou que são iguais para todos os projetos. Gosto de esqueletos vivos, que evoluem, sendo customizados para cada projeto conforme vão sendo usados e gosto também que eles estejam versionados no sistema de versionamento DO PROJETO EM QUESTÃO.

Costumo usar os seguintes esqueletos:

header:
//*****************************************************************************// Version/Revision log :// ====================//$Log: $////*****************************************************************************#ifndef TODO_NAME_H_INCLUDED#define TODO_NAME_H_INCLUDED//################################# Includes ##################################//################################## Types ####################################//################################ Constants ##################################//############################## Public Variables #############################//############################# ForwardDeclarations ###########################//################################# Classes ###################################//####################### Public Function Declarations #########################endif // TODO_NAME_H_INCLUDED//*************************&nbsp;&nbsp;&nbsp; E n d&nbsp;&nbsp; F i l e&nbsp;&nbsp;&nbsp; ***************************** 


cpp:


//*****************************************************************************// Version/Revision log :// ====================//$Log: $////*****************************************************************************//################################# Includes ###################################include "TODO_NAME.h"//################################## Types ####################################
//######################### Private Classes Declaration&nbsp; ######################//################################ Constants ##################################//############################# Private Variables #############################//############################## Public Variables #############################//############################# Private Functions #############################//###################### Private Classes Implementation #######################//###################### Public Classes Implementation ########################//##################### Public Functions Implementation #######################//-------------------------------------------------// Unit tests//-------------------------------------------------#ifdef UNIT_TESTS#include &lt;iostream&gt;#include &lt;assert.h&gt;using namespace std;int main (){&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Unit Testing for TODO_NAME class" &lt;&lt; endl;&nbsp;&nbsp;&nbsp; Logger::logTostdout();&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; cout &lt;&lt; "Testing TODO" &lt;&lt; endl;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; assert(!"No UNITTESTS implemented yet!");&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp; cout &lt;&lt; "&gt;&gt;&gt;&gt;&gt;&gt; Tests finished with no errors" &lt;&lt; endl;&nbsp;&nbsp;&nbsp; return 0;}#endif//*************************&nbsp;&nbsp;&nbsp; E n d&nbsp;&nbsp; F i l e&nbsp;&nbsp;&nbsp; *****************************

declaração de classe:
//=============================================================================// Class: TODO_NAME// Remarks: TODO//=============================================================================class TODO_NAME{public:&nbsp;&nbsp;&nbsp; TODO_NAME() {}&nbsp;&nbsp;&nbsp; ~TODO_NAME() {}private:&nbsp;&nbsp;&nbsp; TODO_NAME(const TODO_NAME&amp; x);&nbsp;&nbsp;&nbsp; // Hide copy ctor to avoid implicit calling&nbsp;&nbsp;&nbsp; TODO_NAME&amp; operator=(const TODO_NAME&amp; x);&nbsp;&nbsp;&nbsp; // Hide = operator to avoid implicit calling}; // End of class TODO_NAME 


Implementação de clase:
//=============================================================================// Class: TODO_NAME//=============================================================================//-----------------------------------------------------------------------------// Method: TODO// Remarks: TODO//-----------------------------------------------------------------------------void TODO_NAME::TODO(TODO){&nbsp;&nbsp;&nbsp; //TODO} 

Makefile:
#*****************************************************************************# Version/Revision log :# ====================#$Log: $##*****************************************************************************all:&nbsp;&nbsp;&nbsp; &lt;&lt;TODO: Implement all target to build your items in the current dirclean:&nbsp;&nbsp;&nbsp; &lt;&lt;TODO: Implement clean target that undoes what all does...install:&nbsp;&nbsp;&nbsp; &lt;&lt;TODO: Implement install target that installs the itens created by all to the correct places.uninstall:&nbsp;&nbsp;&nbsp; &lt;&lt;TODO: Implement clean target that undoes EVERYTHING that install does....PHONY: all clean install uninstall