Netherlands
Joined: Apr 8, 2022
Post Count: 1554
Status:
Offline
Re: Wirings plugin
@Daniels118
Daniele, I haven't looked at the source code of the Wirings and Pan3Dview plugins but I suspect that the dependency of the Wirings plugin on the Pan3Dview plugin is because there are one or more functions in it that the Wirings plugin needs. A good reason to avoid double code and maintenance.
The usual way in programming is to use a library for shared functions, This avoids double code and double maintenance. A plugin references that library and can use all functions it contains: a single function library that can be used by multiple plugins. It is not unusual that function libraries are big and the actual program that uses it is small. It also promotes 'good programming' because you will automatically (have to) program the functions in the library in a way that they are generic for common use. It looks like you are using the Pan3Dview plugin as a "library" for the Wirings plugin. If that is indeed what happens then I suggest that you move all generic functions into a library and have both plugins reference that library.
I primarily program in C# and I have created multiple libraries that I can use for new programs. Over time creating new programs becomes easier and easier because a lot of work is already done in the libraries. And the good thing is: you can reference a hundred custom libraires and if your plugin only uses a single function from one of them only that function is loaded in memory, and only if it is actually called. It's called Dynamic Loading and I'm pretty sure Java does the same as C#. Another tip when using libraries: in your plugin you can inherit an object from the library and extend it for that plugin only. Something to think about when you design objects for your library.
If there is another reason for the dependency, I am very interested to hear what it is.
Keet
---------------------------------------- Dodecagon.nl 1300+ 3D models, manuals, and projects
Italy
Joined: Nov 17, 2021
Post Count: 481
Status:
Offline
Re: Wirings plugin
Hi @Keet, I'm aware of the concept of shared libraries, the reason for this dependency is different. Both plugins Wirings and 3D dimension lines (and perhaps more in the future) let the user interact directly with the 3D view. SH3D has no public API to do this. This functionality is provided by Pan 3D view plugin, which exposes an extension API to interact with the 3D view. The implementation of this API MUST be "installed" just ONCE, and I've choosen Pan 3D view as provider because it has been the first plugin to tweak the 3D view, so it was the natural choice. Moreover it is a general purpose plugin, and it makes sense to use it as a base for other plugins which need this functionality.
As a side note, the jar files that you put in the plugins directory are insulated from each other by the means of different class loaders, so they have no way to share code. The Pan 3D view plugin exposes a simple API which hides a complex communication mechanism under the hood.
Netherlands
Joined: Apr 8, 2022
Post Count: 1554
Status:
Offline
Re: Wirings plugin
Thank you for that explanation, it makes sense. I didn't know that the jar libraries in the plugin directory couldn't be shared, strange. I can do that easily with C#.
I think I would have made a different choice: a "headless plugin" with the extensions for 3Dview interaction and install that together with any plugin that requires it. If it's already there it will just be overwritten/ignored keeping it a single install. The difference with a regular library is obvious: a plugin is loaded by Sweet Home 3D, a custom library by the plugin. I wonder if there's another way around it.
---------------------------------------- Dodecagon.nl 1300+ 3D models, manuals, and projects
Italy
Joined: Nov 17, 2021
Post Count: 481
Status:
Offline
Re: Wirings plugin
Well, I prefer to keep things simpler for the user, a single file for each plugin, without hidden files. Easy to install/uninstall as any other plugin.
Keep in mind that using these plugins without the ability to pan the 3D view is a nightmare. Of course I could embed the core function in each plugin and let the first one to load to install it, but then there would be the risk that the core lib used isn't the last version. Keeping the core separated helps managing the updates easily.
Netherlands
Joined: Apr 8, 2022
Post Count: 1554
Status:
Offline
Re: Wirings plugin
You are right that the other plugins not only rely on the core code but also on the actual functionality of the Pan3Dview plugin. Seeing it in that light I can understand your choice and I think it's a good choice. Never mind that a software architect will disagree, they don't always recognize the user side of the software
---------------------------------------- Dodecagon.nl 1300+ 3D models, manuals, and projects