What's your point?



  • Now that I've significantly sped up and deployed our application, performance problems
    are becoming apparent in some of the other applications. I was asked to help investigate.

    While spelunking through the code, I happened upon this piece of... ingenuity.

    DB Table:
    thePK number(38),
    ...,
    theData blob

    What do you store in theData?


    Everything.


    Everything?


    Yes. It was taking a lot of work to change the code every time we had to store a different piece of data in the db, so we just put it all in this one column.


    There is no type-information; how do you know what data is in a given row?


    We parse it out in code.


    (Panicking) May I see the code?

        private Object parseDbBlobData(byte [ ]in) {
    String inStr = new String(in);
    try {
    int n = Integer.parseInt(inStr);
    } catch (Exception e1) {
    try {
    long l = Long.parseLong(inStr);
    } catch (Exception e2) {
    try {
    double d = Double.parseDouble(inStr);
    } catch (Exception e3) {
    try {
    ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(in));
    return ois.readObject();
    } catch (Exception e4) {
    return inStr;
    }
    }
    }
    }
    throw new IllegalArgumentException("Unknown object from db");
    }

    You know, even forgetting that doubles can look like longs which can look like integers which could yield unpredicatable results and hard to find bugs (they pass all manner of numbers as both serialized objects and in string form), this may not be the right way to do this.

    So what, it works!

    If you had massive pain from a migrain headache, I could drive a spike clear through your skull to take your mind off the pain; it'd work too, but it's probably not the right way to do it!

    What's your point?



  • I have some JSON parsing code that looks identical to that. ... just sayin'.



  • @snoofle said:

    So what, it works!

    You really have found a treasure trove. Putting anything into a blob and then depending on an object parser to ... it's sad. But the attituded "so what, it works" is the true sign of a demented engineer. Design is for pussies, it just has to work. And when it stops working, we'll just build something else.



  • @TGV said:

    http://snoofleaks.org
     

    what the hell is an aks.



  • @snoofle said:

    You know, even forgetting that doubles can look like longs which can look like integers which could yield unpredicatable results and hard to find bugs [...]

    Don't worry. It will throw an IllegalArgumentException in those cases...



  • @dhromed said:

    @TGV said:

    http://snoofleaks.org
     

    what the hell is an aks.

    Pick up the aks and throw it at the little drawf.  He will vanish in a cloud of greasy black somke.

     



  • @da Doctah said:

    @dhromed said:

    @TGV said:

    http://snoofleaks.org
     

    what the hell is an aks.

    Pick up the aks and throw it at the little drawf.  He will vanish in a cloud of greasy black somke.

     

    only 5 replies and I already hate this thread



  • @Speakerphone Dude said:

    @da Doctah said:

    @dhromed said:

    @TGV said:

    http://snoofleaks.org
     

    what the hell is an aks.

    Pick up the aks and throw it at the little drawf.  He will vanish in a cloud of greasy black somke.

     

    only 5 replies and I already hate this thread

    I know what you mean.  He mispelled graesy.

     



  • @El_Heffe said:

    @Speakerphone Dude said:

    @da Doctah said:

    @dhromed said:

    @TGV said:

    http://snoofleaks.org
     

    what the hell is an aks.

    Pick up the aks and throw it at the little drawf.  He will vanish in a cloud of greasy black somke.

     

    only 5 replies and I already hate this thread

    I know what you mean.  He mispelled graesy.

     

    I wonder how the Little People's Defamation League* feels about classic Adventure's implication that dwarves are greasy.

     



  • @TGV said:

    http://snoofleaks.org
    That's teh wierdest way of writing 'snowflakes' I've evre seen.



  • @Zecc said:

    @TGV said:
    http://snoofleaks.org
    That's teh wierdest way of writing 'snowflakes' I've evre seen.
     

    Tit's de wierdest wee oi've aver seyan. Tham thur snoofleaks filling doon frem de skey an woontr.



  • @snoofle said:

    What's your point?
     

    "it's an iron spike - currently approaching your skull at high speed - and will soon solve a multitude of problems..."

    *splurtch*



  • Well, they had the right idea in storing all the data as a blob -- as mentioned, it does avoid those constant schema changes. But what they should have done was use Java serialization to read/write the byte[] blob. This is both highly performant and efficient in terms of lines-of-code.

    Thomas

    (Whistles naively, rides blithely off into the sunset....)



  • @snoofle said:

    "So what, it works!"
     

    "Yes, but at a massive cost to the organisation.

    It's a maintanence headache, it will treble our project times and require far greater effort to manage changes, all because someone picked the worst way imaginable to solve this problem, which it does almost purely by luck, and had no foresight or inclination to look for more efficient ways of performing the same task.

    Who did you say wrote this again...?"



  • @snoofle said:

    You know, even forgetting that doubles can look like longs which can look like integers which could yield unpredicatable results and hard to find bugs (they pass all manner of numbers as both serialized objects and in string form), this may not be the right way to do this.
    Even after all these years, I'm still baffled by the number of people that call themselves developers (a monicker I wouldn't use as liberally as they do), yet don't seem to understand the difference between a database and a file system.

     



  • Wow! They just killed two birds with one rock: do we use an RDBMS or NoSQL? Do we use an ORM or a JDBC?

    It works! Slow, but it works... sort of



  • @Severity One said:

    I'm still baffled by the number of people that call themselves developers (a monicker I wouldn't use as liberally as they do), yet don't seem to understand the difference between a database and a file system.
     

    To functional programmers, data is accessed through a set of API calls or some DAL, so it probably appears to be the same thing conceptually to them.

    If they don't touch the DB or go any further than those interfaces.. then it should appear that way. Let them use getters and setters; leave the management of The Dark Place That Persists Your Data to those that know what they're doing and don't get too bogged down with the implementation details.

    There, there.

    *pats head, condescendingly*



  • @Cassidy said:

    The Dark Place That Persists Your Data
     

    That is such a weird way of saying you're constipated.



  • @dhromed said:

    That is such a weird way of saying you're constipated.
     

    Forgive me.

    I can't state "I have a backlog" without collapsing in uncontrollable giggles.



  • @Cassidy said:

    @Severity One said:

    I'm still baffled by the number of people that call themselves developers (a monicker I wouldn't use as liberally as they do), yet don't seem to understand the difference between a database and a file system.
     

    To functional programmers, data is accessed through a set of API calls or some DAL, so it probably appears to be the same thing conceptually to them.

    If they don't touch the DB or go any further than those interfaces.. then it should appear that way. Let them use getters and setters; leave the management of The Dark Place That Persists Your Data to those that know what they're doing and don't get too bogged down with the implementation details.

    There, there.

    pats head, condescendingly

    Reminds me of this young developer at my client's office, insisting on using an ORM because "it's easier to maintain" but complaining every time someone does a modification to the underlying database model. Surprisingly he's also a big fan of storing blobs instead of using a proper data model, and when asked about using the database outside of his application he is eager ot build an API (also "easier to maintain").



  • @da Doctah said:

    @El_Heffe said:

    @Speakerphone Dude said:

    @da Doctah said:

    @dhromed said:

    @TGV said:

    http://snoofleaks.org
     

    what the hell is an aks.

    Pick up the aks and throw it at the little drawf.  He will vanish in a cloud of greasy black somke.

     

    only 5 replies and I already hate this thread
    I know what you mean.  He mispelled graesy.

     

    I wonder how the Little People's Defamation League* feels about classic Adventure's implication that dwarves are greasy.

     

    point out that is was a "drawf" not a dwarf, and for all we know drawfs could be extremely greasy.



  • @Cassidy said:

    I can't state "I have a backlog" without collapsing in uncontrollable giggles.
     

    @Cowboymeme::Wookiee said:

    Core dump. View log for more details.

    hee hee hee



  • @dhromed said:

    @Cassidy said:

    I can't state "I have a backlog" without collapsing in uncontrollable giggles.
     

    @Cowboymeme::Wookiee said:

    Core dump. View log for more details.

    hee hee hee

    I'm old enough to remember when mentioning "half-height floppy drive" in a memo to be typed made secretaries blush.

     



  • You'll probably remember "I'm upgrading my five-and-a quarter floppy to an eight-inch hard".

    .. unless you're younger than I.



  •  I have two big hard drives.



  • @dhromed said:

     I have two big hard drives.
     

    Is that what you call them? They look like eyes if I squint really hard.


Log in to reply