Below are oversimplified examples, but I wonder which route to take what is the best practice when designing API, the simple or the more complex and robust which is better?
This looks good and goes along with scala ADT concepts but I fear that it would become overly complex and the clients using my API will a little hate me for overcomplicating them with too many objects to think what to pass to my interface.
trait ProcessUpdate { def name: String def id: String def message: String } case class SuccessProcessUpdate(name: String, id: String, message: String) extends ProcessUpdate case class FailureProcessUpdate(name: String, id: String, message: String, e: Exception) ProcessUpdate def success(successUpdate: SuccessProcessUpdate) def fail(failUpdate: FailureProcessUpdate)
This is simple, I think the ones using this API will like me better, but not sure if it's robust enough.
trait ProcessUpdate { def name: String def id: String def message: String def e: Option[Exception] } case class ProcessUpdateInfo(name: String, id: String, message: String, e: Option[Exception]) def update(processUpdate: ProcessUpdate)
What do you think? is there a right answer? this example was oversimplified the more complex the thing the harder the question.