Before starting the refactoring
Jul 14, 2024
code
tests
system
mistakes
changes
3 min read
Sooner or later, every programmer has to perform refactoring of existing code. But before diving in, consider a few things that can save you and your colleagues a lot of time (and spare you from headaches):
It is best to start refactoring by assessing the state of the existing code in the project and the tests written for it. This way, you can identify the strengths and weaknesses of the code in its current state, to preserve its strong points and avoid the mistakes already made. Everyone thinks their system will be better than the current one… until it turns out that the new code is no better, and maybe even worse, than the previous version, all because we did not learn from the mistakes made in the old system.
...
➦ The importance of code formatting
Jul 09, 2024
in •
COBOL
cobol
code
first
kevin mcguire
line
screen
work
poetry
3 min read
In ancient times, I worked on a COBOL project where all participants were forbidden to change the indentation size unless it was necessary to modify the code. All because one day someone broke something – a line of code crept onto the next one and ended up in special columns at the beginning of the line. The ban was in effect even if the code formatting was misleading—which happened—so one had to read the code very carefully, as it couldn’t be trusted. I’m sure the losses from this policy were enormous because it slowed down the work of programmers.
Researchers have shown that a programmer spends more time navigating and reading code (to find the part that needs to be changed) than actually writing code, so it is advisable to optimize these operations.
...
➦ Write code wisely
Jul 09, 2024
below
devil
code
fragments
proof
function
correctness
3 min read
Attempts to prove the correctness of software manually lead to a formal proof that is longer than the code itself and contains errors more frequently than the code. It is preferable to use automated tools, but this is not always possible. Below, a middle ground is described: semi-formal proof of correctness.
The method is based on dividing the code under investigation into short fragments ranging from a single line, which may contain a function call, to blocks no longer than 10 lines, and discussing their correctness. The proof must be convincing enough for your colleague playing the role of the “devil’s advocate.”
Fragments should be chosen in such a way that at the end point of the block, the program state (namely, the instruction address counter and the values of all “live” objects) satisfies a property that is simple to describe, and the functionality of this fragment (state transformation) can be easily described as a single independent task.
...
➦ Before blaming others, check your own code
Jul 08, 2024
sherlock holmes
dirk
compiler
time
code
errors
version
3 min read
A developer – any of us! – often finds it difficult to admit that their code doesn’t work. It seems so implausible that we are more likely to assume there is a bug in the compiler.
In reality, it is very, very rare for code to be non-functional due to a bug in the compiler, interpreter, operating system, application server, database, memory manager, or any other element of system software. Yes, there are bugs, but they are much less frequent than we would like to think.
Once, I actually encountered a bug in the compiler (removing the loop variable during optimization), but in all other cases, my complaints about the compiler or operating system turned out to be unfounded. I wasted a lot of my time, support staff time, and management time, only to end up in an awkward position when it turned out that the mistake was my own.
...
➦ The assembly must be clean
Jul 01, 2024
in •
JAVA
java
warnings
code
need
fix
example
3 min read
Have you ever seen a list of compiler warnings the size of an essay on how not to write code and thought: “Of course, something needs to be done about this… but I just don’t have time for it right now”? And conversely, have you ever seen a single warning appear during compilation and immediately fix it?
When I start a new project from scratch, there are no warnings, no mess, no problems. But as the codebase grows, if no measures are taken, it’s likely that the mess, clutter, warnings, and issues will gradually accumulate. In a large stream of “noise,” it becomes significantly harder to find a truly important warning among the hundreds of others that I am not interested in.
To make warnings useful again, I try to adhere to a policy of zero tolerance for warnings during assembly.
...
➦ Code is design
Jun 29, 2024
design
construction
building
cost
work
3 min read
Imagine waking up in the morning and finding out that a groundbreaking breakthrough has occurred in the construction industry. Now, millions of cheap and incredibly fast robots can create various materials literally from thin air, using almost no energy, and they can repair themselves. But that’s not all: if there are clear blueprints, the robots will build a building according to them without any human intervention, and the cost of this work will be negligible.
One can imagine how this will transform the construction industry, but what changes will occur at a higher level? How will architects and designers behave when the cost of construction becomes negligible? Today, expensive construction is necessarily preceded by the creation and thorough testing of physical and computer models.
...
➦ Continuous learning
Jun 28, 2024
development
twitter
google
journeyman
master
delve
neo
matrix
technologies
technology
group
subject
code
online
4 min read
We live in interesting times. Development is distributed all over the world, and it turns out that many people are capable of doing your job. To remain competitive in the labor market, you need to continuously learn. Otherwise, you will turn into a dinosaur stuck in your job until one fine day it turns out that you are no longer needed, or that your job has been given to someone who is willing to do it for less.
How to solve this problem? Some employers are generous and organize training to develop already hired programmers. Others simply cannot afford to allocate time or resources for this. The most reliable solution is to take care of your own education.
Here is a list of ways to continue learning.
...
➦ Hard work does not justify itself
Jun 26, 2024
act
work
week
hours
project
software
3 min read
Every programmer needs to be convinced that intense work is often unjustified. You can deceive yourself or your colleagues into thinking that by staying late at the office, you are making a significant contribution to the project. But in reality, by working less, you can achieve more—sometimes significantly more. If you are trying to work “productively” and with focus for more than 30 hours a week, you are likely overworking. It might be worth considering reducing your workload, which will allow you to work more efficiently and accomplish more.
It may seem that my statement contradicts common sense and is generally debatable. However, it is a direct consequence of the fact that programming and software development, in general, require continuous knowledge expansion. As you work on a project, you will come to better understand the subject area and, hopefully, find more efficient ways to achieve your goals.
...
➦ The myth of the guru
Jun 26, 2024
in •
GURUS
guru
people
myth
context
questions
3 min read
Everyone who has been working in the computer industry for a long time has had to hear questions like: I am getting an XYZ exception. Do you know what the problem is?
Those who ask such questions rarely bother to show the stack trace, application log, or provide any context that would help understand the problem. Apparently, they think you operate on some other plane where solutions are revealed to you without any analysis of the facts. They consider you a guru.
We expect such questions from people who are not familiar with software, from those for whom the system’s operation seems almost magical. What worries me is that we encounter this even within the programming community. Similar questions arise during software design, for example: “I am writing an application for warehouse management.
...
➦ First say yes
Jun 22, 2024
in •
EDAMAME
edamame
product
request
round
windows
work
3 min read
Recently, I was at the grocery store and searched for edamame, green soybeans (I only vaguely guessed they were some kind of vegetable). I didn’t I knew where to look for this product: in the vegetable section, in the frozen section. products or on the shelves with canned goods? Finally, I gave up and asked a store employee for help. She didn’t know either!
The store employee could have reacted to my request in different ways. She could have made it clear that only a fool doesn’t know where to look for it, or just brushed it off. vague hints, or even just say that they don’t have such a product. But she deemed it possible to find a solution and help the customer.
...
➦