Skip to content

Commit

Permalink
Upgrade to 0.5.4 ('this' and 'self' correctly resolving to role-player)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcgrue committed Mar 16, 2015
1 parent cfea50c commit ce41be9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Add the following to your project file:

```scala
libraryDependencies ++= Seq(
"org.scaladci" %% "scaladci" % "0.5.2"
"org.scaladci" %% "scaladci" % "0.5.4"
),
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0-M5" cross CrossVersion.full)
```
22 changes: 9 additions & 13 deletions demo/src/main/scala/MoneyTransferApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import scaladci._
4. Define role methods (what will those actors do...)
5. Define the trigger that starts off the chain of interactions between the roles
Normally we lowercase parameter names. "Source" and "Destination" of the MoneyTransfer
DCI context are an exception since we want to associate them with our role definitions.
A role definition has to match an object identifier in the context scope. Not necessarily
a class parameter, any val/var will do as long as the identifier name matches a defined role.
Compared to this school-book example, Data classes, DCI Contexts and the runtime
environment would of course normally be in separate tiers.
More info - http://github.com/dci/scaladci
Official website - http://fulloo.info
Discussions - https://groups.google.com/forum/#!forum/object-composition
Expand All @@ -30,22 +25,22 @@ object MoneyTransferApp extends App {
def decreaseBalance(amount: Int) { balance -= amount }
}

// DCI Context - encapsulates a specific "process"/"use case"/"network of interactions" etc
// DCI Context - encapsulates a network of interactions between role-playing objects (often implementing a use case)
@context
class MoneyTransfer(Source: Account, Destination: Account, amount: Int) {
class MoneyTransfer(source: Account, destination: Account, amount: Int) {

Source.withdraw // Trigger method setting off the use case
source.withdraw // Trigger method setting off the use case

role Source { // Role definition
role source { // Role definition
def withdraw() { // Role method
Source.decreaseBalance(amount) // Instance method
Destination.deposit // Role interacts with other role
source.decreaseBalance(amount) // Instance method
destination.deposit // Role interacts with other role
}
}

role Destination {
role destination {
def deposit() {
Destination.increaseBalance(amount)
destination.increaseBalance(amount)
}
}
}
Expand All @@ -63,4 +58,5 @@ object MoneyTransferApp extends App {
// Confirm that amount has transferred
assert(salary.balance == 3000 - 700, s"Salary balance should have been 3000 - 700 = 2300. Is now ${salary.balance}")
assert(budget.balance == 1000 + 700, s"Budget balance should have been 1000 + 700 = 1700. Is now ${budget.balance}")
println("SUCCES!")
}
4 changes: 2 additions & 2 deletions project/build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ object ScalaDciDemoBuild extends Build {

lazy val commonSettings = Defaults.coreDefaultSettings ++ Seq(
organization := "org.scaladci",
version := "0.5.2",
version := "0.5.4",
scalaVersion := "2.11.6",
scalacOptions := Seq("-unchecked", "-deprecation", "-feature"),
resolvers ++= Seq(Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots")),
libraryDependencies ++= Seq(
"org.scaladci" %% "scaladci" % "0.5.2"
"org.scaladci" %% "scaladci" % "0.5.4"
),
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0-M5" cross CrossVersion.full)
)
Expand Down

0 comments on commit ce41be9

Please sign in to comment.