2

Currently I'm working at a .NET project-based company. Our coding is not modularized, mostly we are copy/pasting old code that is needed on a new project and modify it.

I was trying to standardize and modularize some functions (Email Management Module, CMS Module & etc) by implementing a 3-tier architecture concept where each module would have its own independent module database. So that in the future all we'd need to do is just code a presentation layer, reuse the BLL layer, DAL Layer and database.

Is this system design reasonable? Will it work?

4
  • 1
    Yes, your solution works. It will only take the next five years to implement. // In my experience, trying to do things the right way under a management-mandated system based on the "do the quickest thing that works" principle ends up badly.
    – isekaijin
    Commented Jul 13, 2011 at 3:37
  • 1
    Danger Will Robinson, Danger Danger Danger: You used 'that' 4 letter word so common in software, particularly prevalent in failed projects. "Just". See if you can rewrite the sentence without trivializing the difficulty, or overstating the benefits of what you plan to do.
    – mattnz
    Commented Jul 13, 2011 at 3:38
  • my English vocabulary and grammar is poor , can't write the proper sentence now. This my weakness , was trying reading english books to improve it . > <
    – Johnny Tan
    Commented Jul 13, 2011 at 3:51
  • we knowing that was a huge workload , was planning each new project implement those concepts on 1 module , the rest using the old code . :-)
    – Johnny Tan
    Commented Jul 13, 2011 at 3:59

1 Answer 1

0

In my opinion you should not change the code that works. Doing so can cause new bugs and wasting your development time for something that already there. You also need to make a regression testing so

Instead, why don't you implement your new framework for new modules only? By doing this way, at least you can make sure that all your new codes are reusable and neat.

On the code duplication, I believe you should implement something called Code Duplication Detection Tools. In java we have something called CPD(which is part of PMD) [link]. By doing this, you will be able to know which part of code are duplicated and able to make priority to refactor based on number of duplication. Just start refactor these duplication on your spare time and put them in some utility class so it's easier to be accessed from your old and new framework.

Try to find the .net version of CPD-PMD.

Note there is "Rule of Three" which states that

you are allowed to copy and paste the code once, but that when the same code is replicated three times, it should be extracted into a new procedure.

The rule was introduced by Martin Fowler. http://en.wikipedia.org/wiki/Rule_of_three_(programming)

3
  • IIRC, the Rule of Three was about copying between projects. Either way, I still wouldn't recommend copying at all in a project and always extract the functionality. Worse case, if I wasn't allowed to modify the existing code, would be to copy into a generic function for future use, and comment the old code to look at later.
    – tylermac
    Commented Jul 13, 2011 at 14:12
  • No. Rule of Three is not about copying between projects. It's about when you should do the refactoring. This is the full explanation: "The first time you do something, you just do it. The second you do something similar, you wince at the duplication, but you do duplicate thing anyway. The third time you do something similar, you refactor." You can take a look at this reference : my.safaribooksonline.com/book/…
    – Rudy
    Commented Jul 13, 2011 at 15:09
  • "In my opinion you should not change the code that works." What about refactoring? Of course, it's best to refactor when you need to implement a new feature.
    – andho
    Commented Feb 28, 2013 at 9:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.