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
Why an
int– why not anenum?Edit: Also, try not to scatter your
enumall over the place. Use your Comment class as a robust model, add functions forisActive()orisPending()— 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.