class Dog {
constructor(feet) {
this.feet = feet;
}
getFeet() {
return this.feet;
}
}
class Foot {
move(){
//..
}
}
feet = [new Foot(), new Foot(), new Foot(), new Foot()];
dog = new Dog(feet);
for (var foot of dog.getFeet()) {
foot.move();
}
class Dog {
constructor(feet) {
this.feet = feet;
}
walk(){
for (var foot of this.feet) {
foot.move();
}
}
}
class Foot {
move(){
//..
}
}
feet = [new Foot(), new Foot(), new Foot(), new Foot()];
dog = new Dog(feet);
dog.walk();
Automatic detection is possible using parsing trees.
Avoid successive message calls. Try to hide the intermediate collaborations and create new protocols.
#clean-code #software-development #object-oriented #code-smells #programming