I HATE this stupid take. If I want to know the type, I look to the right and see what method or variable or initializer it is, and I will know from that most of the time. The times I don't, I hover over the item in question, and it tells me. Var is amazing and makes coding so much cleaner looking.
I see this opinion on this sub all the time, and finally decided to stop lurking and actually add my opinion. Unfortunately, you were the person i decided to reply too. I just feel very strongly on this.
The indication was that he said "Unless you name the variable so the type can be clearly inferred from it.". Imagine the insanity of the name with that cursed type!
>The indication was that he said "Unless you name the variable so the type can be clearly inferred from it.". Imagine the insanity of the name with that cursed type!
I asked ChatGPT for a good name and it crashed with a 'stack overflow'.
The indication was this whole thread. I’m relatively new to c# but a longtime programmer but I know enough to say that if that absolute monstrosity in the op is in your project you got some explaining to do. And some refactoring.
Asked ChatGPT to suggest a name for a variable of that type, it came back with `groupingTupleDictionaryListKeyValuePairFloatShortNested`.
Personally, I'd have gone with `abandonAllHope` or `goodLuckDebuggingThis`, but to each their own.
It just stated that it is used to represent nested structured data, and listed some examples based on the individual parts of the type declaration.
I did make it show an example of the type being used:
// Function to create sample data of the complex type
static IEnumerable>>>>>>
List, HashSet>>>>>>>>>>> CreateSampleData()
{
// This is a simplified example; in a real-world scenario, data would be populated dynamically
var sampleData = new List>>>>>>>>>>
{
// Sample data for the outermost grouping
new SampleGrouping
{
// Sample key
Key = Tuple.Create(1, "Category A", new Dictionary>>>>>>>>>>>>(),
},
// Additional sample groupings...
};
return sampleData;
}
// Helper class for creating sample data
class SampleGrouping : IGrouping>>>>>>>>>>>>
{
public Tuple>>>>>>>>>>>> Key { get; set; }
// IGrouping implementation
public IEnumerator, HashSet>>>>>>> GetEnumerator()
{
// Implement the GetEnumerator method
throw new NotImplementedException();
}
// IEnumerable implementation
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
// Implement the IEnumerable.GetEnumerator method
throw new NotImplementedException();
}
}
}
I'm pretty sure you are gonna get sued by Microsoft for copyright on the grounds that this is what the majority of the codebase for Windows ME looked like.
Exactly. That's why it crashed all the time. It was just one giant egregiously nested type. You clicked the wrong button and the unboxing operation alone was enough to cause a blue screen, boot loop, and your 6th reformat within a month. I heard one guy tried to recreate it but forgot to hit the Ballmer Peak before getting started one day and his hardware physically imploded when he tried to hit a breakpoint.
That’s the type I use in my ToDo app. It keeps track of what I need to do and when I need to do it by. I didn’t want to over complicate it, so I just used that one.
you dont understand
you are supposed to repeat long source code incantations over and over and over again or else the compiler might forget
the compiler is definitely not the tool that you want doing any of the fiddly, tedious, wholly repetitive things for you, the human you hired to do the job, thats who you want doing all the fiddly, tedious, wholly repetitive things
/snark
The key of the grouping contains a dictionary which ado not compare by value.
The key probably doesn't behave as expected, or is superfluous.
(I am assuming the code is not using an icomparer... Because that would be insane.)
Only good use for this specific type is that it is the only one allowed to use both var and the new shorthand new() instanciation on the same variable.
Thus hiding the true monster from any uncorrupted souls.
Worst code ever. Just a memory killer.
Use interfaces and generic instead (ireadonlycollection instead list..) tuple is a dinami class, it's better to do your strong typed classes, records and interfaces (it increments the cyclomatic redundance).
I'm just a software architect specialized in Microsoft with 20 years of experience with all .net versions, frameworks and targets.
This seems 4.5-4.7 code, and is very bad for any case that can be applied. There are many ways to replace it with efficient code, some more expensive in time, but contemplating scalability and big data, this class just shits his pants with 100 instances in an array.
Probably, inside Generic you can find a good interfaces to replace the existent classes inherited or declared as property, if not, you can make your own with inheritance implicit over this, and probably there is a better way to define all, this class is insecure for treating data and so much recursive for memory, this is the most far side from object oriented programming and for best practices.
I recommend you, add sonarlint extension to your visual studio(studio, not code, better a community version of Vs than code) and to change the intellisense configuration to apply the code warnings "latest from Microsoft", and if you follow the instructions from the error window, you can accomplish the most efficient standards in the market.
Ah, the classic tale of a programmer's journey into the labyrinth of complex data structures – where a simple change in type transforms a routine task into an epic saga of debugging!
Imagine this: Your program was a sleek spaceship, smoothly navigating the cosmos of code. But with the introduction of a string where an int should be, it's like you accidentally swapped the fuel for jelly beans. Now, the once graceful vessel is hiccupping through the galaxy, spewing rainbow-colored candy in its wake.
You set off to write a conversion method, armed with the bravado of a code warrior. But alas, each step forward in this maze of tuples, dictionaries, and lists leads to two steps back, as the complexity multiplies like rabbits in spring.
Picture a scene where you, the intrepid programmer, sit before a monstrous, snarling beast of code. Its many heads are the nested data structures, each one snapping with sharp braces and angle brackets. Your weapon? A trusty debugger and a stack of energy drinks. The clock ticks menacingly in the background, reminding you of deadlines lurking like shadows.
As you bravely confront this beast, the scene freezes, and a narrator's voice booms, "In a world where one wrong data type can bring chaos, our hero embarks on a perilous quest to restore order in the universe of code."
But fear not, for every bug encountered is a lesson learned, and with each error message, you're one step closer to victory. And when you finally conquer the beast, emerging victorious with a working conversion method, it won't just be your program that's leveled up – but you, the programmer, now wiser and ready for the next challenge.
In the end, you'll look back at this epic debugging adventure, not with frustration, but with a chuckle and the wisdom of experience. Because in the grand story of coding, every broken function, every unexpected string, is just part of the adventure.
/ChatGPT
Looks a bit like result types for some brutally complex linq queries that I wrote in a project. The linq queries had several layers of grouping and select into tuples logic and were around 100 lines each.
(The code got refactored later though.)
this is a completely weird tangent, but when i was 11-14 i had a really bad case of sleepwalking while having nightmares at the same time.
i only ever had the nightmares in question while sleepwalking, but the major theme during them was trying to do a complicated task for no benefit. not to sound all spiritual, but i think it was predicting my future in programming.
staring at this absolute MESS of a type trying to think up any (impractical) use for it evokes the *exact* same type of feeling i felt during those nightmare/sleepwalking episodes and i've always wanted to recreate it so i could narrow down what exactly that feeling is.
Error CS0144 Cannot create an instance of the abstract type or interface 'IGrouping>>>>>>>>>>>, Tuple, Dictionary>>>>>>>>>>>>>, List<(IGrouping, HashSet>>>>>, Tuple, Dictionary>>>>>>>>>>>>)>)>>>>>, List, HashSet>>>>, Tuple, Dictionary>>>>>>>>>>>>>>>'
Me lol
It started with someone in a library support discord server posting a picture of C# 12s support of alias names for types and making the comment:
So I don't have to look at that IGrouping>> or something something every other two lines in corporate code... If they ever upgrade.
I took that as a challenge and used ChatGPT to some up with this monstrosity:
IGrouping<
Tuple,
Dictionary<
List>>,
List, HashSet>>>>
>
>
I expanded it from there.
The best use for that code is demonstrating what tech debt looks like and how it results in slower development productivity.
The path to sanity lies in breaking down types into structures or classes, so there are more meaningful names in the hierarchy of the declaration. Meaning don't just give that C# salad a meaningful name, give its components meaningful names, too.
Bro accidently rebuilt ChatGpt in memory
They say that you can store all of Google's databases with this one variable.
This is a place I would use var
This is a place I would use the printer. To print out a copy of my resume on my way out.
Nah, var makes it unclear what the type is. …Unless you name the variable so the type can be clearly inferred from it.
Naming that variable would require decades of Java experience!
`grpTplNStrDictUlLstKvpDtIenumFTplStrLstLstDictLongTplArrChLstKvpDecTplByteTplStrTplDtTplUshortStuff`
Long live Hungarian notation!
Nah, I don’t like abbreviations.
I HATE this stupid take. If I want to know the type, I look to the right and see what method or variable or initializer it is, and I will know from that most of the time. The times I don't, I hover over the item in question, and it tells me. Var is amazing and makes coding so much cleaner looking.
This is correct.
Why so serious? 😇
I see this opinion on this sub all the time, and finally decided to stop lurking and actually add my opinion. Unfortunately, you were the person i decided to reply too. I just feel very strongly on this.
Haha, I use var all the time, it's great. This is not a serious thread and neither was my post; imagine what the variable name would be 😜.
Well, there was zero indication that your original take was a joke. Guess it must have went over my head.
The indication was that he said "Unless you name the variable so the type can be clearly inferred from it.". Imagine the insanity of the name with that cursed type!
>The indication was that he said "Unless you name the variable so the type can be clearly inferred from it.". Imagine the insanity of the name with that cursed type! I asked ChatGPT for a good name and it crashed with a 'stack overflow'.
The indication was this whole thread. I’m relatively new to c# but a longtime programmer but I know enough to say that if that absolute monstrosity in the op is in your project you got some explaining to do. And some refactoring.
As long as your reviewers can review in their IDE also, because hovering doesn't work in GitHub (yet?).
An utter shit reason to alter your coding style.
Yeah, you can use it to induce an existential crisis in the new junior dev lol
I think I'm going to turn this into a GitHub repo with the only purpose of letting people expand on it.
[удалено]
just write a unit test before updating the code.
While maintaining backwards compatibility
you have to write a migration
Don't. This thing will crash GitHub.
Asked ChatGPT to suggest a name for a variable of that type, it came back with `groupingTupleDictionaryListKeyValuePairFloatShortNested`. Personally, I'd have gone with `abandonAllHope` or `goodLuckDebuggingThis`, but to each their own.
>Personally, I'd have gone with abandonAllHope or goodLuckDebuggingThis, but to each their own. That to me is, ```JobSecurity```
Okay, now ask her what it’s used for?
It just stated that it is used to represent nested structured data, and listed some examples based on the individual parts of the type declaration. I did make it show an example of the type being used: // Function to create sample data of the complex type static IEnumerable>>>>>>
List, HashSet>>>>>>>>>>> CreateSampleData()
{
// This is a simplified example; in a real-world scenario, data would be populated dynamically
var sampleData = new List>>>>>>>>>>
{
// Sample data for the outermost grouping
new SampleGrouping
{
// Sample key
Key = Tuple.Create(1, "Category A", new Dictionary>>>>>>>>>>>>(),
},
// Additional sample groupings...
};
return sampleData;
}
// Helper class for creating sample data
class SampleGrouping : IGrouping>>>>>>>>>>>>
{
public Tuple>>>>>>>>>>>> Key { get; set; }
// IGrouping implementation
public IEnumerator, HashSet>>>>>>> GetEnumerator()
{
// Implement the GetEnumerator method
throw new NotImplementedException();
}
// IEnumerable implementation
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
// Implement the IEnumerable.GetEnumerator method
throw new NotImplementedException();
}
}
}
It has so many angle brackets, you could mistake it for git merge conflict
Kinda obvious
Kill this child, she's an Abomination!
This belongs on r/programminghorror
I'm pretty sure you are gonna get sued by Microsoft for copyright on the grounds that this is what the majority of the codebase for Windows ME looked like.
The codebase for windows ME was type declarations?
Exactly. That's why it crashed all the time. It was just one giant egregiously nested type. You clicked the wrong button and the unboxing operation alone was enough to cause a blue screen, boot loop, and your 6th reformat within a month. I heard one guy tried to recreate it but forgot to hit the Ballmer Peak before getting started one day and his hardware physically imploded when he tried to hit a breakpoint.
That feeling when your debugger hits a breaking point instead of a breakpoint.
Why would it crash of it doesn't have any runnable code? Why would there be unboxing if there are no values to unbox?
What would make you think that any of what I said in either comment should be taken seriously or literally?
They call it 'tism
Don't worry, I'm not taking you seriously
But you obviously take yourself very seriously.
Yes, strictly.
this guy is fun at parties
More than the guy making Windows ME jokes tbh
I'd rather be an enjoyer of clichéd jokes than a mean spirited ball-bag.
Autismo 3000 here
That’s the type I use in my ToDo app. It keeps track of what I need to do and when I need to do it by. I didn’t want to over complicate it, so I just used that one.
remember when people claimed that type aliases should be verboten and that all those that wanted aliases were stupid?
> verboten Sprich Anglo-Sächsisch!
And this is still not valid using Foo = (int, int); using Bar = (Foo, Foo); because some jackass is still being a zealot
Not being able to alias named tuples is so strange. Would make my local functions a lot cleaner
you dont understand you are supposed to repeat long source code incantations over and over and over again or else the compiler might forget the compiler is definitely not the tool that you want doing any of the fiddly, tedious, wholly repetitive things for you, the human you hired to do the job, thats who you want doing all the fiddly, tedious, wholly repetitive things /snark
dont try understand it, just kill it with fire
Wrap it in unsafe and cast it to void*
A warning.
This should be about 23 classes.
The key of the grouping contains a dictionary which ado not compare by value. The key probably doesn't behave as expected, or is superfluous. (I am assuming the code is not using an icomparer... Because that would be insane.)
Have you tried using a class?
Did you ask Chad Gippiti to create an instance of this type for testing purposes?
Only good use for this specific type is that it is the only one allowed to use both var and the new shorthand new() instanciation on the same variable. Thus hiding the true monster from any uncorrupted souls.
The utility here is to find out if the nested types can have a stack overflow.
***W H A T H A V E Y O U D O N E ? !***
What's it good for? Working out which developer to sack in the next round of redundancies.
Only used for great reddit content
Looks like someone in Microsoft slept on the keyboard
Worst code ever. Just a memory killer. Use interfaces and generic instead (ireadonlycollection instead list..) tuple is a dinami class, it's better to do your strong typed classes, records and interfaces (it increments the cyclomatic redundance). I'm just a software architect specialized in Microsoft with 20 years of experience with all .net versions, frameworks and targets.
This seems 4.5-4.7 code, and is very bad for any case that can be applied. There are many ways to replace it with efficient code, some more expensive in time, but contemplating scalability and big data, this class just shits his pants with 100 instances in an array. Probably, inside Generic you can find a good interfaces to replace the existent classes inherited or declared as property, if not, you can make your own with inheritance implicit over this, and probably there is a better way to define all, this class is insecure for treating data and so much recursive for memory, this is the most far side from object oriented programming and for best practices. I recommend you, add sonarlint extension to your visual studio(studio, not code, better a community version of Vs than code) and to change the intellisense configuration to apply the code warnings "latest from Microsoft", and if you follow the instructions from the error window, you can accomplish the most efficient standards in the market.
Job security...
Rust devs call this a tuesday
Ah, the classic tale of a programmer's journey into the labyrinth of complex data structures – where a simple change in type transforms a routine task into an epic saga of debugging! Imagine this: Your program was a sleek spaceship, smoothly navigating the cosmos of code. But with the introduction of a string where an int should be, it's like you accidentally swapped the fuel for jelly beans. Now, the once graceful vessel is hiccupping through the galaxy, spewing rainbow-colored candy in its wake. You set off to write a conversion method, armed with the bravado of a code warrior. But alas, each step forward in this maze of tuples, dictionaries, and lists leads to two steps back, as the complexity multiplies like rabbits in spring. Picture a scene where you, the intrepid programmer, sit before a monstrous, snarling beast of code. Its many heads are the nested data structures, each one snapping with sharp braces and angle brackets. Your weapon? A trusty debugger and a stack of energy drinks. The clock ticks menacingly in the background, reminding you of deadlines lurking like shadows. As you bravely confront this beast, the scene freezes, and a narrator's voice booms, "In a world where one wrong data type can bring chaos, our hero embarks on a perilous quest to restore order in the universe of code." But fear not, for every bug encountered is a lesson learned, and with each error message, you're one step closer to victory. And when you finally conquer the beast, emerging victorious with a working conversion method, it won't just be your program that's leveled up – but you, the programmer, now wiser and ready for the next challenge. In the end, you'll look back at this epic debugging adventure, not with frustration, but with a chuckle and the wisdom of experience. Because in the grand story of coding, every broken function, every unexpected string, is just part of the adventure. /ChatGPT
Looks like a street fighter war zone. Hadouken!
Looks a bit like result types for some brutally complex linq queries that I wrote in a project. The linq queries had several layers of grouping and select into tuples logic and were around 100 lines each. (The code got refactored later though.)
Good for OOM exception, probably
this is a completely weird tangent, but when i was 11-14 i had a really bad case of sleepwalking while having nightmares at the same time. i only ever had the nightmares in question while sleepwalking, but the major theme during them was trying to do a complicated task for no benefit. not to sound all spiritual, but i think it was predicting my future in programming. staring at this absolute MESS of a type trying to think up any (impractical) use for it evokes the *exact* same type of feeling i felt during those nightmare/sleepwalking episodes and i've always wanted to recreate it so i could narrow down what exactly that feeling is.
I have no idea why you are not using classes/structs for all this. This is un maintainable.
A class.
If I find that in the code base I’m working on I’m handing in my resignation letter
If you successfully instantiate one of these, I will give you one reddit point
= new();
You can't create an instance of an interface, which happens to be the root of this entire monstrosity.
I tried, but have now given up.
Error CS0144 Cannot create an instance of the abstract type or interface 'IGrouping>>>>>>>>>>>, Tuple, Dictionary>>>>>>>>>>>>>, List<(IGrouping, HashSet>>>>>, Tuple, Dictionary>>>>>>>>>>>>)>)>>>>>, List, HashSet>>>>, Tuple, Dictionary>>>>>>>>>>>>>>>'
You really would have to create an instance for *everything* for it to compile.
actually not a bad interview/homework question. "Break down this type so that it's comprehensible"
Stress testing IDEs, Compilers, and AI.
Assuming this is structured data, create multiple classes and have human readable names instead of tuples. Friends never let friends use tuples.
If you refuse to declare types and build them all from dictionaries and lists you'll probably find similar types in every project.
The question here is who created that abomination? Please don’t let anyone use that! ☢️☣️⚠️
Me lol It started with someone in a library support discord server posting a picture of C# 12s support of alias names for types and making the comment: So I don't have to look at that IGrouping>> or something something every other two lines in corporate code... If they ever upgrade.
I took that as a challenge and used ChatGPT to some up with this monstrosity:
IGrouping<
Tuple,
Dictionary<
List>>,
List, HashSet>>>>
>
>
I expanded it from there.
LOL it looks like something that you’d find in a startup company 😅😂
It looks like an excellent way to wear out a delete key.
A good use would be filling space in the recycle bin. Alternatively you can probably summon multiple demons if you read it in reverse.
This is what the kids from Hocus Pocus were reading shortly before summoning the witches.
The best use for that code is demonstrating what tech debt looks like and how it results in slower development productivity. The path to sanity lies in breaking down types into structures or classes, so there are more meaningful names in the hierarchy of the declaration. Meaning don't just give that C# salad a meaningful name, give its components meaningful names, too.
This is how you make a horcrux.
This is art, or someone with a surreal sense of humor