Primitive Obsession: An OOP Code Smell

preview_player
Показать описание
Discover what the Code Smell "Primitive Obsession" means in coding and how it can signal potential issues in your codebase.

This video breaks down how to recognise this common code smell, understand its implications, and explore ways to refactor your code using Value Objects as the solution to resolve your Primitive Obsession.

Learn how to improve encapsulation, avoid code duplication, and ensure better maintainability by addressing Primitive Obsession in your projects.

---

---

0:00 Introduction to Primitive Obsession
1:26 Recognising Primitive Obsession
2:54 Understanding Primitive Obsession
4:47 Fixing Primitive Obsession

#oop #programming
Рекомендации по теме
Комментарии
Автор

Prefer a written version? There is a visually-explained post on my blog:

metaphoricallyspeaking
Автор

I love the nuance you put in this. It's so easy to go the easy route and make some clickbaity title and going "Why you shouldn't be using primitives" or something like that.

But you explained what a code smell is, that primitives are fine as long as you're aware of better options in certain scenario's.

Looking forward to what topic you'll cover next!

pindabter
Автор

you’re very good teacher I now gained new concept I never knew. Thank you for bringing up this topic.

I would suggest to make OOP roadmap explaining step by step every concept. As I have seen last in the video about inheritance vs composition I didn’t know that inheritance is coupling and composition is decoupling. Terms like coupling and decoupling should be explained and demonstrated well when introducing OOP courses. Unfortunately, most tutorials don’t explain those OOP principles in details, they tend to stop at inheritance and that’s it.

You have special way in teaching so, Please try to make a tutorial about OOP principles in detail explaining all the concepts, techniques and tools.

Thank you for your efforts.

aaf
Автор

Simple and engaging explanation, and beautiful animations and editing - thank you!

soycrates
Автор

dude that hammer sfx was so much louder than other things I thought someone opened a gate behind me

plyr
Автор

1:50 Dart programming language and other programming languages solve this problem with named parameters. It's hard to mix them up, and when you do, only the name characteristic determines to which variable the values are assigned.

rescyy
Автор

I don't think "Primitive obsession" is the best term to use, at least in the example you described.
I absolutely agree that using primitives for everything is a bad practice, just to be clear. Your video demonstrated that very well. The hammer and nail analogy fits, without a doubt.
But I would be inclined to think that such cases occur due to the programmer not spending enough time thinking about the problem, or in case of people newer to coding, unawareness that better solutions exist. It doesn't imply an obsession with using primitives, because I'm sure most people would come up with a solution like yours after spending some time thinking about a better way to handle input validation. It's probably other factors that led to the code smell. It's not like the average programmer just can't help himself but use primitives wherever possible, as funny as that thought may be.

But the term is more of a semantic issue anyway. As stated, the problem is real, no matter what it's called. Great video, I hope to see more of you!

AnthonyYouTube
Автор

La verdad... espectacular explicación! muchas gracias, saludos desde Argentina

diegom.
Автор

the foo is a valid e-mail address. But not many know that.

kamertonaudiophileplayer