Commit c8962e1
committed
refactor: [#238] fix Law of Demeter violations and implement consistent delegation
This refactoring addresses two related architectural concerns:
Phase 1 - Application Layer (Law of Demeter):
- Added 4 convenience methods to Environment: database_config(), tracker_config(), admin_token(), prometheus_config()
- Updated docker_compose_templates.rs to use new methods instead of chaining through context
- Eliminates method chaining violations like self.environment.context().user_inputs.tracker.core.database
Phase 2 - Domain Layer (Consistent Delegation):
- Added 13 accessor methods to EnvironmentContext for all directly-accessed fields
- Updated 11 Environment methods to consistently delegate to context methods
- Changes pattern from direct access (self.context.user_inputs.field) to delegation (self.context.field())
Benefits:
- Single source of truth: EnvironmentContext controls field access
- Better encapsulation: Environment doesn't know context's internal structure
- Easier maintenance: Structural changes only affect EnvironmentContext
- Consistent API: All Environment methods follow same delegation pattern
- Improved testability: Can mock EnvironmentContext methods independently
All 1509 tests passing, pre-commit checks passed.1 parent a624d80 commit c8962e1
File tree
3 files changed
+117
-18
lines changed- src
- application/steps/rendering
- domain/environment
3 files changed
+117
-18
lines changedLines changed: 4 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 150 | + | |
157 | 151 | | |
158 | 152 | | |
159 | 153 | | |
160 | | - | |
| 154 | + | |
161 | 155 | | |
162 | 156 | | |
163 | 157 | | |
| |||
212 | 206 | | |
213 | 207 | | |
214 | 208 | | |
215 | | - | |
| 209 | + | |
216 | 210 | | |
217 | 211 | | |
218 | 212 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
285 | 363 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
| |||
400 | 403 | | |
401 | 404 | | |
402 | 405 | | |
403 | | - | |
| 406 | + | |
404 | 407 | | |
405 | 408 | | |
406 | 409 | | |
407 | 410 | | |
408 | 411 | | |
409 | | - | |
| 412 | + | |
410 | 413 | | |
411 | 414 | | |
412 | 415 | | |
413 | 416 | | |
414 | 417 | | |
415 | | - | |
| 418 | + | |
416 | 419 | | |
417 | 420 | | |
418 | 421 | | |
419 | 422 | | |
420 | 423 | | |
421 | | - | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
422 | 449 | | |
423 | 450 | | |
424 | 451 | | |
| |||
442 | 469 | | |
443 | 470 | | |
444 | 471 | | |
445 | | - | |
| 472 | + | |
446 | 473 | | |
447 | 474 | | |
448 | 475 | | |
449 | 476 | | |
450 | 477 | | |
451 | | - | |
| 478 | + | |
452 | 479 | | |
453 | 480 | | |
454 | 481 | | |
| |||
496 | 523 | | |
497 | 524 | | |
498 | 525 | | |
499 | | - | |
| 526 | + | |
500 | 527 | | |
501 | 528 | | |
502 | 529 | | |
| |||
511 | 538 | | |
512 | 539 | | |
513 | 540 | | |
514 | | - | |
| 541 | + | |
515 | 542 | | |
516 | 543 | | |
517 | 544 | | |
| |||
0 commit comments