Many hard problems in programming originate from one single source: not properly distinguishing the representation of data from the way it is interpreted. Have you ever written code that filters $_GET for SQL injection attempts? Struggled with timezones? Tried to get escaping right for Javascript in HTML? Detected the character encoding of a string? All are examples of this one problem. In this talk we will look at some examples of the representation-interpretation problem and find the general pattern behind it. We will see how primitive types make it so hard for us to get this right, and how we can use value objects to steer us in the right direction. Once you notice the pattern, you’ll be able to reason about and solve these problems much more easily. Contains: math, character sets, strong opinions on string escaping, and an almost illegal slide.

Comments

Please login to leave a comment

Interesting topic and talk had lots of good information.

The SQL escaping example seemed a bit outdated - I think these days most projects use prepared statements. I guess the HTML example to avoid XSS attacks would have been a better main example instead.

Also there were huge sound problems at the beginning, which made it very difficult to follow.

Maybe some more practical examples could have been shown - the Money object was a good one. The string examples regarding converting from Latin1 to/from UTF-8 to/from UTF-16 and representing the bytes in different character sets was an interesting example, but didn't seem very practical. As the speaker mentioned for performance reasons it's maybe only good for a specific problem space, but not good in general.

The timezone example shown was also interesting, but it only showed the wrong way, how to not do it. The correct way seems to explicitly save the timezone, which seems to be difficult in real-life (e.g. databases). Another option might be to just assume somethings (e.g. all strings within the application are UTF-8 already or all date times are UTC), which was slightly mentioned though.

Thanks for the talk and besides my long feedback I enjoyed it and it was a good, refreshing talk. :-)

Too bad for the sound issues that seemed to go unnoticed by the staff, but I guess the speaker wasn't aware.
The talk itself was in my opinion an interesting perspective on types and ValueObjects.

Rated 5

Miro Svrtan at 16:52 on 11 May 2019

Great talk! Especially handling of the audio problems by the speaker: he was so calm that few of us in the audience tought he is not aware of the problem (and he was).

Maybe a small suggestion: for the last example (with the strings,utf8 ..), try to find a bit more exciting example: I personally found it bit distracting/uninteresting and might have lost interest somewhere in it. I still think it's a brilliant talk!

it is always important to remember that our thinking (the content of a variable) can be a limited part of reality (the values that are assigned) and therefore we must prepare for the worst.