Yegor Bugayenko's Blog, page 4
August 28, 2023
Robots vs. Programmers
The release of ChatGPT 3.5 has changed everything for us programmers. Even though most of us (including me) don���t understand how it works, some of us use it more frequently than Stack Overflow, Google, and IDE built-in features. I believe this is just the beginning. Even though, only Microsoft knows what will happen next, let me try to make a humble prediction too. Below, I list what I believe robots (with Generative AI on board) will do in the future.The further into the future, the lo...
August 21, 2023
Fast Tests Help Humans, Deep Tests Help Servers
In order to reveal errors of higher complexity, automated tests are turned into integration tests that involve external resources in test scenarios, instead of their mocks. While this approach improves test coverage, it slows down the entire build pipeline. This compromises the very idea of automated tests, which are meant to be a safety netand help programmers edit code safely. Splitting the tests into ���fast��� and ���deep,��� and then allowing humans to run the former while servers r...
August 14, 2023
The Double-Blind Review Is What Makes Decisions Fair
How does your team review ideas, project proposals, or paper drafts?Imagine I���m on your team and I need a budget allocated to a new project. I craft a proposal, elucidate the motivation, assess the risks, develop a plan, and then what? Do I create a PowerPoint presentation, present to my teammates for half an hour, answer their questions for another half hour, hear their honest feedback, after which they vote and a decision is made? If this is how things are organized within your team, y...
August 7, 2023
Is Two-Step Initialization a Solution or a Symptom?
At times, it might appear practical to execute additional initialization steps for an object after its constructor has completed. However, I���m of the belief that such requirements signal underlying design flaws, such as object mutability,base class fragility, violation of layering, and unfocused abstraction. A constructor should be good enough for all scenarios. If it���s not, refactor the object.
[image error]�������������� (2008) by Igor VoloshinThis is how it usually happens (I found it in Apac...
July 31, 2023
The Hidden Dangers of Method Overloading
Method overloading is a common feature in many programming languages that allows a class to have two or more methods with the same name but different parameters.According to Microsoft, method overloading is ���one of the most important techniques for improving usability, productivity, and readability of reusable libraries.���I disagree. In my opinion, method overloading may lead to less readable code and more bugs,because maintaining two or more implementations under the same name gives r...
July 24, 2023
A Disabled Test In Lieu of a Bug Report
When you find a bug in an open-source library that you use, what do you do?You submit a GitHub issue (or whatever ticket tracking system they use).In the issue, you describe the problem in the best possible way, preferablyproviding a working code example that the author of the library can run locallyto reproduce the bug. If you don���t provide them with an executable snippet of code,they will most likely ask you to do so, unless the bug is trivial.I suggest simplifying the workflow and gi...
July 18, 2023
Just Show Up
According to a study conducted by Dariusz Jemielniak in 2007, the majority of programmers perceive their own managers as highly incompetent. We don���t expect our bosses to be coding-savvy���this level of technical competence is not a requirementfor an average manager. Additionally, we don���t expect them to excel in Gantt Chart wizardry or adhere strictly to risk management protocols���these are management practices that are not commonly observed in software teams today.Instead, what we...
January 18, 2023
On the Layout of Tests
I don���t know what programming language you use, but my experience of recent coding in Java, Ruby, JavaScript, PHP, Python, C++, and Rust tells me that the principle, which I will try to convince you to adhere to ��� is universal for all languages. It���s about the naming of test files. It may look to you like a question of low importance, but let me try to demonstrate that it���s not. How do you name your files with test classes? How many of them do you create in the src/test/java direct...
September 7, 2022
Smaller Try-Blocks Are Better
It often happens, especiallyin Java, that a few places in the methodare potential exception originators. Usually, we make a large method-sizetry block with a single catch at the bottom. We catch allthe exceptions, usually even usinggrouping.This helps us minimize the noise, which is the exception catching.However, such large try blocks jeopardize maintainability: we are unableto provide proper error contextinside catch blocks.
[image error]The Rum Diary (2011) by Bruce RobinsonWhat do you think...
August 29, 2022
Don���t Group Exception Catchers
Sometimes we rethrow exceptions.In Java we do this more often than in other languages, because it haschecked exceptions.Sometimes we must catch and rethrow a few exceptions that originatedfrom different places in a method.Java��7 introduced groupingof different types of exceptions in a single catch block.But even without the grouping, it is possible to just catch IOException oreven Exception and provide a single catch block for all types and alloriginators (methods that throw).Recently...