design-patterns icon indicating copy to clipboard operation
design-patterns copied to clipboard

Implement GetState at GumballMachine

Open kaiosilveira opened this issue 2 years ago • 0 comments

This method is currently only implemented at the TestingGumballMachine for test purposes as I was worried about allowing clients to change the state of the machine if they decided to call methods on the state objects themselves. To fix this, I could implement the Prototype Pattern on each state so I can call Copy() when returning the state to the client. There’s still a problem with the instance of GumballMachine being kept at each state. I can recreate it defaulting to a NoOpGumballMachine or something

kaiosilveira avatar Oct 01 '22 10:10 kaiosilveira