I'm not a developer, but I read this article anyway. All of this blew me away. Like this "@mordaroso" fellow strolled on up, cocked his knee skyward, and jettisoned his leg into the rickety wooden door that previously sheltered my mind. That was just great writing.
How A Pull Request Rocked My World
61–70 of 158 posts
Re: How A Pull Request Rocked My World
#62Generically, I had something like this in my head:
switch (row_type) {
case submittable: ...; break;
case checkable: ...; break;
...
}
Then I started realizing that using a switch means you have isolated things such that they can only be one of the n types. It won't ever be submittable AND checkable, for instance. I assume that's what is desired here: mutual exclusivity for all of these possibilities.Looking back at the original code, I see that by using the nested if/else construct, it effectively gives priority to them in the order in which they are encountered. A row with a submit_button is going to fire off make_submit_cell() whether or not it has checkable set. It trumps the possible call to make_check_cell, in other words.
These two approaches solve two different problems. Without knowing more, it's hard to say whether the "priority" approach makes sense here.
If I had to guess, based on the refactoring which turned it into a series of distinct classes, that sounds like it should have been "pick 1 of n" (one-hot code) all along. If that's so, the if block wasn't just ugly, but it was actually covering up some real problems. It was just asking for trouble in terms of bugs down the road since it allowed nonsensical settings.
But that's just a guess. I could be wrong.
Re: How A Pull Request Rocked My World
#63Those who know this technique either discover it themselves, through "reading, learning, doing", or are shown,like this guy was. None of us was born knowing this. Clay has blogged about his experience of discovering this - that in itself is what makes this a great read for me. I wouldn't be surprised if every single tech book author, at some point after their book has been published, has learned something and thought…
Writing a book is also a great way to discover new things about your subject.
Re: How A Pull Request Rocked My World
#64Reading the comments in this thread is very interesting to me, because each programmer seems certain of the superiority of his own programming style. We have some comments that disparage the change, saying that it obfuscates the code and makes it more difficult to understand. We have others saying that this change is a basic technique and it's "shocking" that the author wrote a book without this simple knowledge. Wha…
+1 for Good programming is not an objective concept.
There is not even a consensus on what is good in programming! Take a look at other professional cultures: people work extremely hard to develop the skills that everybody else in their profession have. What does a software developer do? Whatever they like on their own, there is no professional culture whatsoever: "Don't give a crap about the humankind's experience, I'll invent everything on my own the way I like".
This is actually unbelievable how different programming is in this aspect from other disciplines. I don't even mentor Junior Developers because of that, as I can't refer to anything authoritative and say "Do it like this" because there is always a bunch of folks that do it the opposite way. There is almost nothing to rely on.
Re: How A Pull Request Rocked My World
#65The classic "Replace Conditional with Polymorphism" design pattern, which took me way to long to realize that it also applies to Python.
I'd recommend the book strongly.
Re: How A Pull Request Rocked My World
#66In terms of Gang of Four patterns, I believe this would be Strategy + Factory Method. The book is a little antiquated (1994) but it or a better successor should be required reading for any programmer.
I don't believe that its terribly antiquated. Pretty much everything bases itself off of this book. Edit: drafted iPad - fixed spelling. Trilby - does anyone even use that word anymore?!?
Hardly.
The GoF book is sweet if in this day and age you're still doing Java/C# but if you're programming in a language like, say, Clojure you can throw about 75% of the GoF book into the trash.
pg said to use a Lisp to beat the average and that's what I'm doing. I'm certainly not accepting the status-quo and considering that, say, the "visitor pattern" is a godsend. Most of these "patterns" only make sense in a non-functional and OO language and are only needed because of missing languages concepts (like the lack of high-order function and/or the lack of real macros).
Re: How A Pull Request Rocked My World
#67It's scary to think that this guy who was just shocked to discover a very basic concept of object oriented programming (polymorphism) has written his own book on iOS programming: http://clayallsopp.com/posts/writing-a-programming-book
How many books did you wrote ?
The blog entry is great in that it shows how collaborating over the Internet can lead to improvement but it's indeed a bit concerning that someone who didn't know what polymorphism was had been publishing a programming book.
Re: How A Pull Request Rocked My World
#68Earlier quoted context omitted.
Writing a book is also a great way to discover new things about your subject.
While true, when I purchase a book I'm trusting that the author is an expert in the topic. Maybe my expectations are too high.
Re: How A Pull Request Rocked My World
#69Earlier quoted context omitted.
I don't believe that its terribly antiquated. Pretty much everything bases itself off of this book. Edit: drafted iPad - fixed spelling. Trilby - does anyone even use that word anymore?!?
"I don't believe that it's the trilby antiquated. Pretty much everything bases itself off of this book." Hardly. The GoF book is sweet if in this day and age you're still doing Java/C# but if you're programming in a language like, say, Clojure you can throw about 75% of the GoF book into the trash. pg said to use a Lisp to beat the average and that's what I'm doing. I'm certainly not accepting the status-quo and cons…
Re: How A Pull Request Rocked My World
#70Earlier quoted context omitted.
+1 for Good programming is not an objective concept.
== Programming sucks nowadays. There is not even a consensus on what is good in programming! Take a look at other professional cultures: people work extremely hard to develop the skills that everybody else in their profession have. What does a software developer do? Whatever they like on their own, there is no professional culture whatsoever: "Don't give a crap about the humankind's experience, I'll invent everything…