Skip to content

Commit 0479ac2

Browse files
Merge pull request #10535 from mendix/nc-split-best-practices
Restructure Best Practices for Creating Connectors
2 parents e2163d5 + 6c57560 commit 0479ac2

File tree

10 files changed

+523
-484
lines changed

10 files changed

+523
-484
lines changed

content/en/docs/marketplace/create-content/create-connectors/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ To start setting up your app, open Studio Pro and do the following:
8787
3. Give your module a name fitting for the type of connector you are building.
8888
4. Create the basic folder structure at root level.
8989

90-
For more information, see the [App Setup](/appstore/creating-content/connector-guide-best-practices/#app-setup) section of *Best Practices for Building Connectors*.
90+
For more information, refer to [App Setup](/appstore/creating-content/best-practices/app-setup/).
9191

9292
### Implementing the Connector {#implement}
9393

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: "Best Practices for Creating Connectors"
3+
url: /appstore/creating-content/connector-guide-best-practices/
4+
weight: 7
5+
no_list: false
6+
description_list: true
7+
---
8+
9+
## Introduction
10+
11+
The following pages provide details and recommended best practices for building, testing, and distributing connectors.
12+
13+
## Documents in this Category
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: "App Setup"
3+
url: /appstore/creating-content/best-practices/app-setup/
4+
weight: 8
5+
---
6+
7+
## Introduction {#app-setup}
8+
9+
This section dives into best practices for setting up your app in Studio Pro. For basic instructions, refer to the [Setting Up Your App](/appstore/creating-content/connector-guide-build/#app-setup) section of *Creating Connectors*.
10+
11+
## Studio Pro Version
12+
13+
For people to use your connector, ensure that you are not only targeting end-users that have the latest version Studio Pro. Try to support the latest [LTS](/releasenotes/studio-pro/lts-mts/) version and, if possible, even older supported versions.
14+
15+
The only reason to deviate from this is when your connector requires a certain platform functionality that is only available in a newer version, or requires another module that is only available on a newer version. In that case, use that newer version as your Mendix required version.
16+
17+
## Modules in the App
18+
19+
Create a Mendix app in Studio Pro with the main connector module and a testing module. You can also add an example module showing some use cases.
20+
21+
* The main module contains all the logic needed to let your connector function in apps that import it. Give the main module the name you want to appear in apps after others import your module.
22+
* The testing module has microflows, pages, and Java code to test your module's functionality. This means that you will not have to add the test logic to the module that you will later export and publish.
23+
* You can publish the example module next to the connector main module and testing module to help end-users better understand the implementation of your connector module, or to try it out without having to do too much configuration from the start.
24+
25+
### Setting Up the Main Connector Module {#main-setup}
26+
27+
Mendix recommends that the main module for your connector include the following:
28+
29+
* **_Docs** (folder) – Contains documentation or a reference to documentation, and a version indicator.
30+
* **ReadMe** (snippet) – Used to give a reference to documentation and/or some direct documentation on how to use the module.
31+
* **[ModuleName]_[Version]** (string constant) – Replace [ModuleName] with the name of your module, and [Version] with the version of the module. Use the same standard as the Mendix Marketplace 1.2.3. Refer to the [Versioning](/appstore/creating-content/best-practices/releasing-versioning/#versioning) section in *Releasing and Versioning*.
32+
* As an alternative to the version constant, you can include a subfolder with the version indication.
33+
* **Private** (folder) – This folder contains all the logic that other developers should not touch when implementing your module.
34+
* **UseMe** (folder) – Contains everything the implementing developer could use to implement your module in their application. It can include subfolders for **Microflows**, **Pages**, **Snippets**, **Templates**, and **Constants**.
35+
36+
Your **App Explorer** should look like this after the initial setup:
37+
38+
{{< figure src="/attachments/appstore/create-content/create-connectors/connector-guide-best-practices/app-initial-setup.png" class="no-border" >}}
39+
40+
{{% alert color="info" %}}
41+
This app folder structure example is based on the **Blank Web App** starter app, and contains Mendix Marketplace modules that your app might not have. The important Marketplace module that is shown is the [Unit Testing](/appstore/modules/unit-testing/) module for testing purposes.
42+
{{% /alert %}}
43+
44+
### Setting Up the App Root {#root-setup}
45+
46+
Mendix recommends adding additional folders to the root of your app, on disk. These include the following:
47+
48+
* **DIST** – This contains the releases of your module kept for reference.
49+
* **MarketplaceResources** – This contains all the assets used in the Mendix Marketplace, such as screenshots, videos, and reference documents. It does not contain the release packages.
50+
51+
The app root of your **App Explorer** should look like this after root setup:
52+
53+
{{< figure src="/attachments/appstore/create-content/create-connectors/connector-guide-best-practices/app-post-setup.png" class="no-border" >}}
54+
55+
### Importing Dependency Modules
56+
57+
Use as few dependency modules as possible. When you must use one, make sure it is either platform supported or, if you are creating a company-only connector, maintained by your own company. This ensure that users are are always supported. Otherwise, you might end up having to maintain those public non-platform supported modules to ensure that your connector operates properly.
58+
59+
## Adding the App to Version Control
60+
61+
If you have not already added your app, add it to the [Team Server](/refguide/version-control/#team-server). An alternative solution that Mendix recommends is having a separate public Git repository next to your private Team Server Git repository. This way, you can continue committing and applying changes while you only push to the public repository for a new release to the Marketplace. The automated integration with GitHub from the Marketplace makes this a good option for your public-facing Git repository.
62+
63+
## Working with Java-Intensive Apps
64+
65+
For Java-intensive apps, consider creating an **Implementation** submodule to keep core implementation separate. You can also make the module a Gradle project in order to better manage dependencies and the release pipeline. Create the *gradle.build* file to manage Java library dependencies and the cleanup of the **userlib** folder for export. For further information, refer to [Extending App Setup for Building Connectors with Java](/appstore/creating-content/best-practices/development/#extend-app-java) in *Development*.
66+
67+
## Licensing
68+
69+
Follow your Java Libraries and default to Mendix EULA. Also, Mendix recommends that you do not use copy-left licenses for commercially available connectors.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
title: "Configuration"
3+
url: /appstore/creating-content/best-practices/configuration/
4+
weight: 10
5+
---
6+
7+
## Introduction
8+
9+
You should set up your configuration in such a way as to ensure that your connector can be used in different settings without changes to the module itself. This means that upon deployment or after deployment your connector can be configured to connect to the relevant services.
10+
11+
Using constants is the way to deal with configuration that aligns with the [Twelve-Factor Architecture](https://www.mendix.com/evaluation-guide/enterprise-capabilities/twelve-factor-architecture/) cloud-native approach.
12+
13+
## Simple Configuration
14+
15+
When you are looking for a simple configuration, such as a URL, username, or password, you can use [constants](/refguide/constants/). Constants are ideal for simple flat configurations.
16+
17+
### Simple Configuration with a Free App Environment
18+
19+
When using constants in combination with a Free App, you can use the settings profile to allow for different configurations. Follow these steps to do that:
20+
21+
1. Create a constant.
22+
23+
{{< figure src="/attachments/appstore/create-content/create-connectors/connector-guide-best-practices/simple-config-constant.png">}}
24+
25+
2. Set the value of the constant to the value you want to use in your free cloud node.
26+
27+
{{< figure src="/attachments/appstore/create-content/create-connectors/connector-guide-best-practices/simple-config-value.png" >}}
28+
29+
3. Open your application **Settings**.
30+
31+
4. Click **Duplicate** or **New** to create a new configuration for your local usage.
32+
33+
{{< figure src="/attachments/appstore/create-content/create-connectors/connector-guide-best-practices/simple-config-settings.png">}}
34+
35+
5. In your configuration, open the **Constants** tab and click **New**.
36+
37+
{{< figure src="/attachments/appstore/create-content/create-connectors/connector-guide-best-practices/simple-config-new-constants.png">}}
38+
39+
6. Look up and select your constant.
40+
41+
{{< figure src="/attachments/appstore/create-content/create-connectors/connector-guide-best-practices/simple-config-select-constant.png">}}
42+
43+
7. Change the configuration value of your constant to the value you want to use in your local environment.
44+
45+
{{< figure src="/attachments/appstore/create-content/create-connectors/connector-guide-best-practices/simple-config-change-value.png">}}
46+
47+
8. Save the configuration and publish the application to your free node. When you run locally, Studio Pro will now use the **Active** configuration, while the free cloud node will keep using the value you specified in the **App Explorer**.
48+
49+
## Complex Configuration
50+
51+
You might need a more sophisticated configuration to connect to external systems, either because you will need to have dozens of constants or you want to be able to connect to multiple endpoints without having to replicate your constants each time. You will have to maintain these through configuration tables.
52+
53+
### Disadvantages of Complex Configuration
54+
55+
The following are the disadvantages of complex configuration:
56+
57+
* Configuration in the database or the codebase makes it difficult to deploy your connector/app to any new environment.
58+
* Manual configuration could cause more mistakes.
59+
* Restoring a database to a different environment when the configuration is stored in the database could cause unwanted behavior.
60+
* One big risk of using the database to store configuration is test data going out to production users.
61+
62+
### Advantages of Complex Configuration
63+
64+
The following are the advantages of complex configuration:
65+
66+
* It provides more complexity than constants.
67+
* You can easily perform runtime changes on the configuration.
68+
* You can add wizards/helper flows to guide the user with the configuration.
69+
70+
### Setting Up Complex Configuration
71+
72+
Follow these steps to set up complex configuration:
73+
74+
1. Set up a **Configuration** entity.
75+
76+
{{< figure src="/attachments/appstore/create-content/create-connectors/connector-guide-best-practices/complex-config-entity.png">}}
77+
78+
2. Create the microflow.
79+
Have a single microflow called **DS_GetOrCreateSettings**. It will retrieve your settings from the database, and create it with appropriate default values if it does not exist.
80+
81+
{{< figure src="/attachments/appstore/create-content/create-connectors/connector-guide-best-practices/complex-config-create-microflow.png">}}
82+
83+
3. Set up security on the entity and the microflow.
84+
85+
{{< figure src="/attachments/appstore/create-content/create-connectors/connector-guide-best-practices/complex-config-security.png" >}}
86+
87+
{{< figure src="/attachments/appstore/create-content/create-connectors/connector-guide-best-practices/complex-config-security-2.png" >}}
88+
89+
4. Set up the administrator page.
90+
Have an administration page to manage the configuration. For maximum reusability, have all configuration settings available in a single snippet so your consumer can combine all admin sections from all components into a single area in their application.
91+
92+
5. Encrypt the password and other sensitive information.
93+
94+
#### Further Considerations
95+
96+
When possible, create a microflow to set up the default or starting configuration for your consumers.
97+
98+
Consider adding logic so the configuration can easily be set up from your codebase.
99+
100+
If possible, add an export/import option for the configuration to safely move the configuration between environments. This could be achieved via a JSON export/import of the configuration data.

0 commit comments

Comments
 (0)