Yegor Bugayenko's Blog, page 15
July 2, 2018
What���s Wrong With Global Variables?
Only lazy people haven't written already about how global variables are evil. It started in 1973 when W. Wulf et al. claimed that "the non-local variable is a major contributing factor in programs which are difficult to understand." Since then, many other reasons where suggested to convince programmers to stop using global variables. I think I read them all, but didn't find the one that bothers me most of all: composability. In a nutshell, global variables make code dif...
June 25, 2018
Are You an Architect?
Over twenty five years ago, in 1992, at an OOPSLA workshop in Vancouver, Kent Beck, in answer to the question "What is an architect?" said, according to Philippe Kruchten, that it is "a new pompous title that programmers demand to have on their business cards to justify their sumptuous emoluments." Not much has changed since then. There is a big difference between a smart programmer and a project architect. Here is a list of traits that, I believe, a good architect has.
[image error]N...June 18, 2018
Simplified GitHub Login for a Ruby Web App
You know what OAuth login is, right? It's when your users click "login" and get redirected to Facebook, Twitter, Google, or some other website which then identifies them. Then they go back to your website and you know who they are. It's very convenient for them. It's convenient for you too, since you don't need to implement the login functionality and don't need to keep their credentials in a database. I created a simple Ruby gem to simplify this operation for Gi...
May 28, 2018
Object Validation: to Defer or Not?
I said earlier that constructors must be code-free and do nothing aside from attribute initialization. Since then, the most frequently asked question is: What about validation of arguments? If they are "broken," what is the point of creating an object in an "invalid" state? Such an object will fail later, at an unexpected moment. Isn't it better to throw an exception at the very moment of instantiation? To fail fast, so to speak? Here is what I think.
[image error]Punching the Cl...May 21, 2018
One More Recipe Against NULL
You know what NULL is, right? It's evil. In OOP, your method can return NULL, it can accept NULL as an argument, your object can encapsulate it as an attribute, or you can assign it to a variable. All four scenarios are bad for the maintainability of your code—there are no doubts about that. The question is what to do instead. Let's discuss the "return it" part and I will suggest one more "best practice" on top of what was discussed a few years ago.
[image error]Snatch (...May 7, 2018
An Open Code Base Is Not Yet an Open Source Project
A few weeks ago someone suggested I should try to integrate IntelliJ IDEA's static analysis rules into Qulice, our aggregator of Checkstyle, PMD, FindBugs, and some other analyzers. I do love IDEA's rules—some of them are unique and very useful. I asked whether I could find them somewhere in Maven Central (they are written in Java) and the answer was "You'll have to figure out yourself how to use them, but they are open source." Here comes my opinion about this sit...
April 23, 2018
The Right Way to Report a Bug
You know, at Zerocracy, either you are a programmer or a tester, and we pay for each bug you find and report. Well, not quite. We pay for each bug report a project architect considers good enough to pay for. The architect's decision is totally subjective and non-disputable, according to ��29 of the Policy. Some of our developers find this unfair and ask me to explain how they can report bugs such that they are definitely paid. Here is a non-exhaustive list of my recommendations.
[image error]Burn Aft...April 16, 2018
How to Be Lazy and Stay Calm
What frustrates me most in my profession of software development is the regular necessity to understand large problem scopes before fixing small bugs, especially if the code is legacy and not mine. Actually, it's even more frustrating when the code is mine. The "deep thinking," as they call it, which is always required before even a small issue can be resolved, seriously turns me away from programming. Or did turn me away. Until I started to think differently and encourage mysel...
April 9, 2018
Nine Steps of Learning by Refactoring
I was asked on Twitter recently how is it possible to refactor if one doesn't understand how the code works. I replied that it is "learning by refactoring." Then I tried to Google it and found nothing. I was surprised. To me refactoring seems to be the most effective and obvious way to study the source code. Here is how I usually do it, in nine object-oriented steps.
[image error]Dom Hemingway (2013) by Richard ShepardAccording to Wikipedia, code refactoring is "the process of restruc...
April 2, 2018
Fully Transparent Donations via Zerocracy
Open source is free, as in beer: you write code, nobody pays you. Of course, there are many ways to monetize your efforts, but there will be no direct cash payments from your users, usually. There are ways to collect money, which include an obvious "tip jar" button on your GitHub project page. The chances anyone will pay are low though. In my opinion, this is mostly because nobody trusts you enough—they are not sure you will use the money to make the product better. Most likel...


