Click here to Skip to main content
15,867,308 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
AnswerRe: What version should I use Pin
jsc428-Jan-21 2:48
professionaljsc428-Jan-21 2:48 
QuestionDistributed transactions within a microservices architecture Pin
Pelle3021-Dec-20 0:22
Pelle3021-Dec-20 0:22 
AnswerRe: Distributed transactions within a microservices architecture Pin
Gerry Schmitz21-Dec-20 9:19
mveGerry Schmitz21-Dec-20 9:19 
QuestionWhat technologies to use to build a site like Kaggle? Pin
SIDDHARTH_JAIN12-Dec-20 17:50
SIDDHARTH_JAIN12-Dec-20 17:50 
AnswerRe: What technologies to use to build a site like Kaggle? Pin
Gerry Schmitz13-Dec-20 6:11
mveGerry Schmitz13-Dec-20 6:11 
AnswerRe: What technologies to use to build a site like Kaggle? Pin
Richard MacCutchan13-Dec-20 6:34
mveRichard MacCutchan13-Dec-20 6:34 
QuestionShould we duplicate code? Pin
Member 44870839-Dec-20 9:24
Member 44870839-Dec-20 9:24 
AnswerRe: Should we duplicate code? Pin
Pete O'Hanlon9-Dec-20 21:30
subeditorPete O'Hanlon9-Dec-20 21:30 
The principle of Do not Repeat Yourself (DRY) is one of those areas that is taken too far by some code zealots. Let's take your ToString example here, you notice after a couple of times that you have the same ToString code so you decide to introduce an AsCurrency method. That seems straightforward enough, but you're working in a large codebase so you don't notice that the same logic has been added in pieces of the code that you don't visit. Worse still, somebody has done this elsewhere:
c#>string
Then there was that piece of code which looks like this.<pre>public class FormatConstants
{
  public const string GBP = "£0.##"l
  // .... other patterns removed for brevity
}

...
return myItem.ToString(FormatConstants.GBP);
...
What we're seeing here is that others have attempted to avoid repeating code with varying degrees of success. In all of these cases, there is an element of repeated code because differnt people have taken different approaches to to avoid repeating code. Even if the code doesn't look exactly the same, you are repeating the intent of the code. Now you have introduced yet another way to represent this same conversion. In six months time, someone else comes along and has to add a currency ToString in a few places so they refactor their code to avoid adding repeated code. If you're lucky, they have looked through the codebase looking for other places that does the conversion and picks an already written one; if they've searched using ToString("£0.##") then they might not have found the match so they end up adding yet another new way of formatting this one item. What has happened here is that the search to remove duplication has ended up creating a mess - and this is just with a simple example.

The bottom line is, DRY is a great principle and one that you should try to stick to if it makes sense but you have to accept that, in some cases, you aren't going to achieve it and you shouldn't beat yourself up over it.

AnswerRe: Should we duplicate code? Pin
Gerry Schmitz10-Dec-20 5:45
mveGerry Schmitz10-Dec-20 5:45 
QuestionAdvice for web application technologies / architecture Pin
cpper28-Dec-20 8:46
cpper28-Dec-20 8:46 
AnswerRe: Advice for web application technologies / architecture Pin
DerekT-P10-Dec-20 23:49
professionalDerekT-P10-Dec-20 23:49 
QuestionDesign Pattern advice Pin
Freerk_C16-Nov-20 3:20
Freerk_C16-Nov-20 3:20 
AnswerRe: Design Pattern advice Pin
Pete O'Hanlon16-Nov-20 4:46
subeditorPete O'Hanlon16-Nov-20 4:46 
GeneralRe: Design Pattern advice Pin
Freerk_C16-Nov-20 22:09
Freerk_C16-Nov-20 22:09 
GeneralRe: Design Pattern advice Pin
Rob Grainger6-Jul-21 11:40
Rob Grainger6-Jul-21 11:40 
AnswerRe: Design Pattern advice Pin
Gerry Schmitz16-Nov-20 7:24
mveGerry Schmitz16-Nov-20 7:24 
QuestionData Class for data combined from Other Classes Pin
cjb11010-Nov-20 21:27
cjb11010-Nov-20 21:27 
AnswerRe: Data Class for data combined from Other Classes Pin
Richard Deeming10-Nov-20 21:50
mveRichard Deeming10-Nov-20 21:50 
AnswerRe: Data Class for data combined from Other Classes Pin
Gerry Schmitz10-Nov-20 21:53
mveGerry Schmitz10-Nov-20 21:53 
AnswerRe: Data Class for data combined from Other Classes Pin
Mycroft Holmes11-Nov-20 11:07
professionalMycroft Holmes11-Nov-20 11:07 
GeneralRe: Data Class for data combined from Other Classes Pin
cjb11011-Nov-20 19:20
cjb11011-Nov-20 19:20 
Questionn-Tier Design Question Pin
Kevin Marois2-Nov-20 7:10
professionalKevin Marois2-Nov-20 7:10 
AnswerRe: n-Tier Design Question Pin
Richard Deeming2-Nov-20 22:16
mveRichard Deeming2-Nov-20 22:16 
GeneralRe: n-Tier Design Question Pin
Kevin Marois3-Nov-20 6:16
professionalKevin Marois3-Nov-20 6:16 
AnswerRe: n-Tier Design Question Pin
TimWallace23-Feb-21 22:54
TimWallace23-Feb-21 22:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.