Click here to Skip to main content
15,499,155 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
AnswerRe: What version should I use Pin
jsc428-Jan-21 3:48
professionaljsc428-Jan-21 3:48 
QuestionDistributed transactions within a microservices architecture Pin
Pelle3021-Dec-20 1:22
MemberPelle3021-Dec-20 1:22 
AnswerRe: Distributed transactions within a microservices architecture Pin
Gerry Schmitz21-Dec-20 10:19
mveGerry Schmitz21-Dec-20 10:19 
QuestionWhat technologies to use to build a site like Kaggle? Pin
SIDDHARTH_JAIN12-Dec-20 18:50
MemberSIDDHARTH_JAIN12-Dec-20 18:50 
AnswerRe: What technologies to use to build a site like Kaggle? Pin
Gerry Schmitz13-Dec-20 7:11
mveGerry Schmitz13-Dec-20 7:11 
AnswerRe: What technologies to use to build a site like Kaggle? Pin
Richard MacCutchan13-Dec-20 7:34
mveRichard MacCutchan13-Dec-20 7:34 
QuestionShould we duplicate code? Pin
Member 44870839-Dec-20 10:24
MemberMember 44870839-Dec-20 10:24 
AnswerRe: Should we duplicate code? Pin
Pete O'Hanlon9-Dec-20 22:30
mvaPete O'Hanlon9-Dec-20 22: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 6:45
mveGerry Schmitz10-Dec-20 6:45 
QuestionAdvice for web application technologies / architecture Pin
cpper28-Dec-20 9:46
Membercpper28-Dec-20 9:46 
AnswerRe: Advice for web application technologies / architecture Pin
DerekT-P11-Dec-20 0:49
professionalDerekT-P11-Dec-20 0:49 
QuestionDesign Pattern advice Pin
Freerk_C16-Nov-20 4:20
MemberFreerk_C16-Nov-20 4:20 
AnswerRe: Design Pattern advice Pin
Pete O'Hanlon16-Nov-20 5:46
mvaPete O'Hanlon16-Nov-20 5:46 
GeneralRe: Design Pattern advice Pin
Freerk_C16-Nov-20 23:09
MemberFreerk_C16-Nov-20 23:09 
GeneralRe: Design Pattern advice Pin
Rob Grainger6-Jul-21 12:40
MemberRob Grainger6-Jul-21 12:40 
AnswerRe: Design Pattern advice Pin
Gerry Schmitz16-Nov-20 8:24
mveGerry Schmitz16-Nov-20 8:24 
QuestionData Class for data combined from Other Classes Pin
cjb11010-Nov-20 22:27
Membercjb11010-Nov-20 22:27 
AnswerRe: Data Class for data combined from Other Classes Pin
Richard Deeming10-Nov-20 22:50
mveRichard Deeming10-Nov-20 22:50 
AnswerRe: Data Class for data combined from Other Classes Pin
Gerry Schmitz10-Nov-20 22:53
mveGerry Schmitz10-Nov-20 22:53 
AnswerRe: Data Class for data combined from Other Classes Pin
Mycroft Holmes11-Nov-20 12:07
professionalMycroft Holmes11-Nov-20 12:07 
GeneralRe: Data Class for data combined from Other Classes Pin
cjb11011-Nov-20 20:20
Membercjb11011-Nov-20 20:20 
Questionn-Tier Design Question Pin
Kevin Marois2-Nov-20 8:10
professionalKevin Marois2-Nov-20 8:10 
AnswerRe: n-Tier Design Question Pin
Richard Deeming2-Nov-20 23:16
mveRichard Deeming2-Nov-20 23:16 
GeneralRe: n-Tier Design Question Pin
Kevin Marois3-Nov-20 7:16
professionalKevin Marois3-Nov-20 7:16 
AnswerRe: n-Tier Design Question Pin
TimWallace23-Feb-21 23:54
MemberTimWallace23-Feb-21 23: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.