|
|
|
| Non-WTF Job: C++ Developer at Good Grievance (Ronkonkoma, NY) |
| « Up or Out: Solving the IT Turnover Crisis | The Super Hacker » |
"Having worked in the Computer industry for about twenty years now," Matt writes, "I rarely get the chance to actually write code. But I do get the joy of other people's problems landing at my feet when things go wrong."
"Not too long ago, one of our newer techies emailed me, complaining that he couldn't get load image data from a WebService created by another developer. Given that all of the XML serialization and deserialization is handed through our enterprisey library, it was only when I visted the WebService address in my browser that I was able to see the 'raw' data:
<attachments xmlns = "http://webservices..." > <bytes>37</bytes> <bytes>80</bytes> <bytes>68</bytes> <bytes>70</bytes> <bytes>45</bytes> <bytes>49</bytes> <bytes>46</bytes> <bytes>52</bytes> <bytes>10</bytes> <bytes>37</bytes> <bytes>-30</bytes> <bytes>-29</bytes> <bytes>-49</bytes> <bytes>-45</bytes> <bytes>10</bytes> <bytes>52</bytes> <bytes>32</bytes> <bytes>48</bytes> <bytes>32</bytes> <bytes>111</bytes> ..."The error, for those that care, was that our code expected values in the range 0 to 255, rather than -127 to 128.
|
I suppose it all depends upon how many bits you have in your bytes. Personally, I always overdesign a bit (pun intended) and use 9 bits. Problem solved!
|
|
Hmmmm.
"<bytes>37</bytes>" Are you telling me that your library is wrapping a "<bytes>" + "</bytes>" tag pair around each and every singl *byte* of image data?? Doesn't that blow up image sizes by 16? A 10k would become 160k. Isn't that a little ridiculous? |
|
The real WTF is that the <bytes> tag only contains a single byte....it should be <byte>. </rants>
|
|
Wow.. I had no idea XML could be this useful. Now you can use any random text editor instead of photoshop! Excellent solution once you fix the bug. Again, that would be easy to do with an XML editor. Brilliant!
|
There is one way to fix this problem. Convert each of those to something like this (with namespaces omitted for brevity): <bytes> By doing this, you eliminate the interoperability problem of just how to represent bytes and instead have something that is easy to interpret unambiguously every time!! |
|
Another problem with this technique is that bytes alone mean nothing to most people and you can't tell the dimensions of the image. A better solution would probably be:
<Row> <pixel>Green</pixel> <pixel>Yellow</pixel> <pixel>Red</pixel> </Row> There are many standardized color charts that could be utilized that I believe cover all possible real-life colors, eg: <pixel>Sunset Orange</pixel> <pixel>Light Green</pixel> <pixel>Reddish</pixel> <pixel>Lime Green</pixel> <pixel>Sea Breeze Blue</pixel> <pixel>Woodchip Brown</pixel> This way the underlying encoding for images could be understood by anyone. This might be a worthwhile project for anyone with sufficient XML skills. |
|
XML is like violence: if it doesn't solve your problem, you're not using enough of it.
|
| « Up or Out: Solving the IT Turnover Crisis | The Super Hacker » |