PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
New WINDEV, WEBDEV, WINDEV Mobile 24 feature!
  • Overview
  • How to proceed?
  • Splitting existing code
  • Extract business logic
  • Options related to Business logic / GUI code splitting
  • Project description
  • Window description
  • Describing a page
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Splitting Business logic / GUI code
Overview
During the development of an application, the code that is specific to the interface and the code that is specific to the business logic (access to databases, etc) are often "mixed". Who hasn't used the click process on a button to save data in a data file and to refresh the current window?
WINDEV, WEBDEV and WINDEV Mobile help you split your code to separate business logic from GUI code.
This division has several advantages:
  • structure your code,
  • make reusing and sharing code easier,
  • simplify the webification of your application,
  • ...
Splitting your code will also allow you to use an MV or MVP development method.
WINDEV, WEBDEV and WINDEV Mobile propose to split the code gradually: you can start by splitting your code on new windows only, then on the whole project, window by window.
You can also perform this operation to structure the code of your application, or to choose and generate the classes (or sets of procedures) necessary for re-using and sharing your code.
WINDEV, WEBDEV and WINDEV Mobile provide you with the tools and you decide how to use them.
How to proceed?

Splitting existing code

To split GUI code from Business Logic in an existing code, follow these steps:
  1. Open the project in the desired product.
  2. Open the code editor (Press F2 on a button, for example).
  3. Enable Business/GUI highlighting: in the code editor, go to the "Refactoring" pane, "Business/GUI" group, expand "Display Business logic/GUI" and select the desired coloring mode:
    • No coloring
    • Coloring in line background: in this case, the coloring is applied on the entire line of code.
    • Coloring on the border: in this case, the coloring is applied only on the border of the lines of code.
    Notes:
    • Coloring applies to all projects.
    • The coloring is applied according to the following rules (light theme):
      • Lines of code related to GUI in a GUI process are colored in green.
      • Lines of code related to Business logic in a GUI process are colored in orange.
      • Lines of code related to GUI in a Business logic process are colored in orange.
      • Lines of code related to Business logic in a Business logic process are colored in blue.
    • Examples:
      Example of green and orange code
      Example of blue code
  4. Enable Business/GUI errors: in the code editor, go to the "Refactoring" pane, "Business/GUI" group, expand "Display Business logic/GUI" and click on "Enable Business/GUI errors". This button enables the Business/GUI errors for the current element (window, page, etc.) only.
    Business/GUI errors are displayed in the "Compilation errors", among the programming standard errors (identified by ).
  5. Split your code to prevent this type or error.
    • If necessary, create local (or global) procedures to split your Business logic from GUI code.
    • If necessary use the attributes <GUI> and <Business>. In a code or process containing both GUI code and Business logic, these attributes are used to indicate the use of the variable or procedure.
      Example: The procedure DisplayTrip is considered as a procedure that deals with the GUI (<GUI> attribute) even though it calls RetrieveTrip, a business procedure.
      Note: Calls to business procedures in a GUI process are enclosed by a blue border.

Extract business logic

When all code mixing errors are corrected in the project, it is possible to automatically create global classes or procedures that group all local procedures created to separate the GUI code from the Business Logic.
This operation is useful and recommended:
  • If your project is shared,
  • If your project must be webified,
  • ...
To extract the Business logic:
  1. In the code editor, go to the "Refactoring" pane in the "Business/GUI" group and click on "Extract Business logic".
  2. In the window that is displayed:
    • Select the desired type of splitting: Class or set of procedures.
    • Specify the name of the class or set of procedures.
  3. Validate.
  4. The specified element is automatically created and the code is modified to use the set of procedures or the class.
Options related to Business logic / GUI code splitting

Project description

The option " Indicate when the Business logic and GUI code are mixed" in the project description window ("Compilation" tab) makes it possible to enable or disable the Business/GUI errors on all the elements of the project.
Note: It is recommended to use this option on individual elements before using it on the entire project.

Window description

In a window description, the "Details" tab allows you to define the programming standard via "Programming standard".
In the interface for defining the programming standard, you can enable the Business/GUI errors for the current window.

Describing a page

In a page description window, the "Details" tab makes it possible to define the programming standard via "Programming standard".
In the interface for defining the programming standard, you can enable the Business/GUI errors for the current page.
Minimum required version
  • Version 24
This page is also available for…
Comments
Click [Add] to post a comment