chapter fourteen

14 Advanced data manipulation

 

This chapter covers

  • Manipulating nested data
  • Writing clear and concise business logic code
  • Separation between business logic and generic data manipulation
  • Building custom data manipulation tools
  • Using the best tool for the job

14.1 Whatever is well conceived is clearly said

When our business logic involves advanced data processing, the generic data manipulation functions provided by the language run-time and by third-party libraries might not be sufficient. Instead of mixing the details of data manipulation with business logic, we can write our own generic data manipulation functions and implement our custom business logic using them.

Separating business logic from internal details of the data manipulation makes the business logic code concise and easy to read for other developers.

14.2 Updating a value in a map with eloquence

Dave is more and more autonomous on the Klafim project. He can implement most features on his own, typically turning to Theo only for code reviews. Dave’s code quality standards are quite high. Even when his code is functionally solid, he tends to be unsatisfied with its readability. This time, he asks for Theo’s help in improving the readability of the code that fixes a bug that Theo introduced a long time ago.

DAVE: I think I have a found a bug in the code that returns book information from OpenLibrary API.

THEO: What bug?

DAVE: Sometimes the API returns duplicate author names and we pass the duplicates through to the client.

14.3 Manipulating nested data

14.4 Use the best tool for the job

14.5 Unwinding at ease

14.6 Summary