A
Akari
Guest
I want rise topic about coding style that we use. Now because of many people working we have a lot of different styles of writing code.
Code: [Select]
The only bad thing I see here are using "unsigned int" and "uint8_t" in same part of code.
My style are
Code: [Select]
and
Code: [Select]
but lately I start think that using of s16 and uint8_t are bad and lowers readability of code. I think writing normal short and unsigned byte are a lot better.
This was the first thing. Second are names for class member, functions, variables and so on. We need to select one style and use it till the end and force new members to use our style.
The first thing to deside is - shal we need type of variable in variable name. For example
Code: [Select]
Code: [Select]
Code:
WorldMap *ReadMap(const RString &path, unsigned int nb_rows, unsigned int nb_cols, unsigned int nb_sup) const; uint8_t *cell_data=new uint8_t[sizeof_cell]; const unsigned int nb_cells = nb_rows * nb_cols; for (unsigned int c = 0; c < nb_cells; ++c) if (GAMEFILESYSTEM->ReadFile(path, cell_data, c * sizeof_cell, sizeof_cell)) { const unsigned int cell_tx = (c % nb_cols) * 4 * 8192; const unsigned int cell_tz = (c / nb_cols) * 4 * 8192;
My style are
Code: [Select]
Code:
static void DeleteScript(void); void Run(FieldModule* pFieldModule, const s8 sbEntityId); void Init(FieldModule* pFieldModule, const s8 sbEntityId); void RequestRun(const u8 priority, const u8 scriptId);
Code: [Select]
Code:
MatrixCameraManager::GetProjectionMatrix(void) const{ // crop screen position ro range s16 x = m_ssCameraPositionX; u16 x_add = m_usScreenWidth / 2; x = (x + x_add > m_ssXMax) ? m_ssXMax - x_add : x; x = (x - x_add < m_ssXMin) ? m_ssXMin + x_add : x; s16 y = m_ssCameraPositionY; u16 y_add = m_usScreenHeight / 2; y = (y + y_add > m_ssYMax) ? m_ssYMax - y_add : y; y = (y - y_add < m_ssYMin) ? m_ssYMin + y_add : y; float fMoveX = ((m_fXMax - m_fXMin) / 640.0f) * x; float fMoveY = ((m_fYMax - m_fYMin) / 480.0f) * y; return DISPLAY->GetFrustumMatrix(m_fXMin - fMoveX, m_fXMax - fMoveX, m_fYMin + fMoveY, m_fYMax + fMoveY, 1, 100000);}
This was the first thing. Second are names for class member, functions, variables and so on. We need to select one style and use it till the end and force new members to use our style.
The first thing to deside is - shal we need type of variable in variable name. For example
Code: [Select]
Code:
bool bEnabled = false;VSbool enabled = false;
Last edited: