412 points · by necrodome · 8y ago · 79 comments
Anyone feeling honest resonance with your words should read the book. I can't put it in other words.
In fact, the book itself has two audiences - the problem solver, and the teacher of future problem solvers (with the suggestion that if you're the former, you can also be the latter by talking to yourself). So the book gives you both a bunch of stuff to internalize, and a discussion on how to teach that stuff to other people.
--
Tangentially, reading this is making me do some serious soul searching about the way I approach programming. For instance, Polya emphasizes reviewing your work as an important step in solving a mathematical problem - not (just) to re-check correctness, but to spend some time thinking about the structure of your solution, and learn something from it. This is something I just realized I rarely do in programming - I don't review my code to learn more from the very solution I just implemented. I usually just commit and continue to the next thing. This is a thing I'm going to work on changing.
That said, I think it's worth investing your own time in doing it. I feel a lot more at ease when I take time to think about my work, and I think it pays off in my own career in the long run, even if it costs me some of my own time.
In the old times, many Germanic scholars would build a similar thing using flashcards. It was called a zettelkasten.
https://takingnotenow.blogspot.com/2007/12/luhmanns-zettelka...
https://takingnotenow.blogspot.com/2016/09/luhmanns-zettelka...
https://takingnotenow.blogspot.com/2016/08/my-translations-o...
And, just for quick reference, his entire 'zettelkasten' tag:
https://takingnotenow.blogspot.com/search/label/Zettelkasten
Also some other wikis have similar principles, for example: https://tiddlywiki.com/static/Philosophy%2520of%2520Tiddlers...
I have recently switched all my note-taking and task/todo management to org-mode, but I'm still figuring out how to use it properly. At the moment, I just have a personal.org, refile.org and project specific .org files, all kinda taking the shape of headings with sub-sub-sub-sub-headings inside until there is either none or some content inside, but a personal wiki, it doesn't feel like. It feels more like ordered mess, kinda. It's definitely better than anything I've ever used before.
Any good tips you want to share?
org-mode is a bit like C++ or LaTeX. I say this as a good thing. It has tons of features, but you need to choose what to use and what to keep out.
For me, something that works great is to keep all org files in the same folder, with a flat structure. That includes my task list and my calendar. I version control everything, except organizational things that change often instead of growing like articles. I also keep out of version control first quick drafts of any article.
Knowledge pays compound interest: the more you know, the easier it is to learn new stuff (more branches on the semantic tree). Just jotting down simple unconnected facts and organizing them later has helped me become a much competent person.
> The big idea is "messaging" - that is what the kernal of Smalltalk/Squeak is all about (and it's something that was never quite completed in our Xerox PARC phase). The Japanese have a small word - ma - for "that which is in between" - perhaps the nearest English equivalent is "interstitial".
Bill Kerr once said that point of view is worth 80 IQ points. I think the above statement is a good example.
It's simple enough to seem too trivial to write down. Yet years of work and failure could stand behind it. All too easy for beginners to ignore and trace the same frustrating path.
I've been trying to introduce this into my current company for as long as I've been working there, with no success so far, with varying reasons:
- Unit tests for existing projects often fail - Unit tests for existing projects take several minutes to run - Our current build process cannot be automated.
Quite frustrating, especially since I've seen a lot of cases where it could've saved us from near-disasters.
EDIT: I think on the subject of Emergence, the writer has missed one key point: emergence requires interplay between different levels of the system.
Same here. Except we have no almost no unit tests because
1) Most of the devs don't know how to write unit tests 2) Most of the devs don't know hot to write code that is testable, even if they could write the actual unit tests.
About a year or so ago we had a project that got a few unit tests added to it, within days they were broken nad failing. The dev just added a [TestCategory("Blah")] and excluded them from being run...
> 1) Most of the devs don't know how to write unit tests
> 2) Most of the devs don't know hot to write code that is testable, even if they could write the actual unit tests.
Sounds really familiar... I'd like to add the following one:
> 3) Cannot make the distinction between code that needs unit testsand code that does not need unit tests
4) Don't know how to mock effectively
I've seen three flavours of this one:
- tests that take forever because they don't mock a slow external process that gets called 100s of times in the suite.
- tests that randomly break because someone left a file in /tmp/ or some other lack-of-isolation mystery.
- tests that run like shit off a shiny shovel, because everything is mocked, meaning that nothing is actually tested.
Unit testing is easy for beginners. Unit testing done well is much less so. This results in many inexperienced people writing poor unit tests.
In my last job, I worked on a legacy C++ code base. 500K lines of thorough testing, but none was a unit test. It took 10 hours to run the full test suite. I set about the task of converting portions for unit testability.
I was surprised how much of a challenge it was (and I learned a lot). There were few resources on proper unit testing in C++. Mostly learned from Stack Overflow. Lessons learned:
1. If your code did not have unit tests, then likely your code will need a lot of rearchitecting just to enable a single unit test. The good news is that the rearchitecting made the code better.
As a corollary: You'll never know how much coupling there is in your code until you write unit tests for it. Our code looked fairly good, but when I wanted to test one part, I found too many dependencies I needed to bring in just to test it. In the end, to test one part, I was involving code from all over the code base. Not good. Most of my effort was writing interface classes to separate the parts so that I could unit test them.
2. For C++, this means your code will look very enterprisey. For once, this was a good thing.
3. Mocking is an art. There's no ideal rule/guideline for it. Overmock and you are just encoding bugs into your tests. Undermock and you are testing too many things at once.
4. For the love of God, don't do a 1:1 mapping between functions/methods and tests. It's OK if your test involves more than one method. Even Robert Martin (Uncle Bob) says so. I know I go against much dogma, but make your unit tests test features, not functions.
5. If your unit tests keep breaking due to trivial refactors, then architect your unit tests to be less sensitive to refactors.
6. For classes, don't test private methods directly. Test them through your public interface. If you cannot reach some code in a private method via the public interface, throw the code away!
7. Perhaps the most important: Assume a hostile management (which is what I had). For every code change you make so that you can write a unit test, can you justify that code change assuming your project never will have unit tests? There are multiple ways to write unit tests - many of them are bad. This guideline will keep you from taking convenient shortcuts.
This advice is all about unit tests, and not TDD. With TDD, it is not hard to test yourself into a corner where you then throw everything away and restart. If you insist on TDD, then at least follow Uncle Bob's heuristic. For your function/feature, think of the most complicated result/boundary input, and make that your first unit test. This way you're less likely to develop the function into the wrong corner.
When I completed my proof of work, the team rejected it. The feedback was it required too much skill for some of the people in the team (40+ developers across 4 sites), and the likelihood that all of them will get it was miniscule. And too much of the code would need to change to add unit tests.
I later read this book:
https://www.amazon.com/Art-Unit-Testing-examples/dp/16172908...
And it contains quite a bit of what I learned from unit testing.
Think of it this way: Any time the build is broken, everyone working on the project is interrupted. If you have 10 people working on the codebase and the build is broken for an hour, that's a whole workday and then some wasted.
You could start a grassroots movement - create a pre-push or pre-commit hook that runs tests before it ends up on the remote. Don't worry about the tests taking minutes to run, if you're waiting on that several times a day you're probably publishing too many small changes over the course of a day.
You don't understand; they are continually broken on master.
Furthermore, you assume that we only commit to master after reviews etc have been done. This isn't the case. Commits, even intermittent commits, are pushed to master, and reviewed from there.
I think most people would agree that's an objectively wrong way to do it.
You can do a lot of things between bash scripts, PowerShell, etc. Even custom executables.
Assert(rand() % 2 == 0);
When the test gets run the first time, it can pass and the code can be admitted, but when the next person goes to add code, it can fail. At this point, you've broken your defining principle: that all the code in the test base is correct. The answer of what to do here isnt clear as its a tradeoff in time spent fixing the tests (or potentially the test framework) and developing features. If you have deadlines this becomes more tenuous. Then you figure out that the reason the test is flaky is because it isnt being run in a real environment...etc.
All I'm saying is that it isnt as simple as this "Rule" would like to have you believe.
That’s the idea ... bring back the joy of blogging and meantime capture and grow knowledge.
This post reminds me of some PG essay I once read (too lazy to look it up). Did you use the PG essay as reference material? Because if yes it might be nice to put some links that served as inspiration for the article?
It’s a good book which would also be great as a set of prompt cards IDEO style.
Edit: On a whim I googled and it does exist as a card deck as well!
Why Toys - https://blog.ycombinator.com/why-toys/
The Next Big Thing Will Start Out Looking Like a Toy - http://cdixon.org/2010/01/03/the-next-big-thing-will-start-o...
I suspect the main value of this particular list was actually producing the list, and mainly for the author's sake.
The presentation is actually pretty, and I'm glad people share their favorite learning/knowledge resources. But I guess I'm coming mainly from my frustration of finding so many things interesting but so hard to choose what to focus my attention on.
He talks a lot about 'trails' the people create, so I think the idea is that you'd be able to take this set of notes and links and integrate it with your own set.