Clean Architecture (DDD) using RUST | Domain Driven Design | Diesel | Postgres | Actix web

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ธ.ค. 2024

ความคิดเห็น • 24

  • @amirhosseinahmadi3706
    @amirhosseinahmadi3706 4 หลายเดือนก่อน +19

    You're taking a dependency on Diesel - an infrastructure-level library - in your domain layer. That defeats the point of separating domain and infrastructure.

    • @thesobercoder
      @thesobercoder 2 หลายเดือนก่อน +2

      Domain should be clean and the innermost layer free from all dependencies.

    • @diadetediotedio6918
      @diadetediotedio6918 2 หลายเดือนก่อน +5

      You don't need to be an extreme purist to make things.

  • @chris3079
    @chris3079 4 หลายเดือนก่อน +2

    that was great, would love to see you do a second with testing and/or error handling.

    • @GK-we4co
      @GK-we4co 3 หลายเดือนก่อน

      +1 for testing and domain-level errors (use enums for that to make it bulletproof?)

  • @os365
    @os365 5 หลายเดือนก่อน +1

    Excellent, I am currently using DDD with Rust, but I have a question at minute 6:45, you call in the Queryable and Serializable domain. In that case wouldn't you be contaminating the domain with the infrastructure?

    • @Semicolon10
      @Semicolon10  5 หลายเดือนก่อน +1

      Thanks for the feedback, Actually, there is no definitive right or wrong way when it comes to models in Domain-Driven Design (DDD). My approach is as follows:
      Use domain objects directly for GET requests when they match your data needs, as this simplifies your design and maintains consistency across your application. This approach is particularly effective for read-heavy operations, where performance benefits from avoiding unnecessary transformations and keeping the codebase straightforward.

    • @os365
      @os365 5 หลายเดือนก่อน

      @@Semicolon10 of course, thank you

  • @GK-we4co
    @GK-we4co 3 หลายเดือนก่อน

    I wonder if it is okay on 12:30 to rigidly define dependency on UserService in `fn new()` of a UseCase. How would you mock it in tests?
    EDIT: also, how would you architecturally approach changing something in user, or implementing some user-related logic? Like, editing an email with confirmation, which makes user's email take two separate states:
    - Confirmed(emailAddress: String);
    - and Unconfirmed(perviouslyConfirmedAddress: Option, newUnconfirmedAddress: String, confirmationToken: String).
    And then sending a message to the users's confirmed email.

    • @diadetediotedio6918
      @diadetediotedio6918 2 หลายเดือนก่อน

      If you need to mock user service just turn it into a trait or use some lib for it, not a big deal. You don't need to overly complicate things for the sake of "I can need it".

  • @letoan285
    @letoan285 5 หลายเดือนก่อน +3

    Great Video, could you continue with next videos on this content, jwt authen for example?

    • @Semicolon10
      @Semicolon10  5 หลายเดือนก่อน +1

      @@letoan285 Thats the plan.

  • @aces1_
    @aces1_ 3 หลายเดือนก่อน +2

    Why didn't you create a trait for Service and just create an implementation for that?
    "#[async_trait]
    pub trait UserService {
    async fn register(&self, new_user: &NewUser) -> Result;
    async fn find_by_email(&self, email: String) -> Option;
    }"

  • @DeepakKumar-uz4xy
    @DeepakKumar-uz4xy 5 หลายเดือนก่อน +3

    Hi can you please talk about rust job market as backend developer. Which framework is mostly in used is it axum,actix or rocket?

    • @Semicolon10
      @Semicolon10  5 หลายเดือนก่อน +2

      Surely, I will create a video on the job market. As far as frameworks go, Axum, Actix, and Rocket are all easy and straightforward to use. Each has its strengths that i will discuss in an upcoming video.

  • @pvlzh
    @pvlzh 5 หลายเดือนก่อน +2

    Thanks for the video! It turns out that the trait of the UserRepository, which is located at the domain layer, depends on the newUser structure, which is declared at the presentation layer? Doesn't this violate the order of dependencies in a clean architecture? 🤔

    • @Semicolon10
      @Semicolon10  5 หลายเดือนก่อน

      Thanks for the feedback! Yes, by definition, you're correct. However, when following patterns, there isn't always a one-size-fits-all approach. The best method is whatever works best for your specific situation. While introducing mappers and DTOs adheres to clean architecture principles, it also comes with additional maintenance costs. For straightforward use cases like this one, where the models are simple and relational fetching is minimal, it might be more practical to use domain objects directly.

  • @立立山立山立
    @立立山立山立 4 หลายเดือนก่อน

    Great Video

  • @fernandomarca
    @fernandomarca 4 หลายเดือนก่อน

    Great job. A detail that he has forgotten. You use diesel and not diesel async for this reason it is recommended to wrap the database operations in a web::block. Example in the Actix documentation.
    web::block(move || {
    Obtaining a connection from the pool is also a potentially blocking operation.
    So, it should be called within the 'web::block' closure, as well.
    let mut conn = pool.get().expect("couldn't get db connection from pool");
    insert_new_user(&mut conn, name)
    })
    .wait?
    But this can mess up your repository. So we can use tokio::task::spawn_blocking.
    Good job.

  • @ericzorn3735
    @ericzorn3735 2 หลายเดือนก่อน

    Do you have a GitHub link to the source code for this?

  •  2 หลายเดือนก่อน +1

    This is not pure architecture at all. So many code smells. No workspaces are used, no isolation, primitive obsession, domain infested with infrastructure stuff, etc. Yes, there are some parts of DDD, but you can't call it "Clean Architecture" if there's almost none of it. Content quality can also be discussed. You only say what you write, but we see it. Let's read that. There are no explanations as to why this or that. Almost useless. And hey, take it as constructive criticism. We all need to learn.

    • @Semicolon10
      @Semicolon10  2 หลายเดือนก่อน

      Thank you for your feedback, Also you cannot judge someones content on a single video. This is one of the first on my channel. Try check all of the latest videos. Architectures, Designs are for us we are not for it. So try use per ur case! Peace

    •  2 หลายเดือนก่อน

      ​@@Semicolon10 That's fair. I will definitely check out more videos.

  • @dennisestenson7820
    @dennisestenson7820 หลายเดือนก่อน

    Omg so much boilerplate and repetition.