Skip to content

Commit ce41be9

Browse files
committed
Upgrade to 0.5.4 ('this' and 'self' correctly resolving to role-player)
1 parent cfea50c commit ce41be9

3 files changed

Lines changed: 12 additions & 16 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Add the following to your project file:
1818

1919
```scala
2020
libraryDependencies ++= Seq(
21-
"org.scaladci" %% "scaladci" % "0.5.2"
21+
"org.scaladci" %% "scaladci" % "0.5.4"
2222
),
2323
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0-M5" cross CrossVersion.full)
2424
```

demo/src/main/scala/MoneyTransferApp.scala

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,9 @@ import scaladci._
99
4. Define role methods (what will those actors do...)
1010
5. Define the trigger that starts off the chain of interactions between the roles
1111
12-
Normally we lowercase parameter names. "Source" and "Destination" of the MoneyTransfer
13-
DCI context are an exception since we want to associate them with our role definitions.
1412
A role definition has to match an object identifier in the context scope. Not necessarily
1513
a class parameter, any val/var will do as long as the identifier name matches a defined role.
1614
17-
Compared to this school-book example, Data classes, DCI Contexts and the runtime
18-
environment would of course normally be in separate tiers.
19-
2015
More info - http://github.com/dci/scaladci
2116
Official website - http://fulloo.info
2217
Discussions - https://groups.google.com/forum/#!forum/object-composition
@@ -30,22 +25,22 @@ object MoneyTransferApp extends App {
3025
def decreaseBalance(amount: Int) { balance -= amount }
3126
}
3227

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

37-
Source.withdraw // Trigger method setting off the use case
32+
source.withdraw // Trigger method setting off the use case
3833

39-
role Source { // Role definition
34+
role source { // Role definition
4035
def withdraw() { // Role method
41-
Source.decreaseBalance(amount) // Instance method
42-
Destination.deposit // Role interacts with other role
36+
source.decreaseBalance(amount) // Instance method
37+
destination.deposit // Role interacts with other role
4338
}
4439
}
4540

46-
role Destination {
41+
role destination {
4742
def deposit() {
48-
Destination.increaseBalance(amount)
43+
destination.increaseBalance(amount)
4944
}
5045
}
5146
}
@@ -63,4 +58,5 @@ object MoneyTransferApp extends App {
6358
// Confirm that amount has transferred
6459
assert(salary.balance == 3000 - 700, s"Salary balance should have been 3000 - 700 = 2300. Is now ${salary.balance}")
6560
assert(budget.balance == 1000 + 700, s"Budget balance should have been 1000 + 700 = 1700. Is now ${budget.balance}")
61+
println("SUCCES!")
6662
}

project/build.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ object ScalaDciDemoBuild extends Build {
1818

1919
lazy val commonSettings = Defaults.coreDefaultSettings ++ Seq(
2020
organization := "org.scaladci",
21-
version := "0.5.2",
21+
version := "0.5.4",
2222
scalaVersion := "2.11.6",
2323
scalacOptions := Seq("-unchecked", "-deprecation", "-feature"),
2424
resolvers ++= Seq(Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots")),
2525
libraryDependencies ++= Seq(
26-
"org.scaladci" %% "scaladci" % "0.5.2"
26+
"org.scaladci" %% "scaladci" % "0.5.4"
2727
),
2828
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0-M5" cross CrossVersion.full)
2929
)

0 commit comments

Comments
 (0)