diff --git a/content/books/things-i-learnt/_index.md b/content/books/things-i-learnt/_index.md index a0557ca..f431c6b 100644 --- a/content/books/things-i-learnt/_index.md +++ b/content/books/things-i-learnt/_index.md @@ -17,6 +17,7 @@ template = "section-contentless.html" * [The Magic Number Seven, Plus Or Minus Two](magical-number-seven) * [Cognitive Cost Is The Readability Killer](cognitive-cost) * [Learn The Basics of Functional Programming](functional-programming) + * [Shortcuts Are Nice, But Only In The Short Run](understand-shortcuts) * Testing Software * [Unit Tests Are Good, Integration Tests Are Gooder](integration-tests) * [Testing Every Function Creates Dead Code](tests-dead-code) diff --git a/content/books/things-i-learnt/functional-programming/index.md b/content/books/things-i-learnt/functional-programming/index.md index 4fe374b..1b39597 100644 --- a/content/books/things-i-learnt/functional-programming/index.md +++ b/content/books/things-i-learnt/functional-programming/index.md @@ -65,4 +65,4 @@ more robust code. you end up with random values based on the seed, so even there it is a pure function. -{{ chapters(prev_chapter_link="/books/things-i-learnt/cognitive-cost", prev_chapter_title="Cognitive Cost Is The Readability Killer", next_chapter_link="/books/things-i-learnt/integration-tests", next_chapter_title="Unit Tests Are Good, Integration Tests Are Gooder") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/cognitive-cost", prev_chapter_title="Cognitive Cost Is The Readability Killer", next_chapter_link="/books/things-i-learnt/understand-shortcuts", next_chapter_title="Shortcuts Are Nice, But Only In The Short Run") }} diff --git a/content/books/things-i-learnt/integration-tests/index.md b/content/books/things-i-learnt/integration-tests/index.md index 2db072a..b5759df 100644 --- a/content/books/things-i-learnt/integration-tests/index.md +++ b/content/books/things-i-learnt/integration-tests/index.md @@ -72,4 +72,4 @@ of moving parts. [^2]: Again, it's pure feeling from my experience. I have no data to back that affirmation up, so take it with a grain of salt. -{{ chapters(prev_chapter_link="/books/things-i-learnt/functional-programming", prev_chapter_title="Learn The Basics of Functional Programming", next_chapter_title="Testing Every Function Creates Dead Code", next_chapter_link="/books/things-i-learnt/tests-dead-code") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/understand-shortcuts", prev_chapter_title="Shortcuts Are Nice, But Only In The Short Run", next_chapter_title="Testing Every Function Creates Dead Code", next_chapter_link="/books/things-i-learnt/tests-dead-code") }} diff --git a/content/books/things-i-learnt/understand-shortcuts/index.md b/content/books/things-i-learnt/understand-shortcuts/index.md new file mode 100644 index 0000000..4813c5f --- /dev/null +++ b/content/books/things-i-learnt/understand-shortcuts/index.md @@ -0,0 +1,40 @@ ++++ +title = "Things I Learnt The Hard Way - Shortcuts Are nice, But Only In The Short Run" +date = 2019-07-08 + +[taxonomies] +tags = ["en-au", "books", "things i learnt", "frameworks"] ++++ + +A lot of languages/libraries/frameworks add a way to make things shorter, +reducing the number of things you need to type. + +But, later, that will bite you and you'll have to remove the shortcut and do +the long things. + + + +Frameworks and libraries -- and even some languages -- come with "helpers" for +most boilerplate things. Instead of typing the same 5 lines of code over and +over, you can use a simple function; instead of writing the function with 5 +parameters, you can skip a bit and use another one with just one. Or you could +just add a simple macro expansion on top of your struct/class and it would +complete all the missing points. + +Don't get me wrong, they are great. + +But you must understand what the macro/function is hiding from you. 'Cause +sooner or later, you'll find a case where it doesn't have a perfect fit and +you need to change just a small detail. And then you'll start running in +circles 'cause, well, how the hell the macro/function did _that_? + +I've bitten before by [Spring](http://spring.io/) and +[Serde](https://serde.rs/) 'cause I started with the shortcuts without +understanding what they were doing. And then I got a problem which the +shortcut wouldn't solve, requiring me to go deep into the documentation. And +because I skipped a few steps and jumped straight into the shortcut, it took +me awhile to actually get _what_ I needed to do different from the shortcut to +solve my problem: I had no idea what the shortcut did and, thus, I had no idea +what I needed differently from the shortcut to solve my problem. + +{{ chapters(prev_chapter_link="/books/things-i-learnt/functional-programming", prev_chapter_title="Learn The Basics of Functional Programming", next_chapter_link="/books/things-i-learnt/integration-tests", next_chapter_title="Unit Tests Are Good, Integration Tests Are Gooder") }}