Skip to content

Instantly share code, notes, and snippets.

@ctataryn
ctataryn / composing service layers in scala.md
Created March 28, 2017 16:21 — forked from aappddeevv/composing service layers in scala.md
scala, cake pattern, service, DAO, Reader, scalaz, spring, dependency inejection (DI)

#The Problem We just described standard design issues you have when you start creating layers of services, DAOs and other components to implement an application. That blog/gist is here.

The goal is to think through some designs in order to develop something useful for an application.

#Working through Layers If you compose services and DAOs the normal way, you typically get imperative style objects. For example, imagine the following:

  object DomainObjects {
It has been 5 years now, since I got myself involved into JavaScript. Be it developing projects, guiding people or publishing articles; I feel like, JavaScript gave me an identity, scope and most importantly satisfaction. Thanks JavaScript!
In the last 5 years years I worked heavily in many JavaScript frameworks, be it back or front-end. But Ember was disappeared from my life since 2015 mid. I involved my life in other tools and frameworks of JavaScript. Fortunately one month ago I got a chance to work with a client who wanted me to develop his project in Ember. I was not much excited as ember was a known guy to me, but started developing the project as it’s a day to day life for me. But after delivering the project I started thinking of my experiences with these three front-end frameworks and probably today publishing this article out of my emotions.
Disclaimer
This article is NOT about blaming or lashing out at Angular or React.
This article is NOT about going very deep in technical aspects of these thre
$ docker-compose up
Starting tpreregui_server_1
Starting tpreregui_ember_1
Starting tpreregui_bower_1
Starting tpreregui_npm_1
Attaching to tpreregui_ember_1, tpreregui_npm_1, tpreregui_server_1, tpreregui_b
ower_1
←[33mnpm_1 |←[0m npm info it worked if it ends with ok
←[33mnpm_1 |←[0m npm info using npm@2.14.7
←[36member_1 |←[0m node_modules appears empty, you may need to run `npm instal
def getContentsByUser(userId: UUID, adopted: Boolean = false): Either[UserNotFoundError, List[Content]] = {
getDatabase withDynSession {
val subQuery =
adopted match {
case false => {
for {
uc <- UserContentTable.query if uc.userId === userId.toString && (!uc.adopted.isDefined || !uc.adopted)
c <- ContentTable.query if uc.contentId === c.id
}
yield (uc, c)
[info] Compiling 20 Scala sources to /Users/craiger/workspace/Grind/slick-3.0/target/scala-2.10/classes...
[error]
[error] while compiling: /Users/craiger/workspace/Grind/slick-3.0/src/main/scala/csslick3/ChunkTable.scala
[error] during phase: typer
[error] library version: version 2.10.5
[error] compiler version: version 2.10.5
[error] reconstructed args: -classpath /Users/craiger/workspace/Grind/slick-3.0/target/scala-2.10/classes:/Users/craiger/.ivy2/cache/org.mockito/mockito-all/jars/mockito-all-1.9.5.jar:/Users/craiger/.ivy2/cache/mysql/mysql-connector-java/jars/mysql-connector-java-5.1.26.jar:/Users/craiger/.ivy2/cache/com.typesafe.slick/slick_2.11/bundles/slick_2.11-3.0.3.jar:/Users/craiger/.ivy2/cache/com.typesafe/config/bundles/config-1.2.1.jar:/Users/craiger/.ivy2/cache/org.reactivestreams/reactive-streams/jars/reactive-streams-1.0.0.jar:/Users/craiger/.ivy2/cache/commons-codec/commons-codec/jars/commons-codec-1.8.jar:/Users/craiger/.ivy2/cache/ch.qos.logback/logback-classic
Started by user anonymous
Building on master in workspace E:\JW\Deposit Submission Folder\tpr-dsub-ui
> E:\Program Files\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> E:\Program Files\Git\bin\git.exe config remote.origin.url git@bitbucket.org:tprmbca/tpr-dsub-ui.git # timeout=10
Fetching upstream changes from git@bitbucket.org:tprmbca/tpr-dsub-ui.git
> E:\Program Files\Git\bin\git.exe --version # timeout=10
using GIT_SSH to set credentials
> E:\Program Files\Git\bin\git.exe -c core.askpass=true fetch --tags --progress git@bitbucket.org:tprmbca/tpr-dsub-ui.git +refs/heads/*:refs/remotes/origin/*
> E:\Program Files\Git\bin\git.exe rev-parse "origin/dev^{commit}" # timeout=10
// implicit val chunkStateType = MappedColumnType.base[ChunkState,String](
// { cs:ChunkState => cs.toString},
// { s: String => ChunkState.valueOf(s).get}
// )
val query =
userDistributionQuery.leftJoin(ChunkTable.query.filter { c => c.state === (ChunkState.ASSIGNED:ChunkState) } )
.on { case ((u_id, d_id), c) => c.distributionId === d_id && c.transcriberId === u_id }
.map { case ((u_id, d_id), c) => c.id.? }
implicit val chunkStateType = MappedColumnType.base[ChunkState,String](
{ cs:ChunkState => cs.toString},
{ s: String => ChunkState.valueOf(s).get}
)
val query =
userDistributionQuery.leftJoin(ChunkTable.query.filter { c => c.state === ChunkState.ASSIGNED.toString } )
.on { case ((u_id, d_id), c) => c.distributionId === d_id && c.transcriberId === u_id }
.map { case ((u_id, d_id), c) => c.id.? }
class ChunkTable(tag:Tag) extends Table[ChunkModel] (tag, "chunk") {
//Other columns...
def state = column[ChunkState]("state")