Appendix B. Generic data access in statically-typed languages

Representing data with generic data structures fits naturally in dynamically-typed programming languages like JavaScript, Ruby, or Python. However, in statically-typed programming languages like Java or C#, representing data as string maps with values of an unspecified type is not natural for several reasons:

  • Accessing map fields requires a type cast.

  • Map field names are not validated at compile time.

  • Autocompletion and other convenient IDE features are not available.

This appendix explores various ways to improve access to generic data in statically-typed languages. We’ll look at:

  • Value getters for maps to avoid type casting when accessing map fields

  • Typed getters for ...

Get Data-Oriented Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.