[OpenSCAD] Piping and easily readable (and maintainable) module code in OpenSCAD

benjaminwand benjamin.wand at web.de
Wed Sep 26 06:45:08 EDT 2018


Hi,

this is a question about coding style. (I’m new to functional programming.)
 
I prefer to write in small enough pieces/functionality that I can already
understand it before the first coffee in the morning. In OpenSCAD I use this
pattern:

* variables 
* stuff that gets calculated from them (so I don’t need to repeat same
things in the code many times) 
* functions and modules (that can be located in other files as well,
depending on how much maintenance and space they take)
* the ‘logic’ of the actual item that gets made, where I try to have not
more than three indentations.

For individual objects that works well but now I’m trying to make more
complex modules and there seems to be a piping problem, informations don’t
always go through all the elements that a module-to-be is made of. 
What are the things I need to know about OpenSCAD if I don’t want to write
in two-pages-functions-of-horror but in smaller, easier to maintain parts,
especially when writing modules? Is there a guide or discussion about coding
style in OpenSCAD anywhere?

As an example, these two files makes the same thing. As small-parts-code:
https://github.com/benjaminwand/OpenSCAD-loft-module/blob/master/two%20layers/two%20layers%20example.scad

and as working module: 
https://github.com/benjaminwand/OpenSCAD-loft-module/blob/master/two%20layers/two%20layers%20module.scad

Thanks for the help! 
Yes, if the answer is “read xyz book”, I would consider that helpful.



--
Sent from: http://forum.openscad.org/



More information about the Discuss mailing list