Re:How I Learned to Stop Worrying and Love the State Machine
by paganel on Tuesday February 27, 2018 @08:09AM
(#16473027)
Until you want to model a bar-fight and then a chair (a piece of furniture) becomes a weapon, i.e. "class Chair: Furniture{}" turns into "Class Chair: Weapon {}". Or when the winter gets tougher and longer and "class Chair: Furniture{}" changes into "class Chair: Firewood{}". I know that there's probably a "solution" involving object "composition", but that would only mask the problem, will not really solve it.
[ Parent
| on HN ]
Re:How I Learned to Stop Worrying and Love the State Machine
by yojex on Tuesday February 27, 2018 @08:34AM
(#16473161)
Honest question: does anyone have a clean solution to this problem? I've run into this often and always end up hacking something ugly to make it work.
Re:How I Learned to Stop Worrying and Love the State Machine
by bushin on Tuesday February 27, 2018 @11:23AM
(#16474892)
You probably want to solve "the expression problem".
Re:How I Learned to Stop Worrying and Love the State Machine
by cellularmitosis on Thursday March 01, 2018 @01:06PM
(#16494471)
I'm not sure I understand your objection. Those are protocols, so Chair can adhere to all of them at once.
class Chair: Furniture, Weapon, Firewood {}