The doom of callbacks || deadly diamond of death

Cette expression  a été inventé pour qualifier un problème assez récurrent dans le monde du Javascript touchant traitant l'(a) synchronicité   suite à l’imbrication successives des appels  en  JavaScript.Utiliser des callbacksL lorsque l’on traite des problèmes asynchrones est assez courant afin de différer l’exécution d’instructions du coup on aura de fortes chance poru avoir des problèmes lorsqu’on commence à empiler plusieurs callbacks les uns à la suite des autres. Ce qui va mener  très vite à des choses comme cela :

step1(value, function(data){
step2(data, function(data2){
step3(data2, function(data3){
step4(data3, function(data4){doom
//INSTRUCTIONS
});
});
});
});

C’est ce que l’on appelle the doom of callbacks (les callbacks de la mort). Avouez que ce n’est pas très élégant, tout ça. Par ailleurs, pas mal de problèmes se posent, notamment celui du débug et surtout du test. Ce n’est jamais évident de tester du code bien enfoui dans une pile de callbacks.

                                           deadly diamond of death

dead

Some languages (like C++) allow a class to extend more than one other class.
This capability is known as “multiple inheritance.” The reason that Java’s
creators chose not to allow multiple inheritance is that it can become quite
messy. In a nutshell, the problem is that if a class extended two other classes,
and both superclasses had, say, a doStuff() method, which version of doStuff()
would the subclass inherit? This issue can lead to a scenario known as the
“Deadly Diamond of Death,” because of the shape of the class diagram that
can be created in a multiple inheritance design. The diamond is formed when
classes B and C both extend A, and both B and C inherit a method from A. If
class D extends both B and C, and both B and C have overridden the method
in A, class D has, in theory, inherited two different implementations of the
same method. Drawn as a class diagram, the shape of the four classes looks
like a diamond.


Votre commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l’aide de votre compte WordPress.com. Déconnexion /  Changer )

Image Twitter

Vous commentez à l’aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l’aide de votre compte Facebook. Déconnexion /  Changer )

Connexion à %s