mercredi 7 septembre 2016

What is name of anti pattern !string.IsnullOrEmpty(Employee.Name), (Decapsulation ?)

Very often I run into code that logic that should be within business object is repeated everywhere as such:

if ( !string.IsNullOrEmpty( Employee.Name ) ) Display( Employee.Name );

where as it should be like this :

if ( Employee.IsNameSpecified ) Display( Employee.Name );

and the Employee.IsNameSpecified has the logic of value being specified.

This is just one example, many others come to mind that are reverse of OOP , procedural code being used to make logical decisions about business objects.

When Logic is encapsulated in the BusinessObject then it is just normal OOP practice (or doeas that have a different name? ), what is the opposite called ? Decapsulation ?

Aucun commentaire:

Enregistrer un commentaire