• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need a better design approach for my requirment

 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all

I have set of roles like approver,initiator.
Actions like approve ,reject ,withdraw etc.
user can take this actions on a message depending upon the message status, which can have different value like
DRAFT,AWAITING_APPROVAL,APPROVED.

User should be able to perform a subset of actions based on the user role and the message status.
If he is approver and he should be able to see the 'Approve' button .
If clicks on approve then message should changed its status to APPROVED.

All the actions will inturn update the database,log the action, send the mail etc.Each action can have a different variation of these subtasks.

Can you people suggest me a better approach or a design pattern where i can design a flexible application . so that tomorrow i can add new action or i can add or delete subtask with little change.

Thanks for Reading.
Raj
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use constants to represent those message statuses in some class.

For the roles, why not create a class for each role? A class called Approver, Initiator etc. But now the problem is all these classes need to have a superclass (eg Role) to act as the umbrella. So that in your code you can use polymorphism and just do:

And each user can most like be part of many roles then you need a class called say Group. The whole idea is like MS Windows Active Directory or Unix user policy. A user can be admin, power user bla bla bla.
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you think there should be Role, Approver classes?
What methods will the Role class has, and what are different behaviors between Role and Approver?

These questions need to be answers before come up with Role and Approver classes.
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's a very good question. Well it's not my project... I just suggesting.
 
reply
    Bookmark Topic Watch Topic
  • New Topic