Skip to content

Instantly share code, notes, and snippets.

@tlync
Created September 25, 2013 02:06
Show Gist options
  • Save tlync/6694291 to your computer and use it in GitHub Desktop.
Save tlync/6694291 to your computer and use it in GitHub Desktop.
minimum DDD base
class Id[V](val id: V)
trait Entity[T <: Id[_]] {
val id: T
}
case class User(id: Id[String]) extends Entity[Id[String]]
trait Repository[ID <: Id[_], E <: Entity[ID]] {
def find(id: ID): E
def add(entity: E): E
def delete: E
}
class UserRepository extends Repository[Id[String], User]{
def find(id: Id[String]): User = ???
def add(entity: User): User = ???
def delete: User = ???
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment