Piecewise Functions And Conditional Logic Theory

Decision tree analysis using quick approximations

Is it possible to use piecewise functions for software complexity analysis? This post will be a short analysis of whether or not it makes sense to use piecewise functions to understand conditional logic that exists within a feature or an application.

Conditional Logic

Programmatic Decision Making

In programming, the goal is to configure logical statements in specific arrangements to produce an output of some kind.

The concept is to:

  1. Create an abstraction of a scenario that can be represented with a set of variables

  2. Compose the variables so that they can be compared to one another

  3. Determine the number of conditions or condition ranges that need to be evaluated

  4. Assign functions based on those ranges


Piecewise Functions

I was reviewing these for a class I’m currently in and I find it really interesting as a thought experiment.

I raised the question to myself “Is it possible to take a feature from within an application, and express its complexity mathematically?”

If there are only two conditions, the size of the piecewise function has only two rules.

But as the “height” of the piecewise function grows, this introduces complexity. Not only in the form of new rules but in the complexity of the conditions themselves.

Let’s see an example:

complexity grows with the number of functions, along with condition definitions

The functions themselves may not grow in individual complexity as the list of rules grows. But each new function, and each new consideration, is a new piece of software to be concerned about.

Thinking about it, these sorts of things are glazed over really frequently (me included) during code review, and design in general.

Theory

Understanding approximately how much decision-making a specific piece of code must make is an important thing. And when planning for the work allocation, as well as the maintenance and lifecycle of a feature, having this kind of information can be really valuable.

I feel that quickly grabbing a pencil and sketching out a quick piecewise function to give a pseudo description of what a feature will need to do is a great idea to understand how to POC that feature, or maybe even take it to the MVP stage depending on how complex it may be.

These little functions can even point to one another as well in a diagram if you have the proper software. That’s useful as well to a holistic view of the pipeline of functionality, that may be more useful to people in the team who are not software developers.


Conclusion

I believe it’s a good idea to introduce approximate or guesstimate piecewise functions to understand how complex a feature might be. Take 15-20 minutes to sit and map out these decision trees as equations, and even ‘plumb’ them together so that the total view of the problem can be more easily digested.

Previous
Previous

A Bit About Supervised Learning

Next
Next

No Value Accessor For Form Control Name