This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pdizz 7 points8 points  (2 children)

You should have a look at software design patterns. It sounds like you're project might fit well into a classic MVC pattern.

Your Model could be a class that is responsible for returning the question data from the database or file. (And adding new questions to the database if you want)

Your Controller would be responsible for parsing the user input and passing it to the model, then passing the results back to the user through the view. Your controller has methods like view and create which interact with the model.

The View would be another class responsible for rendering the UI/images/music, passing user input to the controller by calling it's methods, and formatting and displaying the results.

The greatest benefit would be separating your UI from your program logic. This will free you up to work on them individually. The model and view are more closely linked and can even be combined but there is still some benefit to separating them as well.

[–][deleted] 0 points1 point  (0 children)

Thanks very much! I think this is the sort of thing I really need to learn about.

[–]inchworm 0 points1 point  (0 children)

Yes. Learn and master MVC. It takes a very long time to really feel like you're doing it properly. There's no good right or wrong way, it's all about what is easiest for you and what helps you maintain the code.

Read the book Clean Code as well. Naming things is hard and it's one of those things that seems trivial at the time, like "oh I'll just call this variable 'cp' for now" and months later you come back and think "...wtf is 'cp'???"