Arkency 07 March 2017
Today I was working on a feature where I had to create a few similar Active Record objects. I was creating a read model for some financial data. Most of the attributes of created objects were the same but a few were different. In one refactoring step I removed the duplication in passing attributes by using a prototype. Although at that moment I haven't thought of the object in such way.
Arkency 17 February 2017
When we learn programming languages and techniques we go through certain phases: Curiosity Admiration Overdosage Rejection Approval etc. Similarly with other things we enjoy in our life such as ice cream, pizza and sunbathing :) We learn to enjoy them, we try too much of it and learn the consequences. Hopefully some time later we find a good balance. We know, how much of it, we can use without hurting ourselves. I think we can have a similar experience in programming for example when you find out about metaprogramming, immutability, unit testing, DDD. Basically anything. We often need to hit an invisible wall and realize that we overdosed. It's not easy at all to realize it and learn from it. After 8 years of using Ruby and Rails, there are certain constructs that I try not to use anymore because I believe they make maintaining large applications harder.
Arkency 05 February 2017
Let's say you have such a class: (this code is borrowed from this Reddit thread ``` !ruby class CreateSomethingService def initialize(params) parse_parameters params end def run Something.create(name: @name) end private def parse_parameters(params) @name = params[:name] end end ```
Arkency 26 January 2017
You already used fluent interfaces multiple times as a Ruby developer. Although you might not have done it consciously. And maybe you haven't built yourself a class with such API style yet. Let me present you a couple of examples from Ruby and its ecosystem and how I designed such API in my use-case.
Arkency 20 January 2017
Hello, it's Andrzej Krzywda from Arkency here. Today we have a special guest post from Richard Eng, the man who is behind the Smalltalk Renaissance. I've been fascinated with Smalltalk since my University. In a way, my Ruby code is Smalltalk-infected all the time. Many of the great things in programming come from Smalltalk, like MVC, IDE, refactoring. Smalltalk has its history, but it's also still in use in huge, production systems. As Ruby developers we often look at the new, shiny languages. Maybe we can also look at something less new? Maybe we can get inspired with Smalltalk? I'll leave you with Richard and his strong arguments for Smalltalk, enjoy! :)
Arkency 13 January 2017
Arkency 02 January 2017
Today I checked one of the solutions made by our Junior Rails Developer class student. As part of the course they make Rails apps but also learn from smaller code examples delivered by exercism.io. I found there an opportunity for him to learn more about a few things...
Arkency 30 December 2016
Some say: "Event sourcing is hard". Some say: "You need a framework to use Event Sourcing". Some say: ... Meh. You aren't gonna need it.
Arkency 04 December 2016
In programming we are often dealing with an uncertainity. We don't know, we are not sure if something happened or not. Or we are not sure about the result. Especially when it comes to networking/distributed systems but also in other contexts. What I find interesting is that in many cases the techniques used to handle such problems are very similar.
Arkency 28 November 2016
Arkency 20 November 2016
One of the things that can negatively impact a team morale is random builds - builds where sometimes some tests are failing. Inspired by Martin Fowler's article on Quarantine, in some of our projects we came up with a guideline how we can fix the problem as a team.
Arkency 16 November 2016
It took me many years to understand the simple truth. One HTTP request sent by a browser may include a few separate logical commands. One request does not always equal one logical command.
Arkency 09 November 2016
How slow are Ruby exceptions as compared to other frequent actions we may be doing in Rails apps. Like for example, as compared to ActiveRecord::Base#create
Arkency 06 November 2016
If you work with service objects in Rails apps, very quickly you need to have the dependency being passed to the service object constructor. Which usually means, that the Rails controller needs to do it. This blogpost describes how to have a different implementation being passed in the production environment and an in-memory one in the tests.
Arkency 27 October 2016
In Ruby, we don't have to type return at the end of the method. As many other things in our favourite language, this is implicit, not explicit. The value of the last line in a method is also automatically the value of the whole method. Which is a good thing as it helps making the code less verbose and more poem-like. But it also has some dangers.