Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Page 3 of 3 FirstFirst 123
Results 31 to 42 of 42

Thread: OOP vs Procedural

  1. #31
    Quote Originally Posted by thedark_master View Post
    So I use OOP when I am creating all of my projects. There is one thing that I have always wondered about, which is better to have all of your code in a single .as file or split each class in its own .as file? What are the positives and negatives of both and which would you guys recommend?
    A class should have its own file. That is best practise and will also help to find things faster (you don't have to scroll to find a class).

    I wouldn't consider it be true OOP because with one big file there would be no reusablility of classes.

    Private helper classes may be an exeption of this.

  2. #32
    Quote Originally Posted by _kp View Post
    A class should have its own file. That is best practise and will also help to find things faster (you don't have to scroll to find a class).

    I wouldn't consider it be true OOP because with one big file there would be no reusablility of classes.

    Private helper classes may be an exeption of this.
    Thanks for the advise, I will make a file for class from now on.

  3. #33
    So I started transforming my code to true OOP where each class is in its own .as but have ran into a problem. There is a variable that is passed from the main function to the class which I did. But now I need to pass it back from the class to the main function. How do I do that?

  4. #34
    TheCanadian's Avatar
    10,305
    posts
    Noo doot aboot it, eh?
    If you have classes that are just used by one class and aren't really reusable, I'd just use a private class in the same file.
    Proud Montanadian
    We tolerate living and breathing. And niches.

    Name Brand Watches

    Maybe getTimer() or TweenMax is the answer to your problem . . .

  5. #35
    Well here is what I am doing. So I have my main document for a game. In the game the character can walk around and interact with characters in the game. When he interacts with a character, a conversation pops up. The content of the conversation changes depending on which character he interacts with. So before I just had it in the same file, but I am trying to learn how to do things with OOP. So now I am trying to create a class for this conversation function.

  6. #36
    I figure out how to interact with the variables from the main classes in the other classes. I just have to declera it as public in the main document and then call it in the class like this:

    MovieClip(parent).variable

  7. #37
    Dunno if it has been posted already, but here it goes.

    Good OOP = Reusable code = Cool.

    I guess you could reuse good procedural code, but not without copy pasting.

  8. #38
    I think the most important aspect of OOP is that it encapsulates the variables, functions and make it clear about its scope (public, protected, private).

    To pass any variable back from an object to another, use getter:

    PHP Code:
    //variables
    private var velocity:Vector2 = new Vector2(5050);
    //...more code above
    public function getVelocity():Vector2{
         return 
    velocity;
    }
    //...more code below 

  9. #39
    hi thank you for information about oop vs procedual.

  10. #40
    I am totally agree with you. It's all about your interest, how much you take. But OOP is the best to get on...good luck
    Get an Instant Drupal solution for all your Web Development work done at the earliest. http://www.neerjasoftwares.com

  11. #41
    I think OOP is good option.

  12. #42
    Well, I can't say much, I work on a daily basis with 100% OOP code (yay for C#)

    but it seems to be leaning twoard the preferred method of programming, I think its easier, I like it much more than procedural personally

Page 3 of 3 FirstFirst 123

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012