Eryk Dwornicki - Blog

Hello! My name is Eryk, and this is my home page! You can also find me here:

< Return to home

Clean code tips #2 — Surround parts conditions with parentheses

It is more readable — makes it clear when the condition starts & ends

// Before
if (m_planningMode == PLANNING_MODE_SHAFTS && hoveredCellY + 1 >= m_planningStartY)

// After
if ((m_planningMode == PLANNING_MODE_SHAFTS) && ((hoveredCellY + 1) >= m_planningStartY))