Coding guidelines
These guidelines are defaults for Thinkwise + SQL Server projects. Follow them unless you have a clear reason not to — and document exceptions.
Principles
Section titled “Principles”- One rule, one home: avoid duplicating the same rule in multiple concepts.
- Keep concepts thin: UI concepts call into reusable logic instead of embedding business rules.
- Prefer clear models over clever code: the model should express the concept unambiguously.
- Optimize for change: strong defaults beat one-off exceptions.
Where logic lives
Section titled “Where logic lives”| Need | Prefer | Avoid |
|---|---|---|
| Reusable value / label / status | Function (scalar or inlineable) | Copy-paste expressions |
| Reusable base query | Inline table-valued function (TVF) or view | Repeating joins across views |
| Side effects (insert/update/send) | Procedure | Hiding writes in views |
| UI-only behavior | Layouts, actions, report templates | Business rules in UI |
| Guardrails | Validations, constraints, prefilters | “Magic” behavior without rules |
Reuse and separation
Section titled “Reuse and separation”- If you’re copy-pasting logic, extract it. Use Reusable functions and views as the default pattern.
- Prefer composing multiple small functions over building one mega-function.
- Keep integrations and side effects explicit (procedures), and keep reads composable (views/TVFs).
SQL style
Section titled “SQL style”- Use lowercase SQL keywords.
- Prefer leading commas in multi-line
selectlists. - Avoid
select *; list columns explicitly. - Avoid magic numbers; use lookup tables/domains and named values.
- Use
--comments to explain why, not what.
select
c.customer_id
, c.name
, dbo.fn_customer_status(c.status_code) as status
from customer c
where c.active = 1Safety checklist
Section titled “Safety checklist”- Run impact analysis before changing shared functions/procedures.
- Keep deployments safe to re-apply (idempotent where possible).
- Integrate early; validate core flows with real-ish data.
- For performance-sensitive changes, check the execution plan in context (views/reports).
External references
Section titled “External references”- Thinkwise: Concepts — https://docs.thinkwisesoftware.com/docs/sf/business_logic
- Thinkwise: SQL coding guidelines — https://docs.thinkwisesoftware.com/docs/sf/guidelines_sql_coding
- Thinkwise: Data modeling guidelines — https://docs.thinkwisesoftware.com/docs/sf/guidelines_data_modeling