﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>joseph commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>In short if the system is ready to execute tasks it van even execute the commands more efficiently, because they are just tasks to be executed now.
</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment22</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment22</guid><pubDate>Sat, 03 Mar 2012 18:12:21 GMT</pubDate></item><item><title>Ayende Rahien commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>Haroon,
On 3.5, you use the thread pool? Not sure, that depend on what sort of background processing you want.</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment21</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment21</guid><pubDate>Wed, 22 Feb 2012 11:19:33 GMT</pubDate></item><item><title>Haroon commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>@Ayende: Thanks for the response above to @Daniel - really useful info. I was just wondering how would you create a background task in .net 3,5, one that runs later, async? Like what you have in this blog (seen the code on github).

I gotta say, you know how to simplify things *big* time, reminds me of the acronym I have heard KISS (Keep it Simple Stupid) :)

Thanks...</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment20</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment20</guid><pubDate>Wed, 22 Feb 2012 11:08:54 GMT</pubDate></item><item><title>Ayende Rahien commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>Daniel,
When you have tasks, you have just two ways of handling errors.
Expected errors, that are part of the business processing, for example, credit card refused. This should be handled by the task itself, based on its own logic.
Then you have system errors (database down, network timeout, etc). Those are handled by the task executer, retrying the task a few times and finally giving up and writing this to the log.

If you require a notification, you might include that in the task executer.</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment19</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment19</guid><pubDate>Wed, 15 Feb 2012 09:16:30 GMT</pubDate></item><item><title>Daniel Marbach commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>Hy oren
How do you handle exeptions in tasks? When the tasks are executed on a remote syste, (for example the server) how do you inform the client which triggered the action which lead to a new background task?

Daniel</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment18</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment18</guid><pubDate>Wed, 15 Feb 2012 05:32:12 GMT</pubDate></item><item><title>Shane Courtrille commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>Oren.. If you say you keep commands why did you put a line through it on your list?  Shouldn't your list include Commands AND Tasks?</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment17</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment17</guid><pubDate>Tue, 14 Feb 2012 18:52:06 GMT</pubDate></item><item><title>Steve Sheldon commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>The idea of a Command executing now versus a Background Task, or a Delayed Job(the term used on Heroku with Ruby) is useful.

But then this will also lead to a series of posts titled 'Limit your commands' and how commands can be abused in a procedural fashion.</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment16</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment16</guid><pubDate>Tue, 14 Feb 2012 15:49:09 GMT</pubDate></item><item><title>Joe young commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>I am still a bit confused.

In Phil's article he makes use of the IRegisteredObject to let IIS know about the threads. I expected to see the TaskExecutor doing something similar or something that makes use of IRegisteredObject.

But that does not appear to be the case.

Perhaps I am being dense, but could you elaborate a bit more?</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment15</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment15</guid><pubDate>Tue, 14 Feb 2012 15:36:12 GMT</pubDate></item><item><title>Ayende Rahien commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>Joe,
See:
http://haacked.com/archive/2011/10/16/the-dangers-of-implementing-recurring-background-tasks-in-asp-net.aspx </description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment14</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment14</guid><pubDate>Tue, 14 Feb 2012 14:45:09 GMT</pubDate></item><item><title>Joe Young commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>I experimented with the idea of using the Task.Factory to spawn off 
worker threads to do something similar like you do in the TaskExecutor.

I shyed away from it however, as it was my understanding that IIS does not know about those threads and cannot shut them down if the AppDomain recyles or is somehow shut down.

Are you concerned about those situtations if so how do you handle them?

I ended up firing a seperate web request to a "job" area in MVC to handle these situations.</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment13</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment13</guid><pubDate>Tue, 14 Feb 2012 14:37:40 GMT</pubDate></item><item><title>Lars-Erik commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>I agree that it's nice to know what kind of implications sending the command will have. Your naming conventions are as good as any I guess. :) 
Just gets a bit confusing when using the same names as "established patterns".</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment12</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment12</guid><pubDate>Tue, 14 Feb 2012 12:45:31 GMT</pubDate></item><item><title>Ayende Rahien commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>Lars,
The command pattern doesn't talk about when it gets executed. I need a distinction between "running now" "will run in the future". That is why I have commands vs. tasks.
For the vast majority of cases, we execute commands immediately, so I keep this for that.</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment11</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment11</guid><pubDate>Tue, 14 Feb 2012 12:23:42 GMT</pubDate></item><item><title>Lars-Erik commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>Thought it valuable to insert this to the beginning of the first quote. "The client instantiates the command object and provides the information required to call the method at a later time."</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment10</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment10</guid><pubDate>Tue, 14 Feb 2012 11:53:29 GMT</pubDate></item><item><title>Lars-Erik commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>According to http://en.wikipedia.org/wiki/Command_pattern, "The invoker decides when the method should be called. The receiver is an instance of the class that contains the method's code."

How do you relate "A command will execute immediately..." to that definition?

To me, the command pattern is about the client providing all values for an operation in some data structure, then sending the instance through some abstraction to something unknown, which might or might not execute the associated operation immediately.

It might for instance go on a queue, and into a versioning history, and it might be executed once more in a restore operation later.

Thoughts?</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment9</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment9</guid><pubDate>Tue, 14 Feb 2012 11:52:19 GMT</pubDate></item><item><title>Rafal commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>You're right, background processing should be built into the design from the beginning because it's hard to do it later when the application grows and async processing becomes a necessity. 
Users get used to synchronous GUI and will oppose any functions that don't happen instantly, synchronous integration interfaces are impossible to change to async because of their clients being synchronous too, the same with db structure, transactions, status tracking etc.
On the other hand, you can't live without synchronous commands. Maybe this should be something like DPC in device drivers where an interrupt handler is synchronous and supposedly quick and if it needs more processing it can enqueue an async task.

</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment8</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment8</guid><pubDate>Tue, 14 Feb 2012 11:37:22 GMT</pubDate></item><item><title>Ayende Rahien commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>Falhar,
No, commands also have a command executer (discussed later in the series).
They also benefit from some management by the infrastructure.

There are many cases where you want to run things async. But also note that tasks can be run on a scheduler by a totally different machine, HOW they get run is immaterial.</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment7</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment7</guid><pubDate>Tue, 14 Feb 2012 10:09:35 GMT</pubDate></item><item><title>Falhar commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>So if I get this right.
Commands can be run only by themselves. Everything needed to run Command is either in class itself, or in base abstract class.
But Tasks need some TaksRunner to be run. Then TaskRunner can do things like error handling, transaction and session handling. It can run complex tasks composed from different tasks.

Also, is it worth it to run code on server asynchronously? I read some opinions, that the structural overhead is not worth the performance gain.</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment6</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment6</guid><pubDate>Tue, 14 Feb 2012 09:44:08 GMT</pubDate></item><item><title>Tom Janssens commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>Never mind answering that last question, I re-read your blog post and noticed you use tasks for managing internal transitions as well... 

Thanks for the series, and I am looking forward to the next post.</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment5</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment5</guid><pubDate>Tue, 14 Feb 2012 09:34:46 GMT</pubDate></item><item><title>Tom Janssens commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>I assume tasks always relate to "an external context" and can only succeed or fail, no pending states etc (i.e. send an email, report a change, import some data)? </description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment4</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment4</guid><pubDate>Tue, 14 Feb 2012 09:29:47 GMT</pubDate></item><item><title>Ayende Rahien commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>Tom,
FSM is something that I handle with events, not with tasks.

Note that a Task is a good way to handle operations that you might use a saga for, but it can't handle all things that you use a saga for. It is a good way to go if you have fairly simple needs, and don't require the whole bus infrastructure setup.</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment3</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment3</guid><pubDate>Tue, 14 Feb 2012 09:04:57 GMT</pubDate></item><item><title>Tom Janssens commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>As mentioned on twitter, don't you think long running processes might get shattered over multiple classes, making it hard to follow what exactly is going on here? In my more recent experiments, I noticed that in a lot of simple bounded contexts a simple finite state machine driven by conditional launching of events to alter state seems to work pretty well, while still being maintainable...</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment2</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment2</guid><pubDate>Tue, 14 Feb 2012 08:57:53 GMT</pubDate></item><item><title>Yves Reynhout commented on Limit your abstractions: Commands vs. Tasks, did you forget the workflow?</title><description>Although I get what you're getting at, I do find classifying commands as "execute immediately" a bit narrow minded. It depends on how you model and name them. For example, if I have a command called StartRework it should be pretty obvious that it's meant to trigger a process. The command itself MIGHT "execute immediately", but the associated process could take a while. Also, some of the things you attribute to it being a task rather than a command, made me think of it being a saga (which triggered my initial reaction on twitter). As far as the business is concerned it's the process that's worth the most (regardless of calling it a task/saga). Some might implement your task using a domain service (from DDD) or a saga. None of them would be "wrong", just a matter of trade-offs/complexity warranting.</description><link>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment1</link><guid>http://ayende.com/154113/limit-your-abstractions-commands-vs-tasks-did-you-forget-the-workflow#comment1</guid><pubDate>Tue, 14 Feb 2012 08:40:23 GMT</pubDate></item></channel></rss>