This book simply changed my life as a software developer

Tobias Aguiar
7 min readMar 6, 2023

--

Preface

If you’re a software developer and you haven’t read “The Pragmatic Programmer,” you’re missing out on a huge opportunity to improve your skills and change your perspective on programming. As someone who is still reading this book, I can say that it has already had a significant impact on the way I think about programming and how I approach my work.

The authors of this book provide valuable insights and practical advice on how to be a successful and effective programmer.

In this article, I’ll be highlighting specific examples from the book “Pragmatic Programmer” that have had a significant impact on my life as a software developer. I’ll be discussing the importance of being a pragmatic programmer, the value of good code organization, the benefits of testing and debugging, and the role of communication in programming.

The Importance of Being a Pragmatic Programmer

Firstly, a pragmatic programmer is a problem solver who approaches programming challenges with a proactive and solution-oriented mindset.

Note on the sentence above that your main job is not create software. You solve problems to aggregate value. That should be your mindset.

They recognize that solving problems is the heart of programming, and actively seek out new solutions and tools to tackle complex issues. The book provides the example of the “Broken windows” approach, which emphasizes the importance of addressing small issues before they snowball into larger problems.

The broken windows

This approach mentioned in “The Pragmatic Programmer” is a concept originally developed by criminologists James Q. Wilson and George L. Kelling. The idea behind this approach is that visible signs of disorder and neglect, such as broken windows, can create an environment where more serious crime and antisocial behavior is more likely to occur.

In the context of programming, the authors of “The Pragmatic Programmer” suggest that a similar approach can be taken to address small issues in code before they escalate into larger problems. By fixing minor issues promptly, developers can prevent them from becoming more significant and potentially harder to solve.

By adopting a “Broken Windows” approach, developers can create a culture of proactive problem-solving and prevent small issues from turning into larger, more complex problems.

The Value of Good Code Organization

It might be obvious, but it is always important to be said

Keeping code organized and easy to read/understand is crucial for several reasons. Firstly, it makes it easier for developers to work collaboratively on a project. When code is well-organized and easy to understand, team members can quickly and easily navigate the codebase and understand what each piece of code does. This is particularly important when working on large, complex projects with multiple team members.

Secondly, well-organized code is easier to maintain and update over time. When code is easy to read and understand, it’s simpler to make changes and updates without introducing new bugs or errors. This is because developers can quickly identify the purpose of each piece of code and understand how it interacts with other parts of the program.

Orthogonality

The authors of “The Pragmatic Programmer” emphasize the importance of good code organization and offer several strategies for achieving it. One of the most important is the principle of “Orthogonality,” which involves separating different concerns in the code into distinct modules or classes. This helps to reduce the complexity of the code and make it easier to understand and maintain.

This was basically the main principle that made design way better software at work.

It requires two key components: cohesive modules and minimal coupling. Cohesive modules are those that contain related functionality, while minimal coupling means that modules are loosely connected and can be modified independently without affecting other parts of the program.

To illustrate it, let’s have a simple example on a C program.

Consider a program that processes data from multiple sources, performs various calculations, and generates reports. In a non-orthogonal program, the code that handles input from each source would be mixed with the code that performs the calculations and generates reports. This can make it difficult to make changes to the program, since changes to one part of the code may have unintended consequences on other parts of the program. For example:

#include <stdio.h>

int main() {
// Read data from file
FILE *file = fopen("data.txt", "r");
int num1, num2;
fscanf(file, "%d %d", &num1, &num2);
fclose(file);

// Perform calculations
int sum = num1 + num2;

// Generate report
FILE *report = fopen("report.txt", "w");
fprintf(report, "The sum of %d and %d is %d\n", num1, num2, sum);
fclose(report);

// Read data from database
int id = 1;
// ...
// Perform calculations
// ...
// Generate report
// ...

return 0;
}

In the above program, the code that reads data from a file is mixed with the code that performs calculations and generates reports.

Similarly, the code that reads data from a database is also mixed with the rest of the code. This makes it difficult to make changes to the program, since changes to one part of the code may have unintended consequences on other parts of the program.

On the other hand, in an orthogonal program, the code that handles input from each source would be separated from the code that performs calculations and generates reports. This means that changes to one part of the program won’t affect other parts of the program. For example:

#include <stdio.h>

int read_data_from_file() {
FILE *file = fopen("data.txt", "r");
int num1, num2;
fscanf(file, "%d %d", &num1, &num2);
fclose(file);
return num1 + num2;
}

int read_data_from_database() {
int id = 1;
// ...
return /* some data */;
}

int calculate(int data) {
// Perform calculations
return data * 2;
}

void generate_report(int data) {
FILE *report = fopen("report.txt", "w");
fprintf(report, "The data is %d\n", data);
fclose(report);
}

int main() {
int file_data = read_data_from_file();
int database_data = read_data_from_database();
int calculated_data = calculate(file_data + database_data);
generate_report(calculated_data);
return 0;
}

In this program, the code that reads data from a file is separated from the code that reads data from a database, and both are separated from the code that performs calculations and generates reports. This means that changes to one part of the program won’t affect other parts of the program. This makes the program more modular, easier to maintain, and more flexible over time. Thus, an orthogonal program is generally better than a non-orthogonal one.

The Benefits of Testing and Debugging

The book stresses the importance of testing and debugging throughout the programming process. Testing and debugging are crucial because they help to identify errors and bugs in the code, ensuring that the program functions as intended.

The authors recommend a number of different testing strategies, including unit testing, integration testing, and system testing. They also emphasize the importance of testing early and often, as well as automating the testing process to reduce the potential for human error.

Debugging is also an important part of the programming process. The authors argue that debugging is not just about finding and fixing errors, but also about understanding the root cause of those errors. They recommend a number of different debugging strategies, including using debuggers, logging, and code reviews.

Talking with your peers

The authors emphasize the importance of seeking help from others when debugging.

This is because explaining a problem to someone else can often help you understand it better yourself. By describing the problem in detail, you may uncover hidden assumptions or overlooked details that can lead you to a solution.

I had a personal experience where this strategy proved to be effective. I was working on a particularly difficult bug in my code for two days, and I was getting nowhere. I decided to take a break and explain the problem in detail to one of my colleagues. As I described the problem, I realized that there was a fundamental flaw in my approach that I had not noticed before. My colleague was able to offer some suggestions, and after a few more iterations of debugging and testing, I was able to solve the problem.

The Role of Communication in Programming

Effective communication is a critical aspect of programming, and it plays a significant role in the success of any development project.

The book emphasizes the importance of using clear and concise language, avoiding technical jargon, and maintaining good documentation practices. Effective communication not only helps to ensure that everyone is working toward the same goals, but it also helps to build trust and foster a positive team dynamic.

Furthermore, explaining code to others is an important way to ensure that it is readable and maintainable. When we take the time to explain our code to others, we are forced to think critically about its structure and organization, leading to cleaner and more effective code.

Conclusion

In conclusion, “The Pragmatic Programmer” is a book that has revolutionized the way I think about programming. It has provided me with valuable insights and strategies to approach programming problems with more efficiency and confidence. The concepts of being a problem solver, a constant learner, valuing simplicity and communication, writing orthogonal code, keeping code organized and easy to read, debugging effectively, and many others that I didn’t present here are all essential for any software developer who wants to excel in their field.

It is a must-read for any developer who wants to stay ahead of the curve and take their skills to the next level. It has not only changed the way I approach programming, but it has also made me more passionate about the craft. I believe that every programmer can benefit from the lessons and strategies presented in this book.

So, I encourage you to read this book today and start applying its principles to your work. I am confident that you will see the results in your coding skills and the quality of your work.

If you got interested, get your book here.

Other articles

  1. Blink an arduino’s LED without IDE -embedded tutorials 1
  2. Why linux is crucial for embedded software development

--

--

Tobias Aguiar

Software developer | Trying to make complex concepts look easy | Want help or discuss about embedded software development? Email me! tobi.aguiar01@gmail.com