DEV Community 👩‍💻👨‍💻

Discussion on: FizzBuzz Refactoring Challenge with Open/Closed Principle

Collapse
 
galoisgirl profile image
Anna

In real life, you gain some experience and can generally predict in what direction the software might go in the future.

Given FizzBuzz, I'd guess that business asked me to handle divisibility by 3 and divisibility by 5, so it's just a matter of time until they want divisibility by 7. However, it's not very probable they will want to add a case for when a number is a square.

That would lead my to a solution based on the general principle of prime factors, and not the special rules, so basically string concatenation.

If business wants squares, I'll say "well, that's very different from the things we had until now, so this will take some time".

Collapse
 
olivermensahdev profile image
Oliver Mensah Author

Sure but as the requirement keeps changing, I will start identifying patterns and how best to prepare for future changes without changing the code too much.