• Frist (unregistered)

    public class Frist : SerializableObjectBase {

    }

  • giammin (unregistered)

    that code struck me deeply.

    I'm throwing up

  • (nodebb)

    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:

  • Brian (unregistered)

    Man, if only .NET had a built-in API for XML serialization. Oh wait, it does.

  • Zach (unregistered) in reply to Brian

    Hence why this pile of crap is a WTF

  • (nodebb) in reply to Brian
  • ZZartin (unregistered)

    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!!

  • Ryan (unregistered)

    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.

  • (nodebb)

    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.

  • I dunno LOL ¯\(°_o)/¯ (unregistered)

    When I pull a dictionary off of the bookshelf, it's all strings, so that is clearly how to implement dictionaries in code!

  • HK-47 (unregistered)

    My IQ just dropped 20 points from reading this, if I were a woman I could have passed as blonde.

  • Colin (unregistered) in reply to HK-47

    Blonde jokes? You know it's 2018 right..?

    Anyway you can't have a negative IQ.

  • siciac (unregistered)

    Anyway you can't have a negative IQ.

    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.

  • Friedrice the Great (unregistered) in reply to siciac

    For some people, their IQs are imaginary numbers.

  • (nodebb)

    Relevant: https://developer.android.com/reference/android/os/Parcelable

  • sizer99 (google)

    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.

  • (nodebb) in reply to Zmaster

    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.

  • some random dev (unregistered)

    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.

  • Carl Clawson (unregistered)

    For added horror, consider what happens if you attempt to read a file that was written with different regional settings.

  • HK-47 (unregistered) in reply to Colin

    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.

  • Scott Andrews (unregistered)

    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.

Leave a comment on “Stringed Out”

Log In or post as a guest

Replying to comment #:

« Return to Article