-1

I interessted in the "usecases" and "how they interacts with the "context" at "clean architecture".

If I understand right, there will be two contexts.

  • First is the context of the domain-model with instances of the intelligent domain-entity-classes, which are includes all the buisness/domain-logic (e.g."Client")

  • Second is the context of the data-model (db,files,..) with instances of the stupid data-class without any logic (e.g. "ClientDto").

.

An example usecase: create a new client at a bank-software

The presenter/controller of the presentation-layer will call this "usecase", which is in the application-layer. But what will the usecase do or on which "context" will the usecase anything do. Writes the usecase the "new client" two both contextes, or only to the domain-model and these convert the "Client" to "ClientDto" and transfer it to the data-model? (Intuitively I would say the latter, but I also know that the domain model should not know the data interface.)

Editing after answer of @Michael Borgwardt:

Correct, the usecase itself do not active work at these context. The presenter creates a instance of a usecase and transfer it to somebody, who will do something because of this usecase. (so it's more a passive work, because the usecase-instance exist).

For my example.

  1. User push Button "New Client"
  2. View informed Presenter that "New Client" needed
  3. Presenter creates instance of usecase and will send this instance to somebody
Somebody.Publish(new CreateClientUseCase(_view.newClientId,_view.newClientName))

The question is: how is "somebody"? "He" have to updated the two context, which I described. Or?

1 Answer 1

2

This answer is based on a misunderstanding and assumes the older UML/OOD definition of "use-case". But the question is about the "clean architecture" definition of a use case. I'll leave it here to guide people who have the same misunderstanding.

Use cases (in the UML sense) are descriptions of business/domain functionalities from the point of view of the user of the system.

If a use case description refers to any concrete piece of code (such as a class or method), then it's not abstract enough. Use cases (as descriptions) are addressed to a specific audience that most of the time might not have a technical background.

In other words, use cases describe only what the system should do, and not at all how it should be done.

The presenter/controller of the presentation-layer will call this "use case"

No. The user will. Note: typically, users are humans. It's possible for a user (in the context of a usecase) to be an external computer system. But its actions should still be described in an abstract, non-technical manner.

Writes the usecase the "new client" two both contextes, or only to the domain-model and these convert the "Client" to "ClientDto" and transfer it to the data-model?

None of these terms other than "new client" have any place in a use case description.

8
  • Sure, the user will initiate the usecase. But something must happend after the new usecase-instance is alive. I updated my first post.
    – Cit
    Oct 28 at 7:32
  • 1
    Note that within the context of clean-architecture, the term usecase has a different meaning. There it refers to a class that represents a request from a user and that class is responsible for the interactions with the domain and services that are needed to fulfill the request. Oct 28 at 7:54
  • @Cit: Oops, I wasn't aware that the clean architecture concept has its own definition of what a usecase is. My answer is not useful for you; I'll modify it and leave it in place in case other people have the same misunderstanding. Oct 28 at 7:54
  • @BartvanIngenSchenau: You are at the point. Can you explain more how "the interaction with the domain and service" works ?
    – Cit
    Oct 28 at 8:43
  • 1
    Actually, I think your usage of the term "use case" is more correct. If one means "use case" in the sense of some implementation in code, they should write "use case component", "use case class", "use case layer" or "use case implementation", and not just sloppily "use case".
    – Doc Brown
    Oct 29 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.