Blazor - Best Architecture For Blazor Apps? #22821
Unanswered
MrOldham101
asked this question in
General
Replies: 1 comment
-
I use a similar pattern. I have several Component where T is one of the models. This is so I wont have to write different components for different models. I'm unsure if this is a good practice. In some cases I have models that includes models, or list of models. I also would like to have several views to display for each model (such as Initials instead of FullName). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Now I know there is no such thing as a "best" architecture in any category of software development. However, after working with Blazor on a few smaller projects to familiarise myself, I keep coming to the same sort of pattern each time:
Data Models:
good old models that describe the data in your database and control access and validation for it. I'm not sure we will ever get away from these, off the top of my head I cannot find anything negative to say about them.
Services:
Just a class containing all the functionality of a specific model. I find that 1 service class per model class seems to work well. some people like to combine their services with their models however I disagree with this as often you will need to interact with other models within your service class.
Pages / Components - A folder of pages (anything that you stick a page route at the top of) and a folder of reusable UI components. These components/pages deal with what can be displayed (permissions), routing and interacting with any services they need too. Considering Blazor deals with updating the DOM for you, you just edit your data via your services and let Blazor do the rendering.
So far I have found this has trumped every other pattern I have used (MVC, large repositories, etc.) in almost every area. It's fast to develop, enforces separation of concerns, very simplistic and natural to understand and very reusable.
I am interested in what other people think of this pattern I'm using (and if it has a name I am unaware of) and any patterns they are using.
Beta Was this translation helpful? Give feedback.
All reactions