Zomis / Brainduck

Brainfuck Interpreter in Java/Groovy, with a Groovy DSL
40 stars 1 forks source link

Don't pass input to the constructor #1

Open Zomis opened 9 years ago

Zomis commented 9 years ago

From http://codereview.stackexchange.com/a/61654/31562

Don't pass input to the constructor. If this were at all a serious interpreter, you'd probably want to be able to run the same program against different input. So it really makes more sense to have input be a parameter to a run function.

Zomis commented 8 years ago

Possibly use a BrainfuckFactory that can create a BrainfuckRunner. Currently, a BrainfuckRunner is an instance of a running Brainfuck program. A running Brainfuck program only has one source of user input.

A BrainfuckFactory could also store the code converter, and the Groovy context.

Or would a BrainfuckFactory be a bit over-engineering?