Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Procedural v.s Object oriented programming?

  1. #1

    Procedural v.s Object oriented programming?

    Hey Everyone,

    I have taught myself, during previous years, how to write proper Object Oriented code. However, I've noticed that there are still a lot of programmers who prefer the old procedural style. Personally, I can't imagine how to structure my program without using classes/inheritance/visibility and other OOP techniques.
    So I was wondering, how do you feel about this? OOP or procedural? Can someone explain to me how to write big programs without creating any classes?

    Chronoz
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  2. #2
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Now this is totally honest from me, (i'm not that good a programmer and maybe that's why) but:

    a) you can create classes in pascal? I never went past record in datatypes.
    b) OOP?? I just use functions and procedures inside units.
    c) structure, depends on what I'm doing. But usually, Its simply based on the units I'd made previously.

    But as far as I know OOP is better than procedural so why would you want to revert?

    cheers,
    code_glitch

    PS. How do you make a class in pascal??

  3. #3
    Yes, you can create classes in pascal and use all the features that Object orientation has to offer. (Delphi and free-pascal are both "Object pascal" compilers which support OOP)

    But as far as I know OOP is better than procedural so why would you want to revert?
    Well, many people say that it's better, but we can put some question marks there. There are still cases where the procedural approach is better than the OOP approach. There is actually no such thing as "better". Most people prefer OOP nowedays. And no, I don't want to revert. I simply would like to know how to use procedural programming for a big project, without getting lost.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  4. #4
    I like procedural style more than OOP(I use it only with C++ at work), and I can't explain exactly why I like it more... maybe because of love to OpenGL and system programming

    Can someone explain to me how to write big programs without creating any classes?
    Hmm... structures, good architecture and there is no problems with it

  5. #5
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    OOP has always been my choice but not the whole drag and drop thing. although I use lazarus rarely do I use the Vcl I prefer to start with my own base class and go from there. trying to follow your way back through the many class inheritances is some what of a pain. that and most of whats there is no use to me. The other thing that is important to me is having scripting built into the class which is why I use my own base class. it has scripting built into the base so every class that desends from it will naturally inherit this. whether I need to dump the contents of a single object or an entire tree it is always there and I am in control. with a single import I and pull in a very complex scene without the need to hard code it. each object can literally contain its own language that exists only as long as the object exists. scripts can run locally from within the object or globally from the top of the tree. it would be difficult to pull that off procedurally.

  6. #6
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    Well if you wanted to take a step back in time and make a non-OOP [Standard] Pascal program, don't declare any classes or lists. Instead use records and arrays alone. This had proved memory intensive for large arrays of records so you could instead allocate a raw chunk, or chunks of memory and then count your data as you go along, this however is instruction intensive, but you have to weigh the benefits of the one to fit the needs of the other. Starting to see one of the reasons why the object oriented approach to allocating 'objects' was something of a breakthrough?

    Also instead of having a triggered reoccurring method (a nono in the pre-OOP world) where your application would cycle, you'll have to keep your code executing inside of a single repeating loop. This means of structuring is still useful today, though it will negate the ability to use multi-threading, a now mainstay in most desktop or laptop computing. Probably not something a super-3D engine would want, but for some smaller and more independent scale games, this works just fine too.

    OOP is great and it adds all kinds of benefits, --such as more organized code, more optimized memory allocation and multi-threading-- however it is still possible to over-objectify all your project code and add more work to what should be a small or quick and dirty game project. As programmers we're allowed to cheat a little to get the job done, like my old highschool CS teacher used to say "programmers are lazy, so we should always try to do things in a way so that we can be lazy." It's a weird way of putting it, but the idea behind it was to code to make your job easier not harder. At least I sure hope that was his message.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  7. #7
    I like procedural more than OOP, in FARC in only use OOP for only one system which is used only in the first part of the game and useless after, it's better to free it.
    I'll use it also for production caculations threads.
    But apart that, it's mainly records/procedures/functions formatted following strict rules.

  8. #8
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    And I still don't know what I code in... Don't really want to know either since half the time it's a mess.

    Apart from that, I have written some programs with only procedure, but I would recommend against it for your own moral sanity. In my experience, I would agree with farcodev:
    it's mainly records/procedures/function
    and that would be as far as my vocabulary goes, and seems sufficient.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  9. #9

    re

    I think i use OOP where it belong, I mean mostly when writing libs for been used for me or others programmers, when i want complicated things be translated to be used in an easier way; and where instancing that piece of code has sense.

    I still use plain Procedures & functions with Var parameters and simple Records in my programs when they are just more that enough to implememt somthing;

    I have seen people create class just becouse they can, but not becouse it is necesary; i have seen classes which are too short that with one simple records and 2 or 3 simple procedures should have been enough.

    the other day i was reading a game programming book for C++ where the autor difined into a class the matrix and vectors maths; so he like to use things like mymathlib.vectoradd(v1,v2);

  10. #10
    i've seen some big projects using procedural programming like Blender and Quack .. , personally i like procedural in C/C++ ,and OOP in delphi

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

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