-
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework interface definition to cleanly show openAccount. Add HINTS.md… #221
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## Hints | ||
|
||
This exercise is testing mutable state that can be accessed saftely from multiple threads. Scala provides a variety of ways to protect | ||
mutable state. For developers familiar with Java concurrency, Scala can utilize the Java concurrency support such as the Java synchronized block. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
trait BankAccount { | ||
|
||
def closeAccount(): Unit | ||
|
||
def getBalance: Option[Int] | ||
|
||
def incrementBalance(increment: Int): Option[Int] | ||
} | ||
|
||
object Bank { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't you want to use the companion object anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, there is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed the name for the Object from BankAccount to Bank. I didn't like having a BankAccount.openAccount function. It seems like a Bank should be opening accounts not a BankAccount. I thought about having a Bank.scala and BankAccount.scala. But, then I didn't like having 2 .scala files for the exercise.. |
||
def openAccount(): BankAccount = ??? | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although this might already be some sort of spoiler you could add something like:
One could also imagine a standard format with a separate section named "Common Pitfalls" or so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggested addendum by @abo64 seems like a good one, even though it is a bit of a spoiler.