Best Practice for Organizing a Project

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
azeiler
Posts: 12
Last visit: Thu Jan 20, 2022 4:44 pm

Best Practice for Organizing a Project

Post by azeiler »

Product, version and build: Powershell Studio 2019 version 5.6.160
32 or 64 bit version of product: 64 bit
Operating system: Windows Server 2016 Standard
32 or 64 bit OS: 64 bit

********************************************************************************************************
I'm looking for general guidance on how best to organize a Powershell project. Does anyone know of an article or other resource that explains best practice?

I'm working on a Form Project, and currently have pretty much everything (Classes, Import Functions, Export Functions, Processing Functions, Form Event functions) in the MainForm file. I do currently have one function that is something I use a lot in Globals.

I've used Regions to try and organize things in the MainForm, but I'm wondering what the best practice here is? What should go in Globals? Should I separate my classes into a separate file? Different types of functions? Etc.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Best Practice for Organizing a Project

Post by davidc »

We don't have any best practices guidelines but writing a project management blog article is on my to do list.

The organization of the files is pretty much up to you. You can choose to separate all your functions into individual files or keep them with in a single file.
When it comes to community module projects, I often see a single function per file scheme. The beauty of PowerShell Studio, it that it can merge all the project files into a single script, which gives you the best of both worlds: The benefit of separating out functionality when developing the script and at the same time retain the benefit of distributing a single script or packaged execute without relying on secondary script files.

Limitations:

- Form event blocks must be contained in the same psf file. Class and functions can be place in separate files.
- If one class depends on another, I recommend keeping them is the same file otherwise PowerShell's syntax check will complain about missing types.

How to separate files:
If you wish to create individual files like Global.ps1 file, then set the following properties for each project file:

Code: Select all

Build = Include
Shared= True
Setting Shared to True, tells PowerShell Studio to merge the file as is, instead of creating a wrapper invoke function.


Related Links:

Passing parameters to project files:
https://info.sapien.com/index.php/guis/ ... sing-forms


Note: The Call verb was replaced with Show and Invoke verbs. Command Extension was replace with the Shared property:
https://www.sapien.com/blog/2016/11/15/ ... -v5-3-130/


Build Order is covered in this service release article:
https://www.sapien.com/blog/2018/08/14/ ... e-support/


Project File Synchronization:
https://www.sapien.com/blog/2017/07/20/ ... -v5-4-142/
David
SAPIEN Technologies, Inc.
azeiler
Posts: 12
Last visit: Thu Jan 20, 2022 4:44 pm

Re: Best Practice for Organizing a Project

Post by azeiler »

Thanks David, that is helpful. I'll be looking forward to your blog post if/when you get to it!
This topic is 4 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.