"The Clean Code Talks -- Inheritance, Polymorphism, & Testing"
Top Comments
All Comments (85)
-
32:38 Our code is full of this kind of replicated crud. We're eradicating it as we can using these methods.
-
Beautiful :)
-
@Tiddo1000 what you should do is you create a facade (i recommend using DI also) .. consisting of every object toggled by the flags .. 1 flag is for 1 inheritance hierarchy, so if you have multiple flags, that means your class have too many responsibility .. divide it to multiple responsibility and at the last stage, create a facade to aggregate all those responsibility into 1 class ..
-
This lesson is so sueful for me. I've changed my mind through this film in my programming. Thank you.
-
Great video
-
i'm just a few minutes in, but let me speak my mind: re-readability is not a religion; How many times have you actually recycled your code?!
-
@urMamaMuthaSukka That is is correct, it is not very OO. But taking the OO approach is also brittle, just in a different way. As I pointed out, if we need to implement toString() then we have to modify every class, there is no getting around that when you use inheritance to achieve polymorphism. Haskell solves the "add a function later" problem by using type classes for polymorphism, this is a much less brittle approach. It is a bit like using interfaces and the adapter pattern in OO.
-
@jystic That's not very OO. Objects should have specific behavior. If the behavior of the object changes on state, then it's obvious that behavior belongs in it's own object. Your suggestion leads to brittle design, which is harder to maintain, test, and extend.
-
It's really easy to remove all if statements from your code. Take this snippet for example: if(a > b){ c = a - b; } Replace this bad if statement with the following for good, clean code: while(a > b){ c = a - b; break; } If statements = gone
-
@Tiddo1000 One way to achieve this is to use the decorator pattern to decorate your conditional with another conditional.
I agree with jsmartin00, these should be available on a different channel so I can subscribe!
MarkOates 3 years ago 21
@jihedamine It's not about African people, it's about African swallows -- a Monty Python reference, which 80% of the geek viewers of the video are likely to get. (The "Norwegian Blue" in the example refers to another Monty Python sketch about a dead parrot.)
stephenbloch 1 year ago 5