5 ms·
Generic data types aren't necessarily a better approach. My primary language for many years has been PHP, where the default approach used to be just to pass g
by larzang 9y ago
Generic data types aren't necessarily a better approach.
My primary language for many years has been PHP, where the default approach used to be just to pass generic maps around for all data, and it was hell.
You cannot tell if a map passed to you has any of the members you expect, hasn't had additional unexpected members added, or anything else about it without parsing it, it's a mystery bag. There are times when a mystery bag is fine and you're going to be inspecting it anyway, but most of the time your code has at least some expectations about the structure of your data, and for that you need real specific types to maintain any kind of sanity. Otherwise, you're re-validating data over and over or writing code that relies on hope and faith instead of correctness.
- spdionis 9y agoWhy use actual objects and rely on static anlysis when you can write tens of unit tests that ensure the maps/tuples passed around always contain the correct data structures? And you get the added benefit of 100% test coverage.