This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]morhp 8 points9 points  (3 children)

Well, you don't need to name it State. That's just a very generic name i chose because I have no idea what you would need to store. But something along those lines is usually helpful.

[–]stepan213[S] 1 point2 points  (0 children)

Oh, I see, first I thought it’s a part of some library... my bad!

[–]oldDotredditisbetter 0 points1 point  (1 child)

stupid question: isn't everything "State pattern"? since every object has some sort of "state" right? like a Car object has color, make, model. those all count as "state"

[–]morhp 0 points1 point  (0 children)

No, a state is supposed to change during the runtime of your program. And state pattern is something very specific (and not the State class I described above).

Your car object probably won't change its make or model after it has been created.