Defensive programming for non technical people

Defensive programming for non technical people

When developers write code, they can apply different styles; today we talk of Defensive programming.

Defensive programming is a technique that often is used when developing software. It consists of adding extra code to check for errors and prevent them from happening.

In defensive programming, the focus is not only on developing the feature that we need but also on thinking about everything else that could go wrong while the code is executed.

Some common features of defensive programming are:

  • Input validation: Checking that the data entered by the user (or coming from other systems) is valid before processing it.
  • Error handling: Handling errors in a way that doesn't crash the program or lose data.
  • Boundary checking: Checking that all array indices are within bounds.
  • Code reviews: Have someone else check your code for errors before it is released.

The basic concept of defensive programming is to try to reduce the possible bugs that could arise, validating and checking all the values and types of data we expect.

This should reduce the number of bugs in our code and, as a side goal, reduce the number of iterations needed before the end of the development.

Often bugs are due to wrong initial input or due to "assumption" at the implementation level taken by developers. Both of these cases should be avoided/reduced, thanks to defensive programming.

Obviously, it takes more time, but the overall quality of the code is much higher, and the written code will be more resilient to future changes.


No alt text provided for this image

This series of articles is dedicated to managers who are not technical but need a quick introduction to technical topics from various subjects to be more aware in their work.

Feel free to propose new topics clicking here!

To view or add a comment, sign in

More articles by Simone Dall'Angelo

  • Analisi email 2024 e relativi insight

    Ogni anno guardo i 12 mesi precedenti cercando di vedere, dati alla mano, come sia andata la gestione delle email: ecco…

    5 Comments
  • ETF Bitcoin: 3 mesi dopo

    L'11 gennaio sono partite le vendite degli ETF "Spot" Bitcoin autorizzati dalla SEC. I principali ETF sono: IBIT:…

  • Comunicare il marchio con la voce degli intermediari: croce e delizia per il nostro brand

    Come non disperdere valore nella comunicazione online dei propri rivenditori o franchisee? Le aziende che si affidano a…

  • IT ⇢ Design: racconto di un percorso

    È il 2007, lavoro nella prima società che ho fondato con due compagni di classe e ci occupiamo di sviluppo IT. Siamo…

    1 Comment
  • Analisi email 2023 e relativi insight

    Nella mia giornata lavorativa la gestione delle email è un aspetto importante per non creare colli di bottiglia, ma al…

    2 Comments
  • Sul metaverso

    Per un po' sembrava che il metaverso sarebbe stata la grande nuova frontiera dell'innovazione e, anche qui su LinkedIn,…

    7 Comments
  • Blockchain: Come dimostrare qualcosa preservando la propria privacy?

    Come ormai abbiamo imparato, una delle caratteristiche delle blockchain è la loro trasparenza. In ogni momento, dato un…

    1 Comment
  • Crypto domains for non technical people

    In one of the past articles, we talked about the Domain Name System (you can find it here). Today we talk about a…

  • Web servers for non technical people

    The whole internet experience we have daily is possible thanks to web servers. But what are they? How do they work?…

  • SQL injection for non technical people

    In the past article about SQL language (you can find it here) we explained how it works. Through a SQL query, we can…

Insights from the community

Others also viewed

Explore topics