Good and clear names help, good API design helps even better. E.g. if an invalid order identifier is not a logic error in your particular code, but something that a caller code must handle, then don’t use updateOrder(orderId: String, ...) API design in the first place, but design a separate findOrderById(id: String): Order? function that clearly requires caller to do something with the null result, and then have updateOrder(order: Order,...) which cannot be called with invalid order in the first place.

Written by

Project Lead for the Kotlin Programming Language @JetBrains

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store