Comparing Two Design Ideas
I am developing an online service and I need to validate users and process text messages. I have two ideas for this. Can you tell me which idea you think is better and more OO?
1) Create a User object to validate the packet's sender every time I receive a packet. The User object will be forgotten after the verification is done by garbage collection. Create a Message object to process a message every time a text message packet is received. The Message object will be forgotten like the User. The User will verifyitself and the Message will processitself.
Example:
class User{
public User(String userID){
...
}
publicvoid validateYourself(){
...
// queries MySQL database for this ID and validates the user
}
}
class Message{
public Message(String from, String message){
...
}
publicvoid processYourself(){
...
}
}
2) Create a UserManager object and a MessageManager object when the program starts. The UserManager and MessageManager will stay alive for the duration of the program. The UserManager will validateany user and the MessageManager will validateany message.
Example:
class UserManager{
public UserManager(){
...
}
publicvoid validateUser(String id){
...
}
}
class MessageManager{
public MessageManager(){
...
}
publicvoid processMessage(String from, String msg){
...
}
}

