↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

Code Smell: No AND in Function name

The page argues that a function should follow the Single Responsibility Principle and do one thing only. If a name includes “AND”, it usually means the function is handling more than one concern, so the better fix is to split it into separate functions.

Reading notes
#

  • A function name with “AND” suggests the function is doing too much.
  • The recommended solution is to remove “AND” and split the work into separate functions.
  • The Single Responsibility Principle says each module should have one responsibility, with separate concerns kept in separate modules.
  • Following SRP makes a code base more flexible and modular.
  • The article says the same idea applies in non-dev terms, using examples of ingredients sold separately versus pre-mixed.
  • Separate functions are easier to maintain as requirements change.
  • A single function that does multiple things can become bloated and difficult to maintain over time.
  • One community suggestion is to start function names with a verb.
  • Another comment recommends using specific names instead of generic ones like getData().