Shop OBEX P1 Docs P2 Docs Learn Events
Spin Object Design Patterns — Parallax Forums

Spin Object Design Patterns

mre_robmre_rob Posts: 31
edited 2007-05-17 17:23 in Propeller 1
Hello All,
Has anyone put together a white paper or such that would document a proven design pattern for developing Spin objects? It might be helpful to get noobs (such as myself) on the right track out of the box. I'm stumbling right now due to my lack of seeing how to do what when and where things should go.

I really like Matteo's memory map implementation as I find it easy to understand and it makes alot of sense to organize data in that way.

I also like the overall idea of having objects organized at a functional level and extending the "base" class for specific implementation.

I like the idea of making sure that you have the proper stack allocation by including the stack length during development time.

but aside from collecting everyone's spin code and reviewing it, I have found it tough to get a handle on a good method for developing my objects.

Would it be possible to start a community based discussion on the basics of how to design an object in Spin? I am sure that it would be helpful to all.

Thoughts?

Thanks,
Rob.

Comments

  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-05-17 11:56
    Objects in spin are really just collections of functions some of the functions will run in the main cog and some will be loaded into another cog with a coginit. That's all there is to it, its not really object orientated like C++ for example.

    Graham
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-05-17 16:32
    Rob you need to throw out all of your previous understanding of object oriented language, practically none of it applies with Spin. Pretty much the only thing that is the same is the concept of encapsulation.· (no control over memory, no inherency, and no stack allocation for the first Spin thread)·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 5/17/2007 5:21:41 PM GMT
  • mre_robmre_rob Posts: 31
    edited 2007-05-17 17:19
    Paul Baker (Parallax) said...
    Rob you need to throw out all of your previous understanding of object oriented language, practically none of it applies with Spin. Pretty much the only thing that is the same is the concept of encapsulation.

    ·Thanks... will do...
  • M. K. BorriM. K. Borri Posts: 279
    edited 2007-05-17 17:23
    What I ended up doing (so I knew what I was doing stack-wise) was coginit 0 the actual main function with a specified stack, after a few lines of initialization. Probably ugly, but this let me use the stack debugger to see what I was doing [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://forums.parallax.com/showthread.php?p=650217

    meow, i have my own topic now? (sorta)
Sign In or Register to comment.