[.net] Map editor structure

Started by
4 comments, last by taumuon 17 years, 1 month ago
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.
Advertisement
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 :)
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
Hmmm. Ok, I'll just screw around with it until everything seems clean. Thanks a lot for your advice, ++rating.
You can keep code "inside" the form and also keep it relatively clean by expanding it into multiple source files using C#'s partial class support.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

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]
I teleported home one night; With Ron and Sid and Meg; Ron stole Meggie's heart away; And I got Sydney's leg. <> I'm blogging, emo style
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!
C# Physics Engine Tutorials: www.taumuon.co.uk/jabuka/

This topic is closed to new replies.

Advertisement