Hello there. I'm trying to design a system in Java that recognizes users (more than one kind). I'm not sure how to approach this in an Object Oriented way.
There are two kinds of users: regular and admin. The regular ones don't do much except send messages to the system and sometimes receive files or messages from the system. The administrators do regular administrator tasks. Regular users' accounts expire after a certain time (for example, in 24 hours). Admins never expire.
So I'm wondering, should I create an Interface class and then have User and Admin classes implement the Interface class?
Is it even a good idea to have each user as a separate object? I was thinking of creating one object per user, and when the time expires, the object is destroyed. And if that IS a good idea, I'm not sure I know how to dynamically create objects like that. To clarify, let's say I have an event method onFoo() and within that method, I want to create a new regularUser object. I can't just write regularUser fooUser = new regularUser() can I? Since there will be more than one regular user object... I'm very confused now.
Thanks in advance for any advice.
There are two kinds of users: regular and admin. The regular ones don't do much except send messages to the system and sometimes receive files or messages from the system. The administrators do regular administrator tasks. Regular users' accounts expire after a certain time (for example, in 24 hours). Admins never expire.
So I'm wondering, should I create an Interface class and then have User and Admin classes implement the Interface class?
Is it even a good idea to have each user as a separate object? I was thinking of creating one object per user, and when the time expires, the object is destroyed. And if that IS a good idea, I'm not sure I know how to dynamically create objects like that. To clarify, let's say I have an event method onFoo() and within that method, I want to create a new regularUser object. I can't just write regularUser fooUser = new regularUser() can I? Since there will be more than one regular user object... I'm very confused now.
Thanks in advance for any advice.