1

It's well known that

actor should be assigned the smallest task possible

But what is the smallest task?

For example we have some code that sends emails. It's a bunch of classes. The first class converts the incoming object into DTO object. The second class extracts template and applies a DTO to it. And the third class sends the result by email. What is an actor here? Is it a method in each class or is it a class or the whole action?

One of my concerns is that if I make too small actors its much harder to navigate through code in IDE, harder to debug and read the code. What's the benefit of making too small actors in my example (In my example I would prefer to make one actor that will call those three classes. Why shouldn't I do so?)

Eugene To
  • 1,890
  • 2
  • 19
  • 30
  • Can you provide source for your citation? – talex Nov 02 '16 at 16:59
  • 1
    I think you make good arguments as to why a task for an actor shouldn't be as small as possible. – Peter Lawrey Nov 02 '16 at 17:01
  • 1
    The actor model is a model for concurrent computation. Therefore, parts that are not concurrent in nature (eg. mappers, as you describe) should not be put into an actor. – rethab Nov 03 '16 at 17:28

1 Answers1

0

Your well known quote, is (probably...) taken from Scala - Intro To Akka.

If so, it's also taken out of context.

Because, if you move on a few more words down the sentence, than you will get a bigger picture:

To the greatest extent possible, each actor should be assigned the smallest task possible (as previously discussed, following the Single Responsibility Principle)

Now, that link sends you to read a bit about SRP, but I truly think further (and better?) reading is out-there:

etc google it...

Hope this gets you started. Good luck!

Edit: I'm not answering your specific question (examples and such...), because I believe that every application and usage is different and needs a unique view and unique answers. So I recommend you read, understand, and make a valid/thought-about decision.

Community
  • 1
  • 1
MordechayS
  • 1,552
  • 2
  • 19
  • 29
  • Yea, I omitted that part "following the Single Responsibility Principle" on purpose, because "Single Responsibility Principle" is rather ambiguous.For example, in my case with email sometimes it's quite ok to group three classes into one. And even more. If there are still three classes I think it's quite normal to make one actor for all of them. But when people read that quotation most of them think you should do your best to make as small actors as possible and that'll be the best. I don't agree with them and asked that question :) – Eugene To Nov 02 '16 at 19:38