Yegor Bugayenko's Blog, page 5
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...
August 23, 2022
Research Paper Simple Template
My first academic paperwas accepted and published in 1998. My most recent one was rejected by SPLASH just a week ago.I���m writing two papers right now and co-authoring about ten others.So far, my results are very poor: way more rejections than I expected.The key lesson I���ve learned so far: the reason most papers get rejectedis not because they are essentially wrong. Instead, reviewers reject thembecause they have no enthusiasm for decrypting a poorly structured text,even though it may ...
August 9, 2022
Declarative and Immutable Pipeline of Transformations
A few months ago I made a small Java library,which is worth explaining sincethe design of its classes and interfaces is pretty unusual. It���s very muchobject-oriented for a pretty imperative task: building a pipeline ofdocument transformations. The goal was to do this in a declarative andimmutable way, and in Java. Well, as much as it���s possible.
[image error]Barfuss (2005) by Til SchweigerLet���s say you have a document, and you have a collection of transformations,each of which will do someth...
August 3, 2022
The Code and Its Tests in Different Pull Requests
I suggested this idea a few weeks agoon Twitterand got mostly negative reactions. That���s why I wrote this blog post, to elaborate on thesubject in an attempt to convince you. Here is the rule I���m suggesting:always submit changes to the code separately from the changes toits unit tests. Simply put, in one pull request you modify the tests, maybemarking some of them as ���disabled.��� You merge this pull request and thenmake the second one, modifying the code and most probablyremoving ...
July 19, 2022
Command Line Default Options in Linearized Plain Text
A few years agoI created xcop,a simple command line tool thatcan check the style of an XML file. It���s similar toCheckstyle (for Java) andPep8 (for Python),but for XML. It���s pretty easy to use xcop: just run it with a few commandline arguments and it returns the list of errors found in your XML file, if there are any. However,some of the arguments may be convenient to have as defaults and instead ofpassing them through the command line on every execution, we could store them in som...
July 4, 2022
Automated Tests Are the Safety Net that Saves You
Automated tests are the ones that are usually called unit tests or integration tests,or just any tests that are being executed automatically. That���s the differencebetween them and manual tests. What is the purpose of automated tests?First and foremost, they reduce the amount of routine work: we don���tneed to remember how to test a module, the tests remember. We just clicka button and a suite of tests, which may consist of hundreds or thousands,runs and reports errors, if any are found. ...


