« view all projects

Case Enumeration and Branching Code Generator


Project Type: Webpage
Project Link: https://transvec.com/case-enumeration
Initial Release/Completion Date: November 2016
Technologies Used: HTML/CSS/JavaScript, JQuery
Tags: Personal, Programming Tool

A wise professor in college taught us to 'enumerate the cases' when dealing with conditional logic. He showed us how to do it by hand and it was one of those 'lightbulb' moments for me. I realized that this was also the basis of writing good test cases as well. Unfortunately, it's a bit tedious to do this by hand once you start working with more than 2 or 3 boolean conditions. This tool is something I've wanted to make ever since that lecture to automate the process and design and manipulate branching code with the click of the mouse

You can either start from scratch and add variables and method stubs to start building your enumerations, or parse existing if/else branching code that contains boolean variables. Then, you build the if/else code by simply clicking checkboxes to map the different cases to 'states' or method stubs.

This is also useful for debugging or altering existing code. If you have to add a new variable or condition to existing code, you can do it visually by adding the mapping using the interactive truth table. You can also manipulate the code by hand and re-parse it to see the results

This tool will also compare two branching statements to test if they're logically equivalent. There are also various options to manipulate the code that is generated. It will even reduce/simplify long boolean expressions to keep the generated code nice and tidy. It also eliminates unnecessary variables and tests where possible, replacing 'if else' with 'else' where appropriate

I'm pretty proud of this one. I had to work through some difficult recursion, tokenizing and parsing problems, but I learned a lot and hope it's a useful tool for myself and others in the future.