class - How can I reorganize my code into classes in C#? -
i'm working on project in c# w/ xna, , want reorganize , divide parts of classes.
at present, it's 1 game.cs file, want clean bit. unfortunately, i'm not familiar classes. perhaps can me figure out how this, or direct me tutorial of sort?
well, start off thinking of bits of data go naturally. example, if have player's name, score, position, number of lives etc, suggest should have player
class. take @ state, split different groups, , check of existing methods work 1 group of state or another... , put methods state they're interested in.
it gets trickier when 1 method needs deal state multiple objects, of course: typically means you'll put code in 1 type , pass other type in parameter.
a lot of gut feeling, honest - above starting points. on time gets easier, , you'll start think more in terms of responsibilities data - it's starting point, have data need, not organized in right way... whereas deciding on responsibilities within system can lot harder.
Comments
Post a Comment