简体   繁体   中英

What does it mean when object extends class with no implementation

object PostgresDriver extends PostgresDriver

I see this in slick with no implementation whatsoever. I am wonder does that just automatically create a singleton class?

This is pretty standard practice, defining a trait to represent the abstraction and then providing a standard implementation of that trait as an object. If you just do it as the object you don't have an abstraction to refer to it as and stuff like that can make mocking and testing difficult at the least

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM