Using case objects in place of case classes having no members #11
Conversation
+1 for Tomek's pull request |
I'm just not sure whether do we really need to bind the variable in the following line in TransactionSynchronizationManagerTests: case e@AfterCommitEvent => afterEvent = e What is is purpose of this change? |
Do you suggest:
Indeed, I was misled by previous |
Yeah, this binding is a little bit confusing in this context :) . Actually with your case object under the hood we could even consider using boolean variables in this test. For example:
What do you think? |
Looks cleaner, however
What I don't like is the lack of symmetry - your suggestion looks better from that perspective. |
The purpose of this partocular test is to validate that multiple events can be caught by single registration, so I personally would prefer clean boolean variables over strict testing here. |
If the test only makes sure given events were triggered (moreover order is not important), I agree, |
Looks good to me. Thanks for contributing! I will merge as soon as you're done with it. |
Done. Unfortunately case classes and case objects are handled slightly different in pattern matching:
|
I personally prefer the following syntax for matching all classes.
But its up to the spring-scala users to decide how they would like to use the library. I think that pull request is ready to merge in the current state :) . |
* case-object: Use case objects instead of case classes
Merged. Thanks for contributing! |
Idiomatic Scala uses case objects in favor of empty case class.