|
|
|
|
|
by crooked-v
2962 days ago
|
|
This is interesting. Though, for my part, rather than... class Player {
playTurn(warrior) {
warrior.walk();
...
}
}
...I would much rather have something like... import { Warrior } from '@warriorjs/cli';
class MyWarrior extends Warrior {
playTurn() {
this.walk();
...
}
}
...or... function playTurn(warrior) {
warrior.walk();
...
}
The current style is a weird mix of functional and object-oriented handling. |
|
The differences in purpose of the two entities aren't really anything to do with fp vs oop; I don't see what's fp-ish about the first example, and your last example is potentially a weird mix of fp and oop (depending on what "warrior" is, and I can't figure out what use it would be in that context if it wasn't an object with encapsulated methods)