What is a Bad Programmer?
Coding refers to the act of writing instructions in a programming language. In that sense, the coder is also a programmer. The program must serve a clear purpose: automating a routine task, performing repetitive or complex calculations, managing data, and so on. In bioinformatics, programs are designed to transform raw biological data into formats that can be used by other specialists for further analysis.
The program is not a static code but a living thing. The environment around it can evolve, requirements may change, and the program must adapt accordingly to remain useful. Therefore, the code has to be modified and tested by anyone as often as needed.
The code is ambivalent:
- Sequence of instructions that is run by the computer.
- Text that must be easy to read.
Best coding practices have been introduced to improve code readability (by other humans) and, consequently, ease program maintenance. In this context, bad or good code is, above all, code that either jeopardizes or saves the life of the program.
What is a bad code?
- Does not do its job!
- Difficult to change.
Reciprocally, a good code
- Works!
- Is easy to change.
Therefore, what does a good programmer?
- Spends few time refactoring their code.
- Writes new features.
Unreadable code
- A good code is comprehensible by anyone.
- A good code is structured into modules. Divide code into small, manageable parts.
- One single context for each part.
- Variables must have clear, self-explanatory names.
- Syntax is consistent:
kebab-case
: Words are all lowercase and separated by dashes-
.camelCase
: The first word is lowercase, and each subsequent word starts with a uppercase.snake_case
: Words are all lowercase and separated by underscore_
.
What is a module?
A module is a subprogram. It is a file or a collection of files of written code. This code can be reused and invoked from other parts of the program. The term module is broad and can refer to a component, library, package, or assembly.
The code is too complicated!
- When it has no modules (always divide the code in smaller parts)
- When it is too nested
- ⚖️ Golden rule: no more than 3 indentations!
for
for
for
- To ensure that changing one element of the code does not force you to change other parts of the code.
Last but not least
- Reduce coupling between functions as much as possible.
- All functions must be easy to test.
- Don't repeat yourself.
References
The Pragmatic Programmer
Andrew Hunt and David Thomas
From journeyman to master, 1999. ISBN-13: 978-0135957059
Relevant Tags
About the Author
Latest Articles
-
Chado: the GMOD Database Schema
Chado is a relational database schema that underlies many GMOD installations. It is capable of representing many of the general classes of data frequently encountered in modern biology such as sequence, sequence comparisons, phenotypes, genotypes, ontologies, publications, and phylogeny. It has been designed to handle complex representations of biological knowledge and is the most sophisticated relational schemas currently available in molecular biology.JAN 2025 · PIERRE-EDOUARD GUERIN -
Error Messages with a CLI
I am an anxious person. So error messages always makes my heart beat faster. Hopefully, following the Pareto Principle, 80% of error messages are mild while 20% are the really tough one. The point is to solve the first kind as quickly as possible and effortless. To do so, allow the user to solve the issue by himself with clear messages and hints (in the case of errors related to input files or parameters). Clear presentation of the context and precise localization of the error in the code will save a lot of useless and tedious work to the developer. The time spared on the easy errors just by having better messages, then can be reallocated to the second kind of errors, the troublemakers.NOV 2024 · PIERRE-EDOUARD GUERIN -
Generative AI: Integrate openAI API with Python
I was fortunate to follow the course of Sven Warris about software tools to integrate genAI into your own work and applications. The course is aimed at data scientists and bioinformaticians.MAY 2024 · PIERRE-EDOUARD GUERIN