"The Clean Code Talks -- Inheritance, Polymorphism, & Testing"
Top Comments
All Comments (82)
-
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 thought about writing a Renderer class to do the printing job - originally I also wanted to write the toString method - and then I figured "what if I want to have OpenGL output? Or LaTeX?" . So I decided to seperate the structure from it's rendering - and now I'm trying to figure out a sensible way to make the renderer extensible. I think I'm on to something, but I haven't tried it yet.
-
Very good tutorials on object programming. I would love to hear more of them from Misko Hevery. Good job.
-
Misko is the man!
I agree with jsmartin00, these should be available on a different channel so I can subscribe!
MarkOates 3 years ago 20
Because not everyone gets the opportunity to partake in the university system.
Also, it is precious, not pressures.
harking 3 years ago 12