Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Student, Course, Admin Design Question

 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the scenario in my application:

There are several courses and several registered users. Each user can either be a student that is pursuing a course or an admin to manage application content or both. Each user will have his/her profile attached.

I was thinking on couple of alternatives for domain model.

Alt - 1: User is an object. Student and Admin are roles (so I can have a Role object which is inherited by Student and Admin objects). Each User will have a list of roles attached. Each User will also have a UserProfile object attached. Student Role will have List of courses composed, and Admin role will have a List of AdminActivity objects composed.

With this structure I can treat all users equally. Login step will not differentiate between Admin and Student. More roles can be attached later if they come up, by inheriting from Role object. After login, depending on roles attached, UI will show task list. But one concern I have here is difference between the nature of Course and AdminActivity. I can have a super class above them to club them under same umbrella, but I am not fully convinced about it.

Alt - 2: User is an object. Student and Admin are derived from User. Each User will also have a UserProfile object attached. Student object will have List of courses attached, and Admin object will have a List of AdminActivity objects attached.

With this structure also I can treat all users equally. But the confusion I have is for students who also have Admin role (or some other role in future). How will application UI show Admin tasks as well as Student tasks together with single User object?

Can you help me make this picture clearer?
 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Varun,

For alt 1:

User is Role .. Does it make sense??? NO.
so forget about inheriting from Role. I Don't think it is required at all.

alt 2:
Student extends User
Admin extends User

What are the key differences in both [student and admin]???
Actually, as per my understanding,
Student and Admin are not siblings.

Admin is a kind of role. Don't you think so??


So lets put it this way
Student extends / [implements if appropriate] User
Professor extends User

And Student [Actually User if Student is inherited from it, because permissions will be there for all types of users] has a List of Permission

Now Permission is based on Activity [Say create User]
Each Activity[Key] -> [Values]Read ,Update, Create, etc.

In Admin you will have all Activity with create as true.

What do you say, you may have different ideas.

Regards,
Nachiket
[ December 13, 2008: Message edited by: Nachiket Patel ]
 
Varun Chopra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nachiket

Thanks for reply.
As I though more about it, I tend to agree with your ideas.
Admin does not exist in the scenario, it is only the activities that make a user an Admin. So I can just have

User
Student extends User
User composes ActivityList
Student composes CourseList

And ActivityList for a user will contain activities of a normal user and Admin user both if he/she's a student as well as admin.

What do you think of above summary?
 
Nachiket Patel
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello varun,

Yes, it seems okay,

Now everything depends upon requirements & intent of application.
You should explain in more detail, if you want to discuss more.

Regards,
Nachiket
 
Varun Chopra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One problem I still see is finding out if a user has Admin activities.
One requirement is to display ADMIN if a user has rights over ADMIN activities. So how to find this out? This probably indicates I need to group activities under heads (like STUDENT_ACTIVITIES, ADMIN_ACTIVITIES) and associate activity groups to user. What do you think?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic