Clean Architecture by Example in 5 Minutes

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024

Комментарии • 27

  • @medrlayman
    @medrlayman Год назад +6

    One of the best youtube video on Clean Architecture, especially the explanation on dependency inversion principle which is the key technique of achieving inward dependency.

  • @theseenandunseen
    @theseenandunseen 11 месяцев назад +1

    Very informative. Any chance on sharing an example on how this would translate into code (from start to finish)? Thank you !

    • @AboutCleanCode
      @AboutCleanCode  11 месяцев назад +1

      @shadowbit. Have a look here ruclips.net/video/6hIg86y9HuE/видео.html and here ruclips.net/video/pfhDO_hZixw/видео.html and here github.com/plainionist/AboutCleanCode 😉

    • @theseenandunseen
      @theseenandunseen 11 месяцев назад

      @@AboutCleanCode Will definitely have a look at your suggestions.
      Conceptually I think you did an awesome job in this video at describing how each component ought to be linked and/or connected in order to abide to the principles of the clean architecture, however, considering that I'm not a developer by trade, some aspects are a bit confusing and having a 1-to-1 mapping with a tangible example would make things much clearer; (especially when it's in Java or C++). I will give it a go nonetheless based on your described setup.

  • @being_aslam_tiger
    @being_aslam_tiger Год назад

    Thanks for making this video, please make more similar videos.

  • @dragoran149
    @dragoran149 3 месяца назад

    How does the Repository class/module looks like? This have a dependency to the database or the api but they're in the outer layer what violates the rule, but it feels strange to use an interface for this because the repository has to be written in a specific way that the database can understand. Or does it mean it is in the adapter layer it can have direct dependencies to the outer layer?

    • @AboutCleanCode
      @AboutCleanCode  3 месяца назад

      Check out this video ruclips.net/video/pfhDO_hZixw/видео.html did it help?

  • @Wouldntyouliketoknow2
    @Wouldntyouliketoknow2 Год назад

    Thank you for the video! Im really curious to know what software you use for these animated diagrams! Would you share?

    • @AboutCleanCode
      @AboutCleanCode  Год назад

      @DarrellTunnell I wrote my own small web app base on maxGraph JavaScript library 😉

    • @Wouldntyouliketoknow2
      @Wouldntyouliketoknow2 Год назад

      Wow! Would you consider making a video about that project? I like working with diagrams as code and use things like mermaidjs or plantuml. They are very good for static diagrams but they don't have any support for animation. At the same time my PowerPoint skills are not great and I find it a huge time sink. So really I want a way to work programmatically but in a terse way, to create animated diagrams like yours! I'd be curious to learn from your experience before I attempt something myself :-)

    • @AboutCleanCode
      @AboutCleanCode  Год назад

      @@Wouldntyouliketoknow2 At the moment the project is still in prototyping phase but I plan to release it as open source in some point of time. Until then I would recommend MaxGraph JS, it also has great examples to start with github.com/maxGraph/maxGraph/tree/development/packages/html/stories

  • @n0pee349
    @n0pee349 Год назад

    Thanks for this amazing tutorial. Do you have in plans to do an video about your VsCode configuration that you are currently using for .Net?

    • @AboutCleanCode
      @AboutCleanCode  Год назад +1

      Thx! No plans for such a video yet but I just now published a community post, showing the VsCode extensions I have installed ;-)

  • @botondvasvari5758
    @botondvasvari5758 Год назад

    what if I have an embedded system. A mortar that should fire,tilt,pan. There is target and environment. The mortar has motors which are stepper motors they can change in the future. Are the motors part of the domain or I/O ?? (I have a motor abs class which has a calculateRequiredStepsFromAngle(angle) and there is an implementation based on the current motor) I want it this to become clean arch.

    • @AboutCleanCode
      @AboutCleanCode  Год назад +1

      @botondvasvari5758 generally speaking, in Clean Architecture the I/O layer contains the code which interacts with the "outer world". In case of an embedded system this would be all code directly depending on the hardware and/or Operating System and/or device drivers. Any logic we can abstract from these technical details, any decision making i would put into the "entities" (domain model) or "use case" (application logic) layer. If you have a "motor" object which represents the real physical motor and which contains data and computation logic, then this class should be part of the domain or use case layer. But this class must not have any dependency to technical details. For that you would have a dedicated class e.g. MotorDevice which would then be located in I/O layer.

  • @igeoorge3g
    @igeoorge3g Год назад

    Any recommended repo that applies to this?

    • @AboutCleanCode
      @AboutCleanCode  Год назад +1

      @igeoorge3g the source code of most of my videos you can find here: github.com/plainionist/AboutCleanCode for this particular video I have no such repository. the case was derived from one of my projects at work which I cannot share online.

  • @marcin2828t
    @marcin2828t Год назад

    I like the video, can you make similar one about Onion?

    • @AboutCleanCode
      @AboutCleanCode  Год назад

      Thx! I add it to my todo list ;-)

    • @marcin2828t
      @marcin2828t Год назад

      Looking forward to see it! One question : why did you stick to Clean Arch and not an Onion Arch? Any particular reason?@@AboutCleanCode

    • @AboutCleanCode
      @AboutCleanCode  Год назад

      @marcin2828t I do stick with CA because I like the domain and the app logic being the center of the architecture with all technical details pushed to the most outer corners. I think this improves changeability and maintainability of the software a lot because business logic and technology can evolve independently.
      As to my understanding Onion Architecture is quite similar to CA but so far I didn't had a deeper look at it or even used it in any project - maybe I should change this ;-)

    • @marcin2828t
      @marcin2828t Год назад

      Thank you for your answer. I'm the onion-man, and from what I can tell both architectures are not so different in the concept at all. I think that main difference is that layers and building blocks are named and sometimes placed differently. Soon I will be starting a new project for company I work for and I want to try something new. CA is one of the options. On the other end sits concept of Domain Model from DDD which I may incorporate into old good Onion without taking anything else that comes with DDD. There is a chance that I will make a terrible wrong decision and turn into Victor Frankenstein ;) @@AboutCleanCode

    • @AboutCleanCode
      @AboutCleanCode  Год назад

      Personally, I think DDD and CA fit quite well together - same is probably true for Onion Arch and DDD

  • @botyironcastle
    @botyironcastle Год назад

    I think domain is an implementation detail. Usually we need different repres of the same object when we send it back as a response and different repres when we save into a dstastore, so DTOs. I always see too simple samples.

    • @AboutCleanCode
      @AboutCleanCode  Год назад

      This example is very simple, agreed, but I have chosen it intentionally to focus on the basic ideas. I think it could be easily scaled to multiple responses, presenters and data stores. Or do you miss a particular aspect?

  • @ibot0281
    @ibot0281 2 месяца назад

    There are no entities in this example. How do i know what my entities are? I have one simple use case, where i want to return data from a file. Currently, I have created a repository in the frameworks layer which creates an entity for the data i want to return. The entity is passed to the use case layer and there the data is checked (some values must be > 0) and then returned. Do you think this violates the clean architecture? Is it right to use an entity for this? Where would I do the mentioned checks if not in an entity?
    Sorry for the many questions and thank you for your great videos :)

    • @AboutCleanCode
      @AboutCleanCode  2 месяца назад

      @ibot0281 entities usually model the core business rules. they are part of the domain model which is typically valid across multiple applications. But even if I only have a single application I prefer extracting business rules which are valid for all use cases into entities. Repositories need to return either entities or objects defined on the use case layer, if the repository APIs are called from the use case layer, otherwise the dependency rule of the CA would be violated. Low level validation like "must not be null or empty string" are often already done at the border of the system, e.g. in the controller of a web API. Any business rule validation should be either in the use case interactors or in the entities - depending on whether this rule is valid only for particular use case or multiple use cases. HTH