Difference between Interactors and Use Cases - Clean Coders Episode 7

3,188 views
Skip to first unread message

Tom

unread,
Sep 28, 2015, 7:15:50 AM9/28/15
to Clean Code Discussion
Hi there,

I have been studying episode 7 on Use Cases and High Level Architecture. I am using this approach on a component that I am building in work at the moment.

I would just like some clarification on Use Cases and Interactors. I think I understand the use case approach and how use cases specify the intent of the system. 
However in the interactor - boundary architecture diagram in this episode,  I am just wondering is the Interactor here fulfilling the role of the Use Case?
 In my code, should I specify the Use Case as an interface or abstract class and have the Interactor implement this interface?
e.g public interface FindUserUseCase {}

     public class FindUserInteractor implements FindUserUseCase?

or can the Interactor/UseCase be a straight concrete class without implementing an interface? And, is it idiomatic to use "Interactor" or "UseCase" in the class name?

In the Java Case Study videos, I see that "UseCase" is used in the class names.

I appreciate any advice on this?

Thanks a million,
Tom 

Caio Fernando Bertoldi Paes de Andrade

unread,
Sep 28, 2015, 8:48:31 AM9/28/15
to clean-code...@googlegroups.com
Hello Tom,

The terms Interactor and Usecase (sometimes even Command) are used interchangeably.

It’s up to the team to decide which term conveys best the pattern and whether to put it in the class names or not. What’s important is to follow only one standard in a project.

I don’t think anyone has thought about this naming issue the way you said, Usecase being the abstract interface and the Interactor being the implementation, but I guess it’s an interesting naming approach.

Caio


Sent from Mailbox


--
The only way to go fast is to go well.
---
You received this message because you are subscribed to the Google Groups "Clean Code Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clean-code-discu...@googlegroups.com.
To post to this group, send email to clean-code...@googlegroups.com.
Visit this group at http://groups.google.com/group/clean-code-discussion.

Tom

unread,
Sep 28, 2015, 9:18:49 AM9/28/15
to Clean Code Discussion, caio...@icloud.com
Hi Caio,

Great, thanks for your answer. 

Tom
To unsubscribe from this group and stop receiving emails from it, send an email to clean-code-discussion+unsub...@googlegroups.com.

Dave Schinkel

unread,
Oct 12, 2015, 2:12:22 AM10/12/15
to Clean Code Discussion
if this helps, I am growing my repo with examples of tests.  Here you see me referencing my use cases (aka interactor node.js modules): https://github.com/dschinkel/example-tests

Dave Schinkel

unread,
Oct 12, 2015, 2:16:17 AM10/12/15
to Clean Code Discussion
and IMO I think it makes sense to call them "Use Cases" or put them under a usecases folder in your project, because any guy coming to look at your code can at least understand what use cases are probably but wouldn't know what interactors are.  In other words, I wouldn't name my classes or modules something like "personGetInteractor.cs" or "personGetInteractor.js" in the case of a REST API.  I'd call them "personGet.js" an put that under a use cases folder.  Just more clean and clear that the stuff in this folder represents business requirements and business logic for it.

well hopefully people will understand that  :). Not everyone is aware of the clean architecture but again I just wouldn't use the word "interactors" in my code is what I'm saying.  I guess you could, but to each his own.
Reply all
Reply to author
Forward
0 new messages