boxlang-classes-and-ooplisted
Install: claude install-skill ortus-boxlang/skills
# BoxLang Classes and Object-Oriented Programming
## Overview
BoxLang classes are defined in `.bx` files. A class is a blueprint that encapsulates
properties (data) and functions/methods (behavior). BoxLang supports single
inheritance, multiple interface implementation, abstract classes, and static members.
## Basic Class Structure
```boxlang
// File: models/User.bx
class accessors="true" {
// Properties (auto-generates getters/setters when accessors="true")
property name="firstName" type="string"
property name="lastName" type="string"
property name="email" type="string"
property name="createdAt" type="date"
// Constructor
function init( required string firstName, required string lastName, required string email ) {
variables.firstName = arguments.firstName
variables.lastName = arguments.lastName
variables.email = arguments.email
variables.createdAt = now()
return this
}
// Method
string function getFullName() {
return "#variables.firstName# #variables.lastName#"
}
}
```
## Scopes Inside a Class
| Scope | Access | Use |
|-------|--------|-----|
| `variables` | Private | Internal state, private methods |
| `this` | Public | Public methods exposed to callers |
| `static` | Class-level | Shared across all instances |
## Instantiation
```boxlang
// Using `new`
var user = new models.User( "Ada", "Lovelace", "ada@example.com" )
// Using createObject
var user = createObj