Click here to Skip to main content
15,888,610 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Semi-major Win For Me Today Pin
RickZeeland14-Jun-18 7:03
mveRickZeeland14-Jun-18 7:03 
PraiseRe: Semi-major Win For Me Today Pin
Slacker00714-Jun-18 7:23
professionalSlacker00714-Jun-18 7:23 
GeneralRe: Semi-major Win For Me Today Pin
Rick York14-Jun-18 8:05
mveRick York14-Jun-18 8:05 
GeneralRe: Semi-major Win For Me Today Pin
Marc Clifton14-Jun-18 8:40
mvaMarc Clifton14-Jun-18 8:40 
GeneralRe: Semi-major Win For Me Today Pin
David A. Gray25-Jun-18 10:45
David A. Gray25-Jun-18 10:45 
GeneralRe: Semi-major Win For Me Today Pin
Gerry Schmitz15-Jun-18 10:37
mveGerry Schmitz15-Jun-18 10:37 
GeneralRe: Semi-major Win For Me Today Pin
Dr.Walt Fair, PE6-Oct-18 11:39
professionalDr.Walt Fair, PE6-Oct-18 11:39 
PraiseC# Compiler Support for ReadOnlyReferences Pin
David A. Gray13-Jun-18 8:11
David A. Gray13-Jun-18 8:11 
When I saw mention of compiler support for ReadOnlyReferences in the C# 7.2 language, for passing variables by reference but without exposing data to modifications in a list of new features in version 4.7.2 of the Microsoft .NET Framework in What’s new in Microsoft .Net Framework 4.8, I realized that this is a big deal.

Here's why.
  • Without this option, the only way to pass a read-only reference to an object is to create an adapter, so that you can pass through the properties through getter methods, omitting setters entirely.
  • Writing such an adapter is time consuming and error-prone.
  • Using the adapter adds a layer to every request to read a property on the underlying object, because the request must pass through the getter on the adapter, which passes it along to the getter on the adapted object.
  • If your project has many of these, your source code tree has lots of branches that add little value, and the extra objects make the assembly bigger.
See C# Futures: Read-Only References and Structs for additional details not mentioned in the InfoWorld article, not the least of which is that this parameter modifier applies to structs, too. Presumably, that includes the system-defined structs, such as DateTime, char, and others.
David A. Gray
Delivering Solutions for the Ages, One Problem at a Time
Interpreting the Fundamental Principle of Tabular Reporting

GeneralRe: C# Compiler Support for ReadOnlyReferences Pin
Richard Deeming13-Jun-18 8:19
mveRichard Deeming13-Jun-18 8:19 
GeneralRe: C# Compiler Support for ReadOnlyReferences Pin
David A. Gray13-Jun-18 8:43
David A. Gray13-Jun-18 8:43 
GeneralRe: C# Compiler Support for ReadOnlyReferences Pin
Richard Deeming13-Jun-18 9:17
mveRichard Deeming13-Jun-18 9:17 
GeneralRe: C# Compiler Support for ReadOnlyReferences Pin
David A. Gray13-Jun-18 12:17
David A. Gray13-Jun-18 12:17 
RantRe: C# Compiler Support for ReadOnlyReferences Pin
megaadam13-Jun-18 22:49
professionalmegaadam13-Jun-18 22:49 
GeneralRe: C# Compiler Support for ReadOnlyReferences Pin
David A. Gray14-Jun-18 8:09
David A. Gray14-Jun-18 8:09 
GeneralRe: C# Compiler Support for ReadOnlyReferences Pin
Clifford Nelson14-Jun-18 9:13
Clifford Nelson14-Jun-18 9:13 
GeneralRe: C# Compiler Support for ReadOnlyReferences Pin
David A. Gray14-Jun-18 13:00
David A. Gray14-Jun-18 13:00 
GeneralRe: C# Compiler Support for ReadOnlyReferences Pin
Clifford Nelson14-Jun-18 17:19
Clifford Nelson14-Jun-18 17:19 
GeneralRe: C# Compiler Support for ReadOnlyReferences Pin
David A. Gray15-Jun-18 6:00
David A. Gray15-Jun-18 6:00 
GeneralRe: C# Compiler Support for ReadOnlyReferences Pin
Dr.Walt Fair, PE6-Oct-18 11:42
professionalDr.Walt Fair, PE6-Oct-18 11:42 
GeneralUmmmm... WTF? Pin
Brisingr Aerowing25-May-18 15:31
professionalBrisingr Aerowing25-May-18 15:31 
GeneralRe: Ummmm... WTF? Pin
Jon McKee25-May-18 15:36
professionalJon McKee25-May-18 15:36 
GeneralRe: Ummmm... WTF? Pin
RugbyLeague13-Jun-18 21:28
RugbyLeague13-Jun-18 21:28 
GeneralRe: Ummmm... WTF? Pin
Nathan Minier29-May-18 2:09
professionalNathan Minier29-May-18 2:09 
GeneralRe: Ummmm... WTF? Pin
David A. Gray25-Jun-18 10:48
David A. Gray25-Jun-18 10:48 
GeneralRe: Ummmm... WTF? Pin
Dr.Walt Fair, PE6-Oct-18 11:43
professionalDr.Walt Fair, PE6-Oct-18 11:43 

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.