Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Quick question on OOP

Name: Anonymous 2012-03-26 21:14

Hey guys, just a quick question here...
Current making a game in C# (herp derp, yeah... it's a requirement for the course I'm studying) and I've got what I want working so far.
But as for the OOP, I'd just like something clarified. I've made a class for a tiled map, but I also have quite a few variables/objects in the main game class that I'd like to access from the map class. At the moment, I've just made all of these public and it works fine. But it seems to me like this is a bad way of doing it... Just doesn't feel very correct.

I was thinking of making a new class that just contains everything I need (kind of like an interface between the two classes) but that also seems kinda stupid.

So yeah, if anyone understands what I'm asking... What exactly is it that I should be doing here?

Name: Anonymous 2012-03-26 23:16

Pretty much what >>3-kun said.

In another words, your STUFF inside a class should have as much communication inside it as possible - that's called having high cohesion. You can check quickly what kinds of cohesion do exist and compare them with your code using the lame wikipedia link http://en.wikipedia.org/wiki/Cohesion_(computer_science) .

BUT, at the same time, your STUFF should have as FEW communications with OTHER classes/modules as possible. That's called having "low coupling". Check http://en.wikipedia.org/wiki/Coupling_(computer_science) for a quick reference.

Try to rethink how they are working. C# is a nice LANGUAGE to learn some of that stuff - the .NET FW is a pile of shit. So you'll have a fun time refactoring it.

If you noticed something looks cheesy, you may take even less time figuring out.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List