Riot Control

Write Your Logic With Purity

When I first learned about pure functions I tried to map the concept to a core piece of logic on our product. It was hard, and I spent some days figuring it out. The test functionality is an invoice finalizer. We first had all that logic on the fat models, and then we refactored it to interactors and it was a huge improvement. Even so, all the gateway logic and such, seamed like an unnecessary burden. This functionality, in ruby, is something like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class FinalizeDocument

  attr_accessor :document

  def run
    lock do
      sequence = find_sequence
      document.number = increment(sequence.last_document)
      validate_document

      document.status = 'final'
      document.final_date = Time.now

      document.calculate_totals
      document.sign_and_do_crypto_things

      document.save!
    end
  end

end

What It Takes to Be a Great Leader?

Interesting view on leadership.

  • Where are you looking to anticipate change?
  • What is the diversity measure of your network?
  • Are you courageous enough to abandon the past?

REWORK & REMOTE: Office Not Required

Remember the Godfather movies? I bet you’ve seen them before. (If you haven’t, stop reading right now and go watch them. Just kidding.)

There are 3 Godfather movies: Part I, Part II and Part III. Let’s just focus on Part I and Part II. Which one did you like the most? Part I? It’s a classic, great movie. Do you think Part II is better? I know some people who do. It’s also awesome. Both are great movies, there’s no question about that.

The same happens with these two life changing books: REWORK and REMOTE. Both of them are so good it’s hard to say which one is better.

These books have completely changed the way I work and how I manage to keep a healthy work-life balance.

Let me just give you an idea of what they talk about. Then, go read them and change your life forever.

Pure Functions

While learning scala/clojure and functional programming I have come across a very familiar concept: pure functions. It reminds me of an interactor, but I feel that is much more valuable as a concept. The wikipedia says that a function may be considered pure if:

Practical Object-Oriented Design in Ruby

Pratical Object-Oriented Design in Ruby by Sandi Metz

This is one of my favorite Ruby books ever. It is very well written and a joy to read. I highly recommend this book.

So, why is software design so important?

When starting a new software application you have certain requirements. You analise these requirements, build your software and it works. As time goes by, those requirements will change and you will need to refactor your code. If you have a good design architecture, with loosely coupled classes, refactoring your code to meet the new requirements is easy. Otherwise, it will be very painful to make changes.