hjertnes.blog

#

13.11.2017 01:00

Being more mindful about what kind of functions you use where

13.11.2017 01:00

Let’s talk about arrow functions versus regular functions. I love how much more minimal and elegant arrow functions look. But I think we might need to start being more mindful about what we use where.

```text The key difference between the two is that an arrow function shares it’s this with where it is defined, while a function either shares it with the global scope, or the context it is bound to; if you are using strict you have to bind it to something to have a ‘this’ at all. ```

```text I see all the time that me and many other developers are using each one for all the wrong reasons. ```

```text Use regular functions if you don’t interact with ‘this’ or if you are going to bind it. And use arrow functions if you are going to use the ‘this’ of where it is defined. ```

```text A typical place where many people use regular functions where arrow functions is a better option is event handlers in React. And a typical place where people use arrow functions a lot, instead of regular functions, where they are not the best option (because we are lazy) is utility functions. ```

```text Be mindful about the differences, and understand what you are doing and why. ```

Workflow and Pythoninsta.

13.11.2017 01:00

I was looking into how to do something really simple using Drafts and Todoist on Saturday.

The basic idea was that I wanted an easy way to either add or create a new project and then add a series of tasks to it. (First line is the project, and the rest is tasks).

Well. I thought, this is a perfect opportunity to play around with Workflow. So, I made the damn thing and then I also did it using Pythonista.

The verdict? It took way shorter time using Pythonista because I know how it works, but I think something like Workflow is the right tool, if you don’t know how to code.

This is a common thing I often see myself doing. When something is very simple, I almost always end up writing it myself, because then I don’t need to learn all the “jargon” and metaphysics every single system always have.

The difficult thing is to know when to write it yourself, and when to learn what is already there.

#

12.11.2017 01:00

#

12.11.2017 01:00

Anyone tested out Lightroom CC?

Task Management in 2018

12.11.2017 01:00

```text One of the most important, if not the most important part of a well functioning system for managing the things you have to do is a ever changing system to manage it all. ```

```text The system I was happy with in 2010 or in 2012 or 2015 is not the same as what I am happy with today. ```

```text I started to notice some eh let’s call them “growing problems” with my pen and paper only system earlier this autumn; the short version: ```

```text
  • I forgot to write stuff down
  • I didn’t find some of what I wrote down
  • etc
  • etc
  • ```

    ```text So, I decided to move back to Todoist. Their apps aren’t the best, to say the least. But they do have a good API. So I can get it to do what I need. ```

    ```text Where does pen, paper and all the stuff we love fit into this? ```

    ```text While I don’t currently use pen and paper to mange everything (at the moment) I still use it for a few very crucial tasks. I still use my beloved Leuchtturm1917 dot grid notebook in the planning stage, or when I do a brain dump. And I still use it to map out the most important stuff I need to get done day per day per week. ```

    ```text And I do of course bring my notebook instead of a computer do meetings, like a grown up. ```

    #

    11.11.2017 01:00

    #

    11.11.2017 01:00

    #

    10.11.2017 01:00

    The only way to make sure I see everything going on at Micro.blog I have found so far, is to add my timeline feed to Feedwrangler.

    Understanding the difference between functions and arrow functions

    10.11.2017 01:00

    Most React components are written something like this

    ```text I personally think this is very verbose, compared to what it has to be. Because just because most people use regular functions inside their ES6 classes, doesn’t mean you have to. You might disagree, but all the methods I define inside a component should either be moved to some utility file or they need to interact with the components ‘this’.
    The way I write React Components these days, if they aren’t stateless, is written something like this: ```

    ```text The big difference between the two is that I have ditched the constructor, because I’m only using it to set the default state and binding the functions. Then all the methods in the previous class have been replaced by arrow functions that use the expression syntax. Which removes some lines with brackets and a return statement.
    I personally think the latter versjon looks a lot better; or at least a lot cleaner. There are less "stuff". And I’m going to start re-writing a lot of react code to follow this form, and everything new I write will follow this form. I could probably remove many hundred lines of code just in removing brackets, return and unneeded binds and constructors in my work projects. ```