From 357b9d0f2dc97645a75b2cc232d5b3cf69501ba3 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 15 Jul 2019 15:54:08 -0300 Subject: [PATCH 1/7] Forgot some better stuff to do with config files --- .../books/things-i-learnt/config-file/index.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/content/books/things-i-learnt/config-file/index.md b/content/books/things-i-learnt/config-file/index.md index 3723326..8d87027 100644 --- a/content/books/things-i-learnt/config-file/index.md +++ b/content/books/things-i-learnt/config-file/index.md @@ -34,4 +34,22 @@ most of its can be used all the time. If the intersection of used things is very small, it may make more sense to split into different libraries and just "pick and chose" what to use. +But besides the replacement of libraries, you can also think things like: "Ok, +I have to remove elements after a while[^1]; but which would be a good time +that they can exist before I can remove them?" Well, if you're not quite sure +(and, sometimes, even when you're sure), you can use a configuration file to +define how long those elements will stay in the system before being expunged. +Maybe you're not even thinking about how long each element will stay in the +system, but how many of those elements you'll keep in the system before +removing the old ones -- which is, again, a good candidate to be moved to a +configuration file. + +Configuration files allow you to change properties of the system without +recompiling everything. And, if in the future you decide to follow the [12 +Factor app](https://en.wikipedia.org/wiki/Twelve-Factor_App_methodology), +you'll find that you're half-way through it. + +[^1]: In other words, they have a [time to + live](https://en.wikipedia.org/wiki/Time_to_live). + {{ chapters(prev_chapter_link="/books/things-i-learnt/libraries", prev_chapter_title="Create Libraries", next_chapter_link="/books/things-i-learnt/throw-away", next_chapter_title="Be Ready To Throw Your Code Away") }} From 06c10b0a491f4f1c8f64549c67392edd4887823a Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 15 Jul 2019 18:59:13 -0300 Subject: [PATCH 2/7] New chapter: command line options --- content/books/things-i-learnt/_index.md | 1 + .../command-line-options/index.md | 32 +++++++++++++++++++ .../things-i-learnt/resist-easy/index.md | 2 +- .../things-i-learnt/start-stupid/index.md | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 content/books/things-i-learnt/command-line-options/index.md diff --git a/content/books/things-i-learnt/_index.md b/content/books/things-i-learnt/_index.md index 12e3399..127463f 100644 --- a/content/books/things-i-learnt/_index.md +++ b/content/books/things-i-learnt/_index.md @@ -48,6 +48,7 @@ template = "section-contentless.html" * [If Your Data Has a Schema, Use a Structure](use-structures) * [Don't Mess With Things Outside Your Project](outside-project) * [Resist The Temptation Of Easy](resist-easy) + * [Command Line Options Are Weird, But Helpful](command-line-options) * [Start Stupid](start-stupid) * [Always Use Timezones With Your Dates](use-timezones) * [Always Use UTF-8 For Your Strings](use-utf8) diff --git a/content/books/things-i-learnt/command-line-options/index.md b/content/books/things-i-learnt/command-line-options/index.md new file mode 100644 index 0000000..c5c52b1 --- /dev/null +++ b/content/books/things-i-learnt/command-line-options/index.md @@ -0,0 +1,32 @@ ++++ +title = "Things I Learnt The Hard Way - Command Line Options Are Weird, But Helpful" +date = 2019-07-15 + +[taxonomies] +tags = ["en-au", "books", "things i learnt", "configuration", "command line options", "cli"] ++++ + +In this day and age, when everything has a graphical interface, does it still +makes sense to add command line options to your application? In fact, it does. + + + +When I mentioned the configuration file, you may have thought about using +adding a default path for it and using the same file over and over. + +Well, that's not wrong, but what if you want to use a different configuration? +Would you keep moving the original configuration file to another place, moving +your configuration back and keep this back and forth? Keep both versions and +just use a [symbolic link](https://en.wikipedia.org/wiki/Symbolic_link) with +the configuration filename pointing to the one you want? + +Why not add a command line option in which the user can select which +configuration file should be loaded? + +This would make their life _and yours_ easy. + +Also, be aware that, today, there may be libraries to handle command line in +every language, which will help you build a good command line interface, along +with standardizing it to have the same interface as other applications. + +{{ chapters(prev_chapter_link="/books/things-i-learnt/resist-easy", prev_chapter_title="Resist The Temptation Of Easy", next_chapter_link="/books/things-i-learnt/start-stupid", next_chapter_title="Start Stupid") }} diff --git a/content/books/things-i-learnt/resist-easy/index.md b/content/books/things-i-learnt/resist-easy/index.md index 2b4e853..83544e8 100644 --- a/content/books/things-i-learnt/resist-easy/index.md +++ b/content/books/things-i-learnt/resist-easy/index.md @@ -28,4 +28,4 @@ These days, IDEs can autocomplete almost everything, from function names to even how to name your variables. But using the autocomplete is not always a good solution. Finding better names is. -{{ chapters(prev_chapter_link="/books/things-i-learnt/outside-project", prev_chapter_title="Don't Mess With Things Outside Your Project", next_chapter_link="/books/things-i-learnt/start-stupid", next_chapter_title="Start Stupid") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/outside-project", prev_chapter_title="Don't Mess With Things Outside Your Project", next_chapter_link="/books/things-i-learnt/command-line-options", next_chapter_title="Command Line options Are Weird, But Helpful") }} diff --git a/content/books/things-i-learnt/start-stupid/index.md b/content/books/things-i-learnt/start-stupid/index.md index d313143..0145706 100644 --- a/content/books/things-i-learnt/start-stupid/index.md +++ b/content/books/things-i-learnt/start-stupid/index.md @@ -31,4 +31,4 @@ what your IDE is doing. And when you grasp that, you'll be able to use _any_ IDE. -{{ chapters(prev_chapter_link="/books/things-i-learnt/resist-easy", prev_chapter_title="Resist The Temptation Of Easy", next_chapter_link="/books/things-i-learnt/use-timezones", next_chapter_title="Always Use Timezones With Your Dates") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/command-line-options", prev_chapter_title="Command Line Options Are Weird, But Helpful", next_chapter_link="/books/things-i-learnt/use-timezones", next_chapter_title="Always Use Timezones With Your Dates") }} From 6b9facbbdfd8c182dabf5f6463ffe1570e63c96b Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 15 Jul 2019 19:10:29 -0300 Subject: [PATCH 3/7] Chapter reoganization --- content/books/things-i-learnt/_index.md | 3 ++- content/books/things-i-learnt/config-file/index.md | 2 +- content/books/things-i-learnt/libraries/index.md | 2 +- content/books/things-i-learnt/log-events/index.md | 2 +- content/books/things-i-learnt/use-utf8/index.md | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/content/books/things-i-learnt/_index.md b/content/books/things-i-learnt/_index.md index 127463f..8bf37ff 100644 --- a/content/books/things-i-learnt/_index.md +++ b/content/books/things-i-learnt/_index.md @@ -36,7 +36,6 @@ template = "section-contentless.html" * Project Organization * [Organize Your Code by Data/Type, Not Functionality](project-organization) * [Create Libraries](libraries) - * [The Config File Is Friend](config-file) * Writing code * [Be Ready To Throw Your Code Away](throw-away) * [Future Thinking Is Future Trashing](future-trashing) @@ -52,6 +51,8 @@ template = "section-contentless.html" * [Start Stupid](start-stupid) * [Always Use Timezones With Your Dates](use-timezones) * [Always Use UTF-8 For Your Strings](use-utf8) + * "Usability" + * [The Config File Is Friend](config-file) * [Logs Are For Events, Not User Interface](log-events) * [Learn To Monitor](monitoring) * Community/Teams diff --git a/content/books/things-i-learnt/config-file/index.md b/content/books/things-i-learnt/config-file/index.md index 8d87027..5888858 100644 --- a/content/books/things-i-learnt/config-file/index.md +++ b/content/books/things-i-learnt/config-file/index.md @@ -52,4 +52,4 @@ you'll find that you're half-way through it. [^1]: In other words, they have a [time to live](https://en.wikipedia.org/wiki/Time_to_live). -{{ chapters(prev_chapter_link="/books/things-i-learnt/libraries", prev_chapter_title="Create Libraries", next_chapter_link="/books/things-i-learnt/throw-away", next_chapter_title="Be Ready To Throw Your Code Away") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/use-utf8", prev_chapter_title="Always Use UTF-8 For Your Strings", next_chapter_link="/books/things-i-learnt/log-events", next_chapter_title="Logs Are For Events, Not User Interface") }} diff --git a/content/books/things-i-learnt/libraries/index.md b/content/books/things-i-learnt/libraries/index.md index 2c4cd2a..ac3a563 100644 --- a/content/books/things-i-learnt/libraries/index.md +++ b/content/books/things-i-learnt/libraries/index.md @@ -45,4 +45,4 @@ your control, they are external to the project. So you may need to learn how to deal with this before creating the libraries. And, unfortunately, each language and build tool has its own way to manage this. -{{ chapters(prev_chapter_link="/books/things-i-learnt/project-organization", prev_chapter_title="Organize Your Code by Data/Type, Not Functionality", next_chapter_link="/books/things-i-learnt/config-file", next_chapter_title="The Config File Is Friend") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/project-organization", prev_chapter_title="Organize Your Code by Data/Type, Not Functionality", next_chapter_link="/books/things-i-learnt/throw-away", next_chapter_title="Be Ready To Throw Your Code Away") }} diff --git a/content/books/things-i-learnt/log-events/index.md b/content/books/things-i-learnt/log-events/index.md index edeb658..225eebc 100644 --- a/content/books/things-i-learnt/log-events/index.md +++ b/content/books/things-i-learnt/log-events/index.md @@ -43,4 +43,4 @@ could have the values to try to figure out why it failed -- surely, logging why it failed also helps, but you know what I mean. This is an example of something that makes complete sense in logs, but not in user interfaces. -{{ chapters(prev_chapter_link="/books/things-i-learnt/use-utf8", prev_chapter_title="Always Use UTF-8 For Your Strings", next_chapter_link="/books/things-i-learnt/monitoring", next_chapter_title=Learn To Monitor"") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/config-file", prev_chapter_title="The Config File Is Friend", next_chapter_link="/books/things-i-learnt/monitoring", next_chapter_title=Learn To Monitor"") }} diff --git a/content/books/things-i-learnt/use-utf8/index.md b/content/books/things-i-learnt/use-utf8/index.md index 2534afe..3d24960 100644 --- a/content/books/things-i-learnt/use-utf8/index.md +++ b/content/books/things-i-learnt/use-utf8/index.md @@ -52,4 +52,4 @@ single character. Walking through the whole string would require traversing the string character by character, instead of simply jumping straight to the proper position. But that's a price worth paying, in the long run. -{{ chapters(prev_chapter_link="/books/things-i-learnt/use-timezones", prev_chapter_title="Always Use Timezones With Your Dates", next_chapter_link="/books/things-i-learnt/log-events", next_chapter_title="Logs Are For Events, Not User Interface") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/use-timezones", prev_chapter_title="Always Use Timezones With Your Dates", next_chapter_link="/books/things-i-learnt/config-file", next_chapter_title="The Config File Is Friend") }} From 53adeda79eb3a189ac45806228f9a706e82fcb62 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 15 Jul 2019 19:15:31 -0300 Subject: [PATCH 4/7] A bit more reordering --- content/books/things-i-learnt/_index.md | 4 ++-- content/books/things-i-learnt/command-line-options/index.md | 2 +- content/books/things-i-learnt/config-file/index.md | 2 +- content/books/things-i-learnt/log-events/index.md | 2 +- content/books/things-i-learnt/resist-easy/index.md | 2 +- content/books/things-i-learnt/start-stupid/index.md | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/content/books/things-i-learnt/_index.md b/content/books/things-i-learnt/_index.md index 8bf37ff..f192a53 100644 --- a/content/books/things-i-learnt/_index.md +++ b/content/books/things-i-learnt/_index.md @@ -47,12 +47,12 @@ template = "section-contentless.html" * [If Your Data Has a Schema, Use a Structure](use-structures) * [Don't Mess With Things Outside Your Project](outside-project) * [Resist The Temptation Of Easy](resist-easy) - * [Command Line Options Are Weird, But Helpful](command-line-options) * [Start Stupid](start-stupid) * [Always Use Timezones With Your Dates](use-timezones) * [Always Use UTF-8 For Your Strings](use-utf8) - * "Usability" + * Making Things Go * [The Config File Is Friend](config-file) + * [Command Line Options Are Weird, But Helpful](command-line-options) * [Logs Are For Events, Not User Interface](log-events) * [Learn To Monitor](monitoring) * Community/Teams diff --git a/content/books/things-i-learnt/command-line-options/index.md b/content/books/things-i-learnt/command-line-options/index.md index c5c52b1..308c0f3 100644 --- a/content/books/things-i-learnt/command-line-options/index.md +++ b/content/books/things-i-learnt/command-line-options/index.md @@ -29,4 +29,4 @@ Also, be aware that, today, there may be libraries to handle command line in every language, which will help you build a good command line interface, along with standardizing it to have the same interface as other applications. -{{ chapters(prev_chapter_link="/books/things-i-learnt/resist-easy", prev_chapter_title="Resist The Temptation Of Easy", next_chapter_link="/books/things-i-learnt/start-stupid", next_chapter_title="Start Stupid") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/config-file", prev_chapter_title="The Config File Is Friend", next_chapter_link="/books/things-i-learnt/log-events", next_chapter_title="Logs Are For Events, Not User Interface") }} diff --git a/content/books/things-i-learnt/config-file/index.md b/content/books/things-i-learnt/config-file/index.md index 5888858..d1393df 100644 --- a/content/books/things-i-learnt/config-file/index.md +++ b/content/books/things-i-learnt/config-file/index.md @@ -52,4 +52,4 @@ you'll find that you're half-way through it. [^1]: In other words, they have a [time to live](https://en.wikipedia.org/wiki/Time_to_live). -{{ chapters(prev_chapter_link="/books/things-i-learnt/use-utf8", prev_chapter_title="Always Use UTF-8 For Your Strings", next_chapter_link="/books/things-i-learnt/log-events", next_chapter_title="Logs Are For Events, Not User Interface") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/use-utf8", prev_chapter_title="Always Use UTF-8 For Your Strings", next_chapter_link="/books/things-i-learnt/command-line-options", next_chapter_title="Command Line Options Are Weird, But Helpful") }} diff --git a/content/books/things-i-learnt/log-events/index.md b/content/books/things-i-learnt/log-events/index.md index 225eebc..38490fe 100644 --- a/content/books/things-i-learnt/log-events/index.md +++ b/content/books/things-i-learnt/log-events/index.md @@ -43,4 +43,4 @@ could have the values to try to figure out why it failed -- surely, logging why it failed also helps, but you know what I mean. This is an example of something that makes complete sense in logs, but not in user interfaces. -{{ chapters(prev_chapter_link="/books/things-i-learnt/config-file", prev_chapter_title="The Config File Is Friend", next_chapter_link="/books/things-i-learnt/monitoring", next_chapter_title=Learn To Monitor"") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/command-line-options", prev_chapter_title="Command Line Options Are Weird, But Helpful", next_chapter_link="/books/things-i-learnt/monitoring", next_chapter_title=Learn To Monitor"") }} diff --git a/content/books/things-i-learnt/resist-easy/index.md b/content/books/things-i-learnt/resist-easy/index.md index 83544e8..2b4e853 100644 --- a/content/books/things-i-learnt/resist-easy/index.md +++ b/content/books/things-i-learnt/resist-easy/index.md @@ -28,4 +28,4 @@ These days, IDEs can autocomplete almost everything, from function names to even how to name your variables. But using the autocomplete is not always a good solution. Finding better names is. -{{ chapters(prev_chapter_link="/books/things-i-learnt/outside-project", prev_chapter_title="Don't Mess With Things Outside Your Project", next_chapter_link="/books/things-i-learnt/command-line-options", next_chapter_title="Command Line options Are Weird, But Helpful") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/outside-project", prev_chapter_title="Don't Mess With Things Outside Your Project", next_chapter_link="/books/things-i-learnt/start-stupid", next_chapter_title="Start Stupid") }} diff --git a/content/books/things-i-learnt/start-stupid/index.md b/content/books/things-i-learnt/start-stupid/index.md index 0145706..d313143 100644 --- a/content/books/things-i-learnt/start-stupid/index.md +++ b/content/books/things-i-learnt/start-stupid/index.md @@ -31,4 +31,4 @@ what your IDE is doing. And when you grasp that, you'll be able to use _any_ IDE. -{{ chapters(prev_chapter_link="/books/things-i-learnt/command-line-options", prev_chapter_title="Command Line Options Are Weird, But Helpful", next_chapter_link="/books/things-i-learnt/use-timezones", next_chapter_title="Always Use Timezones With Your Dates") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/resist-easy", prev_chapter_title="Resist The Temptation Of Easy", next_chapter_link="/books/things-i-learnt/use-timezones", next_chapter_title="Always Use Timezones With Your Dates") }} From 36fa892ea4d59b06937ac5c31b787a74730ba569 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 15 Jul 2019 19:36:04 -0300 Subject: [PATCH 5/7] New chapter: application composition --- content/books/things-i-learnt/_index.md | 1 + .../application-composition/index.md | 44 +++++++++++++++++++ .../command-line-options/index.md | 2 +- .../books/things-i-learnt/log-events/index.md | 2 +- 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 content/books/things-i-learnt/application-composition/index.md diff --git a/content/books/things-i-learnt/_index.md b/content/books/things-i-learnt/_index.md index f192a53..c6cd3b9 100644 --- a/content/books/things-i-learnt/_index.md +++ b/content/books/things-i-learnt/_index.md @@ -53,6 +53,7 @@ template = "section-contentless.html" * Making Things Go * [The Config File Is Friend](config-file) * [Command Line Options Are Weird, But Helpful](command-line-options) + * [Not Just Function Composition, But Application Composition](application-composition) * [Logs Are For Events, Not User Interface](log-events) * [Learn To Monitor](monitoring) * Community/Teams diff --git a/content/books/things-i-learnt/application-composition/index.md b/content/books/things-i-learnt/application-composition/index.md new file mode 100644 index 0000000..c9ff1ca --- /dev/null +++ b/content/books/things-i-learnt/application-composition/index.md @@ -0,0 +1,44 @@ ++++ +title = "Things I Learnt The Hard Way - Not Just Function Composition, But Application Composition" +date = 2019-07-15 + +[taxonomies] +tags = ["en-au", "books", "things i learnt", "composition", "applications"] ++++ + +When we were discussing [the magical number +seven](/books/things-i-learnt/magical-number-seven), I mentioned that it made +more sense to actually call the functions in sequence instead of each calling +the next. That's basically a "function composition", one thing you can also do +with your applications. + + + +Unix came with the idea of "applications that do one thing and do it well". +And then you could just pick the output of one application and plug it as +input of another (and then plug the output of the second into a third, and so +on). + +Also, I mentioned that you could use [configuration +files](/books/things-i-learnt/config-file) to do the same processing over +different source elements (based on a configuration, that is) instead of +writing an application that would process both in a single shot. + +One problem with that approach is that you may need _both_ results to actually +produce a usable result (for example, how would you build a list of common +followings of two Twitter users if you don't have both lists?). + +That problem can easily be solved if you write a different application that +just receives both lists and compare them. That would greatly simplify your +general codebase 'cause instead of one massive codebase with lots of moving +pieces, you'd have two small codebases, with less moving pieces. One could +still break the other -- say, if you or someone else changes the result of the +first function -- but you will still get the results of the first without +missing the whole 'cause the second is breaking. + +PS: I reckon it's really hard to create application composition with graphical +applications (why would you ask your user to have _two_ applications open at +the same time to make something work?) but you can extrapolate this for almost +everything else. + +{{ chapters(prev_chapter_link="/books/things-i-learnt/command-line-options", prev_chapter_title="Command Line Options Are Weird, But Helpful", next_chapter_link="/books/things-i-learnt/log-events", next_chapter_title="Logs Are For Events, Not User Interface") }} diff --git a/content/books/things-i-learnt/command-line-options/index.md b/content/books/things-i-learnt/command-line-options/index.md index 308c0f3..def1fb0 100644 --- a/content/books/things-i-learnt/command-line-options/index.md +++ b/content/books/things-i-learnt/command-line-options/index.md @@ -29,4 +29,4 @@ Also, be aware that, today, there may be libraries to handle command line in every language, which will help you build a good command line interface, along with standardizing it to have the same interface as other applications. -{{ chapters(prev_chapter_link="/books/things-i-learnt/config-file", prev_chapter_title="The Config File Is Friend", next_chapter_link="/books/things-i-learnt/log-events", next_chapter_title="Logs Are For Events, Not User Interface") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/config-file", prev_chapter_title="The Config File Is Friend", next_chapter_link="/books/things-i-learnt/application-composition", next_chapter_title="Not Just Function Composition, But Application Composition") }} diff --git a/content/books/things-i-learnt/log-events/index.md b/content/books/things-i-learnt/log-events/index.md index 38490fe..db45937 100644 --- a/content/books/things-i-learnt/log-events/index.md +++ b/content/books/things-i-learnt/log-events/index.md @@ -43,4 +43,4 @@ could have the values to try to figure out why it failed -- surely, logging why it failed also helps, but you know what I mean. This is an example of something that makes complete sense in logs, but not in user interfaces. -{{ chapters(prev_chapter_link="/books/things-i-learnt/command-line-options", prev_chapter_title="Command Line Options Are Weird, But Helpful", next_chapter_link="/books/things-i-learnt/monitoring", next_chapter_title=Learn To Monitor"") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/application-composition", prev_chapter_title="Not Just Function Composition, But Application Composition", next_chapter_link="/books/things-i-learnt/monitoring", next_chapter_title=Learn To Monitor"") }} From 151f071a8dab9eb8a6e6c2cac7eff64bdea723ac Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 15 Jul 2019 19:48:12 -0300 Subject: [PATCH 6/7] New chapter: make app composition stupid --- content/books/things-i-learnt/_index.md | 1 + .../app-composition-stupid/index.md | 30 +++++++++++++++++++ .../application-composition/index.md | 2 +- .../books/things-i-learnt/log-events/index.md | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 content/books/things-i-learnt/app-composition-stupid/index.md diff --git a/content/books/things-i-learnt/_index.md b/content/books/things-i-learnt/_index.md index c6cd3b9..6013d97 100644 --- a/content/books/things-i-learnt/_index.md +++ b/content/books/things-i-learnt/_index.md @@ -54,6 +54,7 @@ template = "section-contentless.html" * [The Config File Is Friend](config-file) * [Command Line Options Are Weird, But Helpful](command-line-options) * [Not Just Function Composition, But Application Composition](application-composition) + * [Even for Application Composition, Start Stupid](app-composition-stupid) * [Logs Are For Events, Not User Interface](log-events) * [Learn To Monitor](monitoring) * Community/Teams diff --git a/content/books/things-i-learnt/app-composition-stupid/index.md b/content/books/things-i-learnt/app-composition-stupid/index.md new file mode 100644 index 0000000..e7edb4e --- /dev/null +++ b/content/books/things-i-learnt/app-composition-stupid/index.md @@ -0,0 +1,30 @@ ++++ +title = "Things I Learnt The Hard Way - Even for Application Composition, Start Stupid" +date = 2019-07-15 + +[taxonomies] +tags = ["en-au", "books", "things i learnt", "composition", "microservices"] ++++ + +Application composition may lead to microservices -- which is good -- but +microservices require some ideas about how applications "talk" between them +over the wire (protocols and such) which you don't need to start with. + + + +Again, because you just want to simplify your work, you can make the +applications use files directly: Have your first application generate two +files and the second application receive the file names from [the command +line](/books/things-i-learnt/command-line-options). There, simple and stupid, +and works. + +You can even make the first application, instead of generating a file, just +send its result on the standard output, and have the second application +receive the data from the standard input -- both of which are managed as +files, anyway. Then, with a bit of magic, you can put everything together +without wasting space. + +Worry about talking over the wire later, when you understand how networks +work. + +{{ chapters(prev_chapter_link="/books/things-i-learnt/application-composition", prev_chapter_title="Not Just Function Composition, But Application Composition", next_chapter_link="/books/things-i-learnt/log-events", next_chapter_title="Logs Are For Events, Not User Interface") }} diff --git a/content/books/things-i-learnt/application-composition/index.md b/content/books/things-i-learnt/application-composition/index.md index c9ff1ca..5741b65 100644 --- a/content/books/things-i-learnt/application-composition/index.md +++ b/content/books/things-i-learnt/application-composition/index.md @@ -41,4 +41,4 @@ applications (why would you ask your user to have _two_ applications open at the same time to make something work?) but you can extrapolate this for almost everything else. -{{ chapters(prev_chapter_link="/books/things-i-learnt/command-line-options", prev_chapter_title="Command Line Options Are Weird, But Helpful", next_chapter_link="/books/things-i-learnt/log-events", next_chapter_title="Logs Are For Events, Not User Interface") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/command-line-options", prev_chapter_title="Command Line Options Are Weird, But Helpful", next_chapter_link="/books/things-i-learnt/app-composition-stupid", next_chapter_title="Even for Application Composition, Start Stupid") }} diff --git a/content/books/things-i-learnt/log-events/index.md b/content/books/things-i-learnt/log-events/index.md index db45937..ec8349a 100644 --- a/content/books/things-i-learnt/log-events/index.md +++ b/content/books/things-i-learnt/log-events/index.md @@ -43,4 +43,4 @@ could have the values to try to figure out why it failed -- surely, logging why it failed also helps, but you know what I mean. This is an example of something that makes complete sense in logs, but not in user interfaces. -{{ chapters(prev_chapter_link="/books/things-i-learnt/application-composition", prev_chapter_title="Not Just Function Composition, But Application Composition", next_chapter_link="/books/things-i-learnt/monitoring", next_chapter_title=Learn To Monitor"") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/app-composition-stupid", prev_chapter_title="Even for Application Composition, Start Stupid", next_chapter_link="/books/things-i-learnt/monitoring", next_chapter_title=Learn To Monitor"") }} From c18994f49cb56825009361298c0a9345583ba1b9 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 15 Jul 2019 19:59:20 -0300 Subject: [PATCH 7/7] New chapter: optimization --- content/books/things-i-learnt/_index.md | 1 + .../things-i-learnt/config-file/index.md | 2 +- .../things-i-learnt/optimization/index.md | 39 +++++++++++++++++++ .../books/things-i-learnt/use-utf8/index.md | 2 +- 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 content/books/things-i-learnt/optimization/index.md diff --git a/content/books/things-i-learnt/_index.md b/content/books/things-i-learnt/_index.md index 6013d97..1b2c827 100644 --- a/content/books/things-i-learnt/_index.md +++ b/content/books/things-i-learnt/_index.md @@ -50,6 +50,7 @@ template = "section-contentless.html" * [Start Stupid](start-stupid) * [Always Use Timezones With Your Dates](use-timezones) * [Always Use UTF-8 For Your Strings](use-utf8) + * [Optimization Is For Compilers](optimization) * Making Things Go * [The Config File Is Friend](config-file) * [Command Line Options Are Weird, But Helpful](command-line-options) diff --git a/content/books/things-i-learnt/config-file/index.md b/content/books/things-i-learnt/config-file/index.md index d1393df..692736a 100644 --- a/content/books/things-i-learnt/config-file/index.md +++ b/content/books/things-i-learnt/config-file/index.md @@ -52,4 +52,4 @@ you'll find that you're half-way through it. [^1]: In other words, they have a [time to live](https://en.wikipedia.org/wiki/Time_to_live). -{{ chapters(prev_chapter_link="/books/things-i-learnt/use-utf8", prev_chapter_title="Always Use UTF-8 For Your Strings", next_chapter_link="/books/things-i-learnt/command-line-options", next_chapter_title="Command Line Options Are Weird, But Helpful") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/optimization", prev_chapter_title="Optimization Is For Compilers", next_chapter_link="/books/things-i-learnt/command-line-options", next_chapter_title="Command Line Options Are Weird, But Helpful") }} diff --git a/content/books/things-i-learnt/optimization/index.md b/content/books/things-i-learnt/optimization/index.md new file mode 100644 index 0000000..333e36a --- /dev/null +++ b/content/books/things-i-learnt/optimization/index.md @@ -0,0 +1,39 @@ ++++ +title = "Things I Learnt The Hard Way - Optimization Is For Compilers" +date = 2019-07-15 + +[taxonomies] +tags = ["en-au", "books", "things i learnt", "optimization"] ++++ + +Let say you need more performance on your application. You may be tempted to +look at your code and think "How can I keep this same logic and still remove a +few cycles, so things seem to go faster?" Well, if you want performance, you +need to change your logic. + + + +But before jumping into the code, you may have to check your compiler options. +Maybe you're not generating the optimized version. Maybe there is an option +that you don't use that you can remove from the compilation. + +'Cause "optimization" is what a compiler is for. They _know_ where they can +extract most of the underlying architecture, and people have been finding ways +to make the compiled code more performance for decades. Heck, compilers can +even _delete_ parts of your code 'cause they can "see" that a piece of code +will always produce the same result and, thus, isn't necessary and they will +just put the same result where that piece of code was. + +What you need to do is to think about a better _design_ for your code, not how +to improve the current code. And trying to trick the compiler by [messing with +the types](/books/things-i-learnt/data-types), although may produce faster +code, will really screw you in the future -- specially cause maintenance and +code understanding will take long and figuring out what went wrong will always +be harder. + +Code is written for humans to read. _ALWAYS_. Optimization is what compilers +do. So find a smarter way to explain what you're trying to do instead of using +shorter words or messing with that your code is saying. + +{{ chapters(prev_chapter_link="/books/things-i-learnt/use-utf8", prev_chapter_title="Always Use UTF-8 For Your Strings", next_chapter_link="/books/things-i-learnt/config-file", next_chapter_title="The Config File Is Friend") }} + diff --git a/content/books/things-i-learnt/use-utf8/index.md b/content/books/things-i-learnt/use-utf8/index.md index 3d24960..3c7e33d 100644 --- a/content/books/things-i-learnt/use-utf8/index.md +++ b/content/books/things-i-learnt/use-utf8/index.md @@ -52,4 +52,4 @@ single character. Walking through the whole string would require traversing the string character by character, instead of simply jumping straight to the proper position. But that's a price worth paying, in the long run. -{{ chapters(prev_chapter_link="/books/things-i-learnt/use-timezones", prev_chapter_title="Always Use Timezones With Your Dates", next_chapter_link="/books/things-i-learnt/config-file", next_chapter_title="The Config File Is Friend") }} +{{ chapters(prev_chapter_link="/books/things-i-learnt/use-timezones", prev_chapter_title="Always Use Timezones With Your Dates", next_chapter_link="/books/things-i-learnt/optimization", next_chapter_title="Optimization Is For Compilers") }}