"
Supported by

You don’t encapsulate for it to be reused

Since 1998, I hear some ABAPer colleagues saying that it’s not worth encapsulating a particular piece of code in a function or method because it will never be reused again. And then they go to SE38 and create yet another report full of includes.

The idea that you should encapsulate your code for it to be reused by you or by others is one of the biggest misunderstandings of the history of our planet.

Don’t misunderstand me. I love making and reusing reusable code and, every time I identify something that may be reusable, I try to create it as generic and contained and autonomous as possible to simplify its reuse.

Yet, I believe that every piece of code, regardless of its potential to be reused, ought to always be encapsulated and modularized and liskovized and uniresponsibilized and packaged and all the other -eds you can find. Because the main motivation for all this is creating code which is robust, simple to test, resilient to bugs and, above all, easy to maintain.

And the proof is Ratatouille. Anyone who wants to make proper Ratatouille knows that 4 pots must be used. And then you mix everything. And then you eat it. Many will chose to use only one pot, since everything will end up being mixed together anyway. But if you choose to do it this way you’ll end up with something that seems to be Ratatouille but really isn’t. So, modularization and encapsulation are essential to Ratatouille and, if you use them, it will be so good that everything will be eaten and there will be no left overs to reuse. It is thus proved that you don’t encapsulation to reuse.

Photo by stijn.

Greetings from Abapinho.

2 comentários a “You don’t encapsulate for it to be reused”

  1. Fábio Luiz Esperati Pagoti Diz:

    Concordo 100%

  2. Igor Muntoreanu Diz:

    Fala! Concordo! A grande dificuldade é saber aonde estão as panelas e se ela realmente existem, é isso que deixa a desejar no mundo SAP. O SAP UI5/Fiori, diferentemente tem tudo organizadinho na documentação.

Deixe um comentário


About Abapinho
Abapinho runs on WordPress
Articles (RSS) e Comments (RSS).