3 ms·
Can't we just create a separate class, like a `Battle`? And then do `Battle.between(knight, mage)` where Battle would handle the negotiations between the two c
by hurflmurfl 8y ago
Can't we just create a separate class, like a `Battle`?
And then do `Battle.between(knight, mage)` where Battle
would handle the negotiations between the two classes? Maybe producing a result without mutating the two entities we pass as arguments.
I feel like it depends on what the business is. Is it tracking wizard adventures, fighter exp calculator or distributed battle log.
- choward 8y ago> Can't we just create a separate class, like a `Battle`? And then do `Battle.between(knight, mage)` Exactly. And at the end of the day all you're really doing is defining a function. Why do you need a class at all? Is it just because the language you're using doesn't allow standalone functions? If you're defining a static function that has no state on a class, you don't need the class at all. It's just a function that you want. battle(knight, mage)
- kingdomcome50 8y agoThe missing observation here is the `Battle` or `Collide` operate at a level of coordination. It is at this level where FP shines. Simply adding an `addDamage` method to the above system exemplifies where OOP shines. The above method works at lower, domain level, where the semantics of adding damage are specific to the object to which damage is being added. The point here is that _both_ paradigms should be employed.