Sign in to follow this  
Daniel Miller

[.net] Map editor structure

Recommended Posts

I've made a ton of simple Windows Forms apps, but now it's time for a larger program. I'm currently making a map editor, complete with undo/redo, palettes, copy/paste (for tiles and regions), file metadata, etc. In the past I've just thrown a bunch of fields into my form class itself and let the program do its thing. For larger programs, what do you recommend? Should I do the same? Wouldn't that get out of hand? I guess I'm having trouble modularizing everything when all input/output is with the form.

Share this post


Link to post
Share on other sites
It's a bit hard to give any generic advice on this, but one obvious thing to check is where you can create coherent custom controls to maintain some semblance of order [smile] Another idea would be to stick your data into seperate classes that handle all the logic and having your form eventhandlers just call methods on the data objects, so the interface and data don't get all mixed up.

Hope this helps :)

Share this post


Link to post
Share on other sites
You might want to read on Model-View-Controller.

More generally, what I usually do in C# for program of moderate complexity is have the GUI hook up on some events from the 'logic' classes and call methods on them in it's own events. That way, I can keep my GUI fairly independant from the logic, and vice-versa.

[Edited by - jfclavette on March 6, 2007 12:41:09 PM]

Share this post


Link to post
Share on other sites
You probably already know this, but just in case, I thought I'd metnion why it's a good idea to separate out your UI from the underlying logic (though it is quite obvious).

You want your UI to be as thin a wrapper as possible; this means that you can more easily swap out the UI (for example, move over to WPF), and allows for easier automated testing of the logic behind the UI, and breaking your logic into separate smaller classes allows for easier code reuse.

Don't sweat too much if you can't see how to structure things upfront - have a read up on refactoring to patterns (and read up on the Gang of Four design patterns) so that you can gradally structure your code as you go along.

have fun!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this