4D v11 Components

Components:
Tony Ringsmuth

Why use Components:
- Consistency of reused code. Exact same code between several projects.
- Saves tme: create once, deploy many times
- more bug free
- Opportunity to sell tools

Developers have created lots of developer tool components
- Tn counted 61 components developed internally by 4D.

Demo of the “yes/no/Cancel” component.
- very basic alert dialog that can be called from a hot database.




Terminology:
Matrix Database:
Host Database:
Component:

Partitioned and Shared:
How the component interacts with the host database. “Partitioned” means that the component and host cannot access the objects of the other database.

Project Form:
Component forms must be in the Project Area of the database in order to be used in a component.

Public/Private/Protected method property:

Pasted Graphic

- If the component is compiled, the host database can just see the name of he method. (not the comments)
- If the “Shared by Components and host database” checkbox is not set, the method is not visible or accessible to the host database.
- Forms in the component can’t be directly accessed from the Host. A method in the component needs to open the form.
- Partitioned Variables: All vars are partitioned, regardless of scope.
- No tables in a component database. The methods of the component database will only “see” the tables of the host database. You shold write a script to build the tables it needs in the host database.

Creating a Matrix Database:
- When referencing forms, exclude the table name. this will allow the host to load the component’s forms.?-
- The component database must e in the same Unicode mode as the host database. You can distribute one version of the component with Unicode turned off and one version of the component with nicode turned On, then the user can choose which one to use. (Set Database Parameter(34;0)) will reset the Unicode checkbox to Off.

Tony has built some callback mtods into his forms that allow the host database to insert methods into the event lop of the component. Using object names, the host database can modify the lok & feel of the coponent’s form. The Component executes the eturned method name from the host using the execute command.

Best Pratices:
Include lotsof error checking in the component:
- Parameter count
- Pointer types
- Range checking
- Configurable error handlers (Alert, Log file, Email, etc.)

Distribute a companion 4D Object Library that lines up with the component methods.

Distribute an example host database containing examples of how to use the component.