Wednesday, August 1, 2018

Object-Oriented Patterns: A Simplified Look at State Patterns in Java

There are tons of articles and videos about using object-oriented patterns. If you cannot find a truly good example that resonates with your pre-existing understanding of Java, it becomes a little hard to understand it.  When I was biking with my 8-year-old son, I was always reminding him to gear down when he is biking uphill and to gear up when we are going flat or downhill. This gearing is a great example of how to use the State design pattern. For this tutorial, I will demonstrate the State design pattern through a biking example. I hope it will resonate with your learning style and be easily remembered for future reference.

First, I need to have a bike class. It should be pretty simple:



from DZone.com Feed https://ift.tt/2voDFBU

No comments:

Post a Comment