Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Design Question

Design Question

Scheduled Pinned Locked Moved .NET (Core and Framework)
designbusinessarchitecturehelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andy M
    wrote on last edited by
    #1

    I am doing a design where there is a menu of actions that the user can perform. This isn't about the user interface part. It is about the logic part. I've got a 3-teir architecture going and there are classes in the business logic layer that define what actions are available at a particular time. But there is a problem. I've discovered that there are 3 types of action, although there are many more actions than this. Some actions are optional (the user can choose whether or not to take those actions), some actions are mandatory (the user must take that action before a certain point. Before that point they may choose certain other optional actions, but not others), finally, there are potential actions (these are actions that the user has potentially available to them, but they must satisfy some other condition first before they can take that action. Some of those potential actions are optional and some are mandatory). So far I have an action class. I also have a potential action class, and a mandatory action. The potential action class contains a field which is an action object. The mandatory action class is an abstract base class. The actual actions derive from either the action itself, or the mandatory action class. What I am trying to do is keep coupling to a minimum, but I'm having problems with it. I also have a controller class that contains a list of the actions, this list is passed to the user interface. They user gets to see all the actions. However, if they pick a potential action where the condition is not met they get a message telling them what they need to do in order to take that action. The action of the potential action is to generate the message. I don't know if I'm explaining myself very well. I guess that is part of my problem. If I could explain it well, I would understand it enough not to need to ask the question. Any ideas would be welcome.

    L 1 Reply Last reply
    0
    • A Andy M

      I am doing a design where there is a menu of actions that the user can perform. This isn't about the user interface part. It is about the logic part. I've got a 3-teir architecture going and there are classes in the business logic layer that define what actions are available at a particular time. But there is a problem. I've discovered that there are 3 types of action, although there are many more actions than this. Some actions are optional (the user can choose whether or not to take those actions), some actions are mandatory (the user must take that action before a certain point. Before that point they may choose certain other optional actions, but not others), finally, there are potential actions (these are actions that the user has potentially available to them, but they must satisfy some other condition first before they can take that action. Some of those potential actions are optional and some are mandatory). So far I have an action class. I also have a potential action class, and a mandatory action. The potential action class contains a field which is an action object. The mandatory action class is an abstract base class. The actual actions derive from either the action itself, or the mandatory action class. What I am trying to do is keep coupling to a minimum, but I'm having problems with it. I also have a controller class that contains a list of the actions, this list is passed to the user interface. They user gets to see all the actions. However, if they pick a potential action where the condition is not met they get a message telling them what they need to do in order to take that action. The action of the potential action is to generate the message. I don't know if I'm explaining myself very well. I guess that is part of my problem. If I could explain it well, I would understand it enough not to need to ask the question. Any ideas would be welcome.

      L Offline
      L Offline
      Leslie Sanford
      wrote on last edited by
      #2

      Andy MacAngus wrote:

      I've got a 3-teir architecture going and there are classes in the business logic layer that define what actions are available at a particular time.

      So the actions that are mandatory and optional change over time? For example, an action that is optional at one point in time can become mandatory later? Can you model this as a state machine? Each state is responsible for providing a list of actions that are mandatory, optional, etc.

      A 1 Reply Last reply
      0
      • L Leslie Sanford

        Andy MacAngus wrote:

        I've got a 3-teir architecture going and there are classes in the business logic layer that define what actions are available at a particular time.

        So the actions that are mandatory and optional change over time? For example, an action that is optional at one point in time can become mandatory later? Can you model this as a state machine? Each state is responsible for providing a list of actions that are mandatory, optional, etc.

        A Offline
        A Offline
        Andy M
        wrote on last edited by
        #3

        Leslie Sanford wrote:

        So the actions that are mandatory and optional change over time? For example, an action that is optional at one point in time can become mandatory later?

        Not exactly, but I think this is probably going in the right direction. The states are: * Optional * Potential, but optional * Mandatory * Potential, but mandatory Potential meaning that a certain condition must be met first. Any potential action can transition to plain optional or mandatory. Certain actions are, by necessity, potential while there is a mandatory action available as the condition to be met is the invokation of the mandatory action. I will look in to state machines, but I have to admit to not having read much about them. I'll look for some information on it. If you know of a good article to read on the subject I'd be grateful for a recommendation. Cheers.

        L 1 Reply Last reply
        0
        • A Andy M

          Leslie Sanford wrote:

          So the actions that are mandatory and optional change over time? For example, an action that is optional at one point in time can become mandatory later?

          Not exactly, but I think this is probably going in the right direction. The states are: * Optional * Potential, but optional * Mandatory * Potential, but mandatory Potential meaning that a certain condition must be met first. Any potential action can transition to plain optional or mandatory. Certain actions are, by necessity, potential while there is a mandatory action available as the condition to be met is the invokation of the mandatory action. I will look in to state machines, but I have to admit to not having read much about them. I'll look for some information on it. If you know of a good article to read on the subject I'd be grateful for a recommendation. Cheers.

          L Offline
          L Offline
          Leslie Sanford
          wrote on last edited by
          #4

          Andy MacAngus wrote:

          The states are: * Optional * Potential, but optional * Mandatory * Potential, but mandatory Potential meaning that a certain condition must be met first. Any potential action can transition to plain optional or mandatory. Certain actions are, by necessity, potential while there is a mandatory action available as the condition to be met is the invokation of the mandatory action.

          What I was thinking is that you could have a list of all actions, maybe represent these actions as an enumeration. Your application has a number of discrete states. Each state understands which actions are optional, potential, etc. You could possibly store this information in some kind of lookup table. Anyway, my point is to not look necessarily at the actions as states, but rather have states that know what actions are mandatory, optional, etc. Also, if some actions are mandatory, you could have a state execute them regardless of whether the user has selected them. In your UI, you could make sure the right radio buttons, check boxes, or whatever are selected programmically (and maybe switch to readonly so they can't be deselected). I could go on and on. :) Hope this has given you some ideas.

          Andy MacAngus wrote:

          I will look in to state machines, but I have to admit to not having read much about them. I'll look for some information on it. If you know of a good article to read on the subject I'd be grateful for a recommendation.

          You may find Part I[^] of my State Machine Toolkit articles helpful. Here is an article[^] describing finite state machines and UML statecharts. And an article[^] by H. S. Lahman. One of my personal heros and a regular on comp.object.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups