state-pattern

State pattern with SAX

I have to parse some xml with java SAX parser. As I was busy, I saw that the state pattern could be used here. There are clear states and state transitions defined, resembling the structure of the xml document. To implement the state pattern, I have to define a interface (or abstract class). The most obvious interface methods would b...

State Pattern in iPhone applications (Memory Usage)

Does the state pattern in an iPhone application -- In my case, a relatively light-weight utility application -- use too much memory? The state pattern, as I understand it, uses several classes; these classes represent different states. All of the different state objects are instantiated and stored in different pointer variables until t...

The "state design pattern" could be considered an "architectural pattern"?

"An architectural pattern expresses a fundamental structural organization schema for a software system". There are software systems that can be described as finite-state machines (specially many real-time systems and embedded systems), if we consider the previous description given in the first paragraph for an "architectural pattern", ...

Design Problem - Using a 'variation' on State Pattern - C++

Overview: I am trying to improve the design of a program that I am using state pattern for. I will post a brief description of the problem, an image of the class diagram/description of the current design, followed by header code for the relevant classes. Problem: I'm using a variation of the State Pattern for a program. In this ...

What is the difference between Strategy Design pattern and State Design pattern?

What is the difference between Strategy Design pattern and State Design pattern? I was going through quite a few articles on the web but could not make out the difference clearly. Can somebody please explain in layman's terms? ...

Can State Pattern help with read only states?

I'm trying to model a certain process and I'm thinking that the State Pattern might be a good match. I'd like to get your feedback though about whether State will suit my needs and how it should be combined with my persistence mechanism. I have a CMS that has numerous objects, for example, Pages. These objects (we'll use the example o...

How to state pattern with asp.net mvc?

Hi One question but I'm looking for two solutions: static dynamic Static means I know all states. Dynamic means I don't know states because end user can define it. Static How to create and organize views, viewmodels and actions? I know that state pattern is well suited for that scenario but how to pass data from view models and put ...

NHibernate and State Pattern persistance - a good implementation?

Below is my implementation of the state pattern. In order to persist the State object to my database with NHibernate, I am assigning each state class an enum value. This is stored as a private field on the entity, and mapped to a integer field in my database table. I want to know whether this is a good implementation as I will be using ...

State pattern: Why doesn't the context class implement or inherit the State abstract interface/class?

I'm reading about the State pattern. I have only just begun, so of course I begin by reading the entire Wikipedia article on it. I noticed that both of the examples in the article have some base abstract class or Java interface for a generic State's methods/functions. Then there are some states which inherit from the base and implement ...

State pattern: why states are not Singletons?

I've used the State pattern to implement a simple finite state machine. Looking at the description given on Wikipedia, and more specifically at the suggested Java implementation, I wondered why classes implementing the State interface (i.e. the various states) are not Singletons? In the suggested implementation a new State is created wh...

State pattern in Java

I've read about state pattern and now I'm looking to further my knowledge by exploring a Swing application (exple : calculator) that implements it. where can I find such a tutorial ? it must showcase a really simple application that uses Swing. I'm confused about how the State Pattern could be used in a Swing project ? ...

Fluent NHibernate Mapping - State Pattern

Hi, I'm not too hot on NHibernate / FNH Mapping but I am looking at implementing the state pattern and like the idea of Derick Bailey's article here: I beleive this was a while ago so the mapping code is out of date, can someone give me a hand to update it for FNH 1.1? public class OrderStatusMap: ClassMap<OrderStatus> { public Ord...

Model Profiles as Pattern Instances

Suppose you have a profile for an application. This profile stores some data specifically about one user. You can persist the details of the profile and pull them back each run. Does a profile make a good candidate for the State pattern? If not, is there a good heuristic to model this sort of functionality? ...