Grotius

Hi,

I have a specific, minor question, and a general, major question. :)

First the simple question. Is there any way within GSE to save a backup or earlier version of the file you're modifying, other than simply to "Save As..." I dimly recall that Word has some sort of version-saving feature; does GSE or VS have this I actually find it easier to use Windows Explorer to copy the file to a new folder, but that seems kludgy.

Now the bigger question. I'm fairly new to coding, and while I can get things to work, I don't love the style in which my code evolves. I try my best to create classes and objects to do relevant work, and I try to keep methods short and specific. Still, inevitably I seem to end up with one class with about 30 methods and five other classes with three methods each. I take it this is not great style, but I fear that refactoring will be more trouble than it's worth.

For example, my current "learning project" is a checkers game. I've implemented a basic AI, and both the human and computer can move and capture pieces, though my "kings" code isn't done yet. I have a few simple classes, apart from the default Game1 class: a "piece" class that handles drawing code for the various types of pieces (red, black, king); a "move" class that stores info about each possible move for the AI and player; and a "board" class that has evolved into the Giant Class from Hell. The board initializes and stores the piece positions; handles player mouse input and player moves and captures; handles AI moves and captures; calculates the best move for the AI; and signals various gamestates. I take it this isn't great OOP style, but it's probably too late to parcel it all out to new classes. Should I have had an "AI" class I'm about to implement king movement and captures; should it be its own class Or do I just lard more functions into "board"

I have an analogous question about coding methods. If I try to make a method that will handle future problems, it ends up over-complex. If I try to make a method that handles my current problem, it can't handle future variations on the current problem. E.g.: I tried to make one method to handle all forms of moves, but ultimately I just ended up with specific methods for non-king moves, non-king captures, etc. So I'll have to either amend those methdos to account for kings, or create new methods. In general, is it better to try to code by "making room" for problems that are ahead of you, or to solve the problem in front of you and deal with the later problem later



Re: XNA Game Studio Express Saving backups, refactoring, & other newb questions

Jim Perry

Grotius wrote:
First the simple question. Is there any way within GSE to save a backup or earlier version of the file you're modifying, other than simply to "Save As..." I dimly recall that Word has some sort of version-saving feature; does GSE or VS have this I actually find it easier to use Windows Explorer to copy the file to a new folder, but that seems kludgy.

No, this is what version control software is for.

Grotius wrote:
Now the bigger question. I'm fairly new to coding, and while I can get things to work, I don't love the style in which my code evolves. I try my best to create classes and objects to do relevant work, and I try to keep methods short and specific. Still, inevitably I seem to end up with one class with about 30 methods and five other classes with three methods each. I take it this is not great style, but I fear that refactoring will be more trouble than it's worth.

For example, my current "learning project" is a checkers game. I've implemented a basic AI, and both the human and computer can move and capture pieces, though my "kings" code isn't done yet. I have a few simple classes, apart from the default Game1 class: a "piece" class that handles drawing code for the various types of pieces (red, black, king); a "move" class that stores info about each possible move for the AI and player; and a "board" class that has evolved into the Giant Class from Hell. The board initializes and stores the piece positions; handles player mouse input and player moves and captures; handles AI moves and captures; calculates the best move for the AI; and signals various gamestates. I take it this isn't great OOP style, but it's probably too late to parcel it all out to new classes. Should I have had an "AI" class I'm about to implement king movement and captures; should it be its own class Or do I just lard more functions into "board"

I have an analogous question about coding methods. If I try to make a method that will handle future problems, it ends up over-complex. If I try to make a method that handles my current problem, it can't handle future variations on the current problem. E.g.: I tried to make one method to handle all forms of moves, but ultimately I just ended up with specific methods for non-king moves, non-king captures, etc. So I'll have to either amend those methdos to account for kings, or create new methods. In general, is it better to try to code by "making room" for problems that are ahead of you, or to solve the problem in front of you and deal with the later problem later

Ideally, you would create a class diagram for everything you think you'll need before writing a line of code. That way you know before you're coding that you'll have what you think you'll need. It takes a while before you'll be happy with your code design. I've been coding for 20 years and still write crappy code from time to time.






Re: XNA Game Studio Express Saving backups, refactoring, & other newb questions

Rob Hanz

First, what he said about version control.

Secondly, it's *never* too late to refactor. Often, I find that I prefer to refactor code than to over-design it upfront.




Re: XNA Game Studio Express Saving backups, refactoring, & other newb questions

Jon Watte

Source control


I use Subversion. I have a SVN server daemon running on my server machine in the closet, and save all my changes to it after every session. For more information, see http://www.subversion.org/ (it's free / Open Source).

Ideally, you would create a class diagram for everything you think you'll need before writing a line of code.


That idea has pretty much been discredited at this point, by the measurable success of the Agile development movement.

Yes, you will need some idea of what you're building, but you should really grow the system incrementally, delivering a noticeable improvement for the end users in each milestone. And set milestones frequently. That way, you get early feedback, and can course correct when it's still cheap. This works very well, even when you are your own customer.

I've developed software for over twenty years, and I've learned that, if you do a Big Design Up Front, you always end up with something you thought you needed, but didn't, while not serving some need that you discover along the way.






Re: XNA Game Studio Express Saving backups, refactoring, & other newb questions

Jim Perry

Jon Watte wrote:
That idea has pretty much been discredited at this point, by the measurable success of the Agile development movement.

Discredited Then why have several companies I've worked for done them Agile development is not a magic wand.

Jon Watte wrote:
Yes, you will need some idea of what you're building, but you should really grow the system incrementally, delivering a noticeable improvement for the end users in each milestone.

I never said you would implement the entire thing at once, just have an idea of what should be done. That doesn't mean the design can't change as development occurs though.

Jon Watte wrote:
I've developed software for over twenty years, and I've learned that, if you do a Big Design Up Front, you always end up with something you thought you needed, but didn't, while not serving some need that you discover along the way.

I've been developing for almost twenty years as well. Neither case means you can't design up front. A design document (both gameplay and code) should be living documents, not written in stone. Flexibility is needed, but you don't just start coding without some design in place.






Re: XNA Game Studio Express Saving backups, refactoring, & other newb questions

Grotius

Thanks for all your comments, and for the references to version-control tools. It's particularly useful to read your different perspectives on developing an overall design.



Re: XNA Game Studio Express Saving backups, refactoring, & other newb questions

waruwaru

Grotius wrote:

First the simple question. Is there any way within GSE to save a backup or earlier version of the file you're modifying, other than simply to "Save As..." I dimly recall that Word has some sort of version-saving feature; does GSE or VS have this I actually find it easier to use Windows Explorer to copy the file to a new folder, but that seems kludgy.

You can write a simple batch file and use it in your post-build event. It's a poor-man's backup, and will probably eat up your disk space pretty quickly.