FritzAndFriends / StreamDeckToolkit

A .NET Standard library, template, and tools for building extensions to the Elgato Stream Deck
MIT License
164 stars 45 forks source link

Discussion: Directory structure pattern/recommendations #116

Open hugodahl opened 5 years ago

hugodahl commented 5 years ago

Preface

I wanted to bring this up for discussion before making any changes since the implications are quite far-reaching. I also I didn't feel it would be a wise use of time, nor would it be considerate, to start applying or imposing a pattern without community involvement.

The Issue With the Current Structure

In working through the multiple action support, and then having @codingbandit's changes integrated, it dawned on me that our current directory structure, in both the sample as well as the template, is not sustainable for a few reasons.

  1. There will be a whole lot of xxxAction.cs file in the same root directory
  2. The same situtation is likely to affect the current plugin_inspector directory
  3. There is no clean or easy way to relate, at a glance, an action with a property inspector - or even if there is one for said action (and vice-versa)
  4. Unless a naming pattern is followed, it would be difficult to relate any graphic assets to an action, and vice-versa.

Benefits of the Current Structure

There are benefits which we can take from the current structure and apply as a good example or best/recommended practice. The one which immediately comes to mind is the plugin inspectors, and how they can share common resources - *.js, *.css, *.html, and such files.

Needs

What we really need is to a) identify and prioritize potential pain points and pitfalls, b) determine which issues must be addressed through best practice examples, and which are acceptable with simple guidance provided, and c) implement the changes as agreed upon.

Issues (in no specific or ranked order)

  1. The larger the number of actions defined in a plugin, if one action is implemented in one .cs file, the root directory can get to feeling cluttered very quickly
  2. Difficulty quickly identifying which assets are related to which action(s), if any.
  3. Difficulty quickly identifying whether an action has a related property inspector, and vice versa
  4. If an action does have assets and a property inspector, is there any overlap or reuse of the assets between the action and the property inspector?
  5. How can we best structure the plugin inspectors to benefit from common sources, such as JS libraries, CSS files, etc.
  6. Should we isolate the core and base classes as well as interfaces (ConnectionManager, BaseStreamDeckAction) from the rest of the implementation of the custom actions?

Closing

I have some thoughts (and opinions) on how I envision the project being structured, which I will detail in a later comment, however, I would also like to get some feedback and comments on whether this really is an issue which should be addressed at this time (am I a gun jumping alarmist?), and so, thoughts, opinions, and feedback on possible structure.

hugodahl commented 5 years ago

The pattern that feels most obvious or natural to me at this time, is to Have a directory structures (source and deployment) along these lines:

Source Directory Layout

 +-----------------------------------------------+  
 |                                               |  
 | [Project Root]                                |  
 | +                                             |  
 | |                                             |  
 | +---+ Root files*                             |  
 | |                                             |  
 | |                                             |  
 | +---+ /Actions                                |  
 | |   |                                         |  
 | |   +--+ /MyCustomAction01                    |  
 | |   |  |                                      |  
 | |   |  +---+ [Compiled code files for Action] |  
 | |   |  |                                      |  
 | |   |  +---+ /Assets                          |  
 | |   |  |                                      |  
 | |   |  +---+ /PluginInspector                 |  
 | |   |                                         |  
 | |   |                                         |  
 | |   +---+ /MyCustomAction02                   |  
 | |   |                                         |  
 | |   |                                         |  
 | |   +---+ /MyCustomAction03                   |  
 | |   |                                         |  
 | |   |                                         |  
 | |   +---+ /MyCustomAction04                   |  
 | |                                             |  
 | |                                             |  
 | +---+ /PluginInspector                        |  
 |     |                                         |  
 |     |                                         |  
 |     +---+ [Shared PI files]                   |  
 |                                               |  
 +-----------------------------------------------+  

Deployed Directory Layout

 +--------------------------------------------------------------+
 |                                                              |
 | [Build Root]                                                 |
 | +                                                            |
 | |                                                            |
 | +----+  manifest.json                                        |
 | |                                                            |
 | +----+  Plugin.exe                                           |
 | |                                                            |
 | +----+  [other files supporting the .exe]                    |
 | |                                                            |
 | +----+  /PluginInspector                                     |
 |      |                                                       |
 |      |                                                       |
 |      +---+ [Shared PI files]                                 |
 |      |                                                       |
 |      |                                                       |
 |      +---+ Actions                                           |
 |          |                                                   |
 |          |                                                   |
 |          +---+ /MyCustomAction01                             |
 |          |   |                                               |
 |          |   +---+ [Copy of src/Actions/MyCustomAction01/PI] |
 |          |                                                   |
 |          |                                                   |
 |          |                                                   |
 |          +---+ /MyCustomAction01                             |
 |          |   |                                               |
 |          |   +---+ [Copycofrsrc/Actions/MyCustomAction02/PI] |
 |          |                                                   |
 |          |                                                   |
 |          +---+ /MyCustomAction01                             |
 |              |                                               |
 |              +---+ [Copycofrsrc/Actions/MyCustomAction03/PI] |
 |                                                              |
 +--------------------------------------------------------------+

Issue with this layout

Two notable issue with this layout is that there is additional management needed to take the Property Inspector directories from the individual actions into the deployed PluginInspector directory, and similarly with the images.