cake-pattern

    5熱度

    1回答

    我想了解蛋糕模式。 我在閱讀this的博客。 從博客的示例代碼: case class User (name:String,email:String,supervisorId:Int,firstName:String,lastName:String) trait UserRepository { def get(id: Int): User def find(usernam

    3熱度

    1回答

    我試圖找出通過蛋糕模式混合特質和通過老式延伸混合它們之間的區別是什麼。這裏是我的兩個例子: 威盛蛋糕 trait N { def foo() } trait M { this: N => def bar() } class U extends M with N { def bar() =() def foo() =() } 什麼蛋

    0熱度

    1回答

    我想實現像代碼蛋糕的圖案,但我得到: Error:(47, 36) illegal inheritance; self-type app.server.im.Im_Api_Service_Impl.type does not conform to app.server.im.Persistence[app.server.im.State.State]'s selftype app.server.

    0熱度

    1回答

    在Internet上發現的所有與Cake patter相關的文章中,我都看到了單個級別的依賴關係,這對我來說很清楚。 但是當我開始使用它時,我遇到了一個問題,我不能僅在高級別類中使用服務,而且我需要將它混合到多個位置。 例如,如果我有一個服務,並且此服務與其他一組服務一起工作,並且此組中的每個服務都使用一個數據庫,我嘗試不直接訪問來自這組低級服務的數據庫。我僅在高級服務中完成所有數據庫查詢。 但在

    1熱度

    1回答

    我讀過一些關於Scala的蛋糕模式的文章,基本理解它。以下是我從這篇文章複製了一些示例代碼: 組件: case class User(username:String, password: String) trait UserRepositoryComponent { val userRepository: UserRepository class UserReposito

    1熱度

    1回答

    我有下面的類層次結構: abstract class Event(val timeStamp:Long,val id:Long) case class StudentEvent(override val timeStamp:Long, override val id:Long, firstName:String,lastName:String) extends Event(t

    0熱度

    2回答

    我有一個像下面兩個服務類... 用戶服務: class UserService { dao: UserGroupDao => ... def read(userId: String): Future[Option[User]] = dao.readUser(userId) ... } 集團服務: class GroupService {dao: UserGroupDao => def

    0熱度

    1回答

    我有一個特點,代表了一些模塊,暴露出一些公共方法(覺得服務): trait X { def exposeMe: AService = ... def keepMeHidden: BService = ... } 然後,我有一個Y模塊,需要服務從X 。 Y的客戶還需要X提供一項服務。但我不希望他們只依賴這一項服務,而要依靠整個X。我想要「出口」一種服務是公開的。 trait

    4熱度

    1回答

    我一直在玩蛋糕模式,有一些我不完全理解。 考慮到下面的相同代碼: trait AServiceComponent { this: ARepositoryComponent => } trait ARepositoryComponent {} 混合它們的以下方式運行 trait Controller { this: AServiceComponent => } o

    4熱度

    1回答

    我想知道在Scala中使用函數和DI模式的區別。我想出了以下的理解,我想知道這種理解是否正確。 讓我們來想象一個依賴關係圖。 1)如果我們使用函數作爲構建塊,那麼該圖包含函數作爲節點和參數作爲邊。 2)如果我們使用traits作爲構建塊(如在Cake中),那麼該圖包含作爲節點的特徵和作爲邊的抽象成員。 那麼Cake模式的目的是什麼?爲什麼2比1好?這是當然顆粒化。圖-1可以通過將函數分組成特徵來簡