Click here to Skip to main content
14,449,160 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 7:03
MemberGary Wheeler30-Oct-18 7:03 
GeneralRe: Another code for thought: public members Pin
Mark_Wallace30-Oct-18 23:28
MemberMark_Wallace30-Oct-18 23:28 
GeneralWSO CCC OTD 2018-10-30 Pin
OriginalGriff29-Oct-18 23:57
communityengineerOriginalGriff29-Oct-18 23:57 
AnswerRe: WSO CCC OTD 2018-10-30 Pin
"mega"-in-a-fake-beard30-Oct-18 0:15
professional"mega"-in-a-fake-beard30-Oct-18 0:15 
GeneralRe: WSO CCC OTD 2018-10-30 - We have a winner! Pin
OriginalGriff30-Oct-18 0:18
communityengineerOriginalGriff30-Oct-18 0:18 
GeneralRe: WSO CCC OTD 2018-10-30 Pin
Mark Parity30-Oct-18 0:15
MemberMark Parity30-Oct-18 0:15 
GeneralRe: WSO CCC OTD 2018-10-30 Pin
OriginalGriff30-Oct-18 0:19
communityengineerOriginalGriff30-Oct-18 0:19 
GeneralC# code survey Pin
Super Lloyd29-Oct-18 22:37
MemberSuper Lloyd29-Oct-18 22: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)
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
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 22:56
MemberJacquers29-Oct-18 22:56 
GeneralRe: C# code survey Pin
#realJSOP30-Oct-18 7:08
mva#realJSOP30-Oct-18 7:08 
GeneralRe: C# code survey Pin
Wastedtalent29-Oct-18 23:04
professionalWastedtalent29-Oct-18 23:04 
GeneralRe: C# code survey Pin
CPallini29-Oct-18 23:06
mveCPallini29-Oct-18 23:06 
GeneralRe: C# code survey Pin
Jörgen Andersson29-Oct-18 23:23
communityengineerJörgen Andersson29-Oct-18 23:23 
GeneralRe: C# code survey Pin
CPallini29-Oct-18 23:37
mveCPallini29-Oct-18 23:37 
GeneralRe: C# code survey Pin
GuyThiebaut29-Oct-18 23:13
professionalGuyThiebaut29-Oct-18 23:13 
GeneralRe: C# code survey Pin
Jörgen Andersson29-Oct-18 23:21
communityengineerJörgen Andersson29-Oct-18 23:21 
GeneralRe: C# code survey Pin
GKP199230-Oct-18 0:05
professionalGKP199230-Oct-18 0:05 
GeneralRe: C# code survey Pin
thatraja30-Oct-18 0:18
professionalthatraja30-Oct-18 0:18 
JokeRe: C# code survey Pin
Pete O'Hanlon30-Oct-18 2:12
communityengineerPete O'Hanlon30-Oct-18 2:12 
GeneralRe: C# code survey Pin
Super Lloyd30-Oct-18 2:44
MemberSuper Lloyd30-Oct-18 2:44 
GeneralRe: C# code survey Pin
Nathan Minier30-Oct-18 2:26
professionalNathan Minier30-Oct-18 2:26 
GeneralRe: C# code survey Pin
Super Lloyd30-Oct-18 2:29
MemberSuper Lloyd30-Oct-18 2:29 
GeneralRe: C# code survey Pin
Super Lloyd30-Oct-18 2:30
MemberSuper Lloyd30-Oct-18 2:30 
GeneralRe: C# code survey Pin
MadMyche30-Oct-18 2:53
mveMadMyche30-Oct-18 2:53 
JokeRe: C# code survey Pin
ZurdoDev30-Oct-18 2:55
mveZurdoDev30-Oct-18 2: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.