# Particle best practices

Keep SQL-callable application functions predictable, typed, testable and safe to update.

Source: https://particledb.ai/particles/best-practices/

## Keep inputs explicit

Pass the values a function needs as arguments. Prefer a deterministic transformation that returns the same result for the same inputs. Use SQL to select and join records before applying the function.

Avoid depending on invocation count or row order. External calls and side effects need their own authorization and idempotency design. See [runtime and trust](/particles/limits/).

## Use application-specific names

Choose descriptive names that do not conflict with SQL built-ins. Update callers when changing a name or signature. See [names and errors](/particles/collisions/).

## Treat types as a contract

Annotate every argument and return value. Test the SQL values your application will pass, including NULLs and boundary values. Validate supported mappings with the [Python guide](/particles/python/).

## Test both interfaces

Unit-test the ordinary function, then call the loaded function through SQL. Check returned values and errors, rather than treating successful registration as proof that the implementation works. Follow [testing](/particles/testing/).

## Plan updates and restarts

Pin the module's dependencies and use the same environment in testing and deployment. Keep a working module available for rollback. Test startup loading and a restart before depending on the function in application queries.

[Load and deploy Particles](/particles/loading/) · [Availability and limits](/reference/limits/)
