Development
This chapter covers practical strategies for testing and debugging Zymba code, and the patterns and conventions that make ZeyOS applications maintainable in production.
What's in this chapter
| Page | Content |
|---|---|
| Testing and Debugging | SDK test runner, echo debugging, @Console.log, assertion helpers, common bugs |
| Best Practices | Code organization, naming conventions, database patterns, error handling, performance, anti-patterns |
Quick reference: common pitfalls
| Symptom | Likely cause | Fix |
|---|---|---|
String concatenation produces 0 | Used + instead of . | "a" . $b |
| Object method doesn't update state | Missing $this. prefix | $this.value++ |
| Closure can't see outer variable | Missing use clause | function() use ($x) { ... } |
use capture doesn't accumulate | use is copy, not reference | Use @Array.reduce or pass by argument |
"0" treated as false | "0" is falsy in Zymba | Test explicitly: $v !== null && $v !== "" |
fetchOne crashes on no results | Result is null when not found | Check if ($user is null) before accessing fields |