Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. How far is to far for separation of concerns?

How far is to far for separation of concerns?

Scheduled Pinned Locked Moved The Lounge
csharpasp-netbusinessregexarchitecture
20 Posts 12 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GateKeeper22
    wrote on last edited by
    #1

    I currently working on a project in MVC .net and I found my self asking how far is to far for separation of concerns? A little back history. The project I am working on is separated into business logic, data access, and business entity layers. It is a web app that is developed using the MVC pattern so it also has Controllers and Views. We are currently using our business entity objects as our model for this project. But now one of the developers I work with wants to implement view models that inherit from the business entities. 99.9% of the time the view model will just be an empty class that inherits from the business entities. I am against using adding another layer to the app and I want to find out what some other peoples opinions are.

    H P B R T 8 Replies Last reply
    0
    • G GateKeeper22

      I currently working on a project in MVC .net and I found my self asking how far is to far for separation of concerns? A little back history. The project I am working on is separated into business logic, data access, and business entity layers. It is a web app that is developed using the MVC pattern so it also has Controllers and Views. We are currently using our business entity objects as our model for this project. But now one of the developers I work with wants to implement view models that inherit from the business entities. 99.9% of the time the view model will just be an empty class that inherits from the business entities. I am against using adding another layer to the app and I want to find out what some other peoples opinions are.

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      To be really effective you should really have a decree nisi of concerns. So you probably have a couple of levels still to go.

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” I wouldn't let CG touch my Abacus! When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.

      1 Reply Last reply
      0
      • G GateKeeper22

        I currently working on a project in MVC .net and I found my self asking how far is to far for separation of concerns? A little back history. The project I am working on is separated into business logic, data access, and business entity layers. It is a web app that is developed using the MVC pattern so it also has Controllers and Views. We are currently using our business entity objects as our model for this project. But now one of the developers I work with wants to implement view models that inherit from the business entities. 99.9% of the time the view model will just be an empty class that inherits from the business entities. I am against using adding another layer to the app and I want to find out what some other peoples opinions are.

        B Offline
        B Offline
        BobJanova
        wrote on last edited by
        #3

        This is quite close to a programming question. Generally it's too far if you find yourself adding code simply to fulfil some vision of how it 'should be done'. That sounds like it might be the case here. To my mind, a view model (or a binding helper or presenter or several other names) is essentially a translator between the real model and what the view needs to communicate with – i.e. a view model specifies bindable properties for things you'd want to put on the view, even though those might well be something you don't want in the model. (For example the model might have a uint or a flagwise enum for a collection of flags, but the view model could have ten boolean properties.) If the model already thinks in the same way as your view, you don't need one (yet!).

        1 Reply Last reply
        0
        • G GateKeeper22

          I currently working on a project in MVC .net and I found my self asking how far is to far for separation of concerns? A little back history. The project I am working on is separated into business logic, data access, and business entity layers. It is a web app that is developed using the MVC pattern so it also has Controllers and Views. We are currently using our business entity objects as our model for this project. But now one of the developers I work with wants to implement view models that inherit from the business entities. 99.9% of the time the view model will just be an empty class that inherits from the business entities. I am against using adding another layer to the app and I want to find out what some other peoples opinions are.

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          This question really belongs in the design forum. If I were you, I would ask it over there so that you hopefully get a sensible discussion.

          Forgive your enemies - it messes with their heads

          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

          My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

          1 Reply Last reply
          0
          • G GateKeeper22

            I currently working on a project in MVC .net and I found my self asking how far is to far for separation of concerns? A little back history. The project I am working on is separated into business logic, data access, and business entity layers. It is a web app that is developed using the MVC pattern so it also has Controllers and Views. We are currently using our business entity objects as our model for this project. But now one of the developers I work with wants to implement view models that inherit from the business entities. 99.9% of the time the view model will just be an empty class that inherits from the business entities. I am against using adding another layer to the app and I want to find out what some other peoples opinions are.

            R Offline
            R Offline
            R Giskard Reventlov
            wrote on last edited by
            #5

            Don't do it - you're just adding a layer for the sake of it - unless you can prove it adds something to the project or is absolutely required then remind said pup that simply adding complexity because it is clever does not make it better.

            "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

            G L A 3 Replies Last reply
            0
            • R R Giskard Reventlov

              Don't do it - you're just adding a layer for the sake of it - unless you can prove it adds something to the project or is absolutely required then remind said pup that simply adding complexity because it is clever does not make it better.

              "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

              G Offline
              G Offline
              GateKeeper22
              wrote on last edited by
              #6

              I can't see that it will add any benefit. On the rare case that it does I have created a View model to handle it.

              R 1 Reply Last reply
              0
              • R R Giskard Reventlov

                Don't do it - you're just adding a layer for the sake of it - unless you can prove it adds something to the project or is absolutely required then remind said pup that simply adding complexity because it is clever does not make it better.

                "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                mark merrens wrote:

                adding complexity because it is clever does not make it better

                There speaks a true software engineer. :) It takes many years of banging out code to know that. Young guys, listen.

                ============================== Nothing to say.

                R 1 Reply Last reply
                0
                • G GateKeeper22

                  I can't see that it will add any benefit. On the rare case that it does I have created a View model to handle it.

                  R Offline
                  R Offline
                  R Giskard Reventlov
                  wrote on last edited by
                  #8

                  Without a tangible benefit what's the point? Work for the sake of work: over engineering an application doesn't make it better - more often that not it becomes a support nightmare. KISS: keep it simple, stupid is what I was always taught (and, yes, my name was 'stupid').

                  "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

                  1 Reply Last reply
                  0
                  • L Lost User

                    mark merrens wrote:

                    adding complexity because it is clever does not make it better

                    There speaks a true software engineer. :) It takes many years of banging out code to know that. Young guys, listen.

                    ============================== Nothing to say.

                    R Offline
                    R Offline
                    R Giskard Reventlov
                    wrote on last edited by
                    #9

                    Thanks. :thumbsup:

                    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

                    1 Reply Last reply
                    0
                    • G GateKeeper22

                      I currently working on a project in MVC .net and I found my self asking how far is to far for separation of concerns? A little back history. The project I am working on is separated into business logic, data access, and business entity layers. It is a web app that is developed using the MVC pattern so it also has Controllers and Views. We are currently using our business entity objects as our model for this project. But now one of the developers I work with wants to implement view models that inherit from the business entities. 99.9% of the time the view model will just be an empty class that inherits from the business entities. I am against using adding another layer to the app and I want to find out what some other peoples opinions are.

                      T Offline
                      T Offline
                      TheGreatAndPowerfulOz
                      wrote on last edited by
                      #10

                      You should use a "View Model" when there are class members that have only to do with the view, such as whether or not some element should be displayed, its color, what have you. But in that case I would not inherit from the Business entity object, I would have a copy of the class that I translate back and forth to the entity object. If you're concerned with performance penalty, it really isn't a concern since the user-time and network usage will swamp any time taken to translate between the "View Model" and the "Business Model".

                      If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
                      You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

                      1 Reply Last reply
                      0
                      • G GateKeeper22

                        I currently working on a project in MVC .net and I found my self asking how far is to far for separation of concerns? A little back history. The project I am working on is separated into business logic, data access, and business entity layers. It is a web app that is developed using the MVC pattern so it also has Controllers and Views. We are currently using our business entity objects as our model for this project. But now one of the developers I work with wants to implement view models that inherit from the business entities. 99.9% of the time the view model will just be an empty class that inherits from the business entities. I am against using adding another layer to the app and I want to find out what some other peoples opinions are.

                        M Offline
                        M Offline
                        Mel Padden
                        wrote on last edited by
                        #11

                        Add ViewModels as and when they are needed, not an instant before. Your junior developers will thank you for it, as will your boss for not spending a half-day writing code which has no inherent value. Mr. Merrens represents my feelings on this point very well. Allow me to add my own tuppence ha'penny; As an earnest, aspirational young dev, I spent many months poring over architecture books and learning new and obscure scripting languages, familiarising myself with the DLR etc., in the hope it would make me a better dev, and to an extent it did. But, better still was the realisation that 9/10 times, you don't need this stuff for LOB apps. The Gang of Four book is full of excellent patterns and paradigms. But, and this is a big but, most of them apply to software that does stuff you just don't find yourself doing, in the normal run of things. graphics processing, text editors, machine programming... Most LOB apps consist of a basic UI, some vanilla logic in the middle tier, and data access. That is all. It is THE most important thing to know what you don't need. And this isn't bitter-old-man stuff. Rather, it's bright-young-man-with-better-things-to-do stuff, is what it is. Use frameworks and patterns to remove the makework out of developing software, not to put it in. Data access and logging modules are things you should never, ever, have to write. Another very real way of looking at it is saying that you should reduce the amount of code you write to the bare minimum. That reduces the potential error footprint. Don't go around solving problems that don't exist. Rather, concentrate on the ones that do. :thumbsup: [Edit] Thanks for the 5 votes guys. But, Ahmed, dude? Get out more... :cool: I hasten to add that I have personal experience of making a project much more tiresome than it should have been because I went in guns hot with factory patterns and generics and doodads of every description. Never again. So, I guess, do as I say, not as I do... I have also spent the last two months rewriting a monstrous desktop app which does some very simple things in extremely complex ways, because three separate contractors came in with their own twatfaced opinions about what constituted a proper DAO layer. Ludicrous.

                        Smokie, this is not 'Nam. This is bowling. There are rules. http://melpadden.wordpress.com LinkedIn

                        R T Sander RosselS 3 Replies Last reply
                        0
                        • M Mel Padden

                          Add ViewModels as and when they are needed, not an instant before. Your junior developers will thank you for it, as will your boss for not spending a half-day writing code which has no inherent value. Mr. Merrens represents my feelings on this point very well. Allow me to add my own tuppence ha'penny; As an earnest, aspirational young dev, I spent many months poring over architecture books and learning new and obscure scripting languages, familiarising myself with the DLR etc., in the hope it would make me a better dev, and to an extent it did. But, better still was the realisation that 9/10 times, you don't need this stuff for LOB apps. The Gang of Four book is full of excellent patterns and paradigms. But, and this is a big but, most of them apply to software that does stuff you just don't find yourself doing, in the normal run of things. graphics processing, text editors, machine programming... Most LOB apps consist of a basic UI, some vanilla logic in the middle tier, and data access. That is all. It is THE most important thing to know what you don't need. And this isn't bitter-old-man stuff. Rather, it's bright-young-man-with-better-things-to-do stuff, is what it is. Use frameworks and patterns to remove the makework out of developing software, not to put it in. Data access and logging modules are things you should never, ever, have to write. Another very real way of looking at it is saying that you should reduce the amount of code you write to the bare minimum. That reduces the potential error footprint. Don't go around solving problems that don't exist. Rather, concentrate on the ones that do. :thumbsup: [Edit] Thanks for the 5 votes guys. But, Ahmed, dude? Get out more... :cool: I hasten to add that I have personal experience of making a project much more tiresome than it should have been because I went in guns hot with factory patterns and generics and doodads of every description. Never again. So, I guess, do as I say, not as I do... I have also spent the last two months rewriting a monstrous desktop app which does some very simple things in extremely complex ways, because three separate contractors came in with their own twatfaced opinions about what constituted a proper DAO layer. Ludicrous.

                          Smokie, this is not 'Nam. This is bowling. There are rules. http://melpadden.wordpress.com LinkedIn

                          T Offline
                          T Offline
                          TheGreatAndPowerfulOz
                          wrote on last edited by
                          #12

                          Mel Padden wrote:

                          Use frameworks and patterns to remove the makework out of developing software, not to put it in. Data access and logging modules are things you should never, ever, have to write. Another very real way of looking at it is saying that you should reduce the amount of code you write to the bare minimum. That reduces the potential error footprint.

                          Yes! Yes! Ohh! YES!

                          If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
                          You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

                          1 Reply Last reply
                          0
                          • M Mel Padden

                            Add ViewModels as and when they are needed, not an instant before. Your junior developers will thank you for it, as will your boss for not spending a half-day writing code which has no inherent value. Mr. Merrens represents my feelings on this point very well. Allow me to add my own tuppence ha'penny; As an earnest, aspirational young dev, I spent many months poring over architecture books and learning new and obscure scripting languages, familiarising myself with the DLR etc., in the hope it would make me a better dev, and to an extent it did. But, better still was the realisation that 9/10 times, you don't need this stuff for LOB apps. The Gang of Four book is full of excellent patterns and paradigms. But, and this is a big but, most of them apply to software that does stuff you just don't find yourself doing, in the normal run of things. graphics processing, text editors, machine programming... Most LOB apps consist of a basic UI, some vanilla logic in the middle tier, and data access. That is all. It is THE most important thing to know what you don't need. And this isn't bitter-old-man stuff. Rather, it's bright-young-man-with-better-things-to-do stuff, is what it is. Use frameworks and patterns to remove the makework out of developing software, not to put it in. Data access and logging modules are things you should never, ever, have to write. Another very real way of looking at it is saying that you should reduce the amount of code you write to the bare minimum. That reduces the potential error footprint. Don't go around solving problems that don't exist. Rather, concentrate on the ones that do. :thumbsup: [Edit] Thanks for the 5 votes guys. But, Ahmed, dude? Get out more... :cool: I hasten to add that I have personal experience of making a project much more tiresome than it should have been because I went in guns hot with factory patterns and generics and doodads of every description. Never again. So, I guess, do as I say, not as I do... I have also spent the last two months rewriting a monstrous desktop app which does some very simple things in extremely complex ways, because three separate contractors came in with their own twatfaced opinions about what constituted a proper DAO layer. Ludicrous.

                            Smokie, this is not 'Nam. This is bowling. There are rules. http://melpadden.wordpress.com LinkedIn

                            R Offline
                            R Offline
                            R Giskard Reventlov
                            wrote on last edited by
                            #13

                            Well said. :thumbsup:

                            "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

                            1 Reply Last reply
                            0
                            • G GateKeeper22

                              I currently working on a project in MVC .net and I found my self asking how far is to far for separation of concerns? A little back history. The project I am working on is separated into business logic, data access, and business entity layers. It is a web app that is developed using the MVC pattern so it also has Controllers and Views. We are currently using our business entity objects as our model for this project. But now one of the developers I work with wants to implement view models that inherit from the business entities. 99.9% of the time the view model will just be an empty class that inherits from the business entities. I am against using adding another layer to the app and I want to find out what some other peoples opinions are.

                              V Offline
                              V Offline
                              Vark111
                              wrote on last edited by
                              #14

                              Everyone else has gone over whether you need them or not. So I'll just add this: Please, for love of all that is Holy, if you do use view models, do not ever have them inherit from your business models. Madness lies that way. Have them encapsulate the business models you need, or copy the properties if more separation is needed, but don't ever inherit one layer from another. That completely defeats the purpose of layering in the first place.

                              A 1 Reply Last reply
                              0
                              • G GateKeeper22

                                I currently working on a project in MVC .net and I found my self asking how far is to far for separation of concerns? A little back history. The project I am working on is separated into business logic, data access, and business entity layers. It is a web app that is developed using the MVC pattern so it also has Controllers and Views. We are currently using our business entity objects as our model for this project. But now one of the developers I work with wants to implement view models that inherit from the business entities. 99.9% of the time the view model will just be an empty class that inherits from the business entities. I am against using adding another layer to the app and I want to find out what some other peoples opinions are.

                                L Offline
                                L Offline
                                Lost User
                                wrote on last edited by
                                #15

                                How about you want to include in your model a list of objects and a list of countries for thr drop-down?

                                G 1 Reply Last reply
                                0
                                • L Lost User

                                  How about you want to include in your model a list of objects and a list of countries for thr drop-down?

                                  G Offline
                                  G Offline
                                  GateKeeper22
                                  wrote on last edited by
                                  #16

                                  In that case I would create a view model for the business entity that needed the drop down or use ViewData. I am against creating view models for all of the business entities just so we can say we have a view model layer.

                                  L 1 Reply Last reply
                                  0
                                  • V Vark111

                                    Everyone else has gone over whether you need them or not. So I'll just add this: Please, for love of all that is Holy, if you do use view models, do not ever have them inherit from your business models. Madness lies that way. Have them encapsulate the business models you need, or copy the properties if more separation is needed, but don't ever inherit one layer from another. That completely defeats the purpose of layering in the first place.

                                    A Offline
                                    A Offline
                                    AS TKK
                                    wrote on last edited by
                                    #17

                                    Of all the very-sensible things I see in this thread, this is probably the most critical one! :)

                                    1 Reply Last reply
                                    0
                                    • M Mel Padden

                                      Add ViewModels as and when they are needed, not an instant before. Your junior developers will thank you for it, as will your boss for not spending a half-day writing code which has no inherent value. Mr. Merrens represents my feelings on this point very well. Allow me to add my own tuppence ha'penny; As an earnest, aspirational young dev, I spent many months poring over architecture books and learning new and obscure scripting languages, familiarising myself with the DLR etc., in the hope it would make me a better dev, and to an extent it did. But, better still was the realisation that 9/10 times, you don't need this stuff for LOB apps. The Gang of Four book is full of excellent patterns and paradigms. But, and this is a big but, most of them apply to software that does stuff you just don't find yourself doing, in the normal run of things. graphics processing, text editors, machine programming... Most LOB apps consist of a basic UI, some vanilla logic in the middle tier, and data access. That is all. It is THE most important thing to know what you don't need. And this isn't bitter-old-man stuff. Rather, it's bright-young-man-with-better-things-to-do stuff, is what it is. Use frameworks and patterns to remove the makework out of developing software, not to put it in. Data access and logging modules are things you should never, ever, have to write. Another very real way of looking at it is saying that you should reduce the amount of code you write to the bare minimum. That reduces the potential error footprint. Don't go around solving problems that don't exist. Rather, concentrate on the ones that do. :thumbsup: [Edit] Thanks for the 5 votes guys. But, Ahmed, dude? Get out more... :cool: I hasten to add that I have personal experience of making a project much more tiresome than it should have been because I went in guns hot with factory patterns and generics and doodads of every description. Never again. So, I guess, do as I say, not as I do... I have also spent the last two months rewriting a monstrous desktop app which does some very simple things in extremely complex ways, because three separate contractors came in with their own twatfaced opinions about what constituted a proper DAO layer. Ludicrous.

                                      Smokie, this is not 'Nam. This is bowling. There are rules. http://melpadden.wordpress.com LinkedIn

                                      Sander RosselS Offline
                                      Sander RosselS Offline
                                      Sander Rossel
                                      wrote on last edited by
                                      #18

                                      Mel Padden wrote:

                                      I have also spent the last two months rewriting a monstrous desktop app which does some very simple things in extremely complex ways, because three separate contractors came in with their own twatfaced opinions about what constituted a proper DAO layer. Ludicrous.

                                      I spend days making a bit of code depend more upon abstractions because it just could not do what we wanted it to do, while it should've been able to do that. I had proposed the abstractions earlier on in the design process, but 'they were not necessary and only complicated things'... Then, about two months later, we DID need the abstractions. We were feverishly Inheriting code we didn't need just so we didn't have to copy/paste a couple of 100's of lines that we wanted to re-use, but couldn't due to some missing abstractions. I was still able to add the extra layer of abstractions, but it cost me a couple of days that could have been saved had we done it right from the start. The design is nice and clean now and there is no duplicate code (just a couple of Interfaces extra). Your story is also very true and nicely said. I just wanted to illustrate an opposite case where things were not 'complex' enough (in my experience design is usually perceived as 'added complexity') :)

                                      It's an OO world.

                                      public class Naerling : Lazy<Person>{
                                      public void DoWork(){ throw new NotImplementedException(); }
                                      }

                                      1 Reply Last reply
                                      0
                                      • R R Giskard Reventlov

                                        Don't do it - you're just adding a layer for the sake of it - unless you can prove it adds something to the project or is absolutely required then remind said pup that simply adding complexity because it is clever does not make it better.

                                        "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

                                        A Offline
                                        A Offline
                                        agolddog
                                        wrote on last edited by
                                        #19

                                        What Mark said. This notion of "if we don't add this feature it won't be enterprisy enough is bad. Don't solve problems which don't actually exist. Upon the first need for the new layer, implement the solution at that time. You'll be surprised how often the layer you thought was necessary turns out not to be. It is good, though, to consider those alternatives. That way, you can design your solution in such a way that minimizes the difficulty of extending it in a way you anticipate needing in the future without spending time to actually implement that extension.

                                        1 Reply Last reply
                                        0
                                        • G GateKeeper22

                                          In that case I would create a view model for the business entity that needed the drop down or use ViewData. I am against creating view models for all of the business entities just so we can say we have a view model layer.

                                          L Offline
                                          L Offline
                                          Lost User
                                          wrote on last edited by
                                          #20

                                          "The ViewDataDictionary approach has the benefit of being fairly fast and easy to implement. Some developers don’t like using string-based dictionaries, though, since typos can lead to errors that will not be caught at compile-time. The untyped ViewDataDictionary also requires using the as operator or casting when using a strongly typed language like C# in a View template. An alternative approach that we could use is one often referred to as the ViewModel pattern. When using this pattern, we create strongly typed classes that are optimized for our specific View scenarios and that expose properties for the dynamic values/content needed by our View templates. Our Controller classes can then populate and pass these View-optimized classes to our View template to use. This enables type safety, compile-time checking, and editor IntelliSense within View templates." ViewModels don't have to be inherited from the entities though, although it' still better than using only entities imho.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups