Primitive Obsession and Feature Envy

Primitive Obsession

Signs and Symptoms

  • Use of primitives instead of small objects for simple tasks (such as currency, ranges, special strings for phone numbers, etc.)
  • Use of constants for coding information (such as a constant USER_ADMIN_ROLE = 1 for referring to users with administrator rights.)
  • Use of string constants as field names for use in data arrays.
  • The code becomes more flexible because of object utilization instead of primitives.
  • Code is more organized and the data manipulation is clear without the question of where are all these constants coming from or why are they in an array.
  • Easier finding of duplicate code.

Feature Envy

Signs and Symptoms

  • Less code duplication.
  • Better code organization.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Victor Elizalde

Victor Elizalde

Software Engineer with a passion for sharing knowledge. Also, sports lover, musician, gamer, and a tremendous food fanatic.