Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Great explanation, but it’s little bit confusing where it changes the object alternative.
- Neal
Hi and thanks for the nice post. The thing that I didn’t understand is what is the purpose of the context its only job is to call doAction() of the provided state, why don’t client code call doAction() of state instead, why do I need to create a Context that its only job is to call doAction() ? Thanks
- Adelin
According to me, this is an anti-pattern. This is like having a method whith a boolean parameter and 2 actions in it, depending on this boolean. It doesn’t respect the seperation of concerns and the single responsability principle : 1 method for 1 action. If i need to do the action 1 in a case and the action 2 in another case i’ll create action 1 and action2 méthods. With the same example : method 1 : public boolean isTheTvOn(); method 2 : public void turnOnTheTv(); method 3 : public void turnOffTheTv(); and determine the action to do in a service layer
- Mednnet
why TVContext needs to implement State interface ? I think its not required.
- Lalit Upadheyay
Please change all the references of “it’s” to “its”. They’re driving me crazy (as I work on my dissertation I am sensitive to these things).
- DrJ
This is just awesome. Explained one of the complex design patterns with such a easy example
- Praveen Srivastava
here TvContext implements State interface if i do TvContext tv=new TvContext(); tv.setState(tv); tv.doAction(); wont it start looping??
- deepak lodhi