- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I would also just delete this if I found it, but you couldn't just blindly replace it with a normal double as this is a reference type and properties of type PhbDouble could be set with null values and there might have been logic relying on that.
Perhaps "Phb" didn't know about C# nullable types, namely "double?"?
Presumably "Sole Purpose Of Visit" has in at least some places used "double?" as opposed to just "double".
Admin
DELETE FROM comments WHERE username = 'Jonathan'
INSERT INTO comments (username, comment) VALUES ('NotAThingThatHappens', 'Frsit!')
Admin
Potentially Hazardous Bodger?
Perfectly Horrendous Barfmonger?
Pretentious Holistic Bicycle?
We can't guess what PHB could stand for ...
Admin
It goes to show once again: beauty is only skin deep, ugliness goes right to the bone.
Admin
Are you trying to disrespect my beautiful skeleton?
Admin
I imagine there could be a valid use case for value type wrapper in a reference type (although a generic PhbRef<T> where T: struct is a cleaner approach). I cannot imagine any such cases myself, but I can imagine there could be.
Admin
But you never know when you want to overload the float set method!
Admin
Almost Brillant!
Admin
I had an assumption :-) But I very much doubt ANY PHBs would know code well enough to be the source of the requirement for this..
Admin
I do have to give him credit for adhering to official naming guidelines - 3 letter acronyms are to be pascal cased, and he did that. It's not all bad!!!
Admin
I did indeed make sure I replaced PhbDouble with a nullable real double. (And I never worked out why the class wasn't sealed, and what use the protected member might be.)
Other highlights of PhbCoding included a PhbPoint class (containing nothing much more than an X, Y and Z) and a whole parallel set of PhbMatrix calculations (which of course worked only with PhbPoints). Those were easy to refactor/obliterate.
The ten thousand line long PhbGridView class, which hoisted everything you might want to do with a standard grid view (including event handling), has, however, taken me over a year to refactor. And I'm only half way through it.
Admin
Fans on Dilbert don't need to guess what PHB stands for. It has to do with hair, management, and pointiness.
Admin
When did we get nullable types, though? Could this have predated them?
Admin
This is a step in the right direction from my technique of a friend in school whereby each variable was named after a different boxing legend.
Admin
Picking some nits: perhaps the bodies of the constructor and the Create method got dropped during anonymization, the snippet as provided does not compile.
Admin
Paula H. Bean?
Admin
Nah. Null preceeded type, I think. Let me check the book...
Before the beginning was null.
Yep...
Admin
Ehm, double? is a struct and not a class - using reference types for value types would be highly inefficient and be poison for any GC. That is actually one of the issues SmallTalk was facing, Java has a similar issue because it doesn't have value types, just a few primitives which aren't even based on object (not a unified type system).
So what's the benefit of value types? Well, they only live on the stack, no allocations and cleanups need by the GC. A double? is basically a struct { double Value; bool HasValue; } internally. Because structs are automatically initialized by zero, this means HasValue is false by default, which means it has the value null. The handling of the nullable structs itself is implemented on runtime level (so no quick hack like Java's generics type erasure), so you can use operators in conjunction with keyword null just like with reference types.
TL;DR: Making a reference type which is boxing a small value type like double is a super anti-pattern. If you have a two structs (or in some cases immutable ref types) and they should behave like structs (or immutable ref types) you can put them into a struct if they don't get bigger than 32 bytes (sizeof). If a type should behave like a ref type, then obviously it should be a class, no matter the size - just marking a type as null is not the defining reason why to use ref types tho.
Admin
You will see an great performance boost, less GC back pressure and less allocation latency - if you run it under core, even more so. I would put this under spoiler tags, but sadly there are none :-)
Admin
"The ten thousand line long PhbGridView class, ..., taken me over a year to refactor."
This is what really shits me about the software industry. For every bad developer writing code there is another good one who has to fix their shitty code. It might even be at a 2:1 ratio (or higher!). Just think of all the hours wasted.
I think I have personally spent far more time on refactoring and fixing code than I have on writing new code. And most of that new code is now long gone due to the trend of everything being re-invented and re-written every 5 minutes in the web dev world.
Admin
System.Nullable<T> goes back to .Net 2.0. It's possible for something like this to have predated it, but not very likely. Given that .Net Framework 2.0 was released in early 2006, it's probably fair to at least suggest that this was overdue for refactoring to something more conventional, lo, these 16 years on.
But, it's way more likely that somebody heard about 'primitive obsession' and decided that the solution was to invent their own amplified type for half-baked reasons.
Admin
It's likely that the implementation of the property got lost, too, since there's not much need for a backing field if you're using an auto-property.
Admin
The good developer redoing the work of the bad developer? Half the time they are the same person.
Admin
Come on, it is obviously the Pointy Haired Boss from Dilbert comics
Admin
What no Macbeth reference? double, double, double
Admin
Pointy Haired Boss?
Admin
I imagine there could be a valid use case for value type wrapper in a reference type (although a generic PhbRef<T> where T: struct is a cleaner approach). I cannot imagine any such cases myself, but I can imagine there could be.
Admin
Vielen Dank für die Informationen.
Addendum 2024-02-07 23:23: In der digitalen Welt der Blumenarrangements bin ich auf eine Webseite gestoßen, die nicht nur kunstvolle Blumensträuße anbietet, sondern https://myglobalflowers.de/ diese auch zu einer poetischen Erfahrung macht. Jeder Strauß erzählt seine eigene Geschichte und fängt die Schönheit der Natur in einer digitalen Blumenpoesie ein.