Primitive Obsession: An OOP Code Smell

  Рет қаралды 3,209

Metaphorically Speaking

Metaphorically Speaking

Күн бұрын

Пікірлер: 29
@metaphoricallyspeaking
@metaphoricallyspeaking 4 ай бұрын
Prefer a written version? There is a visually-explained post on my blog: acairns.co.uk/posts/primitive-obsession Disagree? Got feedback? Let me know below, or jump on Discord: acairns.co.uk/discord
@pindab0ter
@pindab0ter 3 ай бұрын
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!
@metaphoricallyspeaking
@metaphoricallyspeaking 3 ай бұрын
Really appreciate the kind words and glad you enjoyed the video. Working on decomposing monoliths at the moment, will likely be creating content on the strangler vine pattern or branch-by-abstraction. Would these topics interest you?
@pindab0ter
@pindab0ter 3 ай бұрын
@@metaphoricallyspeaking I’m very interested in the strangler vine pattern, as we’re employing that at a project we’re working on. One of the big question marks for me is how to not just start, but actually work towards finishing the ‘strangling’, as you might end up with two half implemented solutions.
@aaf2011
@aaf2011 2 ай бұрын
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.
@metaphoricallyspeaking
@metaphoricallyspeaking 2 ай бұрын
Thank you. Appreciate the kind words! :)
@soycrates
@soycrates 4 ай бұрын
Simple and engaging explanation, and beautiful animations and editing - thank you!
@metaphoricallyspeaking
@metaphoricallyspeaking 4 ай бұрын
Glad you liked it!
@pindab0ter
@pindab0ter 3 ай бұрын
Great video once again!
@metaphoricallyspeaking
@metaphoricallyspeaking 3 ай бұрын
Glad you enjoyed it 🫶
@igorpom2
@igorpom2 Ай бұрын
Very nice video, thank you!
@metaphoricallyspeaking
@metaphoricallyspeaking Ай бұрын
Glad you liked it!
@plyr2
@plyr2 4 ай бұрын
dude that hammer sfx was so much louder than other things I thought someone opened a gate behind me
@metaphoricallyspeaking
@metaphoricallyspeaking 4 ай бұрын
I didn't add any hammer sfx - are you sure it wasn't really a gate?! Just kidding, sorry. Still learning sound design and this is solid feedback, appreciate it!
@plyr2
@plyr2 3 ай бұрын
@@metaphoricallyspeaking Hahaha I was walking through a field in the countryside listening quietly through cheap and tinny Bluetooth headphones at 2am so I was prone to being spooked, it honestly made me jump a little bit, I rarely comment on KZbin videos but I figured I would while I stopped to catch my breathe. glad to know it's helpful 😂
@diegom.3782
@diegom.3782 4 ай бұрын
La verdad... espectacular explicación! muchas gracias, saludos desde Argentina
@metaphoricallyspeaking
@metaphoricallyspeaking 4 ай бұрын
te lo agradezco, gracias
@rescyy2235
@rescyy2235 4 ай бұрын
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.
@metaphoricallyspeaking
@metaphoricallyspeaking 4 ай бұрын
Even the programming language in the video supports named parameters, but it's syntactic sugar. It's still possible to make a mistake and mix things up, even if the readability is improved, and still not receive any type violations at runtime. Maybe it's different in dart?
@rescyy2235
@rescyy2235 4 ай бұрын
@@metaphoricallyspeaking Yeah you're right, you can still mix them up, given enough time, a mistake will creep in
@NandaPagi
@NandaPagi 4 ай бұрын
Good explanation, like
@metaphoricallyspeaking
@metaphoricallyspeaking 4 ай бұрын
Glad you enjoyed it! 🫡
@sumgamelab
@sumgamelab 4 ай бұрын
I have Enum Obsession, is that bad?
@metaphoricallyspeaking
@metaphoricallyspeaking 4 ай бұрын
I’ll go with “it depends” :)
@AnthonyYouTube
@AnthonyYouTube 4 ай бұрын
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!
@metaphoricallyspeaking
@metaphoricallyspeaking 4 ай бұрын
Well put. Appreciate the kind words and the constructive feedback! The term was popularized by Martin Fowler in his Refactoring book. Not quite sure if he invented it, but it’s one of many OOP anti-patterns I’m looking to cover.
@kamertonaudiophileplayer847
@kamertonaudiophileplayer847 4 ай бұрын
the foo is a valid e-mail address. But not many know that.
@metaphoricallyspeaking
@metaphoricallyspeaking 4 ай бұрын
Have they emailed you back?
@kamertonaudiophileplayer847
@kamertonaudiophileplayer847 4 ай бұрын
@@metaphoricallyspeaking Alas.
why rust libraries may never exist.
7:26
Low Level
Рет қаралды 287 М.
Wish To Remove Primitive Obsession? Try This Effective Technique!
15:28
Andro, ELMAN, TONI, MONA - Зари (Official Music Video)
2:50
RAAVA MUSIC
Рет қаралды 2 МЛН
🎈🎈🎈😲 #tiktok #shorts
0:28
Byungari 병아리언니
Рет қаралды 4,5 МЛН
Как Ходили родители в ШКОЛУ!
0:49
Family Box
Рет қаралды 2,3 МЛН
How to Use Value Objects to Solve Primitive Obsession
13:54
Milan Jovanović
Рет қаралды 48 М.
Explaining Data Structures Until I Go Insane
8:02
Mults
Рет қаралды 63 М.
Why OOP is evolving(and why it's a good thing)
7:35
TMF
Рет қаралды 14 М.
Treating Primitive Obsession with ValueObjects | DDD in .NET
15:49
Nick Chapsas
Рет қаралды 63 М.
The Most Valuable File Format You've Never Heard Of
15:33
Acerola
Рет қаралды 555 М.
how NASA writes space-proof code
6:03
Low Level
Рет қаралды 2,4 МЛН
3 Ideas on Refactoring by Martin Fowler
5:50
Christopher Okhravi
Рет қаралды 23 М.
A few common code smells to be aware of and how to fix them
6:32
The Shaggy Dev
Рет қаралды 15 М.
Write cleaner code by doing less. The S in SOLID.
9:21
Dreams of Code
Рет қаралды 30 М.
Reacting to Controversial Opinions of Software Engineers
9:18
Fireship
Рет қаралды 2,1 МЛН
Andro, ELMAN, TONI, MONA - Зари (Official Music Video)
2:50
RAAVA MUSIC
Рет қаралды 2 МЛН