I am trying to implement an object-oriented design for stack overflow. I have Member, Question, Answer, Comment object. (not considering tags, bounty other objects for simplicity). I am not able to figure out the storage of data in design.
The user creates a question, Answer, Comment with a title and description. I am not able to figure out where I should save the data because these objects belong to the user and global search also. Answer and comment can also happen on any question but they belong to the user also. so the problem is to store the data user-specific and global.
I have a thought process to create a repository that will keep data for questions, answers, and comments. I can store questionsIds, answerIds, commentIds in member object. similarly, anserIds and comments in Question object. I am not sure it's good practice for object-oriented design or not.
public class Member {
private long memberId;
// few more properties
Member(){
}
public long createQuestion(String title, String description){ return 1;}
public long createAnswer(long questionId, String description){ return 1;}
public long createQuestionComment(long questionId, String description){ return 1;}
public long createAnswerComment(long answerId, String description){ return 1;}
}
public class Question {
private long id;
private String title;
private String description;
Question(String title, String description){
}
}
In case, you want more details. I will create a UML dig for more explanation. If someone knows about any good article please refer me there. If you know about any good book where I can learn more about the object-oriented approach please let me know that also.
Aucun commentaire:
Enregistrer un commentaire