DTOs in Web Development: What You Need to Know

Ғылым және технология

Have you ever heard someone suggest "you should use a DTO!" and wondered what they're even talking about? In this video, you'll learn EXACTLY what DTOs are, when to use them...and when you can ditch 'em!
====
Don't forget to pre-order your copy of Learning Spring Boot 3.0 3rd Edition today at springbootlearning.com/book!
====
ALSO SEE: 👀
✅ Finding Data with SPRING DATA: • HOW can I find my DATA?
✅ DTOs are the "M" in MVC. But what is MVC? • HOW does it help me bu...
✅ Want a deeper dive into the world of DTOs? • Understanding DTOs and...
RESOURCES: 👇
- Grab your copy of Hacking with Spring Boot 2.4: Classic Edition: greglturnquist.com/hacking-wi...
GET MORE: 🎉
- Get a FREE tech ebook at springbootlearning.com/join
- Follow me on Twitter: / springbootlearn
GRAB A MUG FOR YOUR COFFEE ☕ (and a t-shirt): store.springbootlearning.com/
Click "subscribe" under the video (and hit that bell icon) to get notified when new videos come out. Or click here and then click “yes” when prompted: kzread.info...
Got questions or suggestions for future topics? Drop ‘em in the comments!
STUFF I LIKE TO USE: 😍
- Studio gear: springbootlearning.com/kit
- Laptop stand: springbootlearning.com/twelve...
- Music: springbootlearning.com/epidem...
- Recut (pre-editing): springbootlearning.com/recut
- Best place to run Spring Boot apps: tanzu.vmware.com/
DISCLOSURE: All opinions stated here are mine and do not necessarily reflect those of the Spring team nor of my employer. Any usage of "Spring", "Spring Boot", "Spring Framework", "VMware", "Pivotal", or anything else is completely unaffiliated with its owners. From time to time, I may post affiliate links for products I enjoy using.
#springbootlearning #springbootbook
© 2022 Greg L. Turnquist, All Rights Reserved

Пікірлер: 13

  • @ProCoderIO
    @ProCoderIO Жыл бұрын

    ✅ Finding Data with SPRING DATA: kzread.info/dash/bejne/d6eDmrCJn9XMips.html ✅ DTOs are the "M" in MVC. But what is MVC? kzread.info/dash/bejne/kamhyqmrfdynqbQ.html ✅ Want a deeper dive into the world of DTOs? kzread.info/dash/bejne/layKqrKRhqyde6Q.html

  • @memillin
    @memillin Жыл бұрын

    In regards with hexagonal architecture there's a book I recommend "Get your hands dirty on clean architecture by Tom Hombergs"

  • @overrevvv
    @overrevvv4 ай бұрын

    Thank you so much for this well explained video.

  • @ProCoderIO

    @ProCoderIO

    4 ай бұрын

    Be sure your subscribed. The new season of the Pro Coder Show is launching at the end of the month!

  • @coderlady_
    @coderlady_ Жыл бұрын

    Hi, what about validation? can I do the validation on the entity or do I have to create a dto for this purpose ?

  • @ProCoderIO

    @ProCoderIO

    Жыл бұрын

    Depends on where we’re talking about validation. If you mean JSR 303 type validation, it can really be on any class. Though if you’re using DTOs for the web later it would be preferable there so it fails sooner rather than later. Personally, I prefer putting validation checks in either the constructor or the setters. That way; the class validates whether it not bean validators are bootstrapped or not. And this approach is quite easy to unit test.

  • @bradenborman4396
    @bradenborman4396 Жыл бұрын

    Would you call the concept of a wrapper/container class a DTO? I’ve been pushing on my team at work to use wrappers! Hypothetically, if an endpoint just returns a list of users, instead of ResponseEntity I’ve told the team to make a UserResponse class with a single field of List of Users! In my head if we need to modify the structure of the endpoint, I’d rather just tack on a new field to the wrapper class than to have a breaking change to the endpoint! Would love to know thoughts on this 😄 Same thing for Batch jobs, I’ll define a wrapper class to hold data that the reader passes to the processor and so on, for the same reasons

  • @ProCoderIO

    @ProCoderIO

    Жыл бұрын

    Since you have a custom type used to represent the end product on the web, I’d say yes. You could adjust this type in the future as needed to either add fields or alter the presentation using Jackson annotations. You can ignore other fields using these same annotations. And since none of them impact the way the User data is stored in the database you have that decoupled. Now if you needed to apply such annotations to the User type itself; you might need some UserDto as well somewhere in the future but that is pretty to encapsulate in your response DTO. But overall having this class for responses is a solid move.

  • @GodofStories
    @GodofStories Жыл бұрын

    Records in Java are a great newish alternative instead of using DTOs

  • @memillin
    @memillin Жыл бұрын

    Hi Greg! thank you for the advice about this topic. By the way I like your haircut and it seems that you have lost some weight, you look great.

  • @ProCoderIO

    @ProCoderIO

    Жыл бұрын

    Thanks!!

  • @amin-roots
    @amin-roots7 ай бұрын

    Well, hexagons are the bestagons :D

  • @ProCoderIO

    @ProCoderIO

    7 ай бұрын

    Hah.

Келесі