|
2 | 2 |
|
3 | 3 | ## Quick start
|
4 | 4 |
|
5 |
| -1. Install dependencies `npm i` |
6 |
| -2. Start server |
7 |
| - - Usage: `node server <folder>` |
8 |
| - - Example: `node server Pragmatic` |
9 |
| -3. Open in browser: [http://127.0.0.1:8000/](http://127.0.0.1:8000/) |
| 5 | +1. Install dependencies `npm i`; optionaly run tests: `npm t` |
| 6 | +2. Start server `node server <folder>` for example: `node server Pragmatic` |
| 7 | +3. Open in browser: [`http://127.0.0.1:8000/`](http://127.0.0.1:8000/) |
| 8 | + |
| 9 | +## Compare 3 implementations |
| 10 | + |
| 11 | +- Native: pure indexedDB API |
| 12 | + - Goal: fast, minimal, no intermediate abstractions layer, everything just hardcoded in imperative code without abstractions |
| 13 | + - No schemas, just raw `indexedDB.open`, `transaction`, `objectStore`, logic written inline per action |
| 14 | + - Structure: single file |
| 15 | + - Pros: fully transparent usage of IndexedDB |
| 16 | + - Cons: unable to write unittests, no reusability, poor maintainability |
| 17 | +- Enterprise: wrapper for indexedDB API with ceremonies overhead |
| 18 | + - Goal: maximum DDD and Cleal/Layered architecture compliance and code maintainability |
| 19 | + - Abstractions for every responsibility: Database, Repository, Service, UserModel, UserRepository, UserService, Logger |
| 20 | + - Utilities like `exec()` to improve domain code readability and semantics |
| 21 | + - Actions with autobinding to UI: `action(id, callback)` |
| 22 | + - Structure: splitted in 4 modules, multiple classes |
| 23 | + - Pros: testable, proper Separation of Concerns, validation, UI actions, extendable logic |
| 24 | + - Cons: verbose, ceremonies, boilerplate, cognitive heavy, slower to write, overhead for simple apps |
| 25 | +- Pragmatic: wrapped indexedDB API with DSL without ceremonies |
| 26 | + - Goal: minimal yet structured and reusable IndexedDB access |
| 27 | + - Wrapped indexedDB API with DSL for queries and scemas, but without ceremonies, minimal pragmatic solution: just Database and Logger |
| 28 | + - Actions actions with autobinding to UI still via `action(id, handler)`, Logger class reused from `Enterprise` implementation |
| 29 | + - Structure: 2 modules (for db wrapper and for domain code) |
| 30 | + - Declatative DSLs (Domain Specific Language), like: |
| 31 | + - Queries: `db.select({ store: 'user', where: { age: 18 }, order: { name: 'asc' } });` |
| 32 | + - Schemas: `const schemas = { user: { keyPath: 'id', autoIncrement: true } };` |
| 33 | + - Pros: low ceremony, readable and maintainable, declaratice queries and schemas |
| 34 | + - Cons: DSL adds learning curve, SRP (Single Responsibility Principle) and SoC (Separation of Concerns) partially compliance |
10 | 35 |
|
11 | 36 | ## License & Contributors
|
12 | 37 |
|
|
0 commit comments