Page 3 of 3 FirstFirst 123
Results 21 to 21 of 21

Thread: Procedural v.s Object oriented programming?

  1. #21
    Quote Originally Posted by chronozphere View Post
    I'm especially interested in how inheritance is done with procedural programming.
    An example:
    Code:
    TYPE
      TClassA = RECORD
        PropA: INTEGER;
      END;
    
      TClassB = RECORD
        Parent: TClassA;
        PropB: INTEGER;
      END;
    Assuming INTEGER as 32 bit, both records have the "same" first 32 bit, so you can do something like this:

    Code:
    VAR
      TheObject: TClassB;
      OtherInstance: ^TClassA;
    BEGIN
      OtherInstance := POINTER (@TheObject);
      OtherInstance^.PropA := 1;
      WriteLn (TheObject.Parent.PropA);
    END;
    Add procedures and funcitions to the equation and here you have the beggining.

    Quote Originally Posted by chronozphere View Post
    (...) For example, if you heavily rely on complex things like polymorphism, generics or operator overloading, it will be very hard to understand what's going on.
    That's why I never use generics nor operator overloading. When I programmed C++ I had lots of problems with that. Sepcially with operator overloading, because a lot of times the compiler selected the wrong one doing weird conversions and returning bad data. The worst is that data is "valid" so it's hard to find where the problem is.

    BTW, I think most people don't use it correctly. It seems as they're using it because it's cool or because everybody uses it, but I'm not sure if they're really think about if it's really useful or helps to the development.
    Last edited by Ñuño Martínez; 08-10-2010 at 09:08 AM.
    No signature provided yet.

Page 3 of 3 FirstFirst 123

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
  •