Тёмный

AVOID Entity Services by Focusing on Capabilities 

CodeOpinion
Подписаться 85 тыс.
Просмотров 31 тыс.
50% 1

Entity Services are services that are centered around an Entity. For example, a CustomerService or a ProductService. Most times these services focus on data and CRUD operations. These services can cause low cohesion and in turn high coupling. Instead, focus on Capabilities of services and the data encapsulated and owned by the service. Focusing on capabilities will increase cohesion and lower coupling.
🔔 Subscribe: / @codeopinion
💥 Join this channel to get access to source code & demos!
/ @codeopinion
🔥 Don't have the JOIN button? Support me on Patreon!
/ codeopinion
📝 Blog: codeopinion.com
👋 Twitter: / codeopinion
✨ LinkedIn: / dcomartin
0:00 Intro
1:28 Problems with Entity Services
2:17 Capabilities
3:49 Example
6:23 Coupling and Cohesion
#softwaredesign #domaindrivendesign #entityservices

Наука

Опубликовано:

 

1 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 142   
@asbjornu
@asbjornu 3 года назад
Adam Smith's principle of the "division of labour" applies to software just as it does to business and the economy. If it makes sense to hire different people to do shipping than those who do pricing, it will probably make sense to separate them in software as well. Great video, Derek! 👏🏼
@CodeOpinion
@CodeOpinion 3 года назад
I'll have to reference "division of labor" in the future. I wasn't aware of that. Thanks for the share!
@marna_li
@marna_li 2 года назад
I like to revisit this. It has been useful in reasoning about what a complex system can look like. There is also the video about syncing data using integration events: when you for instance want to store the Product Name in each service, but yet keep them in sync. Some would hesitate to do this. "It is bad practice to have duplicate data!". Well, it depends. Can you manage it? You totally can. I have an Identity Service that holds Accounts and basic User info. Then there is another service that holds Items that have been created and edited by some User. Instead of having to ask the Identity Service for the User's First Name and Last Name every time, I create local representations of Users in my Items Service that are controlled in response to events from IdentityService. As a consequence I can store relevant data connected to a User locally in that service.
@louisstekhoven-smith5791
@louisstekhoven-smith5791 3 года назад
Excellent video mate, I spent a good week or two going into a tailspin trying to implement DDD but without releasing I was just trying to apply the patterns to a data-driven mentality still. After watching this I was able to finally make it all click together. Every resource teaching DDD to newcomers should start with this!
@CodeOpinion
@CodeOpinion 3 года назад
Thanks! Glad it helped 🙂
@DanielOpitz
@DanielOpitz 3 года назад
Great video! I've been trying to teach this approach to developers for over two years. For people with a CRUD/ORM/Entity mentality, this higher level concept is really hard to understand. But I don't know why. Now I can give them a link to this video. Thanks.
@CodeOpinion
@CodeOpinion 3 года назад
Thanks. I hope it helps!
@codewithkashif
@codewithkashif 3 года назад
Same here!
@antoniojimenez8768
@antoniojimenez8768 3 года назад
It would be great to see examples of this in action, no about services centric but traditional entities splitting and how it information is created, and propagated.
@criddell86
@criddell86 3 года назад
I like the explanation. One way to think about the initial Product example is to ask yourself if the product should keep track of its quantity.
@hyunbinpark3382
@hyunbinpark3382 Год назад
I was the one who asked about this in the discord ;) I'm really appreciate for this video
@CodeOpinion
@CodeOpinion Год назад
Nice! Hopefully it shed some light
@ofiry
@ofiry 2 года назад
This video is really enlightening, thanks Derek! I would love to see more practical examples for this idea.
@coderanger75
@coderanger75 3 года назад
Great video. Your example section reminds me of how I have recently started challenging my own opinions of how products should be represented in software. I started researching what a product really is and finally came to the conclusion that a product is just a marketing/sales wrapper around a tangible good. Once I started separating the tangible good from the marketing/sales wrapper, my system became easier to maintain and extend. This was incredibly important when I started getting business requests for products that have bundled tangible goods that have one or many fulfillment strategies (physical shipping, digital download, software access, etc).
@CodeOpinion
@CodeOpinion 3 года назад
Interesting insight!
@roamingdev
@roamingdev Год назад
Interesting! We went through the same thinking process a while back. Thought about decoupling what the e-commerce part of the system considers to be a product and what the actual good (and all of its paraphernalia like availability, delivery type, etc.) really is so that a product could be backed by multiple types of goods. I would be interested to know more about your case if you happen to have a blog and your stuff are public. Good thinking!
@magicsmoke0
@magicsmoke0 2 года назад
But how would you actually store that data in a Db? If you have the same property in multiple entities, like Price, and you update it in one, how do you ensure all the other entities get updated as well? Does your DB schema match your domain model or is it different?
@mikemccarthy9855
@mikemccarthy9855 3 года назад
Love this one! Great the way you refactor AWAY from entity/CRUD-centric service boundaries (based on database schema and noun-verb analysis) and towards a model that uses behavior and business language to model what the boundaries should be around "pieces" of a Product. Decomposing those pieces of data around behavior reveals what data is highly cohesive and needs to be grouped together b/c it's changed together (aka, transactional consistency). Someone at Particular software put it like this (and this is para-phrasing): "Often, you'll find you service boundaries cutting right the the middle of your entities". Some comments I've read here show confusion around transactional consistency across all boundaries for a Product, you like you pointed out, you can't have that. You can only enforce transactional consistency of the pieces each boundary owns, and the rest will need to be eventually consistent. One concept that might clear this up is that only one service can logically own the concept of a Product. In this case, what and where is the inception/creation of a "Product" into the system you're modeling? Catalog, Warehouse, etc. Once you identify the true owner of a thing, then that boundary becomes the authority of that thing... the rest of the boundaries that rely on pieces will get those pieces in an eventually consistent manner.
@CodeOpinion
@CodeOpinion 3 года назад
Thanks for the comment. I want to talk/cover more about transactional consistency of aggregates. Dive more into what aggregates actually are (a consistency boundary) that might help.
@kralkatorrik34
@kralkatorrik34 Год назад
Amazing video. The only thing I'm missing here is elaborating on the data shared between services and possible mechanism to solve this issue. For example the dimension and weight of a product may be important to the following services: - Catalog Service - dimensions and weight could be important to the customer - Shipping Service - dimensions and weight could be used to accurately calculate the shipping price - Warehouse service - dimensions and weight could be used to automatically find the best place to store the product in the warehouse
@CodeOpinion
@CodeOpinion Год назад
Agree, they might care about that data for some reason, but they don't need to own it. I think I talked about this a bit more here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-uKURpE12Mgo.html
@zimcoder
@zimcoder 3 года назад
I like the explanation but I would like to see a practical example of this. What does it mean also for reports and general data mining in this paradigm?
@CodeOpinion
@CodeOpinion 3 года назад
Good question. I'll cover UI and reporting in another video! Thanks for the suggestion.
@umair_me
@umair_me 3 года назад
good question.
@codewithkashif
@codewithkashif 3 года назад
@@CodeOpinion That's a very good question and a practical working example will suffice this great concept in action! Looking forward for that
@sangmin7648
@sangmin7648 2 года назад
Any updates on this? Can’t seem to find the video on this
@douwedejong1223
@douwedejong1223 Год назад
Maybe give your report generator authority to read the databases or create an internal endpoint for listing.
@HuyLe-ef2vg
@HuyLe-ef2vg Год назад
awesome ! really helpful! thanks
@IsaacLarbiOnline
@IsaacLarbiOnline Год назад
Great video! I learnt something new and VERY useful. Thanks for sharing, you earned a like.
@CodeOpinion
@CodeOpinion Год назад
Glad it was helpful!
@andersjuul8310
@andersjuul8310 3 года назад
Thought provoking -- love it!
@CodeOpinion
@CodeOpinion 3 года назад
Thanks 👍
@carlosjosejimenezbermudez9255
@carlosjosejimenezbermudez9255 3 года назад
CRUD driven services are easy to just start writing, I believe that's probably why they are so prevalent.
@CodeOpinion
@CodeOpinion 3 года назад
Agree, probably because the vast majority of tutorials for beginners are focused on CRUD. It's partially the reason I started this channel.
@michaelabbott7139
@michaelabbott7139 2 года назад
@@CodeOpinion At what point would you move away from Entity services? In my experience lessons like these tend to fall into YAGNI until a service or domain becomes complex enough to justify incorporating it.
@MrBa143
@MrBa143 2 года назад
I wish this is what i were taught. I've been stuck in a very CRUD like way of thinking since passing my exams. Thinking capabilities gives a much better view on the domain we are within.
@RobyMarcellino
@RobyMarcellino 2 года назад
Totally agree. Nice video!
@CodeOpinion
@CodeOpinion 2 года назад
Thanks!
@iham1313
@iham1313 Год назад
it is about object oriented and monolithic thinking - even in oop you should separate based on behaviours/capabilities instead of building a super-base class ... good example and explanation - thx!
@CarlosAlbertoBrasil
@CarlosAlbertoBrasil Год назад
Another great share of knowledge, at the beginning, I was ... what!!! but I could understand and agree
@MykhayloS
@MykhayloS 3 года назад
Another reason for the love toward entity driven architecture is that when splitting the monolith, it looks easier to keep the same DB structure and just add some microservices on the top of it. And you end up with a distributed monolith...
@ivandrofly
@ivandrofly 8 месяцев назад
Thank you
@iandrake4683
@iandrake4683 3 года назад
I really like the format you're doing here. Particularly that it's opinionated and reasoned well. I don't always agree, but I'm always interested in what you're saying...if that make sense.
@CodeOpinion
@CodeOpinion 3 года назад
Appreciate the comment. That's been the goal is to push back a bit against some current "standard" practices. Also, to explain some concepts that have been convoluted by our industry.
@dinov5347
@dinov5347 2 года назад
I agree with the sentiment. I may not agree 100% but I love how you present all of these topics and it really does makes me think, a lot. All decisions are about trade-offs but you to have to be open to unique ideas and approaches. E.g your presentation on the ReST architecture (like adding verbs to the url etc).
@rainron2664
@rainron2664 3 года назад
I got some feels of interface segregation here.. thank you for this sir.😊
@CodeOpinion
@CodeOpinion 3 года назад
Ya, interesting way of thinking of it!
@bunnihilator
@bunnihilator 2 года назад
How would that be done in spring boot? Multiple entity classes to one table?
@cestarop
@cestarop 2 года назад
Your channel is amazing, man!
@CodeOpinion
@CodeOpinion 2 года назад
Glad you enjoy it. Thanks!
@geertvanwauwe9832
@geertvanwauwe9832 3 года назад
How would you make sure that all these bounded context have the same SKU? Would you keep a cache in each BC? Do you make one owner of the SKU for example catalog or do you have different SKU's for basically the same product?
@CodeOpinion
@CodeOpinion 3 года назад
The SKU is the same for the identical product in each context. Some service could own it and it's generation. Other services could be notified via an event of it's generation. Or not. Depends on if the other services need to know about it's creation. You can have a SKU in the catalog, that sales doesn't have. Which just means that product won't be sold.
@krystian5858
@krystian5858 3 года назад
Wow, in just 7:30 minutes you saved me a lot of time. Just to make sure I understood correctly. I can have a "Product" locally, AND have separate ProductService (or different; it would handle concept of Products in a more complete manner) and just keep them in sync (ProductService -> local Product table), correct?
@CodeOpinion
@CodeOpinion 3 года назад
The only ting you're really keeping in "sync" is the SKU. That's what shared across all services. You could have a primary service that owns the shared identifier, "SKU'. This could be the ProductCatalog service. When a new product is added to the catalog, it would publish an event that all the other services would consume to be aware of the new product.
@javisartdesign
@javisartdesign 3 года назад
It woul be nice to compare the differences between data and capabilities from the API (Rest) perspective and how this methods are mappeed
@CodeOpinion
@CodeOpinion 3 года назад
Likely going to illustrate this in an upcoming video. Stay tuned.
@mikaeljirhage7679
@mikaeljirhage7679 3 года назад
I really enjoy your channel, thank you for your effort. I have a question about properties that needs to be shared. For instance the name of the property needs to be shown to the user when they are updating the product info, the cost and the price and when viewing the quantity on hand. Does that mean that the catalog service must be called each time to get the name, or do the other microservices keep a local read-only cache of the name?
@CodeOpinion
@CodeOpinion 3 года назад
Either is a possibility. Having a local cache can be helpful but obviously has trade-offs of staleness if that matters. It really comes down to doing composition for the UI. I'll be covering that in future videos soon.
@ebichu8126
@ebichu8126 3 года назад
Hey! Thanks for the nice clip. When it comes to Rest API, I think its methods are somehow CRUD centric(GET /POST etc..), so it is hard to keep the official naming convention of it. I think putting verbs on the Rest resource is more natural in behavior-rich design. Do you have any opinion about it? :) Thanks!
@CodeOpinion
@CodeOpinion 3 года назад
Check out this video, it might answer the question: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-6XO6vSiioWE.html
@olmanmora21
@olmanmora21 2 года назад
Gosh, this channel should have 10MM of subs at least, all B.S. content about software design out there are massive misleading, whoever has participated in a couple of real world projects can confirm that what this guy is exposing it's truth. Data Centric model works fine until it grows and becomes a big giant monster that no one is capable to work in efficiently, an endless source of frustration.
@CodeOpinion
@CodeOpinion 2 года назад
Well last year this time I only had 5k subs so a few people are catching on! Thanks for watching.
@copycatzen
@copycatzen 3 года назад
This is awesome aproach, for those services you mentioned (AdjustPrice, ShipProduct, ReceiveProduct, UpdateProductInfo), if I were to have HTTP REST APIs to expose these services, what would be your approach for naming them? PUT Product/UpdatePrice, POST Product/Ship, POST Product/Receive, PUT Product/UpdateInfo ? any recommendation?
@CodeOpinion
@CodeOpinion 3 года назад
All I'd really be concerned with is if they need to be idempotent. If they do, then PUT, otherwise POST.
@Knigh7z
@Knigh7z 2 года назад
Critical when creating loosely coupled micro services!
@dino56ac49
@dino56ac49 Год назад
I wonder how do you design the API to match these actions? You do Rest and then translate? Or are there any other conventions that are more suitable?
@CodeOpinion
@CodeOpinion Год назад
I talk about it more in this video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-6XO6vSiioWE.html
@SeaRich
@SeaRich 2 года назад
the point is the interface.
@antoniusgolly3417
@antoniusgolly3417 3 года назад
Awesome series. Much appreciated! It closes a long-existing gap between those who *want* to learn DDD and those who are able to implement DDD. I'll stay tuned for more episodes. One question. You are going from a "badly" implemented data schema with loads of dependencies over a badly implemented service approach (Entity-driven) to a good service implementation (behavior-driven). It really makes sense how you organize services and their methods. Question is now, what would you suggest the data schema should look like, i.e. the required tables. Are you suggesting to match the database tables the new microservices (several product tables for sales, purches, etc.) or is it "ok" to leave the schema as is. I suggest the former but I feel you didn't say that explicetly. Thanks, man
@CodeOpinion
@CodeOpinion 3 года назад
Each service would have it's own table with just the data it owns. That way you can't couple by schema since each service can't directly access the data owned by another service. Make sense?
@antoniusgolly3417
@antoniusgolly3417 3 года назад
@@CodeOpinion Absolutely, thanks for the clarification. The biggest challenge in learning to apply DDD is to free our minds from all we know about database relations.
@bobbycrosby9765
@bobbycrosby9765 2 года назад
@@CodeOpinion This makes sense, but there's a tradeoff here - you can partially create a product. This increases the number of states your system can be in, and can result in some issues, especially because - in my experience - people tend not to test out these abnormal system states.
@mabdullahsari
@mabdullahsari 2 года назад
@@bobbycrosby9765 You don't? A product is a single product in each bounded context. If a product available in Warehouse is not available in Sales, then all that means is that that product is in stock, but not available for sale.
@ofiry
@ofiry 2 года назад
Derek, what if u need to show all catalog, prices, and inventory count on a product table in the same web page? will u still use this capabilities approach ?
@CodeOpinion
@CodeOpinion 2 года назад
UI Composition. I don't have a video yet on this but the gist is you have to compose all the data together. That can be done in the client, on the server in an gateway/bff, or within a particular boundary that does all the composition. Regardless, data needs to be composed generally.
@guybrushthreepwood2910
@guybrushthreepwood2910 Год назад
Underneath this there's the idea of a bounded context in the scope of a microservice.
@CodeOpinion
@CodeOpinion Год назад
Indeed but in a logical boundary, not a microservice.
@aristideherve5748
@aristideherve5748 2 года назад
Awesome
@CodeOpinion
@CodeOpinion 2 года назад
Thanks!
@amgadtawfik7534
@amgadtawfik7534 Год назад
Hi Derek, While I agree with you. I wanted to know your opinion. When having a microservice per capability not per business model, this usually leads to have a microservice that is not micro anymore. It becomes more of a service in a kind of SOA environment. What are your thoughts onthat and how to prevent that?
@CodeOpinion
@CodeOpinion Год назад
Exactly. Have appropriate size services.
@jessestruyvelt7593
@jessestruyvelt7593 3 года назад
I like the idea of it but having a really hard time applying this to our real world scenarios. I feel like my aggregates are trapped into CRUD stuff. Our application is heavy data focused (we need to maintain a lot of data which just is data that we need to store), which is about 60% of the application. But we also have 40% of actual functionality and behaviors. Though can't seem to translate it to our domain model. Would love to see more real life examples.
@CodeOpinion
@CodeOpinion 3 года назад
I find at the outer edges, stuff that's more setup/referential data and not core to the domain will be CRUD.
@jessestruyvelt7593
@jessestruyvelt7593 3 года назад
​@@CodeOpinion Thanks for the quick reply. Do you know any source of examples for this? My brain still doesn't have the eureka moment of completely understanding it. Even with a simple case like clients having contracts.
@GusRJ70
@GusRJ70 3 года назад
Instersting, but how do we manage the very first product , and its Price? Perhaps with one method on Sales with the first date for that product ?
@CodeOpinion
@CodeOpinion 3 года назад
That could be in the catalog. Depends if you need one service to initiate the creation or not. Meaning, do Catalog could be the creation point and publish an event to let the other services know there is a new product with SKU=abc123. But that might not be required.
@ArinSinabian
@ArinSinabian Год назад
Interesting video I have question. What If you want to search for product with name and "in stock" and also retrieve price. Should you have another microservice (for example search service) with seperate db that has that data side by side and duplicated? Or should I call catalog service, sales service and warehouse service to get that information just to search?
@CodeOpinion
@CodeOpinion Год назад
I'm going to be publishing some videos soon about this. Ultimately is about UI/View composition and there are different ways to deal with it.
@ArinSinabian
@ArinSinabian Год назад
@@CodeOpinion I read about materialized view pattern where you store all data together and update the data with event carried state transfer. This will make the read data eventual consistent. So for example if price is adjusted an event say priceIncreased is broadcasted with the new price. Then the read database is updated with new price. Is it something in line with this approach you are gonna make a video about? But will this approach couple services or not? I am thinking the service responsible for read DB is now coupled to all the other services that send events.
@joaomelo6642
@joaomelo6642 3 года назад
great video. tks. how would you organize the data layer drived by this design by capabilities?
@CodeOpinion
@CodeOpinion 3 года назад
Each service/boundary owns its own data relevant to the capabilities. Meaning each would have it's own schema. However, you organize that is per service/boundary.
@joaomelo6642
@joaomelo6642 3 года назад
That's cool, @@CodeOpinion. Tks for the reply. I never worked with microservices, this is all new and very interesting to me. Your videos are helping a lot! Reusing the product example... we would have many product tables? One in each service schema? If so, (1) the same product would be replicated with the same SKU but a different set of attributes in each service schema? (2) The data consistency between each product copy would be assured by services reacting to some sort of event bus?
@CodeOpinion
@CodeOpinion 3 года назад
@@joaomelo6642 Correct. Each service would have it's own schema of a product but only the relevant data to the service. If you do care about keeping a local copy cache of data owned by other services, you'd be consuming events. Local caches are a whole different conversation that add a lot of complexity. Caches in general add complexity.
@joaomelo6642
@joaomelo6642 3 года назад
awesome @@CodeOpinion . tks for you time :)
@ayyappaj8111
@ayyappaj8111 2 года назад
By this approach, Won't there be too many tables or in the end it will be nearly the same as CRUD based design? Also, consider if we just need to show up quantityInHand while displaying product information in the future, how to handle this?
@CodeOpinion
@CodeOpinion 2 года назад
Ultimately you're talking about queries/reads and how to compose that together from disparate services. I'll be covering the ideas behind UI and ViewModels Composition in another future video,
@GeekOverdose
@GeekOverdose Год назад
Just 1 quick question: for shared properties like product SKU, how to keep it consistent across services?
@CodeOpinion
@CodeOpinion Год назад
Owner of the SKU or where it originates could be publishing an event. It's not changing generally. So in this example, let's say the catalog/marketing service originates a new SKU, an event would be published that other boundaries would subscribe and consume.
@GeekOverdose
@GeekOverdose Год назад
@@CodeOpinion so would there be a single service (catalog/marketing) that is the owner of a property (SKU) of an entity (Product)? And the other copies of this property in other services are replicas, that get updated via events? Or could multiple services mutate the value of a shared entity property and publish an event to notify everyone else?
@fennecbesixdouze1794
@fennecbesixdouze1794 Год назад
Wish you would flesh out these kinds of examples more in code.
@CodeOpinion
@CodeOpinion Год назад
Good suggestion. This video is a bit older so might revisit this topic again with more code illustration.
@srik790
@srik790 3 года назад
I always get confused what would UI would look like for product. As data will reside in different bounded context. How can it be updated in a single transaction.. I.e For creating product Ui would look like as follows: Name Desc Cost Price. Now when user saves the form.. the SKu will be created at UI level (guid)and data will be sent to its respective Context.. what if Sales fails to save .. so there will be a catalogue without Price.
@Zshazz
@Zshazz 3 года назад
That's still looking at it from a data centric POV, but instead you're just combining it with a capability centric backend. Technically, you can handle that with transactions, but what you _should_ be doing is instead rethinking that entire UI design to begin with and figuring out who is actually using your application and what task they're trying to accomplish. A single UI for editing name, description, price, and cost is trying to combine a bunch of separate tasks into one. Talk to the business/domain expert to figure out who is editing the name/description and who is updating the price, and who is updating the cost and you'll (probably) find out these are different people and they are doing it as a part of different processes. Lumping them all into the same UI is "simple," but sub-optimal. You'll find that a form-fitted UI for a specific task will make it so that users get their work done more efficiently, and when you take that approach you'll lean towards designing these capability centric services.
@CodeOpinion
@CodeOpinion 3 года назад
You will move into a task based UI. Instead of having a form that contains everything, rather your going to have task/action based controls/forms to perform the specific capabilities.
@nemanjazivkovic6895
@nemanjazivkovic6895 3 года назад
@@Zshazz True. While you can technically do it, spanning transactions over multiple databases/microservices is where I would draw the line and start rethinking solution or combining the microservices.
@nemanjazivkovic6895
@nemanjazivkovic6895 3 года назад
Good question, this is the reason microservices are "eventually consistent". This is where things get complicated with various retries and failovers, etc... While there are ways to span transactions over multiple systems (google "handling distributed transactions"), for example "two-phase commit", I like to avoid it if possible.
@CodeOpinion
@CodeOpinion 3 года назад
Agree, avoid the distributed transaction :) Check out my video on sagas if you get into that position of a long running process that span multiple boundaries. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-rO9BXsl4AMQ.html
@anikaitmakkar989
@anikaitmakkar989 3 года назад
How does such an approach work on related data? Let's say I have items, and those items have posts related to them(users created posts), other users can like these posts. How does such a system get decomposed into a capability oriented system, rather than CRUD based approach
@CodeOpinion
@CodeOpinion 3 года назад
"Like" is a task/command. Beyond referencing a post. If there aren't invariants related to likes, then it doesn't have to be even in the same boundary as posts.
@anikaitmakkar989
@anikaitmakkar989 3 года назад
@@CodeOpinion Yes, I am doing it in the same manner, items have their own service, price-posts have their own and likes have their own. The only coupling is validating whether an item exists before creating a price post related to it and similarly for like, making sure the price post exists. I doubt I could have a way around this and achieve total independence of these services. I would also like to say, I recently found your channel through the http error responses. After rolling out my own way of handling errors, setting up custom return objects, I am really happy to know that a consistent way to do so exists!
@Abdullah-zc1uy
@Abdullah-zc1uy 3 года назад
how to get out of CRUD mentality?
@CodeOpinion
@CodeOpinion 3 года назад
In the core of your domain, users will talk in terms of tasks/actions. On the outermost edges for referential stuff they might not talk that way and CRUD may be more appropriate. But at the core, they will talk in terms of actions and workflow.
@romanlunin386
@romanlunin386 2 года назад
does it mean that now you have to created 4 tables instead of one in the database even though you're running a monolith architecture? or is it one table where different modules are concerned about different properties of that table. and yeah, that's a type of question that only data centric person could ask :)
@CodeOpinion
@CodeOpinion 2 года назад
It can be either, but it's about ownership of who can change that data. Only one logical boundary should be able to change it. I don't generally like the idea of integrating boundaries at the database level because it's really hard to manage, so for that, prefer to also use an API defined to get the data you need from another boundary.
@rcts3761
@rcts3761 2 года назад
To keep with the example from the video, let's say we have a ProductCatalog microservice that owns the SKU and general product data, a warehouse microservice that owns the stock information and a sales microservice that owns the pricing information. You have shown in other videos how a task-based UI (in contrast to CRUD) for this would look like, but how would this UI work when you are creating a new product instead of editing an existing one? You'd have to create the product base information first, then add pricing and stock information afterwards. This is pretty awkward and leads to a situation where the "product" is in an invalid state, because it has no stock or pricing information.
@CodeOpinion
@CodeOpinion 2 года назад
Well the assumption that the same individual would be entering all this product information including sales and inventory all in the same time within the form? I'm not entirely sure why that would even happen realistically. However, I get its an example so for arguments sake let's say you needed to. Well, having the client/UI have a single form that makes multiple calls to various boundaries (catalog, sales, warehouse) isn't really that awkward to me. The SKU is the identifier that is common between boundaries. There's nothing technically wrong with there being the existence of a product in the Catalog that doesn't exist within Sales. That's not an invalid state.
@smithmathieu47
@smithmathieu47 3 года назад
How should data be handled that needs to exist authoritatively, but is logically required for multiple processes? For example, suppose the system has the requirement that it may only sell products that are on hand. Should QuantityOnHand be an attribute of sales, or an attribute of the warehouse? Suppose we want to add a new capability to the system, such as reserving inventory when none is on hand. Do reservations become a capability of sales, warehouse, both, or a new service altogether? It would be helpful to go through a more complete example and discuss some of the common issues that come up with this capabilities centric framing.
@CodeOpinion
@CodeOpinion 3 года назад
Good question. I did cover this in my saga video discussing long running processes. It might be helpful if you haven't watched it yet. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-rO9BXsl4AMQ.html Let me know if that helps.
@AleksandarTaseski
@AleksandarTaseski 3 года назад
maybe you don't even need Saga, it's all about domain modeling... 'Quantity on hand' obvious belong to Warehouse service, because refers to total quantity you have physically in warehouses. In Sales instead of 'Quantity on hand', probably you will have 'Available To Promise' witch refers to quantity on hand + supply (planned/purchased orders) - demand (sales orders including/excluding forecasted demand). Of course, based on your requirements, you may have something like 'Available For Sale' with excluded supply in ATP formula.
@CodeOpinion
@CodeOpinion 3 года назад
@@AleksandarTaseski Yes, I use ATP in a bunch of my other examples in some of my videos. Check our my Context is King: Finding Service Boundaries talk that describes this. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-dnhshUdRW70.html
@codewithkashif
@codewithkashif 3 года назад
Again awesome content! I understand that we should not focusing on CRUD instead of behavior... So should we also splitting that entity in database according to its behavior...? If yes then, Is this also true even when that project is not in distributed(microservices) architecture?
@CodeOpinion
@CodeOpinion 3 года назад
As usual "it depends". The context I'm referring to are large systems. I recommend splitting them up when it makes sense to partition your system into logical components. That doesn't need to mean it's distributed. Check out my videos on Loosely Coupled Monolith. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-48C-RsEu0BQ.html
@entity1566
@entity1566 3 года назад
But I need to provide my services. :(
@cosmiccoffee8497
@cosmiccoffee8497 3 года назад
You're hired, you can be the design manager and yell at my programmers now :P
@TimCluyts
@TimCluyts 3 года назад
Hmm, good insight but I am not yet 100% convinced to be honest. I never liked the "Let's have a microservice for every single piece of data" structure to begin with and never really followed it in that respect. However, this sounds like you'd be building a microservice for every "actor", to which I also don't fully agree with. To me a microservice could have more than just the single piece of data or single actor. It can be a combined effort of multiple pieces of data and actors, as long as the link between them is direct if that makes sense. For instance a customer and his cars owned could be a service to which both admins and customers connect (talking backend service). But the car and its parts could be a different one as long as it logically makes sense to split them up. I'm not really sure if I am making myself clear here either.
@CodeOpinion
@CodeOpinion 3 года назад
I'm not sure if I'm following your example but I will say that this approach is to eliminate coupling via direct synchronous request/response for capabilities. To create autonomy. I also view the definition of a service that has behaviors and owns data. But I think you're suggesting a service can be purely for behaviors that are ultimately doing interactions between other services?
@06silverfire
@06silverfire 3 года назад
But why? What does this afford? You say less decoupling but what does that mean in ROI. I mean this all works just fine but I don’t see the advantage over Entity based as Entity based is straight forward to find things. Why rebuild the wheel if it isn’t better, just different.
@CodeOpinion
@CodeOpinion 3 года назад
Coupling and Cohesion are a yin and yang. You want to high cohesion and low levels of coupling. But generally you need one with the other. It's about finding a balance. Generally I find entity services have high coupling and low cohesion, which is exactly the opposite of what you're after.
@ledjonbehluli1306
@ledjonbehluli1306 3 года назад
Why? Well if you have a small application which you can manage the "ripple" effect of changes, and it doesn't have to scale for a larger audience, than I agree with you, keep simple as it just "works". If in the other hand you or a team can't manage these ripple effects (in a timely fashion), and your app needs to scale for a large audience, than you go with approach Derek elaborated on the video. Obv it comes with it's drawbacks (mainly costs & more complex technological aspect's)
@CodeOpinion
@CodeOpinion 3 года назад
Thanks for the additional comment. I agree, everything has tradeoffs. If you have a simple model and data structure with coupling that's in check, then you don't need to separate by behaviors. I often times forget to put some context in that I'm relating these concepts to large systems where as you mentioned, you have a large audience (teams/services, whatever, coupling in general). Thanks for the comment, appreciated it.
@0w784g
@0w784g 2 года назад
There's no reason these idiomatic capabilities would not be right at home atop a entity service layer. AdjustPrice just takes a dependency on your 'Product' entity service. Tell me, how would you handle AdjustPrice without an 'entity service'?
@CodeOpinion
@CodeOpinion 2 года назад
Entity Service being CRUD around an Entity. You can still use entities but expose behaviors and tasks, not CRUD. Check out this video on decomposing CRUD into a Task Based UI if you haven't already: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-DjZepWrAKzM.html
@acidrazor
@acidrazor Год назад
Personally I would never design my DB to have quantity and price on the product entity to start with. Reporting would be ass if sales wants a rundown on products sold before and after a deal or a price increase. new stock would have new cost pricing that affects margins if retail pricing stays the same etc. But that has nothing to do with the video and Im just bored. 😜
@gafarolanipekun1202
@gafarolanipekun1202 2 года назад
Your approach do not follow Object oriented programming. Can you slip yourself into 2? This approach will accommodate a whole lot of repetition, at the long run will be very difficult to manage. Loose coupling can also be achieved in Service oriented design which is to sync your dev into using more composition/aggregation. I think it is futuristic but still need more juice.
@ck_naik
@ck_naik 2 года назад
Simple data model but massive schema 🤣
@dagochen
@dagochen Год назад
You missunderstood the sense of entity servcices. What you are describing here are usecases. Entity Services have one job: make sure each instance of an entity issssss valid and follows the business rules.
Далее
The HIDDEN Challenge of Microservices: UI Composition
11:11
Event Sourcing Example & Explained in plain English
18:23
"I NEED data from another service!"...  Do you really?
10:41
Wait... PostgreSQL can do WHAT?
20:33
Просмотров 191 тыс.
Is an ANEMIC Domain Model really that BAD?
10:36
Просмотров 17 тыс.
Monolith vs Microservices vs Serverless
23:05
Просмотров 76 тыс.
Defining Service Boundaries by Splitting Entities
10:43
Beware! Anti-patterns in Event-Driven Architecture
10:34
КРУТОЙ ТЕЛЕФОН
0:16
Просмотров 6 млн
Battery  low 🔋 🪫
0:10
Просмотров 13 млн