Robert C Martin - The Single Responsibility Principle

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ม.ค. 2025

ความคิดเห็น • 62

  • @ChristianLeovido
    @ChristianLeovido 4 ปีที่แล้ว +22

    0:00 - Ice breaker - Entropy
    6:14 - SRP, Views and SQL, Why separate things?
    8:50 - Report generator example
    11:41 - Responsibility for one person
    13:14 - Mixing HTML and SQL example
    14:13 - One change affecting other code
    16:17 - Rigidity
    17:20 - How can you separate the changes?
    17:40 - Employee example
    19:37 - Deceptive module; modules should know less about business objects
    21:21 - Separate into smaller classes
    21:50 - Roman numerals kata, TDD feels slow; comparison using TDD vs. no TDD
    26:25 - Separate into smaller classes
    30:05 - How many methods should a class have?
    30:45 - The database is a detail; should be replaceable; our modules shouldn't care is we use SQL, NOSQL
    34:41 - Business rules shouldn't belong on the database
    36:10 - Symptoms of bad system design
    38:10 - Forced to change in many places
    39:25 - Fragility, touch a module and everything works, in a different part
    43:00 - Mastermind
    45:05 - Responsibilities breakdown
    49:00 - Separating is hard
    49:20 - Refactoring
    50:30 - Separating code should be the last operation

  • @DanielRamBeats
    @DanielRamBeats 8 ปีที่แล้ว +18

    I really appreciate his talks.. The fact he doesn't need slides or examples and can conceptually engage you in re-thinking design patterns is amazing.

  • @joebenge7420
    @joebenge7420 7 ปีที่แล้ว +131

    Problem with S.O.L.I.D is everyone who teaches it uses abstract examples: "Person", "Animal", "Employee", etc. These relations are obvious to anyone, but not all programming relations are as intuitively recognized. I think people should start using examples from real world applications. Show pseudo-code of a theoretical power-point application, sales system, photoshop. Yes, showing OOP is easy when using things we already recognize as physical "objects", but this get much more complex in applications.

    • @stefammagnumfernandesdemen4942
      @stefammagnumfernandesdemen4942 7 ปีที่แล้ว +4

      Joe Benge Start applying this principle in simple modules, then you'll start to understand on how to apply in complex modules. Please, don't get me wrong, this is a tip and the way I followed.

    • @johnnyLikeVideo
      @johnnyLikeVideo 7 ปีที่แล้ว +9

      Yes, but we need someone to show us a big project sometimes to see it actually done.

    • @ItsAStuckPixel
      @ItsAStuckPixel 6 ปีที่แล้ว

      its done in the same way. simple or complex, the principle is the same... especially single responsibility.

    • @caesarbala
      @caesarbala 6 ปีที่แล้ว

      Agree to you try to watch learn code solid principles of Bob paid courses but totally worth

    • @mescellaneous
      @mescellaneous 6 ปีที่แล้ว +1

      what is an acronym? it's a brand, it's catchy, it seems to have huge meaning packed into it because each letter is actually a word, woah!
      SOLID is like someone giving one whole talk on "balance". would you watch a lecture on someone telling you how he is able to stand on one leg for a long period of time? how many lectures do you have to watch before you begin actually practicing balancing? can anyone teach you how to balance in a day? or is it a continual exercise that you get better and better at?
      are there rules to balancing? sure you have to understand about gravity and maybe intuitively about fulcrum. but you learn by doing it. all of his talks are effectively useless, he's just riding his clean code book. you dont watch bill nye to learn physics, so you shouldnt watch bob martin to learn to code. if you want to watch to learn, you watch someone who actually codes and is in practice. i highly suspect this guy is out of practice.
      i deplore this bob martin man, specifically because he has so LITTLE to say. but what can you do, right? there are kids and sometimes kids want to watch clowns. and who is going to ban that?

  • @TJ-hs1qm
    @TJ-hs1qm 5 หลายเดือนก่อน +2

    The Single Responsibility Principle: The art of making an entire presentation about one slide

  • @kamillatosinski3054
    @kamillatosinski3054 6 ปีที่แล้ว +23

    My code at work is in maximum enthropy

    • @grumly85
      @grumly85 2 ปีที่แล้ว

      You wish it'd be. Until someone else changes it. 😬

  • @turbulentgazelle6276
    @turbulentgazelle6276 6 ปีที่แล้ว +15

    Heads up and tails down are the same thing right?

    • @graemejob1613
      @graemejob1613 5 ปีที่แล้ว +3

      I caught that as well. I thought he was starting out on a trick question!

    • @georged8644
      @georged8644 4 ปีที่แล้ว +3

      Physics isn't exactly his strong suit even though he wastes several minutes of every lecture he gives on it.

    • @carsonholloway
      @carsonholloway 3 ปีที่แล้ว

      So the answer should be 1000

  • @VladimirMinkin
    @VladimirMinkin 4 ปีที่แล้ว +3

    If every programmer (especially the one who called himself software architect) at least watched this lecture or better read his book (better first book on that path) before they started develop complex system how good life might be. Thanks for sharing!

    • @daniels3980
      @daniels3980 2 ปีที่แล้ว

      Not all at, it would just raise the bar and then we would have to really up our game to be the top income brackets.
      Luckily, as long as management focuses on going fast above all else, we won't have to worry about it.

    • @VladimirMinkin
      @VladimirMinkin 2 ปีที่แล้ว

      @@daniels3980 Sometimes going fast depends on stability of the system.

  • @PeterHeard
    @PeterHeard 10 ปีที่แล้ว +3

    Awesome!

  • @pazuzutru-truluv7094
    @pazuzutru-truluv7094 5 ปีที่แล้ว +2

    This sounds so much like Viewpoint analysis by Fukes and Finklestien back in the 80s

  • @BryonLape
    @BryonLape 4 ปีที่แล้ว

    I've written many .Net applications that used Oracle for the database.

  • @seemapradhan6970
    @seemapradhan6970 7 ปีที่แล้ว +1

    One question related to identifying the people requesting the change. Where does the request for changes for Save() and FindByID() originate from? Sometimes new features introduce database schema changes. Sometimes performance optimization results in schema changes. Would it be correct to mention DBA as the source for change? Origin in the former case is end-user whereas in the latter, it is test team...

  • @Strategiusz
    @Strategiusz 6 ปีที่แล้ว +9

    Calling this Single Resposibility Principle instead of Single Role Principle is a billion dollar mistake.

    • @ishcatu
      @ishcatu 5 ปีที่แล้ว +1

      This.
      It's about a unique role and about a responsibility towards a user/code group (this agreeing united user/code group should be the one and only reason to change) and not about inner responsibility (cohesion) and Uncle Bob writes about this greatest misunderstanding of the principles in his book "Clean Architecture".
      Even a simple primitive constant can violate the SRP if it's used by disagreeing user/code groups instead of playing just one role.

  • @paulfrischknecht3999
    @paulfrischknecht3999 ปีที่แล้ว

    Transactions really break the "my application doesn't know it's a (sql) database"... You can definitely isolate very well against the relational model in sql, but I have not found a good way to let an application rely on transactionality of db modifications when the db is not actually transactional...

  • @BryonLape
    @BryonLape 4 ปีที่แล้ว

    Heads up and tails down is the same state.

  • @grygoriymelnyk4533
    @grygoriymelnyk4533 7 ปีที่แล้ว +3

    He will never reveal an SRP solutions that appears in 26:10 :-)

  • @magniffsdigitaldevices2153
    @magniffsdigitaldevices2153 4 ปีที่แล้ว

    Hm, it seems that Mr. Martins understanding of entropy is a bit messed up as he said, that going back in time we should expect the Universe be in a higher entropy state. It is opposite, isnt it? Anyway, great talk.

  • @habibmammadov7213
    @habibmammadov7213 6 ปีที่แล้ว

    Great talks !

  • @ChristopherJohnsonIsAwesome
    @ChristopherJohnsonIsAwesome 8 ปีที่แล้ว +3

    This is great but I'd rather see a more practical example of someone applying this logic. Does anyone have a suggestion?

    • @thomaswarner8884
      @thomaswarner8884 8 ปีที่แล้ว +2

      If ever you work for public services in Europe you'll get multiple full scale examples !

  • @thomaswarner8884
    @thomaswarner8884 8 ปีที่แล้ว

    Some nasty bug was attracted to SRP @35:26 : ) Did you try to squash it ?

  • @ropro9817
    @ropro9817 7 ปีที่แล้ว +2

    Lol, I love Uncle Bob, but why does he always start off his talks about completely random physics topics? :)

    • @h8h892
      @h8h892 6 ปีที่แล้ว

      Because he wants to remember us of the logic of physics and the importance of science. It let the smart persons say what if we add some science as an accelerator for programming?
      Stupid persons say I just don't get it :)

    • @tubeyoupmj7
      @tubeyoupmj7 4 ปีที่แล้ว +2

      Because people are sometimes late, so he warms things up with a brief, interesting story before getting to the main talk.

  • @NicholsonLifting
    @NicholsonLifting 9 ปีที่แล้ว +9

    So, I generally love Uncle Bob (I have purchased all of his books), but this talk was pretty terrible. First quarter wasted to a discussion of physics, after that he is getting somewhere with a concrete example that he is about to show possible solutions for when all of a sudden he cuts off and starts talking about TDD and Katas and then he never gives any resolution to the example. I am a new developer and I would have really benefited if he actually showed some concrete solutions. I can infer what they should be, but what if my intuition is wrong and leads to bad code? I just want to know how he would have refactored the employee class...

    • @DanielRamBeats
      @DanielRamBeats 8 ปีที่แล้ว +1

      +NicholsonLifting there can't really be a concrete example because there are too many. It's not really like an equation, it's more like a philosophy. You have to change the way you think about building systems so no thing is solely dependant on another class, rather you have either an interface or a generic class that facilitates the request. Example: USB is an interface, but can can have many uses. I hope that makes sense!

    • @ropro9817
      @ropro9817 7 ปีที่แล้ว

      +NicholsonLifting, I totally agree! I love Uncle Bob, but this is the 5th talk of his that I've watched now, where he opens with an extremely long-winded and unrelated talk about physics! If I wanted to learn about physics, I'd go watch a Neil Degrasse Tyson or Lawrence Krauss talk.

    • @user-baev
      @user-baev 7 ปีที่แล้ว +2

      That's the reason classes and systems become harder to maintain and why programming is so hard. Martin gave exactly what needs to understand the basic principle, his intro wasn't out of place, it was perfectly fit into its purpose. And yet you're asking for concrete example or concrete implementation. Use abstract thinking. Or any thinking.
      Also, intro wasn't about physics. It was about programming industry. It was about computer programs. It was about single responsibility principle.

    • @gamemusicmeltingpot2192
      @gamemusicmeltingpot2192 4 ปีที่แล้ว

      @@ropro9817 hows it long winded it is 6 / 50 min talk
      its supposed to draw the viewers in and its for the live audience not you, you can skip past it

  • @AndyThomasStaff
    @AndyThomasStaff 7 ปีที่แล้ว +7

    How not to give a presentation 101. Skip to 17:05, watch 1 minute, then delete this video. Trust me, there's nothing else valuable in here.

    • @kristupasantanavicius9093
      @kristupasantanavicius9093 7 ปีที่แล้ว +2

      Really? I watched few of his talks and they are entertaining and informative at the same time. Perfect for after work.

    • @mescellaneous
      @mescellaneous 6 ปีที่แล้ว +5

      i have been watching his talks and it's all junk. yes, he isn't promoting bad advice per se, but he doesn't really give solid practical advice either. and his talks are usually filled with fluff.
      he's an out of practice programmer giving talks because there is demand for him. i am surprised how he made a career out of this, his book must have built a huge cult following.
      i actually like his history/science tangents and how they are great analogies to software, but without doing any new work, he is just a puppet spewing something you can find on wikipedia. except he will draw it out and make it sound profound because he has nothing else to work with.

    • @vivekvitthalraopatil2775
      @vivekvitthalraopatil2775 4 ปีที่แล้ว +1

      @@mescellaneous Damn, you salty

  • @georged8644
    @georged8644 4 ปีที่แล้ว +1

    Single Responsibility Principle - Talk about software design, and not physics, in a lecture about software design.

  • @ChrisSeltzer
    @ChrisSeltzer 8 ปีที่แล้ว +6

    I know he's revered in the community but I find his presentation style unbearable.

    • @Fizzgg
      @Fizzgg 8 ปีที่แล้ว +2

      Agree, there's too much filler. He spends 20 mins making the exact same point. This whole talk could be condensed down to 15 mins or less.

  • @MercedeX7
    @MercedeX7 9 ปีที่แล้ว +2

    First 16 minutes when he was rambling about the coin flipping which had absolutely nothing to do with the topic. nor did he try to relate that discussion to the topic. Secondly, real life software development s much different and under strict constraints than what he perceives it to be. It's good that a function or module should do only 1 task or related tasks but applying the same theory to a function read it programmers.stackexchange.com/questions/275646/is-the-single-responsibility-principle-applicable-to-functions

    • @shipper66
      @shipper66 9 ปีที่แล้ว

      spot on! I

    • @andurilan
      @andurilan 9 ปีที่แล้ว +11

      Mercede Have you ever worked in a "real life software development" environment? It's a nightmare PRECISELY because firms don't follow the SOLID principle.
      Have you ever had to maintain spaghetti code 10-100k lines long where classes and functions and methods have multiple responsibilities, arcane couplings, spooky actions from a distance, etc. Let alone having to hunt down dependencies hacked together for the wont of C-level managers.
      My guess is if you have, and support it, you are glutton for punishment, or dont value your time.
      Keep in mind he is also one of the original creators of AGILE development and a HUGE proponent of FP, which uses only functions instead of objects to implement logic.

    • @vibovitold
      @vibovitold 9 ปีที่แล้ว +4

      Mercede there can always be too much of a good thing, SRP is no different. but personally i prefer to err on the side of SRP and related principles, and i wish other developers had the same approach.
      btw "Uncle Bob" isn't some sort of an academic theoretician as you seem to imply, given his bio it's safe to assume he knows a thing or two about "real life software development"

    • @techotopo
      @techotopo 7 ปีที่แล้ว +1

      bla bla bla, rant, rant, who are you?