Repository Pattern

  Рет қаралды 66,776

Coding Concepts

Coding Concepts

Күн бұрын

A concise guide to understanding the Repository Pattern for cleaner, more maintainable code.
Let's Connect 🤝:
codingconcepts.io/connect

Пікірлер: 109
@jojojawjaw
@jojojawjaw 3 жыл бұрын
The first 25 seconds of this tutorial alone, does a better job explaining the repository pattern than a hundred other tutorials on KZfaq. This is the best tutorial on repository pattern.
@CodingConcepts
@CodingConcepts 3 жыл бұрын
Thank you very much. I really appreciate it.
@sonictailsandsally
@sonictailsandsally 11 ай бұрын
Seriously though! He get’s straight to the point!
@guilherme-l-moraes
@guilherme-l-moraes 2 жыл бұрын
The only problem with this channel is that it has only two videos. Please, post more! High-quality content, easily digestible explanations, and top-notch edition. You got one more subscriber.
@CodingConcepts
@CodingConcepts 2 жыл бұрын
Thank you! I’m working on getting another one out.
@tsunamio7750
@tsunamio7750 Жыл бұрын
This is not simply an explanation on the repository pattern. This video reaches about so many principles that young engineers have a hard time acquiring. I already knew all of those concepts but never truly acquired them. You shine bright so strong on those concepts that I now not only understand them, but I also have intuition and instinct about looking out for improvements like those to decouple and reuse code. There is no code per se, yet it did serve as a wonderful example.
@maretzelaltar7833
@maretzelaltar7833 Жыл бұрын
this is the only video where I was able to understand Repository Pattern. Short but the way the lesson is delivered is clear and easy to digest.
@sonictailsandsally
@sonictailsandsally 11 ай бұрын
Thank you! I had the gut feeling this vid would give me the answers I was looking for. Should have watched it first and saved time!
@jadawo
@jadawo 2 жыл бұрын
One of the best explanations of design patterns I have ever seen. Keep up the great work
@jimbobwylie
@jimbobwylie 2 ай бұрын
Why do you only have 2K subscribers?! This is the only one of at least 10 previous videos that has explained Repositories for a true beginner to understand! And this video is 3 years old. Thank you for this!
@CodingConcepts
@CodingConcepts 2 ай бұрын
Thank you!
@mb3_media
@mb3_media Жыл бұрын
Man, that is the bet explication about that design pattern that I've seen. Thank you so much for your effort
@drewb9
@drewb9 2 жыл бұрын
This was the best explanation of the Repository Pattern. Thank you for this.
@Johnny-pf1ni
@Johnny-pf1ni Жыл бұрын
Great explanation on the Repository pattern. It makes so much sense to me now.
@infiniteloop5804
@infiniteloop5804 Жыл бұрын
I don't comment often on videos, but this video definitely deserves a THANK YOU!!
@harshpatel105
@harshpatel105 2 жыл бұрын
Amazing video
@ItsNylrak
@ItsNylrak 3 жыл бұрын
How does this guy don't have a million subs? Explains very well and is easy to understand, only thing I'd suggest is giving quick demo example in the video. Keep up the good work!
@ewomer100
@ewomer100 Жыл бұрын
He put up two videos and ghosted.
@ItsNylrak
@ItsNylrak Жыл бұрын
@@ewomer100 A year ago he seemed very promising ngl
@dylan8389
@dylan8389 2 жыл бұрын
Absolutely amazing video, as a relatively inexperienced developer I’m currently learning C# and this video has made complete sense to me.
@andreigudumac4328
@andreigudumac4328 Жыл бұрын
Hoping that you make some more videos on design patterns. Thank you. Keep up the good work!
@yellowswordg
@yellowswordg 3 жыл бұрын
Keep them coming. People will love your tutorials!
@Knigh7z
@Knigh7z 2 жыл бұрын
In DDD your repositories should be per aggregate rather than business object. An aggregate may be a business object but it may be more than just one, depending on your needs to enforce consistency during a write. This usually works well with the repository as you'll open a transaction as part of the repository operation.
@nagamahesh656
@nagamahesh656 2 жыл бұрын
Crystal Clear Explanation.
@ricardoislasruiz3186
@ricardoislasruiz3186 2 жыл бұрын
This is the best video about this topic I have found on KZfaq!
@CodingConcepts
@CodingConcepts 2 жыл бұрын
Thank you!
@balu.92
@balu.92 2 жыл бұрын
Best tutorial ever! So much explained in so little! ❤️
@zeshanrabnawaz1699
@zeshanrabnawaz1699 Жыл бұрын
Great Job Buddy ......
@Ajith4u81
@Ajith4u81 3 жыл бұрын
Best video i ever heard about the Repository pattern
@shywn_mrk
@shywn_mrk Жыл бұрын
I just found this video and your channel. Please continue your amazing work again and keep creating these kind of content 💪🏻
@naelshichida7940
@naelshichida7940 Жыл бұрын
Hey man, thanks so much for this. Me, Dom and Max love your work.
@abymathew575
@abymathew575 Жыл бұрын
really good video with good diagrams. Expecting more videos from you.
@jasontaylor8304
@jasontaylor8304 Жыл бұрын
Awesome video! Very clean and clear and explanation is spot on.
@javierolazaran7227
@javierolazaran7227 3 жыл бұрын
Loved the topic and the explanation.
@SuhasBharadwajK
@SuhasBharadwajK 10 ай бұрын
This is such high-quality content, man! Superb production. You deserve tons of more subscribers. Maybe pushing more videos every week will do the trick.
@shaziakaleem4411
@shaziakaleem4411 2 жыл бұрын
Very well explained. Life saver literally. Thank you
@shaharts8333
@shaharts8333 3 жыл бұрын
Great video boss👍💥👌
@arsenhakobyan00
@arsenhakobyan00 Жыл бұрын
This is such a great video. I'm so glad I found your channel. Are you planning on creating more videos like this?
@JD-sn1lr
@JD-sn1lr 2 жыл бұрын
In the Generic Implementation section, I think you wanted the IRepository to have a Find method of T entity Find(long id) because it will return the T type for any implementation and not just User
@CodingConcepts
@CodingConcepts 2 жыл бұрын
You are right! Thank you for pointing that out! That was an oversight on my part. I’ll see if I can add a note at that part of the video to clarify things. Thanks again for letting me know!
@emirhansoylu
@emirhansoylu 2 жыл бұрын
Wow, this is amazing work. Thank you!
@doointhedoo
@doointhedoo 10 ай бұрын
Great videos. Subscribed. Would like to see more industry real life examples. Especially this part ( 10:46 ).
@slowmollyfar
@slowmollyfar Жыл бұрын
Thanks a lot for these explanations, illustrations nice as well
@paulstanley2789
@paulstanley2789 3 жыл бұрын
Great video.I hope you can make some more.
@twentxx
@twentxx Жыл бұрын
Man, this is very good video Thank you 😊 We will waiting for your videos
@bokunochannel84207
@bokunochannel84207 2 жыл бұрын
awesome content, more about design pattern please.
@ashishchandra4078
@ashishchandra4078 Жыл бұрын
Great explanation , thank you :)
@MsLiberanimus
@MsLiberanimus Жыл бұрын
the best explanation ever 🙌🙌🙌
@juanavalo
@juanavalo 2 жыл бұрын
Great video!
@mohamedQ
@mohamedQ Жыл бұрын
nice and easy to understand straight to the point thx a lot
@nilpunch2
@nilpunch2 3 жыл бұрын
You are cool, make more videos like this, and your channel will grow very quickly!
@AkhmadKhanifZyen
@AkhmadKhanifZyen 2 жыл бұрын
this is high quality concepts, too bad this channel ended up only with 2 videos. i still waiting for another concepts. keep up the good work.
@CodingConcepts
@CodingConcepts 2 жыл бұрын
Thanks! I’m working on another video. Apologize for the delay!
@Zoreens
@Zoreens 2 жыл бұрын
@@CodingConcepts :D
@CodingConcepts
@CodingConcepts 2 жыл бұрын
@@Zoreens I’m working on one. Promise 🙂
@josephthecreator
@josephthecreator Жыл бұрын
Amazing video, thank you.
@ahmeda.algily4998
@ahmeda.algily4998 2 жыл бұрын
Wow , just wow 👏👏
@pheroqt1238
@pheroqt1238 2 жыл бұрын
Hey, are you planning to continue on design patterns (and other topics) in this channel? Really nice explanations!
@CodingConcepts
@CodingConcepts 2 жыл бұрын
Appreciate the nice comment. I am working on another video. Just takes me some time because it’s something I do in my spare time and I’ve been busy at work. I plan on going through the DDD concepts first and take it from there.
@pawekoaczynski4505
@pawekoaczynski4505 2 жыл бұрын
just the video I needed, thanks c:
@kieljnsz
@kieljnsz 4 ай бұрын
Thanks man! Please post more
@CodingConcepts
@CodingConcepts 4 ай бұрын
Thank you!
@nikhilgoyal007
@nikhilgoyal007 Жыл бұрын
thanks very much!
@alexgavidia7356
@alexgavidia7356 2 жыл бұрын
The best! Thanks
@ksdekamil
@ksdekamil 2 жыл бұрын
great job
@sanamjha1209
@sanamjha1209 2 жыл бұрын
eagerly waiting new video.
@utkachannel4411
@utkachannel4411 Жыл бұрын
wow, thank you very much !
@yaulinfung9615
@yaulinfung9615 3 жыл бұрын
keep it up!
@rasimatics
@rasimatics 2 жыл бұрын
Great!!!
@stevenkjames
@stevenkjames 2 жыл бұрын
Cool
@ruslanustiuhov5510
@ruslanustiuhov5510 3 жыл бұрын
nice one!
@lorenzosala3527
@lorenzosala3527 3 жыл бұрын
Thank you so much!
@CodingConcepts
@CodingConcepts 3 жыл бұрын
You’re welcome!
@andrey_aka_skif
@andrey_aka_skif 8 ай бұрын
The Repository pattern seems simple. Great! I need to implement it in my project! I'm making it. Fabulous! Wait... I need filters... Damn. What I should do? Should I add filtering methods to the repository? It is a bad idea. I need to read the Internet. Hmm... CQRS? Now I have to use the Repository only to update the business object. To get composite data I have to use Queries. They are not so clean anymore. They usually know about the database type. What's the result? The simple idea of a Repository results in a complex mess of Repositories and Queries. Usually there is also a Unit of Work running nearby. What do you think about compound queries in the context of the Repository?
@CodingConcepts
@CodingConcepts 8 ай бұрын
For most cases it’s usually acceptable to have different method definitions. -FindByName -FindByEmail -FindByPhone etc.. If your query is particularly complex, or it needs to be used in other areas of the system, typically complex business logic, you may want to look into the specification pattern. In short, you would encapsulate the query logic inside the specification object, and then inject that specification wherever needed, in this case, a repository. Happy Coding! Rob
@TramoTech
@TramoTech 2 жыл бұрын
👍
@abdelrahmanmoubarak7934
@abdelrahmanmoubarak7934 2 жыл бұрын
That's really great
@egor.cleric
@egor.cleric Жыл бұрын
What about aggregation root?
@InfoAufArabisch
@InfoAufArabisch 5 ай бұрын
Could you please elaborate more about the test problem at 02:24 till 02:45? I don't understand how this makes it harder to write a test
@CodingConcepts
@CodingConcepts 5 ай бұрын
Of course! At 2:24 I was trying to illustrate a scenario where a lot of logic resides in the controller. When you see "thick" or "bulky" controllers like this, it becomes very difficult to test your code because of the dependencies these controllers are using. ie: a database. The design at 2:45 is improved because it moves the database dependency out of the controller and into the repository. This puts us in a position to use a Mock for our repository to better target the specifc area of code we're looking to test. Hope this answers your question. Happy Coding! Rob
@noblenetdk
@noblenetdk Жыл бұрын
impressingly precise and consice. Haven't seen this explained that clear before. Do the pattern have any drawbacks? Keep up the good work!
@CodingConcepts
@CodingConcepts Жыл бұрын
Interesting question! I haven't thought about it from this context. There isn't an obvious tradeoff or drawback that comes to mind. I would say the biggest debate I've seen regarding the pattern has delt with specific implementations. Particularly when injecting an Object Relational Mapper (ORM) such as Entity Framework, which already implements the Repository Pattern (with unit of work) itself and will lead to code duplication and violation of the DRY principle (Don't Repeat Yourself).
@pictzone
@pictzone Жыл бұрын
@@CodingConcepts Why would you inject an ORM if you already created a custom data access layer with the repository pattern? The only reason I see where you would reach such a situation is if your main data access is already an ORM and you also integrate your own repository for more custom work. Wouldn't this scenario only create complementary code, thus not violating the DRY principle? (i mean it's still not 100% DRY, but still reasonably well)
@CodingConcepts
@CodingConcepts Жыл бұрын
​@@pictzone Great question! There is no definitive answer to this and it really comes down to the trade-offs you're willing to accept. I find myself writing my own repository classes because I find it makes my code much more testable. I'm a strong advocate for Test Driven Development (TDD) and I believe good code is testable code. By writing my own repositories, I'm able to easily mock their return values with testing tools such as Moq. I'm able to reduce the duplicate code it creates, which you've correctly identified, by using generic repositories in a lot of cases. ORM tools do provide in memory testing tools, but I just don't find the usability as streamlined as Moq. So for me, I find the trade off of increased testability at the cost of some duplication acceptable.
@alexaugusto5935
@alexaugusto5935 2 жыл бұрын
In case the data comes from another application, like from another REST API. Can the implementation of the Repository, be the consumer client of the REST API? Or Repository Pattern only applies to something like Databases?
@CodingConcepts
@CodingConcepts 2 жыл бұрын
You’re typically going to be using the repository pattern in conjunction with a database or some other data store. You could receive data from a REST Api such as a CustomerId to then fetch additional information about that customer using a repository. I hope that clears things up for you.
@kislayapant6119
@kislayapant6119 2 жыл бұрын
Great explanation. Just one suggestion, please do not use Uppercase everytime. It is sometimes very hard to read the content displayed over the screen.
@CodingConcepts
@CodingConcepts 2 жыл бұрын
Thanks for the feedback!
@yosiyosiro3866
@yosiyosiro3866 2 жыл бұрын
I sub
@newagene8276
@newagene8276 Жыл бұрын
What can be done for other complex operation how to segregate those in terms of repositories? outrside crud we might need more methods in a large software
@CodingConcepts
@CodingConcepts Жыл бұрын
Take a look at the specification pattern
@fodiecamara965
@fodiecamara965 10 ай бұрын
Post more videos
@pgbpro20
@pgbpro20 2 жыл бұрын
Very helpful! Flexibility is spelled wrong throughout haha.
@CodingConcepts
@CodingConcepts 2 жыл бұрын
Thank you for letting me know!
@iMaxos
@iMaxos 2 жыл бұрын
GOLD
@futsuchinpo9892
@futsuchinpo9892 Ай бұрын
thanks man
@CodingConcepts
@CodingConcepts Ай бұрын
You’re welcome!
@futsuchinpo9892
@futsuchinpo9892 Ай бұрын
@@CodingConcepts woah you still active on KZfaq ? Nice
@CodingConcepts
@CodingConcepts Ай бұрын
Yup 🙂
@andianwar5784
@andianwar5784 Жыл бұрын
come back bro
@feoktant
@feoktant 3 жыл бұрын
Are you sure about generic interface repo? Not all repositories should look like this. Some business objects should not be deleted, other should not be updated.
@CodingConcepts
@CodingConcepts 3 жыл бұрын
I agree. Not trying to make the argument that a generic repository is best in all cases. Just trying to show different strategies and implementations. Appreciate your comment.
@m3hdim3hdi
@m3hdim3hdi 9 ай бұрын
what is the difference between the DAO and the Repository pattern?
@CodingConcepts
@CodingConcepts 9 ай бұрын
There is a pretty good discussion I had in the comments about this with another viewer. I linked the comment below. Let me know if that clears things up. kzfaq.info/get/bejne/rpxzZZOrzcCsp2w.html&lc=UgwoV2MDbSnxx_sXtFR4AaABAg
@titobundy
@titobundy 4 ай бұрын
@@CodingConcepts I don't see the discussion. Is the url correct?
@CodingConcepts
@CodingConcepts 4 ай бұрын
@@titobundy Sorry about that. I'm not seeing the comment any more. I will post the discussion here. Question: I might be confused but i find this pattern really similar to the use of Data Access Objects. Are there any differences ? Should we be using one over the other ? Reply: A Data Access Object (DAO) is all about data persistence. It will sit below the Repository, and will match one to one with an underlying database table or view. It's an object representation of the underlying data schema. It's logicless. The return type of a repository is going to be an Entity or Aggregate which are business objects. They may closely resemble the underlying data schema, but you're getting business objects back. Which will have some form of business logic in them. In general, you'll see DAOs used in more complex architectures, to handle specific persistence requirements. Question: So if i understood correctly, they are used together and DAO will return data as JSON for example, when Repository will cast it to Business objects (and perform other operations) ? Do you have some tips on how to know if we should use DAO, repository or both ? Reply: A repository is an abstraction of a collection of objects. A DAO is an abstraction of data persistence. A UserRepository should only ever return User. It shouldn't for example return a RoleObject. A UserDAO on the other hand, it would be acceptable to return information about a User and have another method to return information about it's Roles. As it's only concern is how the information is persisted/stored in the database. The key thing to note here is it's just returning data for you. A good use case for a DAO would be when the underlying data schema is very complex. Perhaps, that UserObject needs several database operations behind the scenes to construct. Put logic like that in a DAO, not a Repository. An Object Relational Mapper (ORM) such as Entity Framework, is going to eliminate the need for a DAO in most cases. It's going to do most of that work for you.
@titobundy
@titobundy 4 ай бұрын
@@CodingConcepts Thank for your post. I would like to have your point of view. Do you think tools like TypeOrm or Spring Data, which apply the repository pattern, do so according to Martin Fowler's definition in his book Refactoring or perhaps Eric Evans in his book DDD, or do you think such implementations are closer to what DAO offers?
@CodingConcepts
@CodingConcepts 4 ай бұрын
@@titobundy I can't speak specifically to TypeOrm or SpringData as I haven't used those tools before, I mainly use Entity Framework. But in general, I would say both. Modern ORM's are applying the repository "by the book" but are also becoming exceptionally well at mapping complex data objects. I would expect the need for a DAO layer to decrease over time.
@CandiceWilliams_
@CandiceWilliams_ Жыл бұрын
I wish I had more time to pick this up so I know how to communicate with my devs and explain how I need to be able to access payment history and user referrals with my flutter app so I can create reports to keep my affiliates and stockholders up to date… if any one has any tips please share. I appreciate you so much in advance.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 758 М.
Should you use the Repository Pattern? With CQRS, Yes and No!
10:27
ОДИН ДЕНЬ ИЗ ДЕТСТВА❤️ #shorts
00:59
BATEK_OFFICIAL
Рет қаралды 8 МЛН
Final muy increíble 😱
00:46
Juan De Dios Pantoja 2
Рет қаралды 48 МЛН
БОЛЬШОЙ ПЕТУШОК #shorts
00:21
Паша Осадчий
Рет қаралды 8 МЛН
How principled coders outperform the competition
11:11
Coderized
Рет қаралды 1,6 МЛН
Deep Dive Into the Repository Design Pattern in Python
11:56
ArjanCodes
Рет қаралды 73 М.
What are Business Rules? It's not this.
10:58
CodeOpinion
Рет қаралды 28 М.
10 Design Patterns Explained in 10 Minutes
11:04
Fireship
Рет қаралды 2,2 МЛН
Have you replaced your DB because of the Repository Pattern?
10:53
Git MERGE vs REBASE: The Definitive Guide
9:39
The Modern Coder
Рет қаралды 88 М.
5 Design Patterns That Are ACTUALLY Used By Developers
9:27
Alex Hyett
Рет қаралды 202 М.
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 603 М.
Master Golang with Interfaces
21:54
Kantan Coding
Рет қаралды 8 М.
Самый дорогой кабель Apple
0:37
Romancev768
Рет қаралды 122 М.
GamePad İle Bisiklet Yönetmek #shorts
0:26
Osman Kabadayı
Рет қаралды 524 М.
Мой инст: denkiselef. Как забрать телефон через экран.
0:54
Best mobile of all time💥🗿 [Troll Face]
0:24
Special SHNTY 2.0
Рет қаралды 2,9 МЛН