Avoiding Union (use a module instead)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Avoiding Union (use a module instead)

OpenSCAD mailing list-2
I often find myself thinking about OpenSCAD best practises and programming best practises, and one idea I've been thinking about recently is whenever there's a situation where I'd use union I instead use it as a reminder to instead make it a module as an opportunity to name and describe what that bit of code is doing.

I think OpenSCAD should be made up of lots of small modules in the same way that small functions is a best practise for programming.

Thoughts?

Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Avoiding Union (use a module instead)

jon_bondy

Many minor union()s are of obscure parts that would be incredibly difficult to name as a module().  I use module()s when I can name them easily and clearly.  The remaining code is commented but not named as a module().

On 3/28/2021 4:24 PM, irevdev via Discuss wrote:
I often find myself thinking about OpenSCAD best practises and programming best practises, and one idea I've been thinking about recently is whenever there's a situation where I'd use union I instead use it as a reminder to instead make it a module as an opportunity to name and describe what that bit of code is doing.

I think OpenSCAD should be made up of lots of small modules in the same way that small functions is a best practise for programming.

Thoughts?

Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Avoiding Union (use a module instead)

OpenSCAD mailing list-2
To push back, the fact that they are obscure is all the more reason to name them, because they'll be difficult to figure out what they do, if you come back to the code in a couple months.

Yes it can be difficult but it like that expression "there are only two difficult things in programming, recursion and naming things". Difficult but worth doing if you want to make the code more readable. There's nothing wrong with long descriptive names.

Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]