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

  • Home
  • SEARCH
  • 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 772501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:48:45+00:00 2026-05-14T18:48:45+00:00

I have a Contract class. The contract is valid 1 Jan 2010 – 31

  • 0

I have a Contract class. The contract is valid 1 Jan 2010 – 31 Dec 2010.

It can be in state Active or Passive, depending on which date I ask the instance for it’s state.
ex. if I ask 4 July 2010, it’s in state Active, but if I ask 1 Jan 2011, it’s in state Passive.

Statemachine diagram:

From Start state, which state should it go to next ?
I’m thinking a pseudo state “default” with an entry function deciding which state to go to next, and then a substate machine with Active and Passive, and then an End state on removal.

But this seems to complicated for such a trivial problem.

How would you do it ?

  • 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-05-14T18:48:45+00:00Added an answer on May 14, 2026 at 6:48 pm

    Hmm, you want either do what you describe, which will allow the Contract to be in invalid (start/end) state when someone tries to use the contact without prior date event, or you can try to add the call to that function in a constructor, so your contract is in proper state right away. There might be other solutions, but you should think about what other events (messages/method calls) can happen on the contract than the date. Some might affect the stae as well. BTW. your solution is not as complicated when you instead of embedding the state machine only connects the start and end to active and passive states.

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

Sidebar

Related Questions

I have a Contract class. The contract is valid 1 Jan 2010 - 31
Can a class have a Service Contract attribute and its methods Operation Contract. Or
I have a Silverlight Project which passes data using the Data Contract to a
I have a custom class Contact . I am trying to bind a List<Contact>
I have a contract in the offering from a client to develop an intranet
I have a service contract that defines a method with a parameter of type
I have a request for some contract work from an organization that uses Excel
I'm in a new contract where they seem to have gone overboard with Agile,
I have a method fetchObjects(String) that is expected to return an array of Contract
Do you use Design by Contract professionally? Is it something you have to do

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.