Showing unapproved comments in a discussion system In my project (which is a discussion system) there are approved and unapproved comments. There's a class that tells if unapproved comments should be shown. But I cannot think of a good name for this class. Right now it's named ShowUnapproved but doesn't that sound like a Boolean? (Rather than a configuration setting.)

Is the name ShowUnapproved clear to you? Or can you think of a better name?

Here is the class:

sealed abstract class ShowUnapproved {
  def shallShow(post: Post): Boolean // a "post" is e.g. a comment
}


object ShowUnapproved {

  case object None extends ShowUnapproved {
    override def shallShow(post: Post) =
      post.someVersionApproved
  }

  case object All extends ShowUnapproved {
    override def shallShow(post: Post) = true
  }

  case class WrittenByUser(userId: String) extends ShowUnapproved {
    override def shallShow(post: Post) =
      post.userId == userId
  }
}


Here're two examples of how to use it:

PageReneder.renderPage(page, ShowUnapproved.All)
PageReneder.renderPage(page, ShowUnapproved.WrittenByUser(userId))


And what would you call instances of this ShowUnapproved class?

I'm currently naming them showUnapproved which definitively sounds like a Boolean to me, and might be confusing:

val showUnapproved = ...  // sounds like a Boolean but it is not

val anyPendingApprovalText: NodeSeq =
  if (showUnapproved.shallShow(post)) makePendingApprovalText(post)
  else Nil
  // does `showUnapproved.shallShow` above sound good to you?
What about something like this:

sealed abstract class CommentVisibility {
  def shallShow(comment: Comment): Boolean
}

object CommentVisibility {
  case object HideUnapproved
  case object ShowUnapproved
  case class ShowAllByUser(userId)
}


Usage:

renderPage(page, CommentVisibility.ShowUnapproved)


That's easy to understand :-) And can be amended to include e.g. showing/hiding comments with too many flags. (One would add another case class, perhaps using the Composite design pattern)

And reminds of CSS I think: "visibility: hidden / visible"