I have a number of function pairs to manipulate resource, for example:
def loadFile(name: String): Option[String]
def writeFile(name: String, data: String): ???
loadFile is currently implemented to return resultant String using Option Some/None but what about writeFile?
Like loadFile, if writeFile fails I would like it to return a response wrapped in a nice Try or Option rather than throw an exception or return a null, Boolean, or response code.
What are some recommended best practices?
def writeFile(name: String, data: String): Try(Unit)
or
def writeFile(name: String, data: String): Option(Unit)
and just test success flag?
What is the best scala-thonic way to approach this?