Reputation: 760
I have some web application for placement on external sites. This application is a widget for comments like disqus (disqus.com).
Each comment it's a entity object with fields: "author", "body", "time" and etc. In additional to these fields comment object has field with name "active" That is:
@Entity
class Comment {
private User author;
private String body;
//... and a lot of many other attributes
private boolean active;
}
The "active" field used to separate active and deleted comments. If "active" == false the comment is deleted, if no it's active.
Very soon I will introduce a functional which allows to pre-moderation of comments. That is user publishes a comment but until administrator has not approved it, comment still not active.
So the question is what's the best way to make it?
I see two ways:
1) Change "active" field from boolean to int and keep the status of comment,
for instance: 0 - pre-moderation, 1 - active (approved), -1 deleted, -2 not approved may be some thing else...
2) Leave "active" boolean field and added additional field for status
Upvotes: 0
Views: 157
Reputation: 4544
Why an int
- why not an enum
?
enum CommentStatus {
Deleted, Pending, Active
}
Edit: Also, try not to scatter your enum
all over the place. Use your Comment class as a robust model, add functions for isActive()
or isPending()
-- whether you use one field or two, or whether you use an enum or an int, that's an implementation detail. Hide that shizzle, yo.
Upvotes: 2