Skip to content

Instantly share code, notes, and snippets.

@FagnerMartinsBrack
Last active August 3, 2017 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FagnerMartinsBrack/0a2e40687eb18b9a64d9034c69636b58 to your computer and use it in GitHub Desktop.
Save FagnerMartinsBrack/0a2e40687eb18b9a64d9034c69636b58 to your computer and use it in GitHub Desktop.
(Medium) The Role Of Affordance In Software Design
class Soldier {
handEquip(weapon) {
this.equipedWeapon = weapon;
}
useHandEquipmentAgainst(enemy) {
this.equipedWeapon.shoot(enemy);
}
}
class MachineGun {
open(bottle) {
alert('*Opening A Bottle With The Machine Gun*');
}
shoot(enemy) {
alert('*Shooting The Machine Gun Against The Enemy*');
}
}
// ...
const john = new Soldier();
john.handEquip(new MachineGun());
john.useHandEquipmentAgainst(new Soldier());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment