KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Remember to type check named parameters
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: June 3, 2025

When creating a method, using an object as the parameter (instead of using multiple parameters) allows the method to handle named parameters, making it more flexible, readable, and easily refactored. Since the parameters essentially are packaged in one object, they cannot be individually type checked by #DECLARE keyword. Thus, it is important to type check each named parameter of the object. For example:

#DECLARE($employee : Object)

// check types of named parameters
ASSERT(Value type($employee.name)=Is text; "Employee name value must be text type")
ASSERT(Value type($employee.dob)=Is date; "Employee date of birth value must be date type")
ASSERT(Value type($employee.id)=Is real; "Employee ID value must be number type")

// Do stuff with name parameters...

In the above example, the method takes in an "employee" object. Each named parameter (“name”, “id”, “dob”) is type checked before doing anything with their values.