Application-like code structure
ChrisCantrell
Posts: 25
Forgive me if this is a newbie question. I promise, I have spent considerable time searching for the answers.
SPIN seems very good in building individual objects, but it doesn't seem to provide for large application development.
For instance, I want to isolate the filesystem code in one module and the HTTP request handling in another. Both objects need the common string-engine. It seems I have to list the "STREngine" in every object that needs it. That seems to make several copies of the code.
I encounter the same problem with the PST serial terminal. If I want to put "print(HERE)" in different modules then I have to include PST in all modules and it makes copies of the code.
Am I doing something wrong? Is there a better pattern for sharing libraries and code between modules? Am I just really, really new to SPIN?
SPIN seems very good in building individual objects, but it doesn't seem to provide for large application development.
For instance, I want to isolate the filesystem code in one module and the HTTP request handling in another. Both objects need the common string-engine. It seems I have to list the "STREngine" in every object that needs it. That seems to make several copies of the code.
I encounter the same problem with the PST serial terminal. If I want to put "print(HERE)" in different modules then I have to include PST in all modules and it makes copies of the code.
Am I doing something wrong? Is there a better pattern for sharing libraries and code between modules? Am I just really, really new to SPIN?
Comments
Let's take PST... you have PST fired up in your top level object but you're trying to debug values in a child object. Simply expose the child member through a getter. If you need a memory block, return a pointer.
I'm not sure about "STREngine" but I wrote a string parsers that spins up in a COG from the top level object and is available to any object through pointers.
http://www.agaverobotics.com/spinneret/source/
Let me try my question a different way. I have object "HTTPProcessor" written in SPIN that uses several of the string functions in "STREngine" (compare strings, strings-to-upper-case, etc). I have object "ConfigFileParser" written in SPIN that also uses the same string functions in "STREngine".
It seems that I must add "STREngine" to every object that needs the string functions. And the compiler makes a copy of "STREngine" code for each object. It would be nice to share a single copy of the string functions across all objects that use it. Maybe this is just a limitation of SPIN. But I hope I am just missing something simple and fundamental.
Thanks again for your help, Mike.
-Phil
Good luck with your project!
-Phil