Yegor Bugayenko's Blog, page 17
January 1, 2018
Operator new() is Toxic
To instantiate objects, in most object-oriented languages, including Java, Ruby, and C++, we use operator new(). Well, unless we use static factory methods, which we don't use because they are evil. Even though it looks so easy to make a new object any time we need it, I would recommend to be more careful with this rather toxic operator.
[image error]The Gift (2015) by Joel EdgertonI'm sure you understand that the problem with this operator is that it couples objects, making testing and reuse ve...
December 25, 2017
The Formula for Software Quality
How do you define the quality of a software product? There is definitely an intrinsic emotional component to it, which means satisfaction for the user, willingness to pay, appreciation, positive attitude, and all that. However, if we put emotions aside, how can we really measure it? The IEEE says that quality is the degree to which a product meets its requirements or user expectations. But what is the formula? Can we say that it satisfies requirements and expectations to, say, 73%?
[image error]Coco Chan...December 18, 2017
SRP is a Hoax
The Single Responsibility Principle, according to Robert Martin's Clean Code, means that "a class should have only one reason to change." Let's try to decrypt this rather vague statement and see how it helps us design better object-oriented software. If it does.
[image error]The Thomas Crown Affair (1999) by John McTiernanI mentioned SRP once in my post about SOLID, saying that it doesn't really help programmers understand the good old "high cohesion" concept, which was i...
December 11, 2017
Alan Kay Was Wrong About Him Being Wrong
Time to time someone is asking me what I think about what Alan Kay, the father of OOP, the designer of Smalltalk, the first object-oriented language, said in 1998 about OOP. He literally said that the very term "object" was misleading and a more appropriate one would be "messaging." Here is what I think.
[image error]Rain Man (1988) by Barry LevinsonI believe that there are two orthogonal means of interaction between objects: messaging and composition. Let's say, we have a point...
December 4, 2017
DAO is Yet Another OOP Shame
Someone asked me what I think about DAO and I realized that, even though I wrote about ORM, DTO, and getters, I haven't had a chance yet to mention DAO. Here is my take on it: it's as much of a shame as its friends—ORM, DTO, and getters. In a nutshell, a Data Access Object is an object that "provides an abstract interface to some type of database or other persistence mechanism." The purpose is noble, but the implementation is terrible.
[image error]Requiem for a Dream (2000) by Da...November 27, 2017
How Micro Is Your Tasking?
"What are you doing now?"—when you hear this question from your boss, be aware: you're dealing with a micromanager. Keeping us busy is the key objective of these creatures and this is what makes them so annoying. To the contrary, effective managers make sure we are productive, meaning that our results satisfy their expectations. They are not interested in knowing what we are doing to deliver them—they manage the project, instead of managing us. And the first step to...
November 20, 2017
Trust. Pay. Lose.
"Listen up, dude," a friend of mine said when he called yesterday, "I trusted them for over a year—we've been partners. They've been programming it all and I was busy doing business development. Now they've quit and I'm left with nothing! What am I supposed to do with all these JavaScript files? How do I even know they are mine? Moreover, they don't even want to cooperate. I feel like a hostage. Please, help me out!" What could I say? "It'...
November 13, 2017
Constructors or Static Factory Methods?
I believe Joshua Bloch said it first in his very good book "Effective Java": static factory methods are the preferred way to instantiate objects compared with constructors. I disagree. Not only because I believe that static methods are pure evil, but mostly because in this particular case they pretend to be good and make us think that we have to love them.
[image error]Extract (2009) by Mike JudgeLet's analyze the reasoning and see why it's wrong, from an object-oriented point of view....
November 6, 2017
Five Features to Make Java Even Better
I stumbled upon this proposal by Brian Goetz for data classes in Java, and immediately realized that I too have a few ideas about how to make Java better as a language. I actually have many of them, but this is a short list of the five most important.
[image error]Idiocracy (2006) by Mike JudgeGlobal Variables. There are Singletons in Java, which, as we all know, are nothing but global variables. Wouldn't it be great to enable global variables in Java and get rid of Singletons. PHP, JavaScript, Ruby...
October 23, 2017
Software Quality Award, 2018
This is the forth year of the Software Quality Award. The prize is still the same—$4,096. The rules are still the same. Read on. Previous years are here: 2015, 2016, 2017.
Fill THIS FORM to submit.
Rules:
One person can submit only one project.
Submissions are accepted until September 1, 2018.
I will check the commit history to make sure you're the main contributor to the project.
I reserve the right to reject any submission without explanation.
All submissions will be published o...


