Yegor Bugayenko's Blog, page 23

September 26, 2016

Command, Control, and Innovate

Command and control has worked effectively in military units across the world for thousands of years. But apparently we've just discovered that the best companies are built on different verbs, which are inspire, delegate, trust, lead, innovate, etc. The question is whether we really uncovered something new that our predecessors failed to understand for ages or something else is going on.

Andrei Rublev (1966) by Andrei TarkovskyAndrei Rublev (1966) by Andrei Tarkovsky

We are lazy and greedy animals. To work and produce somethin...

 •  0 comments  •  flag
Share on Twitter
Published on September 26, 2016 17:00

September 19, 2016

OOP Without Classes?

I interviewed David West, the author of the Object Thinking book, a few weeks ago, and he said that classes were not meant to be in object-oriented programming at all. He actually said that earlier; I just didn't understand him then. The more I've thought about this, the more it appears obvious that we indeed do not need classes.

Battleship Potemkin (1925) by Sergei M. EisensteinBattleship Potemkin (1925) by Sergei M. Eisenstein

Here is a prototype.

Let's say we have only types and objects. First, we define a type:

type Book { v...
 •  0 comments  •  flag
Share on Twitter
Published on September 19, 2016 17:00

September 12, 2016

Inheritance Is a Procedural Technique for Code Reuse

We all know that inheritance is bad and that composition over inheritance is a good idea, but do we really understand why? In most all articles I've found addressing this subject, authors have said that inheritance may be harmful to your code, so it's better not to use it. This "better" part is what bothers me; does it mean that sometimes inheritance makes sense? I interviewed David West (the author of Object Thinking, my favorite book about OOP) a few weeks ago, and he said...

 •  0 comments  •  flag
Share on Twitter
Published on September 12, 2016 17:00

September 6, 2016

Gradients of Immutability

Good objects are immutable, but not necessarily constants. I tried to explain it here, here, and here, but now it's time to make another attempt. Actually, the more I think about it, the more I realize that immutability is not black or white—there are a few more gradients; let's take a look.

Twelve Monkeys (1995) by Terry GilliamTwelve Monkeys (1995) by Terry Gilliam

As we agreed here, an object is a representative of someone else (some entity or entities, other object(s), data, memory, files, etc.). Let's exam...

 •  0 comments  •  flag
Share on Twitter
Published on September 06, 2016 17:00

August 29, 2016

Vertical vs. Horizontal Decomposition of Responsibility

Objects responsible for too many things are a problem. Because their complexity is high, they are difficult to maintain and extend. Decomposition of responsibility is what we do in order to break these overly complex objects into smaller ones. I see two types of this refactoring operation: vertical and horizontal. And I believe the former is better than the latter.

Once Upon a Time in America (1984) by Sergio LeoneOnce Upon a Time in America (1984) by Sergio Leone

Let's say this is our code (it is Ruby):

class Log def initialize(path) @...
 •  0 comments  •  flag
Share on Twitter
Published on August 29, 2016 17:00