This document explains the coding standards which should be followed when developing software for our platform. Details are also given for integrating with existing software on the platform, how to package your application for our marketplace and how to test your zApp locally whilst running a lighter weight version of our platform.
|1.0||Initial version of document|
|1.1||Updated Testing section|
Table of Contents
This chapter provides the standards for developing software using ZDMP components. It is very important for the programmers to maintain the coding standards otherwise the code will be rejected during code review. Only the app code which is submitted to our Gitlab will be reviewed, if your app refers to some code outside of the Gitlab we cannot review this code.
- Coding guidelines increase the efficiency of the software and reduces the development time.
- Coding guidelines help in detecting errors in the early phases, so it helps to reduce the extra cost incurred by the software project.
- If coding guidelines are maintained properly, then the software code increases readability and understandability thus it reduces the complexity of the code.
- It reduces the hidden cost for developing the software.
- A coding standard gives a uniform appearance to the codes written by different engineers.
- It improves readability, and maintainability of the code and it reduces complexity also.
- It helps in code reuse and helps to detect error easily.
- It promotes sound programming practices and increases efficiency of the programmers.
These rules talk about which types of data that can be declared global and the data that can’t be.
- Global variables should be avoided whenever possible.
For better understanding and maintenance of the code, the header of different modules should follow some standard format and information. The header format must contain below things that is being used in various companies:
- Name of the module
- Date of module creation
- Author of the module
- Modification history
- Synopsis of the module about what the module does
- Different functions supported in the module along with their input output parameters
- Global variables accessed or modified by the module
Some of the naming conventions are given below:
- Meaningful and understandable variables name help anyone to understand the reason of using it.
- Local variables should be named using camel case lettering starting with small letter (e.g., localData) whereas Global variables names should start with a capital letter (e.g., GlobalData). Constant names should be formed using capital letters only (e.g., CONSDATA).
- It is better to avoid the use of digits in variable names.
- The names of the function should be written in camel case starting with small letters.
- The name of the function must describe the reason of using the function clearly and briefly.
Proper indentation is very important to increase the readability of the code. For making the code readable, programmers should use White spaces properly. Some of the spacing conventions are given below:
- There must be a space after giving a comma between two function arguments.
- Each nested block should be properly indented and spaced.
- Proper Indentation should be there at the beginning and at the end of each block in the program.
- All braces should start from a new line and the code following the end of braces also start from a new line.
All functions that encountering an error condition should either return a 0 or 1 for simplifying the debugging.
- On the other hand, Coding guidelines give some general suggestions regarding the coding style that to be followed for the betterment of understandability and readability of the code. Some of the coding guidelines are given below:
Code should be easily understandable. The complex code makes maintenance and debugging difficult and expensive.
Consider these two sets of code which do the same thing:
Even though the top example uses more lines of code, it is more obvious what is happening and all levels of programmers would have an easier time understanding it.
Each variable should be given a descriptive and meaningful name indicating the reason behind using it. This is not possible if an identifier is used for multiple purposes and thus it can lead to confusion to the reader. Moreover, it leads to more difficulty during future enhancements.
The code should be properly commented for understanding easily. Comments regarding the statements increase the understandability of the code.
Lengthy functions are very difficult to understand. That’s why functions should be small enough to carry out small work and lengthy functions should be broken into small ones for completing small tasks.
GOTO statement makes the program unstructured, thus it reduces the understandability of the program and also debugging becomes difficult.
One declaration is recommended per line as it encourages commenting and it does not lead to confusing code.
In a method, declare local variables just before they are needed. This overcomes this problem of a big list of parameters are the beginning of a method and also the use of each variable is clearer.
Always use brackets with these statements even when they are optional.
These principles establish practices that lend to developing software with considerations for maintaining and extending as the project grows. Adopting these practices can also contribute to avoiding code smells, refactoring code, and Agile or Adaptive software development.
SOLID stands for:
S – Single responsibility
O – Open-closed principle
L – Liskov substitution principle
I – Interface segregation principle
D – Dependency inversion principle
If you are not aware of how these work in practice, there are many examples online and I would highly suggest that you take the time to research this.
For the Authorization this is still a work in progress but as of right now, the following details are needed to gain a valid access token and interact with the API gateway.
Body with x-www-form-urlencoded / Content-Type: application/x-www-form-urlencoded
form data of:
client_id : ZDMP_API_MGMT_CLIENT
username : zdmp_api_mgmt_test_user
password : ZDMP2020!
grant_type : password
This will then return some data such as:
“scope”: “email ZDMP_Full_API_Access profile”
You can then use that token in a call such as:
Header will be – Authorization : Bearer access_token
Integrating with zApps
Here we explain our initial plans on how to integrate with other zApps within your zApp.
•Firstly, they add the dependency in the Marketplace/manifest file: that way if you install a zApp that depends on another zApp, you need to buy/install the dependency(s).
•This would require, that all zApps will be single tenant, that is, all zApps get deployed per tenant.
•The zApp will include an env variable in the questions/values file to be able to configure the dependency URL for the zApp.
•Those values will be set during deployment time by the Secure Installation
•There will probably be some naming conventions for the URL, which we are already using but not defined: appid-tenantid.platform.zdmp.eu. So zApp with zapp1 id and tenant1 URL would be zapp1-tenant1.platform.zdmp.eu.
If you have a front-end browser application then you should integrate the dash-button into your application. This adds functionality to be able to log into the system, check licensing information and also navigate to various components. There is a guide on how to integrate it here:
All code needs to be tested thoroughly before being submitted to the Marketplace. You should test on multiple browsers/environments with various versions depending on the type of application for which would make sense. You should also test that it works on Kubernetes / as part of the mini zdmp running that locally.
For testing we do not require anything specific, you should be as thorough as you like with your own testing.
We have documentation on how to convert your application from running locally to being packaged to run on Kubernetes and as part of our system:
We have some detailed documentation on how you can run the mini ZDMP locally and test your zApp with the system:
Once your zApp is ready to be sold on the marketplace we have some guidelines of how to do that which can be found here: