When .gitgnore is not enough

| Comments

I’m currently working on a project with multiple dev teams contributing together to a few different repositories, combined into one system. And we’re using git, of course. We have very strict branching model. It takes weeks to see your work merged to master, even for the simplest things. The project is quite big and sometimes I’m using pieces of code that nobody else’s using, even when working on the same module. And here’s where the .gitignore file is not enough.

Why refactoring is important

| Comments

We usually have no time to refactor, the client wants us to work on bugs fixing or new features. S/he pays for it, so we’re doing what s/he wants. Time goes and we keep adding new features, finding new bugs, debugging, fixing, adding features, debugging and so on. The client is happy, s/he sees we always work on the actual ticket, which improves the visible part of the application, s/he is glad we’re not wasting time on refactoring, s/he thinks it’s pointless to change the things that work. The truth is that thanks to refactoring, we save time.

Why it's worth to know the NullObject pattern

| Comments

From time to time most of the Ruby/Rails developers are facing a situation when an app is trying to call a method on a certain object, which out of nowhere appears in our system as nil, instead of an instance of the desired class. The worst scenario in such situations, assuming that you want to solve this problem somehow, is to take advantage of Ruby’s open classes and achieve a quick win by monkey-patching the NilClass to avoid raising the famous NoMethodError. Even if you’re new in Ruby world, you should know that it’s a really bad practice and do not do that. You can, of course, achieve the goal in a few different ways, and here we’ll be describing one of them. Have you ever heard about the NullObject pattern? Here’s a quick introduction on how to use it.

How well do you know JavaScript?

| Comments

We all know JS somehow, how confident are you? Is NaN equal NaN? Is null equal 0? What is the result of adding two empty Arrays? If you know these ones, you’re really good, but still can find some more interesting JS facts by reading further. Let’s go!

What is CORS preflight for?

| Comments

Sometimes I really miss the times when everything was so simple, even though lots of things seems to be really easy today. I remember the days we had only HTML, no backend/frontend separation, no frameworks, no CSS*, nothing. So let’s talk about browser-level cross-origin HTTP requests performing some kind of pre-CORS ‘sanity check’ using options method that allow us to e.g. fetch the JSON data from remote API for our node-powered Ember SPA. To be more clear, we’ll take a look on a CORS preflight requests :)

A few things about ActiveRecord transactions

| Comments

From time to time you have to wrap some magic code in an ActiveRecord transaction. In such cases it’s better to make sure your code does its job or you’ll face the problems sooner or later. Even if you code only for fun, it’s worth to know a few things about transactions before you fall into the deep forest of debugging strange issues you can avoid. Just to make sure we all know what we’re talking about, let me paste the Rails API description of the AR transactions:

Transactions are protective blocks where SQL statements are only permanent if they can all succeed as one atomic action. The classic example is a transfer between two accounts where you can only have a deposit if the withdrawal succeeded and vice versa. Transactions enforce the integrity of the database and guard the data against program errors or database break-downs. So basically you should use transaction blocks whenever you have a number of statements that must be executed together or not at all.

I love this description :-) it’s everything you basically need to know to understand what an ActiveRecord transaction is. Ready for a few quick tips? Go on!

Lifelong learning: Codewars

| Comments

We have so many tools to develop ourselves today that is unlikely to use each of them even once a week. I’ve decided to launch a new series here and it will be related to the process I’m pretty sure you’re familiar with: lifelong learning. This term is quite self-explanatory, but if you’re not sure what does it mean I suggest you to at least take a look on lifelong learning wikipedia explanation. The first sentence there actually does the job:

"Ongoing, voluntary, and self-motivated pursuit of knowledge for either personal or professional reasons."

As I’ve mentioned we have tons of tools and resources to help us grow and I personally tried and still use some of them. I use Duolingo for languages (not the programming ones! I have 339 days streak in Spanish today!), I renew my CodeSchool subscription from time to time (last week I’ve done that to see their React course), I spend some time on Codewars, I dived into edX resources some time ago, I explored the content of Codecademy and so on, and so on. Of course - these are the online resources, but the screen is not my siamese brother so I also read some papers and even wrote a post about the books I think every ruby/rails dev should read. Reading is obviously a part of the lifelong learning process and don’t forget about the traditional paperbooks. Anyway, today I’ll share with you my thoughts about Codewars - a place where you can try yourself with some real-world coding challenges.

Ruby symbols and its garbage collecting

| Comments

Symbols are one of the most mysterious things for Ruby beginners. When I was starting with Ruby I also wondered what is going on sometimes and what these symbols are at all. I’m not a programming veteran, but today I know a little bit more about some things and will share some thoughts here with you. This time about about Ruby symbols, not accidentally described as things above. We start with the basics about what are symbols and when to use them. Finally we’ll dive deeper to take a look on how they are managed by the Ruby GC.

Programming quotes vol.2

| Comments

I’ve finally made up my mind, I will definetely launch a subpage on this blog with all the quotes I think are worth to know. But before it happen, here’s the second part of the ones I like most:

"No matter how slow you are writing clean code, you will always be slower if you make a mess."

Uncle Bob Martin

"Make it work first before you make it work fast."

Bruce Whiteside