- 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
public class Frist : SerializableObjectBase {
}
Admin
that code struck me deeply.
I'm throwing up
Admin
I posted this in my work slack along with a lot of :face_vomiting: :face_vomiting: :face_vomiting: :face_vomiting: :face_vomiting: :face_vomiting: :face_vomiting:
Admin
Man, if only .NET had a built-in API for XML serialization. Oh wait, it does.
Admin
Hence why this pile of crap is a WTF
Admin
What goes around goes around goes around comes all the way back around
Admin
Bonus points if at some point you come across a data type that doesn't always clean convert back and forth between strings and whatever type it is!!
Admin
This feels way too familiar.. One project I worked on started doing this until I switched it to use the built-in XML serialization. Pieces still needed to be manually deserialized due to the generic nature of the protocol, but at least we were able to automatically serialize everything we sent to the client.
Admin
You could do what the legacy code I have to work with does; most of the params passed around are heterogeneous hashmaps/tables with string/object key/value pairs. They are constructed from method local vars, passed to another method that pulls the values out (checking for nulls, casting to a type, hardcoded keys) into local method vars, uses them, and repeat/rinse for calling other methods. WHen that is too onerous to bother with, the code just sets a global app/system property that anything anywhere can change/read at any time.
Makes for fun debugging and modification.
Admin
When I pull a dictionary off of the bookshelf, it's all strings, so that is clearly how to implement dictionaries in code!
Admin
My IQ just dropped 20 points from reading this, if I were a woman I could have passed as blonde.
Admin
Blonde jokes? You know it's 2018 right..?
Anyway you can't have a negative IQ.
Admin
Sure you can. Scores from tests are estimates of IQ, but IQ is normally distributed and can your actual IQ can be any real number.
Admin
For some people, their IQs are imaginary numbers.
Admin
Relevant: https://developer.android.com/reference/android/os/Parcelable
Admin
I just have to point out how stunningly efficient it is to do a dictionary lookup by string and a string to int conversion every single time you want to access a property. Instead of just, you know, returning the int from a fixed offset.
Admin
This platform what the f**kery from the vendor is mind boggling. No vendor is perfect so I'm not pointing fingers but there should be a book for each platform listing the built in WTFs and what not to do etc.
Admin
The obvious solution is to write a class derives from that one which uses reflection to add all its properties to the dictionary, then you use that one for all your own classes. Given that everything's a string, this really wouldn't be hard.... And avoids death-by-boilerplate after a few weeks/months.
Well, the obvious solution is to show mangement how stupid this is, and just use the framework's built-in serialisation or any one of a million third-party packages already available to do this for you.... But that's in the world of the sane.
Admin
For added horror, consider what happens if you attempt to read a file that was written with different regional settings.
Admin
No, I came from the future, blonde jokes are in again in 2218 and of course i cannot have negative IQ, below zero range seems to be reserved for you.
Admin
What about deserialization? Hopefully every single property uses a constant for its key so that it's not duplicated between serialization and deserialization. Of course you don't need that if you just serialize normally. Perhaps the names of properties could be explained to the developer as built-in constants.