No announcement yet.

Object Orient Programming build-in in all versions of PB

  • Filter
  • Time
  • Show
Clear All
new posts

  • Object Orient Programming build-in in all versions of PB

    Hello Support en PB staff

    OOP have the most avantages then structerd programming:
    - create new classes and components
    - re-use code
    - polyformisme
    - constructors and destructors
    - objects
    - in very good for more complexed applications building
    - data-abstraction
    - encapsulation
    - inheritance
    - dynamic binding
    - event programming
    - etc

    think about it


  • #2
    Actually, OOP is more of a design decision and coding style than actual language constructs. OOP constructs are merely syntactic sugar that do make life easier. However, it is very possible to program using object-oriented techniques in PB. I agree that PB needs OOP constructs. They would sure make life easier. But there's nothing stopping you from using objects now.

    A UDT is actually a primitive (as in very simple) object. Using a UDT it's very possible to create basic, static OOP constructs. One method is to have the first parameter of a function or sub be a reference to a variable of that type. This makes a simple member function.

    Inheritence virtualism, and polymorphism are all possible, but they are quite difficult, given PB's weak pointer facilities (IMHO; no casting is the main problem. Another is that calling functions by pointer requires all params to be byref). But there are workarounds. In reality, the code generated by a C++ compiler is simply static, non-OO machine code that merely simulates OO behavior. (That's a little simplistic, I'll admit)

    After saying all this, I agree, PB really does need OOP stuff sooner or later.

    With regards to event programming, that is a function of the OS, mainly. Under Windows, PB is event-driven, in that that's simply how windows works. Unless you're programming for a specific library or framework, DOS simply is not event-driven.

    Anyway, it's worth some serious thought.