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. Duplication vs. Complexity

Duplication vs. Complexity

Scheduled Pinned Locked Moved The Lounge
questionjavascriptvisual-studiodesignalgorithms
37 Posts 25 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.
  • J Jacquers

    Rubber ducking here... ;) I'm working on a project that has a form which the user must fill in to submit a request. This form is used for various request types (+- 4) and shares common functionality (about 70%) between them. I have the choice of duplicating the form (UI and probably Logic) for the various request types or having one form with sections and columns that will be shown or hidden based on the request type. Either approach has pros and cons... Duplication: More maintenance if the common sections / logic change. Each request type's form will need to be updated. Complexity: Potentially many if else statements and more complex to understand and maintain e.g. changes in the common sections could break it for multiple request types. Which approach would you use? Maybe there is a hybrid approach? Edit: This is an Angular project, but I think the question applies to development in general.

    M Offline
    M Offline
    Mircea Neacsu
    wrote on last edited by
    #5

    Without knowing all the details, it seems I have to point the obvious: do whatever is easier for the user. Don’t let him wade through a long, complicated form just because it makes your code nicer. In the end, users’ time is more valuable than yours (at least because there are so many of them) and making them happy should be the most important thing. Without them your company would not survive and you’d be looking for a job.

    Mircea

    J Kornfeld Eliyahu PeterK G 3 Replies Last reply
    0
    • M Mircea Neacsu

      Without knowing all the details, it seems I have to point the obvious: do whatever is easier for the user. Don’t let him wade through a long, complicated form just because it makes your code nicer. In the end, users’ time is more valuable than yours (at least because there are so many of them) and making them happy should be the most important thing. Without them your company would not survive and you’d be looking for a job.

      Mircea

      J Offline
      J Offline
      Jacquers
      wrote on last edited by
      #6

      I'm all for simplification, but I don't have a choice in how the form is structured and all the fields displayed are required. My question was aimed at the code layout / structure.

      1 Reply Last reply
      0
      • M Mircea Neacsu

        Without knowing all the details, it seems I have to point the obvious: do whatever is easier for the user. Don’t let him wade through a long, complicated form just because it makes your code nicer. In the end, users’ time is more valuable than yours (at least because there are so many of them) and making them happy should be the most important thing. Without them your company would not survive and you’d be looking for a job.

        Mircea

        Kornfeld Eliyahu PeterK Offline
        Kornfeld Eliyahu PeterK Offline
        Kornfeld Eliyahu Peter
        wrote on last edited by
        #7

        Mircea Neacsu wrote:

        making them happy should be the most important thing

        Except that sometime the most desired thing is to wipe them out totally :mad:

        "The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012

        "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

        M D 2 Replies Last reply
        0
        • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

          Mircea Neacsu wrote:

          making them happy should be the most important thing

          Except that sometime the most desired thing is to wipe them out totally :mad:

          "The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012

          M Offline
          M Offline
          Mircea Neacsu
          wrote on last edited by
          #8

          :laugh: Sure, but don’t we have the same love/hate relationship with many in our own families. Seriously speaking, I’m a passionate advocate for a user centric point of view. I’ve seen too many programmers and ‘architects’ in their ivory tower looking with disdain to lowly users and forgetting our whole profession come in existence just to help these users. Can you imagine the people at MIT programming the Apollo guidance computer and saying “screw these astronauts, they are just some trained monkeys”?

          Mircea

          1 Reply Last reply
          0
          • J Jacquers

            Rubber ducking here... ;) I'm working on a project that has a form which the user must fill in to submit a request. This form is used for various request types (+- 4) and shares common functionality (about 70%) between them. I have the choice of duplicating the form (UI and probably Logic) for the various request types or having one form with sections and columns that will be shown or hidden based on the request type. Either approach has pros and cons... Duplication: More maintenance if the common sections / logic change. Each request type's form will need to be updated. Complexity: Potentially many if else statements and more complex to understand and maintain e.g. changes in the common sections could break it for multiple request types. Which approach would you use? Maybe there is a hybrid approach? Edit: This is an Angular project, but I think the question applies to development in general.

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #9

            see yourself in 1 year, what kind of psychopath will you be when you'll have to do changes in that code. Refactor your code.

            CI/CD = Continuous Impediment/Continuous Despair

            J 1 Reply Last reply
            0
            • J Jacquers

              Rubber ducking here... ;) I'm working on a project that has a form which the user must fill in to submit a request. This form is used for various request types (+- 4) and shares common functionality (about 70%) between them. I have the choice of duplicating the form (UI and probably Logic) for the various request types or having one form with sections and columns that will be shown or hidden based on the request type. Either approach has pros and cons... Duplication: More maintenance if the common sections / logic change. Each request type's form will need to be updated. Complexity: Potentially many if else statements and more complex to understand and maintain e.g. changes in the common sections could break it for multiple request types. Which approach would you use? Maybe there is a hybrid approach? Edit: This is an Angular project, but I think the question applies to development in general.

              N Offline
              N Offline
              Nagy Vilmos
              wrote on last edited by
              #10

              I've successfully used a single dialog with all content and then injected the display and validation logic from a container. It should give you the best of both worlds.

              veni bibi saltavi

              N 1 Reply Last reply
              0
              • M Maximilien

                see yourself in 1 year, what kind of psychopath will you be when you'll have to do changes in that code. Refactor your code.

                CI/CD = Continuous Impediment/Continuous Despair

                J Offline
                J Offline
                Jacquers
                wrote on last edited by
                #11

                That's definitely part of my consideration on choosing the approach :) It's quite likely that another company will do the maintenance though due to an arrangement we have :laugh:

                1 Reply Last reply
                0
                • J Jacquers

                  Rubber ducking here... ;) I'm working on a project that has a form which the user must fill in to submit a request. This form is used for various request types (+- 4) and shares common functionality (about 70%) between them. I have the choice of duplicating the form (UI and probably Logic) for the various request types or having one form with sections and columns that will be shown or hidden based on the request type. Either approach has pros and cons... Duplication: More maintenance if the common sections / logic change. Each request type's form will need to be updated. Complexity: Potentially many if else statements and more complex to understand and maintain e.g. changes in the common sections could break it for multiple request types. Which approach would you use? Maybe there is a hybrid approach? Edit: This is an Angular project, but I think the question applies to development in general.

                  G Offline
                  G Offline
                  GuyThiebaut
                  wrote on last edited by
                  #12

                  Complexity is perhaps going to make it easier to extend. Duplication will in all likelihood make it easier to debug. I know it's the wrong answer from a software engineering point of view - but from the point of view of someone who spends a lot of time fixing defects on a huge code base I would go for duplication. I have seen a lot of code that makes use of inheritance and quite frankly I have found it to at times be something of a nightmare. Complexity is clever and is elegant but it can make tracking and fixing bugs a lot more difficult.

                  “That which can be asserted without evidence, can be dismissed without evidence.”

                  ― Christopher Hitchens

                  J 1 Reply Last reply
                  0
                  • J Jacquers

                    Rubber ducking here... ;) I'm working on a project that has a form which the user must fill in to submit a request. This form is used for various request types (+- 4) and shares common functionality (about 70%) between them. I have the choice of duplicating the form (UI and probably Logic) for the various request types or having one form with sections and columns that will be shown or hidden based on the request type. Either approach has pros and cons... Duplication: More maintenance if the common sections / logic change. Each request type's form will need to be updated. Complexity: Potentially many if else statements and more complex to understand and maintain e.g. changes in the common sections could break it for multiple request types. Which approach would you use? Maybe there is a hybrid approach? Edit: This is an Angular project, but I think the question applies to development in general.

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #13

                    Inheritance and specialization. Maybe make the common sections into UserControls, etc.

                    1 Reply Last reply
                    0
                    • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

                      Mircea Neacsu wrote:

                      making them happy should be the most important thing

                      Except that sometime the most desired thing is to wipe them out totally :mad:

                      "The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012

                      D Offline
                      D Offline
                      Daniel Pfeffer
                      wrote on last edited by
                      #14

                      Be careful what you wish for - we are all users, occasionally...

                      Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

                      1 Reply Last reply
                      0
                      • G GuyThiebaut

                        Complexity is perhaps going to make it easier to extend. Duplication will in all likelihood make it easier to debug. I know it's the wrong answer from a software engineering point of view - but from the point of view of someone who spends a lot of time fixing defects on a huge code base I would go for duplication. I have seen a lot of code that makes use of inheritance and quite frankly I have found it to at times be something of a nightmare. Complexity is clever and is elegant but it can make tracking and fixing bugs a lot more difficult.

                        “That which can be asserted without evidence, can be dismissed without evidence.”

                        ― Christopher Hitchens

                        J Offline
                        J Offline
                        Jacquers
                        wrote on last edited by
                        #15

                        GuyThiebaut wrote:

                        Complexity is clever and is elegant but it can make tracking and fixing bugs a lot more difficult.

                        Yeah, that's what I'm hoping to avoid.

                        J G 2 Replies Last reply
                        0
                        • N Nagy Vilmos

                          I've successfully used a single dialog with all content and then injected the display and validation logic from a container. It should give you the best of both worlds.

                          veni bibi saltavi

                          N Offline
                          N Offline
                          Nelek
                          wrote on last edited by
                          #16

                          Welcome Back Mr. Vilmos. ;) Long without seeing you. I hope everything is fine with you and your people.

                          M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                          1 Reply Last reply
                          0
                          • J Jacquers

                            GuyThiebaut wrote:

                            Complexity is clever and is elegant but it can make tracking and fixing bugs a lot more difficult.

                            Yeah, that's what I'm hoping to avoid.

                            J Offline
                            J Offline
                            Jorgen Andersson
                            wrote on last edited by
                            #17

                            That's when you're overdoing it. Put everything common in a base file that you inherit. Duplicate the rest.

                            Wrong is evil and must be defeated. - Jeff Ello

                            1 Reply Last reply
                            0
                            • J Jacquers

                              Rubber ducking here... ;) I'm working on a project that has a form which the user must fill in to submit a request. This form is used for various request types (+- 4) and shares common functionality (about 70%) between them. I have the choice of duplicating the form (UI and probably Logic) for the various request types or having one form with sections and columns that will be shown or hidden based on the request type. Either approach has pros and cons... Duplication: More maintenance if the common sections / logic change. Each request type's form will need to be updated. Complexity: Potentially many if else statements and more complex to understand and maintain e.g. changes in the common sections could break it for multiple request types. Which approach would you use? Maybe there is a hybrid approach? Edit: This is an Angular project, but I think the question applies to development in general.

                              F Offline
                              F Offline
                              Fueled By Decaff
                              wrote on last edited by
                              #18

                              A bit of a different idea: could you implement the common code in UserControls and classes so they have a well defined internal API?

                              F 1 Reply Last reply
                              0
                              • J Jacquers

                                GuyThiebaut wrote:

                                Complexity is clever and is elegant but it can make tracking and fixing bugs a lot more difficult.

                                Yeah, that's what I'm hoping to avoid.

                                G Offline
                                G Offline
                                GuyThiebaut
                                wrote on last edited by
                                #19

                                I would also favour composition over inheritance where possible. So you could have a baseclass form that is very basic, then the implemented forms can perhaps use some form of builder to class to individually tailor those forms. Using composition may make it easier to see what each form is built from.

                                “That which can be asserted without evidence, can be dismissed without evidence.”

                                ― Christopher Hitchens

                                1 Reply Last reply
                                0
                                • F Fueled By Decaff

                                  A bit of a different idea: could you implement the common code in UserControls and classes so they have a well defined internal API?

                                  F Offline
                                  F Offline
                                  Fueled By Decaff
                                  wrote on last edited by
                                  #20

                                  Hmm, metal note: refresh the page and read any new posts before posting. PIEBALDconsult beat me to this by about 2 hours and 30 minutes.

                                  E 1 Reply Last reply
                                  0
                                  • J Jacquers

                                    Rubber ducking here... ;) I'm working on a project that has a form which the user must fill in to submit a request. This form is used for various request types (+- 4) and shares common functionality (about 70%) between them. I have the choice of duplicating the form (UI and probably Logic) for the various request types or having one form with sections and columns that will be shown or hidden based on the request type. Either approach has pros and cons... Duplication: More maintenance if the common sections / logic change. Each request type's form will need to be updated. Complexity: Potentially many if else statements and more complex to understand and maintain e.g. changes in the common sections could break it for multiple request types. Which approach would you use? Maybe there is a hybrid approach? Edit: This is an Angular project, but I think the question applies to development in general.

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

                                    Every time I've re-used UI for multiple forms I've come to regret it. Ask yourself, who are the stakeholders for every form? Are they the same? Do they know if another form is changed? Do all forms change at the same time? If any of your answers is "no" then duplicate them, they look the same (for now), but are functionally different. I didn't and am now in a situation where one form is evolving while the other isn't and the amount of if-else's is too damn high! :sigh: Now, I only re-use specific elements or components on a page. Talking web (ASP.NET MVC and Razor Pages) and WinForms experience here (maybe your hybrid approach?).

                                    Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

                                    1 Reply Last reply
                                    0
                                    • J Jacquers

                                      Rubber ducking here... ;) I'm working on a project that has a form which the user must fill in to submit a request. This form is used for various request types (+- 4) and shares common functionality (about 70%) between them. I have the choice of duplicating the form (UI and probably Logic) for the various request types or having one form with sections and columns that will be shown or hidden based on the request type. Either approach has pros and cons... Duplication: More maintenance if the common sections / logic change. Each request type's form will need to be updated. Complexity: Potentially many if else statements and more complex to understand and maintain e.g. changes in the common sections could break it for multiple request types. Which approach would you use? Maybe there is a hybrid approach? Edit: This is an Angular project, but I think the question applies to development in general.

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

                                      A series of "user controls": no "duplication" - only reuse. Show / collapse based on context. The common "70%" is an obvious candidate for abstracting into a user control that becomes familiar; UI, business rules, or both.

                                      It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

                                      1 Reply Last reply
                                      0
                                      • J Jacquers

                                        Rubber ducking here... ;) I'm working on a project that has a form which the user must fill in to submit a request. This form is used for various request types (+- 4) and shares common functionality (about 70%) between them. I have the choice of duplicating the form (UI and probably Logic) for the various request types or having one form with sections and columns that will be shown or hidden based on the request type. Either approach has pros and cons... Duplication: More maintenance if the common sections / logic change. Each request type's form will need to be updated. Complexity: Potentially many if else statements and more complex to understand and maintain e.g. changes in the common sections could break it for multiple request types. Which approach would you use? Maybe there is a hybrid approach? Edit: This is an Angular project, but I think the question applies to development in general.

                                        B Offline
                                        B Offline
                                        BillWoodruff
                                        wrote on last edited by
                                        #23

                                        ideally ... 1) define a generic base Form with common features/controls/logic all specific types will use. 2) define specific Forms that inherit from the base Form.

                                        «The mind is not a vessel to be filled but a fire to be kindled» Plutarch

                                        1 Reply Last reply
                                        0
                                        • J Jacquers

                                          Rubber ducking here... ;) I'm working on a project that has a form which the user must fill in to submit a request. This form is used for various request types (+- 4) and shares common functionality (about 70%) between them. I have the choice of duplicating the form (UI and probably Logic) for the various request types or having one form with sections and columns that will be shown or hidden based on the request type. Either approach has pros and cons... Duplication: More maintenance if the common sections / logic change. Each request type's form will need to be updated. Complexity: Potentially many if else statements and more complex to understand and maintain e.g. changes in the common sections could break it for multiple request types. Which approach would you use? Maybe there is a hybrid approach? Edit: This is an Angular project, but I think the question applies to development in general.

                                          M Offline
                                          M Offline
                                          Mike Winiberg
                                          wrote on last edited by
                                          #24

                                          Some interesting comments in this thread - funnily enough almost all focussed on the technical details of one approach or the other rather than a general principle. To my mind, and after decades of coding in lots of environments, I (and this is only my personal opinion here!) always find a single codebase is overall easiest to maintain. Having multiple copies of similar, but not quite the same, code is just asking for trouble, especially as a generic logic error may not manifest in the same way in all duplicates. Careful structuring of the code, with - useful! - comments about what each section (however coded) is doing and why, will be much easier to keep working or amend than multiple similar versions. Especially so for someone unfamiliar with the codebase. Obviously for very small chunks of functionality this may not be true, but the more complex the process being modelled the greater the benefits of not creating multiple copies... All IMHO, of course, as I said!

                                          J 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