Learning the State Pattern