Metaphorically Speaking
Metaphorically Speaking
  • Видео 17
  • Просмотров 42 312
Primitive Obsession: An OOP Code Smell
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.
---
Website: acairns.co.uk
Twitter: andrewcairns
Discord: acairns.co.uk/discord
Substack: acairns.substack.com
---
0:00 Introduction to Primitive Obsession
1:26 Recognising Primitive Obsession
2:54 Understanding Primitive...
Просмотров: 3 257

Видео

Composition over Inheritance Explained by Games! #programming
Просмотров 18 тыс.11 месяцев назад
Let's explore the principle of Composition over Inheritance in the context of Object-Oriented Programming (OOP) and... our favourite 8-bit video games! This video uses metaphors and analogies from retro video games to explain the concepts of Composition and Inheritance. It highlights the advantages of Composition and why it may be a more beneficial approach. The video illustrates the principle ...
What is a Command Bus? #software #architecture
Просмотров 1,6 тыс.Год назад
Bonus points for letting me know fun ways the metaphors/analogies fall apart! 🤣 What is a Command Bus? In this video, we'll take a quick look at what a Command Bus is and how it is similar to a bridge connecting land together. We'll explore how the car is a Message which progresses through a Message Bus (which is what a Command Bus is) encountering different segments we can think of as Middlewa...
Dates and Times are HARD! #php
Просмотров 1,3 тыс.Год назад
Dates and times are hard (and not just in Laravel or PHP!), but they aren't broken. Most of the time, they work fine, but when they don't - it can be super confusing. From off-by-one errors and almost borderline unexplainable results from calculations - it's easy to fear dates. But don't. Accept the fact that dates can be weird because dates are weird in the real world, too! In this video, I ex...
Artisan shortcuts can be dangerous for your project! #laravel #php
Просмотров 4 тыс.Год назад
Don't make this mistake in your Laravel project. Laravel uses Symfony's Console package which allows you to specify shortcuts when running commands from the terminal. However, this is a terrible idea in production as it leaves your vulnerable to making a previously stable command ambiguous. 0:00 intro 0:51 shortcuts 1:15 source diving 1:35 pattern matching 2:47 strong opinions 3:26 outro Websit...
What Are Transaction Boundaries?
Просмотров 701Год назад
What Are Transaction Boundaries?

Комментарии

  • @kamilmackiewicz4848
    @kamilmackiewicz4848 17 часов назад

    Didn't understood that, eh..

  • @JoeyG-o8r
    @JoeyG-o8r 21 день назад

    Great video man, God bless you.

  • @juancarlospizarromendez3954
    @juancarlospizarromendez3954 23 дня назад

    Using Composition instead Inheritance could make a mess the alternative to the diagrams of UML (Unified Modeling Language) because it is complicated to design the Composition's diagrams (like the Design Patterns of Gang of Four).

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 23 дня назад

      If I understand correctly, you believe we shouldn't use composition because drawing the diagrams is too complex?

    • @juancarlospizarromendez3954
      @juancarlospizarromendez3954 23 дня назад

      @@metaphoricallyspeaking Yes, briefly, UML has a relationship "is a" for Inheritance, but there is not a way to replace the relationship "is a" by "has a" for the Composition. It complicates me a lot.

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 23 дня назад

      I'm sure there is a representation in UML. I think it's the same as dependency injection - quick google and it looks like in UML it's a filled diamond. Inheritance being a triangle outline. Correct me if I'm wrong! The diagram topic is an interesting one to me, though. Would you use composition more if it were more easily represented in a diagram? I myself would worry I was compromising the design of the system, which I'd value higher. Keen to hear what you think?

  • @igorpom2
    @igorpom2 Месяц назад

    Very nice video, thank you!

  • @IceForgeOfficial
    @IceForgeOfficial 2 месяца назад

    This video is beautiful man! I love the visuals and pacing and insights

  • @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.

  • @ralphguichette9952
    @ralphguichette9952 2 месяца назад

    If only people learned to TEACH like you just did. I've been trying to understand this for a very long time, and I just now understood it. Thank you!

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 2 месяца назад

      Very grateful you shared this. Helping to build mental models on how to think about software development is the whole reason I started the channel. Glad I could help!

  • @cosmotect
    @cosmotect 3 месяца назад

    As a non coder working with visual scripting languages I have been discovering these concepts by myself, and it's quite rewarding to see my suspisions confirmed by someone more knowledgable

  • @pindab0ter
    @pindab0ter 4 месяца назад

    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.

  • @pindab0ter
    @pindab0ter 4 месяца назад

    Great video once again!

  • @NandaPagi
    @NandaPagi 4 месяца назад

    Good explanation, like

  • @sumgamelab
    @sumgamelab 4 месяца назад

    I have Enum Obsession, is that bad?

  • @kamertonaudiophileplayer847
    @kamertonaudiophileplayer847 4 месяца назад

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

  • @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

  • @AndrewGraaff-n4g
    @AndrewGraaff-n4g 4 месяца назад

    Your content is great. And your communication is very good. The problem and solution described are informative and helpful. But I don't agree with the definition of domain events. A domain event is simply an event which is related to a business process/action being performed e.g. StartEngine Command emits a 'EngineStarted' domain event. These should definitely never be consumed by other domains, external services etc. within the same transactional boundary.

  • @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 4 месяца назад

      @@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 RUclips videos but I figured I would while I stopped to catch my breathe. glad to know it's helpful 😂

  • @soycrates
    @soycrates 4 месяца назад

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

  • @diegom.3782
    @diegom.3782 4 месяца назад

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

  • @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

  • @elatronion
    @elatronion 4 месяца назад

    SuperMario is a Mario. Mario: It's a me?

  • @takapapatapaka5326
    @takapapatapaka5326 5 месяцев назад

    That's a great video, nice explanation and incredible visuals ! Thanks for sharing you amazing work

  • @RUEDO123
    @RUEDO123 5 месяцев назад

    I don't like the fact that this video misses the importance of interfaces and polymorphism which are solutions to most of the inheritance problems that the video talks about. I honestly think that if you're going to make any kind of program and you're being smart about you program's architecture, you will inevitable use both.

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 5 месяцев назад

      That's fair. Polymorphism is certainly important. The video aimed to demonstrate how composition can address specific problems associated with inheritance. Hopefully I didn't imply it's the only necessary paradigm.

    • @RUEDO123
      @RUEDO123 5 месяцев назад

      @@metaphoricallyspeaking No not at all, the video was great! I just felt like it was a bit unfair for inheritance hahah

    • @anand_-
      @anand_- 4 месяца назад

      ​@@RUEDO123 hey do you have any resources on polymorphism and how do use interface ... ?

    • @RUEDO123
      @RUEDO123 4 месяца назад

      @@anand_- No but it's pretty easy to find them with a google search

    • @RUEDO123
      @RUEDO123 3 месяца назад

      @@anand_- not at the top of my head, but I'm sure there are videos and tutorials explaining the concepts

  • @DUHRIZEO
    @DUHRIZEO 5 месяцев назад

    Whoa. The "has a" vs "is a" statement flipped the missing switch in my brain. You rock brother.

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 5 месяцев назад

      Thank you - glad I could help you build a mental model of Composition over Inheritance! 💪

    • @danielsonstudios
      @danielsonstudios 2 месяца назад

      Completely agree!

  • @steve_rico
    @steve_rico 5 месяцев назад

    Amazing explanation

  • @cariyaputta
    @cariyaputta 5 месяцев назад

    Nice explanation.

  • @edgeeffect
    @edgeeffect 6 месяцев назад

    I don't understand how all the managers have become so obsessed with Laravel... I've used... uuuum.... 7 .... 8? PHP frameworks over the years and I'd say that Laravel is by far the worst. And way too much magic is one of the many things that make it so.

  • @alexMKDtheBEST
    @alexMKDtheBEST 6 месяцев назад

    This was such a cool and beautiful video! I'm probably gonna binge all your videos when I get back from work later

  • @Rai2M
    @Rai2M 6 месяцев назад

    2:42 int player_state = 1 // 2, 3, 100, 102020 no inheritance, just pure states )))

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 6 месяцев назад

      Sometimes we might not want to merge all logic into a single class and toggle based on the state

    • @UglyMoneyChannel-pw8hl
      @UglyMoneyChannel-pw8hl 5 месяцев назад

      @@metaphoricallyspeaking so basically separate the states into separate scripts?

  • @tobiasmercader8091
    @tobiasmercader8091 6 месяцев назад

    first time watching one of your videos, and honestly im impressed. I hope this goes well for you so that i can enjoy these videos in the fututre and so that you can improve even more the quality.

  • @davecollett3497
    @davecollett3497 7 месяцев назад

    Refreshing to hear real world advice, rather than the usual "always do this" nonsense. Just because a toolset has a tool, doesn't mean should or shouldn't use it. Tools are not good or bad by themselves, but using a hammer for a screw is a bad idea. Great content

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 7 месяцев назад

      Thanks Dave, Glad you enjoyed the video! Nothing is black and white - just lots of different shades of grey in different contexts. It's our jobs as engineers to understand the tradeoffs and make the best decision with the information we have. Also, I just recently used the hammer/nail metaphor in an article! 🤣 acairns.co.uk/posts/primitive-obsession

  • @coderized
    @coderized 7 месяцев назад

    Fantastic video! Loved the design, graphics, editing and relatable gaming analogies throughout. Honestly, top work!

  • @pindab0ter
    @pindab0ter 9 месяцев назад

    That’s one hell of a foot gun! It would’ve taken me quite a while to figure that one out. Good to show that explicit is better than implicit.

  • @pindab0ter
    @pindab0ter 9 месяцев назад

    This is amazing stuff!

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 9 месяцев назад

      Thank you! ☺️

    • @pindab0ter
      @pindab0ter 9 месяцев назад

      @@metaphoricallyspeaking I do think there’s a market for accessible and engaging explanations of software engineering concepts. Looks like you’ve got it nailed down. Instantly subscribed!

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 9 месяцев назад

      @@pindab0ter Thank you. Thanks for the kind words! :D Not nailed down at all, I'm afraid. Learning a lot as I go! Haha

    • @pindab0ter
      @pindab0ter 9 месяцев назад

      @@metaphoricallyspeaking the combination of your voice, your visual style and the fact that you’re covering not beginner but intermediate topics make me look forward to you future videos!

  • @adiadiadi
    @adiadiadi 9 месяцев назад

    Awesome vid!! Did you record this inside of a video game?

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 9 месяцев назад

      Yeah, I did indeed - Fortnite. My son’s favourite at the moment

  • @init_bobjames
    @init_bobjames 9 месяцев назад

    Fantastic production quality and excellent teaching skills. Great work 👏👏

  • @codeik0
    @codeik0 11 месяцев назад

    The graphic design is crazy. Easy sub earn

  • @metaphoricallyspeaking
    @metaphoricallyspeaking 11 месяцев назад

    Prefer a written version? There is a visually-explained post on my blog: acairns.co.uk/posts/composition-over-inheritance Disagree? Got feedback? Let me know below, or jump on Discord: acairns.co.uk/discord

  • @valseedian
    @valseedian 11 месяцев назад

    haven't watched the video yet, just wanted to say I (a 20yr veteran programmer) just learned about the concept a few weeks ago, though I've been an unknown advocate and practitioner of composition since being introduced to requisite oop in Java in high-school. I've carried the notion through all my projects since. always thought inheritance was a bad idea outside of strict polymorphic virtual functors where you can leverage the compiler to produce code states nessesary vs boilerplate every time a new instance is found. templating in c++ does exactly this for functional and procedural bros ok, watched the video. that last sentence "use inheritance when it exists in that domain" is basically saying the same thing. nothing in the real world actually does this. the nature of reality is to have many close but independently unique variants with- at best- partial heredity on average due to the imperfect copy problem. practically nothing is perfectly all of one other thing plus new stuff.

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 11 месяцев назад

      Super detailed reply. Appreciate you sharing your perspective! 🙌

  • @dragonfiregaming4427
    @dragonfiregaming4427 11 месяцев назад

    @ThePrimeTimeagen We need your reaction. Primeagen approved or nah?

    • @dragonfiregaming4427
      @dragonfiregaming4427 11 месяцев назад

      This was a great video @metaphoricallyspeaking. Keep up the great work!

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 11 месяцев назад

      I would be proud and terrified - in equal measures! But, if he were to roast the video, at least I could take the low-road and mock his hair! 😁

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 11 месяцев назад

      Appreciate the kind words. Will certainly try! :)

  • @DoekeNorg
    @DoekeNorg 11 месяцев назад

    Nice. But the question is: do you really need it? "After column" is not especially performant on large tables as data needs to be shifted.

  • @stephensamra
    @stephensamra 11 месяцев назад

    I really enjoyed this one, especially the animation. Great work.

  • @WalterGordyCanada
    @WalterGordyCanada 11 месяцев назад

    Love the style for sure! The ad threw me for a loop though. I thought I had click out of the video by accident.

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 11 месяцев назад

      Unfortunately I haven't reached the dizzying heights RUclips have set for monetisation and can't control when the ads show 😢 One day, maybe... Glad you enjoyed it, though!

  • @kodacoda
    @kodacoda 11 месяцев назад

    this video has so much style, I love it, keep up the good work ;)

  • @abuyusuf-af
    @abuyusuf-af 11 месяцев назад

    Very interesting insights, keep it up! Subscribed.

  • @quetzalcoatl-pl
    @quetzalcoatl-pl 11 месяцев назад

    5:07 - oh yes, bonus point for you and scott

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 11 месяцев назад

      Scott is incredible. And his cinematography is at such a high standard. His drawer organiser video made me impulse-purchase a 3d printer.

  • @frostyrobot7689
    @frostyrobot7689 11 месяцев назад

    Nice. Subscribed.

  • @michabbb
    @michabbb 11 месяцев назад

    nice explained, but the word "middleware" is not your friend *g*

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 11 месяцев назад

      I'm not sure if you don't like the way I say "middleware", or if you don't like using middleware? 😅

  • @gebruikersnaam999999
    @gebruikersnaam999999 Год назад

    This was very helpful! But some more code examples would be nice!

    • @metaphoricallyspeaking
      @metaphoricallyspeaking Год назад

      Yeah, I think that's fair. I do feel code is better consumed in a different format, though - like a blog post? What do you think? Would a follow-up blog post be a useful addition? Glad you found the video helpful and appreciate the constructive feedback! 🙌

  • @cmgmyr
    @cmgmyr Год назад

    Great video! Carbon has numerous "...NoOverflow()" methods (->addMonthWithOverflow()), but you have to know they are there :/ I've also ran into this issue many times.

    • @metaphoricallyspeaking
      @metaphoricallyspeaking 11 месяцев назад

      Thanks Chris! And, thanks for sharing - I had no idea these methods existed!

  • @DR_DinoMight_IRL
    @DR_DinoMight_IRL Год назад

    Awesome explanation, I’ve always struggled to find a good analogy for command bus this sums it up perfectly! Keep it up!