Scala, Design Patterns, Programming, Factory Pattern.
RuntimeException("Unknown file type") } } } This is more extensible than letting the client create the concrete Reader implementations, cause in case the name of the Reader implementations change, instead of needing to change then the client code, with this approach only the ReaderFactory is needed