Click here to Skip to main content
15,890,186 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Another code for thought: public members Pin
Gary Wheeler30-Oct-18 6:03
Gary Wheeler30-Oct-18 6:03 
GeneralRe: Another code for thought: public members Pin
Mark_Wallace30-Oct-18 22:28
Mark_Wallace30-Oct-18 22:28 
GeneralWSO CCC OTD 2018-10-30 Pin
OriginalGriff29-Oct-18 22:57
mveOriginalGriff29-Oct-18 22:57 
AnswerRe: WSO CCC OTD 2018-10-30 Pin
megaadam29-Oct-18 23:15
professionalmegaadam29-Oct-18 23:15 
GeneralRe: WSO CCC OTD 2018-10-30 - We have a winner! Pin
OriginalGriff29-Oct-18 23:18
mveOriginalGriff29-Oct-18 23:18 
GeneralRe: WSO CCC OTD 2018-10-30 Pin
Mark Parity29-Oct-18 23:15
Mark Parity29-Oct-18 23:15 
GeneralRe: WSO CCC OTD 2018-10-30 Pin
OriginalGriff29-Oct-18 23:19
mveOriginalGriff29-Oct-18 23:19 
GeneralC# code survey Pin
Super Lloyd29-Oct-18 21:37
Super Lloyd29-Oct-18 21:37 
Yes it's a programming question, but wait a moment, I am NOT asking to solve any problem here, I am asking to select your favourite of 2 options.
I think what they want me to do here at work is disgusting. I have to suck it up anyway, since it's the guy who accepts pull request that tells me to do it, period. But I am curious whether or not I am in good company with my prejudice.

It's about DTO, constructors with zillion of parameters and all private properties.

code I prefer and put in my pull request, with 24 properties (i.e large number of properties)
C#
public class FooDto
{
   public T1 Property1 { get; set; }
   // ....
   public T24 Property24 { get; set; }
}
// ....
class MyFooClass
{
    private T1 property1;
    // ....
    private T24 property24;

    public FooDto ToDto()
    {
        return new FooDto()
        {
            Property1 = property1,
            //....
            Property24 = property24,
        };
    }
}

how I have asked to rewrite the code, feels disgusting to me, but curious how many people share, or dislike, my opinion
C#
public class FooDto
{
   public FooDto(T1 value1 /** 24 values later */, T24 value24)
   {
        Property1 = value1;
        // .....
        Property24 = value24;
   }

   public T1 Property1 { get; }
   // ....
   public T24 Property24 { get; }
}
// ....
class MyFooClass
{
    private T1 property1;
    // ....
    private T24 property24;

    public FooDto ToDto()
    {
        return new FooDto(property1 /** */, property24);
    }
}

In his defence he has an argument. If someone use that DTO as well, the compiler will force them to initialise all values.
Though one could counter argument that we got unit test for just that.

At any rate, which of those 2 is your favourite code style?
A new .NET Serializer
All in one Menu-Ribbon Bar
Taking over the world since 1371!

GeneralRe: C# code survey Pin
Jacquers29-Oct-18 21:56
Jacquers29-Oct-18 21:56 
GeneralRe: C# code survey Pin
#realJSOP30-Oct-18 6:08
mve#realJSOP30-Oct-18 6:08 
GeneralRe: C# code survey Pin
Wastedtalent29-Oct-18 22:04
professionalWastedtalent29-Oct-18 22:04 
GeneralRe: C# code survey PinPopular
CPallini29-Oct-18 22:06
mveCPallini29-Oct-18 22:06 
GeneralRe: C# code survey Pin
Jörgen Andersson29-Oct-18 22:23
professionalJörgen Andersson29-Oct-18 22:23 
GeneralRe: C# code survey Pin
CPallini29-Oct-18 22:37
mveCPallini29-Oct-18 22:37 
GeneralRe: C# code survey Pin
GuyThiebaut29-Oct-18 22:13
professionalGuyThiebaut29-Oct-18 22:13 
GeneralRe: C# code survey Pin
Jörgen Andersson29-Oct-18 22:21
professionalJörgen Andersson29-Oct-18 22:21 
GeneralRe: C# code survey Pin
GKP199229-Oct-18 23:05
professionalGKP199229-Oct-18 23:05 
GeneralRe: C# code survey Pin
thatraja29-Oct-18 23:18
professionalthatraja29-Oct-18 23:18 
JokeRe: C# code survey Pin
Pete O'Hanlon30-Oct-18 1:12
mvePete O'Hanlon30-Oct-18 1:12 
GeneralRe: C# code survey Pin
Super Lloyd30-Oct-18 1:44
Super Lloyd30-Oct-18 1:44 
GeneralRe: C# code survey Pin
Nathan Minier30-Oct-18 1:26
professionalNathan Minier30-Oct-18 1:26 
GeneralRe: C# code survey Pin
Super Lloyd30-Oct-18 1:29
Super Lloyd30-Oct-18 1:29 
GeneralRe: C# code survey Pin
Super Lloyd30-Oct-18 1:30
Super Lloyd30-Oct-18 1:30 
GeneralRe: C# code survey Pin
MadMyche30-Oct-18 1:53
professionalMadMyche30-Oct-18 1:53 
JokeRe: C# code survey Pin
ZurdoDev30-Oct-18 1:55
professionalZurdoDev30-Oct-18 1:55 

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.