Bendy classes and dynamic programming