Can anybody share example of using state pattern with flyweight pattern (flyweight pattern is for creating state objects to save memory)?
UPDATE:
How to use a combination of state and fw patterns?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Autoboxing uses the flyweight pattern to minimise object creation (for small values of Integer)
e.g. for Boolean and Byte all possible values are cached.
Java uses states for many components, however a state machine also includes functionality switched by state.
Here is an example I wrote using
enumhttp://vanillajava.blogspot.com/2011/06/java-secret-using-enum-as-state-machine.html