Aug 9, 2017 · 1 min read
I have seen this in other places and question why you would put that in a decorator. I know that it seems like a great place to save for all commands… But not all commands save to a database. Perhaps one command sends an email or creates a file. State is still changed, even though it isn’t updating the database. But now all commands are going to have a context with a transaction created whether you need/want one or not. The command should really be dealing with opening and closing connections/transactions since it knows what needs to be done. Cross-functional things like logging or validation make much more sense as decorators. Just my 2 cents. :)