学習が進み、演習プログラム→演習プロジェクトぐらい進歩しました。
そこでの悩み事といえば、膨大化していくコードでのメンテナンスやさらなる拡張でしょう。
幸いなことに、設計も製作も管理運用も全て一人なので、思わぬバグを入れられる心配はありませんが。
設計に関して役に立つ本や知識、Webサイトなど教えて下さい。
*今のひどさをコードにすればこんな感じです:
クラス: class Cell{略};
class CellTable{略};
変数: CellTable *lp_table;
プロトタイプ: BOOL myShuffleCells(Cell *,int);
中身: BOOL myShuffleCells(Cell *table,int size){
srand((unsigned) time(NULL));
for(int i=0;i<size;i++){
int new_pos = rand()%size;
RECT rc = *(table[i].myGetCellRect());
*(table[i].myGetCellRect()) = *(table[new_pos].myGetCellRect());
*(table[new_pos].myGetCellRect()) = rc;
}
return true;
}
コメント: *(table[i].myGetCellRect()):
Cell* → Cell[] → 関数呼び出し → 戻り値:RECT* → 構造体:RECT
呼び出し: myShuffleCells((*lp_table)[0],lp_table->myGetTableSize());
コメント: (*lp_table)[0] = CellTable* → CellTable → operater[]呼び出し → 戻り値:Cell*
operator[]: const Cell *CellTable::operator[](const int num)const{
return &(this->table)[num];
}
Cell *CellTable::operator[](const int num){
return const_cast<Cell *>(
static_cast<const CellTable &>(*this)[num]);
}
コメント: CellTable* → CellTable → const CellTable & + [num] → const Cell[num] → 戻り値:const Cell* → 戻り値:Cell*