Questionable Design?

Granted, I'm only a hobbiest, but it seems that many of the samples in this beta just have some very poor design regarding encapsulation.

Is it no longer one of the pillars of good OO that an objects data is private and exposed through accessors


Answer this question

Questionable Design?

  • DigitalFusion

    I'm not sure with "many of the samples", but I _definitely_ concur with this sentiment when it comes to the Spacewar example. Spacewar doesn't even seem like much of a "port." When opening up the Spacewar example, you will notice that there are ZERO GameComponents in the entire application. Now, a game that is being true to "the XNA way", I'd imagine, would certainly have more than _zero_ GameComponents.

    It's unfortunate since I'd imagine a good number of people would try to use Spacewar to learn XNA. And if they do, they're not going to learn much about XNA. As someone who is passionate about good code and design patterns, seeing such a non-XNA-type code base being used as "the XNA learning tool" is quite disappointing.


  • Skurcey2

    Although if you open up the help file (in XNA GSE: Help -> Contents), you'll find a section on XNA. Not only that, there are a BUNCH of "How To" articlettes (<- my own word for short articles :P) that show things like: drawing a sprite, make a scrolling background, rotate a sprite, transform a point with a Matrix, make a first-person camera, make a third-person camera, detect whether two objects collide, detect whether a user clicked a 3d object, detect whether a button is pressed, playing a sound, changing sound volume levels, etc. That's just the tip of the iceberg too.

    You can find all of these under: Xna -> Xna Game Studio Express -> Programming Model -> AppModel/Graphics/Math/Input/Sound/etc. Once again, you can bring this help up by choosing "Contents" from the "Help" menu in XNA GSE.

    So, there are actually quite a few smaller samples. It's the larger Spacewar sample that leaves me desiring more since it is _not_ a good XNA example.


  • Paul Steele

    The ZMan wrote:

    Thanks for the feedback - I'm always happy to get good and bad because it makes me better next time. Don't forget to upload your game so that 20,000 people can rip on it too!

    Sometimes in the real world corners are cut to ensure delivery. Its no good having perfect code if you never actually ship anything. Ask Jason about Tanks and SpaceBalls :-)

    Ouch!!! Talking about a low blow :). LMAO. Andy, you are truly the man. And I know I deserved that one :P.

    I definitely agree that I need to upload a _finished_ game to get ripped apart since you have put your money where your mouth is when I haven't :).

    And sometimes it's easy for my "academic sense" to get in the way without remembering that you are dealing with real deadlines out there. I can't wait to see what future samples you are working up (now that GameComponents and GameServices exist :D).


  • stombiztalker

    While I partially agree, I have to say that just because a GameComponent derived object wasn't used, it doesn't make the sample a bad example of an XNA game. It still used many XNA Framework objects.

  • Sachin Saxena

    Jeff Weber wrote:
    I'm guessing the GameComponent stuff wasn't fully flushed out when the SpaceWars team was building there game. Remember, they were working with a Alpha(probably pre-alpha) product.

    Yeah, I just chatted with Andy Dunn about this. When he was coding up this sample, the GameComponent concept didn't really exist yet. Which, considering that, it's perfectly understandable that there isn't a single GameComponent :). So, I pull my critique back a bit :). With how functional the XNA Framework is, it's easy to forget that we are still using the Beta (and hence, the samples probably were built on Alpha-esque framework).


  • sjb500

    ThwartedEfforts wrote:
    I'm glad someone else had the balls to mention this. Not only is the Spacewar demo a sloppy example of what Game Studio Express can do, you also need prior knowledge of C# to add keyboard or mouse support—something every gamer takes for granted.

    IIRC, it's a matter of uncommenting one #define to get keyboard support. Really tough. I'm not trying to start a flame war here, but it seems your comment is a bit off-base. The whole "you also need prior knowledge of C#" is kind of a given for using GSE isn't it

    I've rarely seen sample games in SDKs that were meant to be production pieces. I think Space Wars is a great sample in that it shows how to do many things and it's a completely playable game at the same time. It's rare you get a complete game in samples. Everyone is going to have their own way of doing things. I wouldn't expect any sample to be a "Here's the way it has to be done".



  • Ruurd Boeke

    Jim Perry wrote:

    ThwartedEfforts wrote:
    I'm glad someone else had the balls to mention this. Not only is the Spacewar demo a sloppy example of what Game Studio Express can do, you also need prior knowledge of C# to add keyboard or mouse support—something every gamer takes for granted.

    IIRC, it's a matter of uncommenting one #define to get keyboard support. Really tough. I'm not trying to start a flame war here, but it seems your comment is a bit off-base. The whole "you also need prior knowledge of C#" is kind of a given for using GSE isn't it

    I've rarely seen sample games in SDKs that were meant to be production pieces. I think Space Wars is a great sample in that it shows how to do many things and it's a completely playable game at the same time. It's rare you get a complete game in samples. Everyone is going to have their own way of doing things. I wouldn't expect any sample to be a "Here's the way it has to be done".

    I don't quite agree. Spacewars is a great example for game development, sure. However, Spacewars is _not_ a good example of an XNA game. With the purpose of GameComponents and GameServices to extend XNA, there is not a _single_ GameComponent in Spacewar.


  • yanivpinhas

    Now that my tears have dried and my heart is no longer hurting I can give you a response since I did the coding for Microsoft for SpaceWar.

    1. There was no such thing as a game component when SpaceWar was written - it was done on pre beta1 code. Hence no content pipeline, hacky model loading and no components.

    2. The code was originally intended for a demo and became a beta starter kit after it was started. The idea was to give everyone at least one completed game to see how things worked. The alternative was that you got nothing. This is also why there was originally no keyboard control and why it was added at the last minute though a #define.

    3. The code was done pretty fast and went through multiple pre beta builds of XNA just to make things interested for me.

    4. There was no time left at the end for fxcop type checking and some of the refactoring that I would have liked to do. I tried to get most of the XML comments done and I do try to be fxcop compliant as I code but I'm not perfect. There are also some great places for perf optimisation too that I didn't have time to do (though to be fare someone at Microsoft did fix a couple of these before beta 1 shipped)

    5. I'm know there are some bad design bits in there, and some bits that we could argue on for a long time because design is very objective. This was a demo of an XNA game rather than a demo of perfect OO code.

    6. Like XNA framework SpaceWar is a beta. Feedback can go in connect.

    Thanks for the feedback - I'm always happy to get good and bad because it makes me better next time. Don't forget to upload your game so that 20,000 people can rip on it too!

    Sometimes in the real world corners are cut to ensure delivery. Its no good having perfect code if you never actually ship anything. Ask Jason about Tanks and SpaceBalls :-)



  • darthziv

    Well, I certainly didn't want to start a flame war and I admit my coments were not completely flushed out(like the beta, sorry couldn't resist).

    It does seem that Microsoft, though, has a prepensity for putting, well, to be blunt, questionable code out for public examples. Code that is either simply poor OO, or breaks their own pubilcized standards.

    An example would be the reams of .Net code on MSDN that uses hungarian notation. Now, I don't want to get into an argument about the merits or problems with hungarian notation, just to mention that in "proper formatting" hungarian notation for .Net is not recommended. Even fxcop catches m_ and flags it as a warning. It's these very things that drive a hobbiest like myself crazy when trying to learn, albiet in a silo.



  • medel

    Steve Hoff wrote:
    Granted, I'm only a hobbiest, but it seems that many of the samples in this beta just have some very poor design regarding encapsulation.

    Is it no longer one of the pillars of good OO that an objects data is private and exposed through accessors


    I'm assuming you're referring to the Spacewar example ( or did you mean the output of the community at large ) I see a couple places where they have public members, but otherwise seemed solid to me.

    As a standalone project, I don't have many complaints re: overall design. On the other hand, I agree with Jason that it doesn't make a very good "teaching" project. You can't just dig in and hack it to pieces. And it's the dev's have said themselves to ignore the model loading mechanism -- any reliance on the content pipeline had to be ripped out because that piece didn't make the beta deadline.

    Myself, I would have preferred several demo projects that had smaller, more targeted scope (loading a mesh, playing a sound, creating a shader, etc.) much like the samples that come with DirectX.

    That said, it is a beta and I'm sure that crunchtime of Gamefest + the beta deadline didn't allow them the luxury of fleshing everything out to their satisfaction.

  • dbloom

    I'm glad someone else had the balls to mention this. Not only is the Spacewar demo a sloppy example of what Game Studio Express can do, you also need prior knowledge of C# to add keyboard or mouse support—something every gamer takes for granted.

    I guess there'll be an argument that, by using poor coding practices and omitting key features, Microsoft is throwing people in at the deep end and encouraging them to make the changes themselves. Or perhaps Microsoft is encouraging us to buy Xbox controllers, who knows But for anyone new to programming, the way Spacewar has been presented is an instant barrier: witness the number of messages in this forum.

    It does look pretty slick though. You don't need gameplay these days anyway :)

  • WynApse

    The keyboard solution in the tutorials thread is more than 50 lines of code.

    Why is knowledge of C# a "given" when using Game Studio Express One of the entries in the FAQ reads, "What is the C# language " Assuming everyone who downloads GSE knows C# is no different to assuming everyone who buys a PC knows how to use it. Fact is, they don't.

    I'm not sure why I'm defending an obvious statement. You just have to look at some of the posts here to realise that people are falling over at the first hurdle. And the more they fall, the less likely they are to continue using GSE, and will instead slink back to the likes of DarkBASIC.


  • Mondo2435

    I'm guessing the GameComponent stuff wasn't fully flushed out when the SpaceWars team was building there game.  Remember, they were working with a Alpha(probably pre-alpha) product.

  • boran_blok_edan

    The code makes me feel somehow back in the good old VC20/C64 days when
    OOP was something very theoretical and games were coded like this.
    Things were put together in Basic and somtimes extended by some assembler-routines.
    And it worked pretty well....having loads of fun......

    A lot of projects around at the moment are about clones of games
    from that time and SpaceWar is just like that.
    And we are talking about a beta version which lacks the content-pipeline-features
    and a lot of other useful stuff we don't know almost nothing about.......

    SpaceWar is not the superbest example I think and the required
    XBox360-Controller is an issue for itself.
    But it contains stuff that features OOP as well like the SceneItem-Class or
    the AssetCache - it's also beta.....for now it's ok for me.
    Take a look at this post

    For the final release of GSE CP and GameComponents will do
    most the horsework I hope and there will be more evolved examples
    based on this features.Then we'll know....

    I guess SpaceWar is about learning XNA and not meant to be as an OOP -Tutorial or a C# Manual.
    I wonder if all those Megasellers out there stand the OOP-Design-Test...

    For learning purposes I personaly like fewer lines of code to take a look at the idea behind it.



  • Questionable Design?