> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Anti-patterns

> Common LoT mistakes and proven alternatives — for authors and reviewers.

## Common LoT mistakes

These are the most frequent mistakes in LoT development. Avoid them whether you're writing new code or reviewing existing output.

| Anti-Pattern                         | Why It's Bad                                                               | Do This Instead                                                                                                                                         |
| ------------------------------------ | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Omitting type casts in math          | Implicit type handling leads to silent errors                              | Always cast: `PAYLOAD AS DOUBLE`, `GET TOPIC ... AS DOUBLE` — see [Operations](/v2.0/lot-language/actions/operations)                                   |
| Triggering models on timestamps      | Timestamps update every tick — model fires constantly                      | Trigger on the primary data field: `AS TRIGGER` on value, not timestamp — see [Schema definition](/v2.0/lot-language/models/schema-definition)          |
| Inconsistent naming across models    | `sensorID` in one model, `sensor_id` in another                            | Standardize on `snake_case` for all field names — see [Naming conventions](./naming-conventions)                                                        |
| Using Python for native LoT tasks    | Python adds overhead for simple publish/get/if operations                  | Use Python only for math libraries, ML, API calls, or complex parsing                                                                                   |
| Leaving `$SYS/#` topics unrestricted | System topics contain broker commands and sensitive data                   | Create a priority-10 Rule restricting `PublishSys` and `SubscribeSys` — see [Rules syntax](/v2.0/lot-language/rules/syntax)                             |
| Generic entity names                 | `Action1`, `Rule1`, `MyRoute` are meaningless in a system with 50 entities | Name by purpose: `MonitorPressure`, `ProtectSysTopics`, `SensorDatabase`                                                                                |
| `PUBLISH` for internal state         | Broadcasts data that only your own Actions need                            | Use `KEEP TOPIC` for internal state; `PUBLISH` for external subscribers — see [Writing reusable logic](./reusable-logic#internal-state-keep-vs-publish) |
| Monolithic Actions                   | One Action doing 15 things is hard to test and debug                       | Split into callable Actions with `INPUT`/`OUTPUT` — see [One Action, One Job](./reusable-logic#one-action-one-job)                                      |

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Naming conventions" icon="tag" href="/v2.0/lot-language/usage-patterns/naming-conventions">
    Entity, variable, and topic naming standards.
  </Card>

  <Card title="Writing reusable logic" icon="code" href="/v2.0/lot-language/usage-patterns/reusable-logic">
    Callables, wildcards, and KEEP vs PUBLISH patterns.
  </Card>
</CardGroup>
