Backward Compatibility: Practice

Welcome back! Today, we'll master what we learned about backward compatibility in practice. Prepare to apply all the knowledge to practical tasks, but first, let's look at two examples and analyze them.

Task 1: Enhancing a Complex Data Processing Function with Optional Parameters and Default Values

Let's say that initially, we have a complex data processing class designed to operate on an array of associative arrays, applying a transformation that converts all string values within the array to uppercase. Here's the initial version using PHP:

We intend to expand this functionality, adding capabilities to filter the items based on a condition and allowing for custom transformations. The aim is to retain backward compatibility while introducing these enhancements. Here's the updated approach using optional parameters and closures:

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal