If you Google FizzBuzz, you will see there are gazillion implementations in different programming languages of these rules:
For numbers 1 through 100,
- if the number is divisible by 3 print Fizz;
- if the number is divisible by 5 print Buzz;
- if the number is divisible by 3 and 5 (15) print FizzBuzz;
- else, print the number.
What's wrong with not writing code at all for the rules for FizzBuzz, and model it instead in the way everyone understands? I could not find any implementation of FizzBuzz as simple and self-descriptive as this one:
I am just trying to say that sometimes it is better not to code the logic, simply because it is easier to understand and maintain.
Ok look, here is a random solution just by Googling:
class FB{static public void main(String[]b){for(int i=0;i<100;System.out.println((++i%3<1?"Fizz":"")+(i%5<1?"Buzz":i%3<1?"":i)));}}
When you write business logic in code, that's exactly what it looks like in a couple of months (if not the week after you've written it!). No matter how well you've written it, it's going to be hard to understand after a while, because you are going to lose the context, no matter what.
Happy FizzBuzz!
To learn more about Decision Tables and alternatives to modeling a Decision Table (DT), please visit https://resource.flexrule.com/knowledge-base/decision-table
Last updated December 15th, 2020 at 08:07 am, Published July 3rd, 2015 at 08:07 am
CEO and the founder of FlexRule – He is an expert in architecture, design, and implementation of operational decisions, business rules, and process automation. Created Decision-Centric Approach, a methodology that brings People, Data, Rules, and Processes together to automate operational business decisions.
This approach is recognized by Gartner as the missing link to provide business value to organizations.
Leave A Comment
You must be logged in to post a comment.