What is Primitive Obsession and How Can we Fix it?by@samwalpole
10,408 reads

What is Primitive Obsession and How Can we Fix it?

tldt arrow
EN
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

Primitive Obsession is a code smell in which primitive data types are used excessively to represent your data models. Primitives are the basic data types available in most languages. For example, a string could represent a name, an address, or even an ID. The problem with primitives is they are very general. They can't contain any model-specific logic or behaviour, meaning that any logic must be stored in the containing class. This means you end up with classes containing lots of unrelated logic, which violates the Single Responsibility Principle.

Company Mentioned

Mention Thumbnail
featured image - What is Primitive Obsession and How Can we Fix it?
Sam Walpole HackerNoon profile picture

@samwalpole

Sam Walpole


Receive Stories from @samwalpole

react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa