Should I create separate ViewModels for Models which inherit the same interface and use the same views?












-2















I am currently trying to learn MVVM - this is my first application, apologies if my understanding is poor. I have been tasked with creating a Medical Resource Management System which allows for different disciplines of Doctor e.g. Cardiologist, Pulmonologist, Urologist etc to be registered and deregistered in the system.




These Doctors must hold discipline specific information




All disciplines inherit from an IDoctor interface. Currently I have 10 separate Models - one for each discipline of doctor. These doctors will all interact with similar views i.e register view, deregister view, however, I am unsure how I should approach hooking up each Model to the view via the ViewModel. Should I create separate ViewModels foreach Discipline's interaction with the View or contain all disciplines within one ViewModel?



I have created the following view:



RegistrationView



From here I am unsure if I should create a ViewModel for each specific Discipline of Doctor which interacts with this View or if there is some more practical way to approach this.










share|improve this question

























  • Currently I have 10 separate Models - one for each discipline of doctor.... can't that be solved in another way?

    – Stefan
    Nov 21 '18 at 21:31











  • How different are the types of doctor model? Do they each contain specific information or have logic in them?

    – Coops
    Nov 22 '18 at 16:50











  • @Coops One of the Doctor types (Surgeons) must be registered with a latest certification date, similarly other doctors have discipline specific data.

    – MattR
    Nov 22 '18 at 18:59
















-2















I am currently trying to learn MVVM - this is my first application, apologies if my understanding is poor. I have been tasked with creating a Medical Resource Management System which allows for different disciplines of Doctor e.g. Cardiologist, Pulmonologist, Urologist etc to be registered and deregistered in the system.




These Doctors must hold discipline specific information




All disciplines inherit from an IDoctor interface. Currently I have 10 separate Models - one for each discipline of doctor. These doctors will all interact with similar views i.e register view, deregister view, however, I am unsure how I should approach hooking up each Model to the view via the ViewModel. Should I create separate ViewModels foreach Discipline's interaction with the View or contain all disciplines within one ViewModel?



I have created the following view:



RegistrationView



From here I am unsure if I should create a ViewModel for each specific Discipline of Doctor which interacts with this View or if there is some more practical way to approach this.










share|improve this question

























  • Currently I have 10 separate Models - one for each discipline of doctor.... can't that be solved in another way?

    – Stefan
    Nov 21 '18 at 21:31











  • How different are the types of doctor model? Do they each contain specific information or have logic in them?

    – Coops
    Nov 22 '18 at 16:50











  • @Coops One of the Doctor types (Surgeons) must be registered with a latest certification date, similarly other doctors have discipline specific data.

    – MattR
    Nov 22 '18 at 18:59














-2












-2








-2


0






I am currently trying to learn MVVM - this is my first application, apologies if my understanding is poor. I have been tasked with creating a Medical Resource Management System which allows for different disciplines of Doctor e.g. Cardiologist, Pulmonologist, Urologist etc to be registered and deregistered in the system.




These Doctors must hold discipline specific information




All disciplines inherit from an IDoctor interface. Currently I have 10 separate Models - one for each discipline of doctor. These doctors will all interact with similar views i.e register view, deregister view, however, I am unsure how I should approach hooking up each Model to the view via the ViewModel. Should I create separate ViewModels foreach Discipline's interaction with the View or contain all disciplines within one ViewModel?



I have created the following view:



RegistrationView



From here I am unsure if I should create a ViewModel for each specific Discipline of Doctor which interacts with this View or if there is some more practical way to approach this.










share|improve this question
















I am currently trying to learn MVVM - this is my first application, apologies if my understanding is poor. I have been tasked with creating a Medical Resource Management System which allows for different disciplines of Doctor e.g. Cardiologist, Pulmonologist, Urologist etc to be registered and deregistered in the system.




These Doctors must hold discipline specific information




All disciplines inherit from an IDoctor interface. Currently I have 10 separate Models - one for each discipline of doctor. These doctors will all interact with similar views i.e register view, deregister view, however, I am unsure how I should approach hooking up each Model to the view via the ViewModel. Should I create separate ViewModels foreach Discipline's interaction with the View or contain all disciplines within one ViewModel?



I have created the following view:



RegistrationView



From here I am unsure if I should create a ViewModel for each specific Discipline of Doctor which interacts with this View or if there is some more practical way to approach this.







c# wpf mvvm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 19:34







MattR

















asked Nov 21 '18 at 21:28









MattRMattR

11




11













  • Currently I have 10 separate Models - one for each discipline of doctor.... can't that be solved in another way?

    – Stefan
    Nov 21 '18 at 21:31











  • How different are the types of doctor model? Do they each contain specific information or have logic in them?

    – Coops
    Nov 22 '18 at 16:50











  • @Coops One of the Doctor types (Surgeons) must be registered with a latest certification date, similarly other doctors have discipline specific data.

    – MattR
    Nov 22 '18 at 18:59



















  • Currently I have 10 separate Models - one for each discipline of doctor.... can't that be solved in another way?

    – Stefan
    Nov 21 '18 at 21:31











  • How different are the types of doctor model? Do they each contain specific information or have logic in them?

    – Coops
    Nov 22 '18 at 16:50











  • @Coops One of the Doctor types (Surgeons) must be registered with a latest certification date, similarly other doctors have discipline specific data.

    – MattR
    Nov 22 '18 at 18:59

















Currently I have 10 separate Models - one for each discipline of doctor.... can't that be solved in another way?

– Stefan
Nov 21 '18 at 21:31





Currently I have 10 separate Models - one for each discipline of doctor.... can't that be solved in another way?

– Stefan
Nov 21 '18 at 21:31













How different are the types of doctor model? Do they each contain specific information or have logic in them?

– Coops
Nov 22 '18 at 16:50





How different are the types of doctor model? Do they each contain specific information or have logic in them?

– Coops
Nov 22 '18 at 16:50













@Coops One of the Doctor types (Surgeons) must be registered with a latest certification date, similarly other doctors have discipline specific data.

– MattR
Nov 22 '18 at 18:59





@Coops One of the Doctor types (Surgeons) must be registered with a latest certification date, similarly other doctors have discipline specific data.

– MattR
Nov 22 '18 at 18:59












2 Answers
2






active

oldest

votes


















0















Should I create separate ViewModels foreach Discipline's interaction with the View or contain all disciplines within one ViewModel?




A ViewModel is to support a View. So, in your case, first define your view: i.e.: create the labels, lists, buttons etc.



This will give you a better view (excuse the pun) on your ViewModel. Normally the view is to interact, and it doesn't make sense to create 10 different screens for just a different discipline.






share|improve this answer
























  • The pun is appreciated! I will work on the view and see if it clears this up for me

    – MattR
    Nov 21 '18 at 21:45











  • Good luck, let me know if it did ;-)

    – Stefan
    Nov 21 '18 at 21:56



















0














in MVVM view and ViewModel are somehow tightly coupled. I would not say to build exactly one VM for each View. Its totaly dependent on view, how It will function. For example You have task to display address of customer such that customer details page can see address in tab control with each and every information, where there is another view where customer address displays only few columns, and another one, where customer can edit his address.
Ideally these 3 view have same business, i.e. show address, but layout is different; also only edit view has extra functionality to edit changes.
In such situation, you don't need to create saperate VM for each view, instead create one VM and use it smartly.



Now Models and ViewModels are loosely coupled, Only models will be part of VM, which is required by View.
In address example I might have Models of CustomerAddress, City, or POBox (which retrieve all information based on PO code).
but I dont need to create VM for Pobox or City; but Address VM need these models.
Hope you got the point






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420700%2fshould-i-create-separate-viewmodels-for-models-which-inherit-the-same-interface%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0















    Should I create separate ViewModels foreach Discipline's interaction with the View or contain all disciplines within one ViewModel?




    A ViewModel is to support a View. So, in your case, first define your view: i.e.: create the labels, lists, buttons etc.



    This will give you a better view (excuse the pun) on your ViewModel. Normally the view is to interact, and it doesn't make sense to create 10 different screens for just a different discipline.






    share|improve this answer
























    • The pun is appreciated! I will work on the view and see if it clears this up for me

      – MattR
      Nov 21 '18 at 21:45











    • Good luck, let me know if it did ;-)

      – Stefan
      Nov 21 '18 at 21:56
















    0















    Should I create separate ViewModels foreach Discipline's interaction with the View or contain all disciplines within one ViewModel?




    A ViewModel is to support a View. So, in your case, first define your view: i.e.: create the labels, lists, buttons etc.



    This will give you a better view (excuse the pun) on your ViewModel. Normally the view is to interact, and it doesn't make sense to create 10 different screens for just a different discipline.






    share|improve this answer
























    • The pun is appreciated! I will work on the view and see if it clears this up for me

      – MattR
      Nov 21 '18 at 21:45











    • Good luck, let me know if it did ;-)

      – Stefan
      Nov 21 '18 at 21:56














    0












    0








    0








    Should I create separate ViewModels foreach Discipline's interaction with the View or contain all disciplines within one ViewModel?




    A ViewModel is to support a View. So, in your case, first define your view: i.e.: create the labels, lists, buttons etc.



    This will give you a better view (excuse the pun) on your ViewModel. Normally the view is to interact, and it doesn't make sense to create 10 different screens for just a different discipline.






    share|improve this answer














    Should I create separate ViewModels foreach Discipline's interaction with the View or contain all disciplines within one ViewModel?




    A ViewModel is to support a View. So, in your case, first define your view: i.e.: create the labels, lists, buttons etc.



    This will give you a better view (excuse the pun) on your ViewModel. Normally the view is to interact, and it doesn't make sense to create 10 different screens for just a different discipline.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 21 '18 at 21:36









    StefanStefan

    8,41873760




    8,41873760













    • The pun is appreciated! I will work on the view and see if it clears this up for me

      – MattR
      Nov 21 '18 at 21:45











    • Good luck, let me know if it did ;-)

      – Stefan
      Nov 21 '18 at 21:56



















    • The pun is appreciated! I will work on the view and see if it clears this up for me

      – MattR
      Nov 21 '18 at 21:45











    • Good luck, let me know if it did ;-)

      – Stefan
      Nov 21 '18 at 21:56

















    The pun is appreciated! I will work on the view and see if it clears this up for me

    – MattR
    Nov 21 '18 at 21:45





    The pun is appreciated! I will work on the view and see if it clears this up for me

    – MattR
    Nov 21 '18 at 21:45













    Good luck, let me know if it did ;-)

    – Stefan
    Nov 21 '18 at 21:56





    Good luck, let me know if it did ;-)

    – Stefan
    Nov 21 '18 at 21:56













    0














    in MVVM view and ViewModel are somehow tightly coupled. I would not say to build exactly one VM for each View. Its totaly dependent on view, how It will function. For example You have task to display address of customer such that customer details page can see address in tab control with each and every information, where there is another view where customer address displays only few columns, and another one, where customer can edit his address.
    Ideally these 3 view have same business, i.e. show address, but layout is different; also only edit view has extra functionality to edit changes.
    In such situation, you don't need to create saperate VM for each view, instead create one VM and use it smartly.



    Now Models and ViewModels are loosely coupled, Only models will be part of VM, which is required by View.
    In address example I might have Models of CustomerAddress, City, or POBox (which retrieve all information based on PO code).
    but I dont need to create VM for Pobox or City; but Address VM need these models.
    Hope you got the point






    share|improve this answer




























      0














      in MVVM view and ViewModel are somehow tightly coupled. I would not say to build exactly one VM for each View. Its totaly dependent on view, how It will function. For example You have task to display address of customer such that customer details page can see address in tab control with each and every information, where there is another view where customer address displays only few columns, and another one, where customer can edit his address.
      Ideally these 3 view have same business, i.e. show address, but layout is different; also only edit view has extra functionality to edit changes.
      In such situation, you don't need to create saperate VM for each view, instead create one VM and use it smartly.



      Now Models and ViewModels are loosely coupled, Only models will be part of VM, which is required by View.
      In address example I might have Models of CustomerAddress, City, or POBox (which retrieve all information based on PO code).
      but I dont need to create VM for Pobox or City; but Address VM need these models.
      Hope you got the point






      share|improve this answer


























        0












        0








        0







        in MVVM view and ViewModel are somehow tightly coupled. I would not say to build exactly one VM for each View. Its totaly dependent on view, how It will function. For example You have task to display address of customer such that customer details page can see address in tab control with each and every information, where there is another view where customer address displays only few columns, and another one, where customer can edit his address.
        Ideally these 3 view have same business, i.e. show address, but layout is different; also only edit view has extra functionality to edit changes.
        In such situation, you don't need to create saperate VM for each view, instead create one VM and use it smartly.



        Now Models and ViewModels are loosely coupled, Only models will be part of VM, which is required by View.
        In address example I might have Models of CustomerAddress, City, or POBox (which retrieve all information based on PO code).
        but I dont need to create VM for Pobox or City; but Address VM need these models.
        Hope you got the point






        share|improve this answer













        in MVVM view and ViewModel are somehow tightly coupled. I would not say to build exactly one VM for each View. Its totaly dependent on view, how It will function. For example You have task to display address of customer such that customer details page can see address in tab control with each and every information, where there is another view where customer address displays only few columns, and another one, where customer can edit his address.
        Ideally these 3 view have same business, i.e. show address, but layout is different; also only edit view has extra functionality to edit changes.
        In such situation, you don't need to create saperate VM for each view, instead create one VM and use it smartly.



        Now Models and ViewModels are loosely coupled, Only models will be part of VM, which is required by View.
        In address example I might have Models of CustomerAddress, City, or POBox (which retrieve all information based on PO code).
        but I dont need to create VM for Pobox or City; but Address VM need these models.
        Hope you got the point







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 4:46









        Kamran AsimKamran Asim

        48426




        48426






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420700%2fshould-i-create-separate-viewmodels-for-models-which-inherit-the-same-interface%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

            Alcedinidae

            Origin of the phrase “under your belt”?