Shop OBEX P1 Docs P2 Docs Learn Events
Advantage of objects? — Parallax Forums

Advantage of objects?

FranklinFranklin Posts: 4,747
edited 2010-05-03 19:23 in Propeller 1
Is there an advantage or disadvantage·to linking an object as opposed to including the code in your main spin file? And if your code uses an object twice (in the main file and called from an object) is it loaded twice or shared between the two instances?

Thanks,

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

Comments

  • heaterheater Posts: 3,370
    edited 2010-05-03 19:23
    Technicalities aside the biggest advantage of objects is that you don't have to write them all yourself. Want a UART? Get one from OBEX. Want a FAT file system? Easy enough to find. Plus they will be improved, optimized, debugged as time goes by with out you having to do anything[noparse]:)[/noparse] (Except report bugs and requests back to the authors).

    Think of it like building circuits out of ready made chips rather than creating your own with transistors every time.

    As for you own code. It's good practice to split the functionality of your applications into independent parts. Divide an conquer. Small parts can me written and tested more easily than a huge sprawling application. Besides you may want to reuse parts of your code in future projects. If you write code like that in the first place it's easier to do.

    Finally we out here might benefit[noparse]:)[/noparse] You create generally a useful object and perhaps release it into the wild. Everyone gains.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
Sign In or Register to comment.