bank move: 100 from: checkingAccount to: savingsAccount
Java: bank.move(100, checkingAccount, savingsAccount) bank move: 100 from: checkingAccount to: savingsAccount
Java: bank.move(100, checkingAccount, savingsAccount)bank.move(new Amount(100), new FromAccount(checkingAccount), new ToAccount(savingsAccount));
If you are really trying, you will be able to convey enough information so that your fellow programmer. will understand what you are trying to accomplish. Unfortunately, in practice, even Java Experts will convey to you that this style is wrong, classes and objects are " too expensive", primitive values are fine, and that this is too verbose.*
I learned about this style from Yegor Bugayenko's Book "Elegant Objects", go check it out. https://www.elegantobjects.org/
*) Yes, Java is verbose; not trying to defend that. I am very happy about keyword arguments in Python, for example. But, as soon as you have classes, ctors, objects, you can use them to add rich semantics into your code. Works with functional languages and other, better typesystems, too.
In Python, adding from=from_account, to=to_account to clarify a call is basically free; you don't have to change the callee and you don't have to change any other call sites.
very well said
bank.move(new Amount(100), AccountChannelFactory.create(AccountChannelFactory.CHECKING_CHANNEL, checkingAccount), AccountChannelFactory.create(AccountChannelFactory.SAVINGS_CHANNEL, savingsAccount));
bank.move( move: 100, from: checkingAccount, to: savingsAccount )
This option is also available for many of the other languages supported by the various JetBrains IDEs. bank balanceOf: (bank findAccount: #savings)
However, parens aren't necessary when a nested message takes no arguments, or uses a binary selector. eg: bank withdraw: 3 + 4 from: user checkingAccount
There are 3 messages here. 1. 3 + 4 (execute method + with argument 4)
2. user checkingAccount (getter with no arguments)
3. bank withdraw: <result of #1> from: <result of #2> bank.move(100, from=checkingAccount, to=savingsAccount)