picostitch
crafting (and) JavaScript

TestJSSummit - Notes for Day 2

After live blogging on day 1 I made a plan for day 2. I will watch all content in 2x speed and just pause whenever I need a bit to write. It's just a video, so I can catch up by higher speed. Also I came to the conclusion that I don't even need to be fully in sync, except for the polls and the live chatting, but there is too much life going on in parallel that I am glad about the pause button.

Continue reading β†’

I had planned building the kata for Number.parseInt() already a while ago. Starting to work I discovered very quickly that this seemingly tiny kata is quite a rabbit hole that offers a lot of things one can learn. Especially about how things evolve in the spec and how to read the spec, fortunately this is a pretty easy to read part of the spec.

Unfortunately I discover very often when using jest that a lot of the things point me to smells in a test. Jest even encourages some of those instead of encouraging us to write better tests. I found some things over time, so I just collect them here.

This is post #3 in the category "Browser Tools", focusing on understanding the loading times by charting them in a Waterfall chart. In part 1 and part 2 about Resource Timing I covered the attributes startTime, responseEnd, duration and initiatorType. Now I want to understand what happens after a resource starts loading and what do some attributes mean, like fetchStart, requestStart and responseStart, to mention the most relevant ones.

This is post #2 about Resource Timing, with a focus on understanding loading dependencies. In part 1 "Resource Timing - The API" I covered the attributes responseEnd and startTime. Now I will try to show how the API can be used to see which resources block each other, which is the step to understand before optimizing site speed, a very essential step to know what is the right thing to optimize.

Since I moved to Linux for work I started to look up and collect the git commands I need most. On Linux I do not have my beloved GitUp app which is an amazing visual and fully keyboard controllable git tool available for MacOS only. Here is my list of git commands. As usual I created this collection so I know where to copy+paste commands from ;).

You don't need to rename all your ".js" files to ".ts" to go all in on TypeScript, you can go gradually. Adopt TypeScript step by step, become familiar with it in your existing JavaScript project. No need to put development on hold for weeks, while you convert the code base to TypeScript and fix all type errors. Read on to see how I adopt TypeScript for JavaScript for the sourcecode of jskatas.org.

I have been through a couple projects to build my blog. None survived, so I just build, just what I need, with just enough code to get it done.

It was the second time that we did Tetris as our task for the JSCodeRetreat and I have to say, that the participants' comment made me realize that we are on the right track. Though not all comments were purely in favor of Tetris, I think Tetris is the better task for a (JS) CodeRetreat.

It was Evren who triggered the idea of using Tetris as the task for the next JSCodeRetreat. And I have to say it was a good idea, it was a bit more challenging than the Game of Life and left more room for discussions and also allowed to explore more (software) design challenges.

I just wanted to install a github-flavored markdown plugin for vim. Until today I only used vim as it falls out of the box. So I had to do a couple detours before I got a vim plugin installed. Since I like the simplicity of the Mikado Method I apply it very often (maybe too often). In this case I used a very simple form of it, actually mainly to document all the steps I had to take on this detour. Read more below.

While refactoring some badly tested code, a pattern of how I extract dependencies emerged. The actual intention was to improve the testability. In this case dependency injection is the tool that helped me. Read here to find out the steps I found to separate the dependencies.

This is newsletter #3 - about crafting (and) JavaScript - March 13th, 2017. Every Monday you will receive a hand-selected collection of links about JavaScript and how to craft better software. Let's get started ...

Welcome to the newsletter #2 - about crafting (and) JavaScript - March 6th, 2017. Every Monday you will receive a hand-selected collection of links about JavaScript and how to craft better software. Let's get started ...

Welcome to the newsletter #1 - about crafting (and) JavaScript - February 28th, 2017. Every Monday you will receive a hand-selected collection of links about JavaScript and how to craft better software. Let's get started ...

This topic came up today when we discussed the #crewmeister API, and made me think. Until I remembered that we once in a project used to use the pure POST params, which are basically key-value pairs. And the question also reminded me of my PHP times, there the server-side knew how to handle a key which looks like user[0] and builds and array. But when I ran into that problem back then we used to use python and there we didn't have that.

This sticks out, so far :) Avdi Grimm's article about the law of demeter, reading it including all commetsn until the end will take a bit of time but is exactly what explains a lot of things that imho we do wrong in lots of software we write, I am working on improving myself around it. For the completeness here is the paper initially laying out the law of demeter.

Actually we are currently discussing and evaluating to use react or alike and this react lifecycle comes in perfectly and somehow also makes the point stronger that a well documented, cared and widely used project is a good thing to be using. Decided!

At this point in the EmberJS Framework Basics Part 2 video the author explains how you can make (computed) properties out of 'normal' methods by using what the ember.js Ember.Object offers. It starts out with friend.age(), which returns what you expect. The author wants to write this as a property (as one accesses it in ember!) like this friend.get('age'). How is that done? Well, ember extends the native prototype of Function, so you can write this inside an ember object definition age: function (){}.property().

730.975 byte - the size of the main JS file of an empty app that ends up in the dist folder after building the app by ember build --environment=production.

In the last days I had to learn a lot about how to use, write and understand user stories. This talk by Mike Cohn is a pretty good kick start and summary for the hows and whys.

I just read a post about GraphQL, and because the headline and all the article contains so much excitment and passion for the topic I read it until the end.

I know that the calling of functions can be quite noise-less, no parantheses and commas. But it also leaves me baffled at times. I can't get my head around this one either.

Don't promisify fs.exists since this does not play by the rules of node style callback params, where the first one should be err and then data. It seems this does return only the data, which promisify understands as an error and does throw right away. Instead do what the node js docs suggest too and use fs.access instead, like so: promisify(fs.access)(aPath, fs.R_OK). See it in action [here in the cosmowiki].

I had been fighting for the last years, always again to make WebStorm run all my tests the way I want. I moved tests into the src folder then back into a tests folder. The latter is painful, since I have to keep the structures of two folders in sync that way, which is just inefficient, especially when I refactor so much, which I think is simply necessary and the right thing to do.

My laziness actually pulls me strongly towards #noEstimates. I guess it's because the "no" means I have less work to do. Which I could kind of back up with the argument Robert Weissgraeber gives at the beginning of his talk, which is that we should remove all unnecessary work, all waste.

Uncle Bob nicely shows the parallels between accountants and TDD. One value gets put on the asset side and the other on the liability side, they add up to be 0. And then he questions why accountants meet their deadlines, even though they do things twice. Accountants do this for five hundred years, its a "law". We still need to get there with TDD, but we are on the best way and I second that and try to do my part with the JSCodeRetreat.

C# has a way better expression for what we write in JavaScript like so obj.method && obj.method() and in C# you can do obj?.method() which is pretty slick I think. See this video (in german) for a short explaination.

RethinkDB is a topic that I had been investing some time into, because I tried to figure out which DB to use for cosmowiki. What convinced me about: it is a DB which offers the best of both worlds, the NoSQL world (schema "freedom") and SQL DB's relational data. RethinkDB has joins built-in as one of the core features. Besides built-in joins it claims to have a very simple scale out mechanism and almost magic, transparent fail-over since version 2.1.

My pet project ES6 Katas is a playground for learning, if you look in the repo you see lots of things moving around and changes made. Most of it is because I try to apply new learnings and try to get to a structure that really is what I consider good software. Lots of new bits of information I learn I try to apply there or at least play around with it and figure out what's a better way to do things. This often might end up in a forth and back of things and in not being able to decide what is right, and it looks like nothing moves forward, but that's just on the surface.

Unfortunately I missed Franziska's session at SoCraTes 2015 on this topic, but fortunately she wrote about it, make sure to also read through her commits backwards, of course :). Very nice and readable! An article "Kickstart your next project with a Walking Skeleton" she referred to, that explains the process too. While reading more and more of the [c2 wiki] I am asking myself where is the difference to a spike which Kent Beck defined as

In this talk, Uncle Bob starts to set the context for why our industry has a hard time catching up with the speed and also why it is so important that we do spend more time on mindfully constructing software. It's worth spending those 1,5h watching this talk, or less if you 2x the video speed :).

The new dojo? I started with dojo about 10 years ago, or so. Now I see reapp which seems to be the same as dojo, lots of widgets, just around react and transferred 10 years ahead and to mobile.
Good stuff? Or not?

In order to keep all your meta data of your project in one place and only create files that actually just copy those data you can use projectz where you maintain data like title, description, author(s), badges, ... in one CSON file and with a special markup you can update fill in the templates files like README, package.json, ...

IDEs are awesome, but sometimes in my way and setting up test runners sometimes defeats the purpose of being fast with tests, which also means having feedback constantly and continuously.