BrainsToBytes - page 5

DB Replication (IV): Replication lag

You can read the previous article in the series here: replication mechanisms It’s time we talk about an important property of real-world replication: replication lag. In the first article of the series, we mentioned that there are two forms of replication: synchronous and asynchronous. Synchronous replication waits until every follower has app...

Read more

DB Replication (III): Replication mechanisms

You can read the previous article in the series here: replication mechanisms We’ve been talking about replication log and change stream in the last two articles in this series. This is the mechanism the leader uses to communicate changes to the followers. As you can imagine, there are different implementations with their advantages and disadvan...

Read more

Depend on behavior, not on data

This is one of the most powerful pieces of advice in OO programming I’ve ever received. It means that objects shouldn’t be seen just as a collection of data structures. Instead, you should visualize them as software entities that can respond to messages and answer questions about themselves. We achieve this by hiding away implementation detail...

Read more

Things I wish I had known when I started programming, Part 8

Yepp, more things I wish I’d known when I started, 8th edition. You can find the first article in the series here. And the previous article here Programming is not about memorizing, it’s about understanding When I started programming I felt very frustrated when I tried to write simple things just to find out I forgot some syntax details. I c...

Read more

Writing good software comments II

In a previous article, we talked about the importance of comments in software development. Even though they are powerful tools for improving the readability of our code, we should use them with care. A good comment can make the code easier to understand, but a bad one can harm your productivity. Bad comments clutter your editor and make code h...

Read more

Writing good software comments I

Comments are, to put it mildly, a controversial topic. There are two very strong opinions in software development, both extremely popular and widespread. The first one states that comments are evil, and you should not use them under any circumstance. The main argument is that instead of using comments, you should try to make the code as readabl...

Read more

Ruby iterators and the yield keyword (with examples)

Ruby iterators and the yield keyword Ruby iterators are a special type of method supported by collections. They are like any other regular method, but they receive an additional input in the form of a code block. Iterators are one of the most useful features of the Ruby language, and using them effectively is a great way of creating clean metho...

Read more

Things I wish I had known when I started programming, Part 7

Yepp, more things I wish I’d known when I started, 7th edition. You can find the first article in the series here. And the previous article here Test your code Writing tests is one of those things that you appreciate more as you gain experience. In the beginning, it’s hard to understand why we need tests. I know it works, how do I know it w...

Read more

Better arguments == Better functions

Arguments play a very important role in the readability of a function. When implemented properly, they show intent and provide information about the function’s behavior. This is one of the reasons why investing time in engineering good arguments can help to improve the quality of your code. Let’s see how we can make the most of our arguments, or...

Read more

Things I wish I had known when I started programming, Part 6

Yepp, more things I wish I’d known when I started, 6th edition. You can find the first article in the series here. And the previous article here Don’t try to predict the future We suck at predicting the future. Every time you make an architectural/design decision, you close options in your design and constrain your program’s options for cha...

Read more

Things I wish I had known when I started programming, Part 5

Yepp, more things I wish I’d known when I started, 5th edition. You can find the first article in the series here. And the previous article here You read code more often than you write it. Optimize for reading Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human bei...

Read more

Things I wish I had known when I started programming, Part 4

Yepp, more things I wish I’d known when I started, 4th edition. You can find the first article in the series here. And the previous article here Love maintenance work or at least learn to appreciate it Very few things are more despised by programmers than doing maintenance work and working with legacy apps. This can be counterproductive, as...

Read more

The Liskov Substitution Principle

In 1987, while delivering a keynote on data abstractions and hierarchies, Barbara Liskov introduced the idea that would eventually become the Liskov Substitution Principle. The following is a modern (and very formal) description of the principle: Let Φ(x) be a property provable about objects x of type T. Then Φ(y) should be true for objects ...

Read more

Effective code reviews in 5 easy steps

Code reviews are one of those things that you either really love or really hate. When done well, they can dramatically increase the quality of your code and teach you lots of important practices. Poorly done reviews, on the other hand, can make you dread every time you try to push your code into version control. While your team’s attitude and ...

Read more