State pattern question - Java

This is a discussion on State pattern question - Java ; Hi,
We use the state pattern to get rid of plenty of if-if else -statements.
In each concrete state we need to access id's that can be created in any
state. All concrete states ( for this conntext) needs to ...

State pattern question

Hi,

We use the state pattern to get rid of plenty of if-if else -statements.
In each concrete state we need to access id's that can be created in any
state. All concrete states ( for this conntext) needs to access id's.

I don't want to create an instance for containing id's and pass that in the
constructor for each concreate state.

Re: State pattern question

Mikael Petterson wrote:
> Hi,
>
> We use the state pattern to get rid of plenty of if-if else -statements.
> In each concrete state we need to access id's that can be created in any
> state. All concrete states ( for this conntext) needs to access id's.
>
> I don't want to create an instance for containing id's and pass that in the
> constructor for each concreate state.
Don't use IDs, let the object identity itself be the "id" of the state.
Thats one of the points of using the State pattern.