I am learning Ruby, and learning the SketchUp API. One thing I am struggling to grasp is the subtle differences between Classes, Methods, and Modules, and how to split up code amongst multiple files. Although I have a couple of Ruby books that I am studying, I don’t seem to be connecting with the examples they provide. I am able to fudge my way through and have successfully made my first extension, but I know the code is horribly organized. And I think there are situations where I’ve defined a class, where really I could’ve just used a method… I’m also struggling with the correct use of Constant variables, where I want to define a variable that I can use across my entire extension.
I’m curious to see if there are examples of SketchUp extensions that you’d recommend that use multiple files, so I can read the code and follow along and sort of “figure out” why it’s organized the way it is, and what is located in a separate file vs what’s included in the main file. I think the context would really help me recognize when a class is more appropriate than a method, and how granular you should get when creating classes. I’ve read a book that really drills down the idea of making each class only do ONE thing (If your class does more than one thing, they should be two classes). Just wondering what would be considered a good, clean, well organized SketchUp extension.
I am aware of the SketchUp Ruby API Tutorials and some of the simple plugin examples by the SketchUp team. But the examples are sort of wrapped up into a “parent” extension so you don’t have to install each one individually, so that confuses me a little. I am also aware of the Multi-file template by @DanRathbun, which is great, but since (of course) the template is blank, it’s hard for me to understand exactly what I should be doing with it.
So if there are any simple examples of a multi-file extension that demonstrates good Ruby practices, I would love to study them. Thank you for your help. I’m having a lot of fun with it so far. It really gets your imagination going with what you can do with SketchUp.