Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8308531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:50:23+00:00 2026-06-08T18:50:23+00:00

There’s a task connected with changing state of an entity . And I’m quite

  • 0

There’s a task connected with changing state of an entity. And I’m quite confused thinking whether it should be an event-based approach which involves something like CQRS or I can use a State pattern and leave all logic inside the entities.

I have found an article which shows a domain model (or a piece of it) that uses a State pattern: http://www.prowareness.com/blog/?p=1448

Ordering system is quite close to my domain model. So the example is great. But still I’m wondering if it is a good practice considering MVC pattern and if it is possible to implement with RavenDB/NHibernate?

EDIT: question rethought

Let’s follow the example:

First, here’s a domain entity called Idea:

[Serializable]
public class Idea : AbstractEntity<Guid> {
    private static IStateFactory stateFactory;
    private AbstractState state = new InitiatedState();

    [Required, StringLength(150)]
    public String Title { get; set; }
    [Required]
    public String ProblemContext { get; set; }
    public DateTime CreatedOn { get; set; }
    public Guid InitiatorId { get; set; }
    [Required]
    public Decimal InvestmentAmount { get; set; }

    public Boolean IsInitiated {
        get { return this.state.IsInitiated; }
    }
    public Boolean IsRejected {
        get { return this.state.IsRejected; }
    }
    public Boolean IsUnderInitialAssessment {
        get { return this.state.IsUnderInitialAssessment; }
    }
    public Boolean IsConfirmedForImplementation {
        get { return this.state.IsConfirmedForImplementation; }
    }
}

Whereas AbstractState is:

public abstract class AbstractState {
    public virtual Boolean IsInitiated {
        get { return true; }
    }
    public virtual Boolean IsRejected {
        get { return false; }
    }
    public virtual Boolean IsUnderInitialAssessment {
        get { return false; }
    }
    public virtual Boolean IsConfirmedForImplementation {
        get { return false; }
    }
}

and state factory interface is defined like this:

public interface IStateFactory {
    AbstractState GetState(String state);
}

the final thought is to put the method:

public void AlterState(String stateString) {
    this.state = stateFactory.GetState(stateString);
}
  1. Is the design ok? what are the cons and pros?
  2. What about extensibility? From my perspective one can extend/implement its own state factory. But if there’s a change in AbstractState itself everything changes accordingly.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:50:24+00:00Added an answer on June 8, 2026 at 6:50 pm

    You maybe interested in Stateless, a hierarchical state machine by Nicholas Blumhardt. Read this my SO answer here regarding it’s capability. Here is a simple workflow processor example from my blog, and I currently use it with the Pipe and Filter pattern, and it works quite nicely.

    Edit

    I also have an implementation that uses Stateless with RavenDB if you are interested.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are a lot of blogs saying that a hasOwnProperty check should be used
There's quite a few solid tutorials out there, and I haven't had too much
There is a moment in my app, that I need to force to show
There is a column that exists in 2 tables. In table 1, this column
There's a Rails 3.2.3 web application which doesn't use any database. But in spite
There is a directed graph having a single designated node called root from which
There are two intents on the receiver side which are called from the same
There are nice SO question and answers about this issue, but these options didn't
There are two table s : one is the master and one the detail
There was a similar question posted asking in general about alternatives to Qt. Well,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.