Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > General > Best Practices

Reply
 
Thread Tools Rate Thread Display Modes
Old 01-01-2009, 09:40 PM   #1
emacrisema
worst coder ever!!!
 
Join Date: Aug 2008
Location: end of the world (botosani)
Posts: 15
Default large scale games oop or procedural ?

I made a few games , in which I had ONLY a document class .
for ex: http://www.rockyou.com/games/games-view.php?id=83020
I've read (skimmed) Advanced AS3 with Design Patterns by Adobe Press just before the holidays . I was really proud then .
Two weeks later -surprise- I can't remember a thing .
I mean I know objects should be closed and basic blah blah blah.
But I can't apply all that (except singleton )

Has anyone coded a large scale game without design patterns ?
What's easier , make my game without them (DP) or learn them ?

Thank you

Last edited by emacrisema; 01-01-2009 at 11:49 PM..
emacrisema is offline   Reply With Quote
Old 01-02-2009, 04:14 AM   #2
yell0wdart
jordanrift.com
 
Join Date: Sep 2007
Location: Phoenix, AZ
Posts: 297
Default

During the game's initial design and coding, I think that question's answer will depend on your mindset. For you, who knows procedural code, and doesn't have much experience with OO design or agile development, procedural will be easier.

For a developer who only knows OO and thinks in design patterns, then OO will be easier to develop.

When it comes time to fix bugs or add new functionality to the game, then OO with design patterns will be FAR easier to maintain, regardless.
__________________

bad developer

Jordan Rift
yell0wdart is offline   Reply With Quote
Old 01-02-2009, 06:49 AM   #3
maskedMan
Obfuscated Coder
 
maskedMan's Avatar
 
Join Date: Apr 2008
Posts: 678
Default

Also, trying to force OOP when you're new to it can cause you confusion and headaches. For example, you have written many different classes but they are all in fact tightly coupled (they store references to each other, or they all offer static instances of themselves to be freely modified by any other member). This tight coupling negates all the benefits of separating the functionality of the classes and is more or less the equivalent of just moving code around.

Depending on your style, OOP and design patterns can sometimes seem needless. You might wonder when you'll ever use some of the things you're studying until one day it just all falls into place. Even though your first attempts can be dangerously off-base, you have to get them out of the way sooner or later, yes?

Having said this, there's value in knowing when to break the rules. But the trick is you have to know them first. Perfectly encapsulated and well-abstracted code is lovely to maintain, but the greater the amount of indirection, abstraction, and function calling you endeavor the worse your performance will become. Then of course are the situations where you're crunched for time and you just can't stop to think of the perfect way to structure your architecture. Sometimes, things need to be done 'yesterday' as it were. Those are the times when you have to be brave and just do what needs to be done.
__________________
man.mask = mask_mc;

Sigh. The AS3 version just doesn't look at nice as
'man.setMask(mask_mc);'

Last edited by maskedMan; 01-02-2009 at 06:52 AM..
maskedMan is online now   Reply With Quote
Old 01-02-2009, 08:59 AM   #4
emacrisema
worst coder ever!!!
 
Join Date: Aug 2008
Location: end of the world (botosani)
Posts: 15
Default not my mindset

Well , OOP is definitely not suited for my mindset .
I'm the most lazy and disordered person in the world .
I like simple , effective / hack solutions .
But for reusability and easy debugging it seems OO is the way.
I still don't know which way to go .
I have set my goal at about one month (about 6 hours/day) to make a proper TBS (maybe with multiplayer ).I have found another oop-dp book which seems to take more time explaining the concepts , but I guess without some STRONG examples it will vanish out of my head just like the first one .

Is it time to get real ?
http://gettingreal.37signals.com/toc.php
Or just continue reading books about some OOP concepts that will take ages to get into my blood ?

Well I think you've already answered that , but ... I don't know ... maybe someone will throw some great article with lots of code that will make me the greates actionscript programmer ever

Edit: I think a "open-source" OOP coded game (uml included) might help .Does anyone know any ?

Last edited by emacrisema; 01-02-2009 at 11:29 AM..
emacrisema is offline   Reply With Quote
Old 01-02-2009, 07:30 PM   #5
emacrisema
worst coder ever!!!
 
Join Date: Aug 2008
Location: end of the world (botosani)
Posts: 15
Default the most trashy book on OOP by FOE

I've read 150 pages of Object Oriented Actionscript (Friends of Ed) , and I got to the flex chapter .
They are actually so annoying that they show me how to click next in the flex installation setup (that coming from a book that has OOP in the title ! ! ! ! ! ! ! ) . That's worse then calling me stupid in the face . I really wonder if I should go on ?
How deep could they go into DP if they commited this "murder" ?

Also one of them says on page 84 "I do not normally use public properties in a class and instead expose private and protected properties through getter/setter methods."

There are TONS of web articles where it says clearly " too many getter/setter are the proof of bad design" .

So should I go on reding something like this ? ... I guess not ... but I'm desperate .I need to learn OOP !!!

Thank you

Edit: Wait , there's more , they teach me how to draw a sphere ! LOL
That's it ! This book might be good for my 11 years old brother ! I quit !

Last edited by emacrisema; 01-04-2009 at 10:39 AM..
emacrisema is offline   Reply With Quote
Old 01-03-2009, 04:30 PM   #6
yell0wdart
jordanrift.com
 
Join Date: Sep 2007
Location: Phoenix, AZ
Posts: 297
Default

This book was fantastic in teaching me design patterns. Might not be quite your speed, but it's a great book to get you started. The code samples are in Java, but it's close enough to AS for you to apply it w/o any issues.

The trick to learning OOP is not in a book, though. You're not going to learn it until you start doing it. I'd recommend picking a couple smaller projects you coded in the past in your procedural style and recode them with OO and design patterns in mind. Keep refactoring and implementing patterns where they seem to work well. As you keep doing it, you'll learn to think that way, and it eventually will fall into place.
__________________

bad developer

Jordan Rift

Last edited by yell0wdart; 01-03-2009 at 04:32 PM..
yell0wdart is offline   Reply With Quote
Old 01-03-2009, 05:55 PM   #7
maskedMan
Obfuscated Coder
 
maskedMan's Avatar
 
Join Date: Apr 2008
Posts: 678
Default

I get your frustration. I think a reasonably good book on the subject is "Advanced Actionscript 3 with Design Patterns". It's not too overwhelming, and even though it is by no means exhaustive it does a good job summarizing some of the most common patterns and what they are useful for.

I have (and at times like and hate) Head First Design Patterns, which is a Java book but easily applicable to AS in terms of what it teaches you. The style of the head first books is goofy and personable, but I don't think they talk down to you.

About using too many getters/setters, I think it would be useful for you to just go ahead and try it out. Go whole hog and make everything private or protected and see how you personally like it. You may find that you're suddenly thankful that you can offer access to a property via a mutable interface, or you may find it completely worthless and an unacceptable drag on performance. Only once you do it will you get a feel for why and when you should or shouldn't.

(Full disclosure time: I use get/set them all the time, but am beginning to feel compelled to use public variables in classes marked 'final' in the event that I have to use loops or otherwise iterate the structure and I know that the class has no siblings or won't likely be taking part in polymorphism. Problem is that when you do that you shoot yourself in the foot if you program to interfaces, which I am finding to be incredibly useful.)
__________________
man.mask = mask_mc;

Sigh. The AS3 version just doesn't look at nice as
'man.setMask(mask_mc);'
maskedMan is online now   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
procedural or oop ? Marcello2 ActionScript 3.0 9 11-25-2008 03:10 PM
AS3 OOP to Procedural renton79 ActionScript 3.0 1 10-05-2008 03:58 PM
how to improve the speed on scale large photos rj2house ActionScript 2.0 15 06-02-2008 01:06 PM
Large scale actionscript tutorials fjellaksel ActionScript 2.0 3 09-26-2006 02:37 AM
Centering a large external swf that can scale and print. sweetleaf ActionScript 2.0 0 09-09-2004 10:11 PM


All times are GMT. The time now is 07:16 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.