Ok, so I have been working on this program for a while now. It is a sudoku puzzle board generator. Now I don't know why but about half way through the program I got the crazy idea to turn the whole thing into one big object. Everything, all the functions and variables, the whole lot. At first I thought this was a bit silly, but now that it is done, its brilliant!

All of my functions are now member functions of the sudoku object. It can randomly output an entire new series of numbers that meet the sudoku requirement and it has a convenient print to screen member function. It has an initial constructor that sets it up. And member functions that can erase its numbers and reset with new numbers. Any time I want to create a new instance of the object I can now say things like,

sudoku Bob;
sudoku pooka;
These could become the building blocks for a larger game. Object Oriented programming with complex objects is awesome!
I have a tendency to do the opposite and make programs with lots of simple objects and then try to put them together like code Lego. Maybe I should try it this way.
@chrisname: the sarcasm is extremely difficult to detect :p

@Manga: You're using an Anti-pattern:
+1 @ LB

While it might seem like a good idea for small projects, it is a maintenance nightmare. It does not scale up well at all.

Typically the smaller your objects, the easier they are to code, use, and find/fix errors in.

That said.... A Sudoku puzzle generator does not seem all that complex and it seems like it would work just fine as a single class... or even a single function (which uses some localized/hidden support functions internally). But it all depends.
No sarcasm, I was being sincere.


"does not seem all that complex"

I hope I can come to think like you one day. As it stands it took me the greater part of a year to work that one out.

But now that I think about it more, maybe you are right and it is a simple object. I only called it complex because it was difficult for me to figure out. In my other console game I am working on, my objects are just a small list of variables. This was the first time I tried to use a constructor and had member functions.
Last edited on
Topic archived. No new replies allowed.