@@ -386,7 +386,7 @@ _by_ far the most _used_ feature of a Todo List. <br />
386
386
#### ` ADD ` item _ Acceptance Criteria_
387
387
388
388
Adding a new todo item's text should
389
- append the item ` Object ` to the ` model.items ` Array.
389
+ append the todo item ` Object ` to the ` model.todos ` Array. < br />
390
390
Such that the ` model ` is transformed (_ data is added_ ) in the following way:
391
391
392
392
_ BEFORE_ :
@@ -406,7 +406,9 @@ _AFTER_:
406
406
}
407
407
```
408
408
409
- #### Hold On, How Does Todo Item _ Text_ Get "Passed Into" ` update ` ...?
409
+ #### Hold On, That Doesn't Seem "_ Right_ " How Does Todo Item _ Text_ Get Added?
410
+
411
+ ![ sotp-sign-fail] ( https://user-images.githubusercontent.com/194400/43678248-ba12f248-9807-11e8-8ebc-0afd8fd8bb0e.jpg )
410
412
411
413
While considering the "Acceptance Criteria"
412
414
for adding an item to the Todo List,
@@ -429,14 +431,14 @@ function update(action, model) {
429
431
does not have a ** parameter** for passing in the Todo List item Text (` title ` ),
430
432
i.e. how do we add "data" to the ` model ` ...?
431
433
432
- We don't want to "mess with" either of the other two parameters,
433
- both ` action ` and ` model ` have clearly defined
434
-
435
434
436
435
That's "_ Oh kay_ "! (_ don't panic_ !) <br />
437
436
If we ** ` try ` ** to think about implementation up-front,
438
- we would _ invariably_ be "over-thinking"
439
- it's called "*** Waterfall*** "".
437
+ we would _ invariably_ be "over-thinking" things
438
+ and get "stuck" in the
439
+ [ "analysis paralysis"] ( https://en.wikipedia.org/wiki/Analysis_paralysis )
440
+ of
441
+ [ "*** waterfall*** "] ( https://en.wikipedia.org/wiki/Waterfall_model )
440
442
441
443
As you are _ about_ to see, we can _ easily_ change the function signature,
442
444
in the _ next_ test _ without affecting_ our exiting (_ passing_ ) test!
@@ -456,6 +458,10 @@ You can "_refactor_" a function's _implementation_ to your heart's content,
456
458
safe in the knowledge that all your _ existing_ tests still pass.
457
459
i.e. the _ rest_ of the app "** still works** " ** _ exactly_ as expected** .
458
460
461
+ We don't want to "mess with" either of the other two (_ existing_ ) parameters,
462
+ both ` action ` and ` model ` have clearly defined purposes,
463
+ but we _ need_ a way to pass "data" into the ` update ` function!
464
+
459
465
With that in mind, let's _ amend_ the ` update ` ** ` JSDOC ` ** comment
460
466
and function signature to:
461
467
@@ -483,7 +489,9 @@ node test/todo-app.test.js
483
489
_ Everything_ should still pass:
484
490
![ update-default-branch-test-passing] ( https://user-images.githubusercontent.com/194400/43581137-c6aa236e-964f-11e8-96d0-ef724659761e.png )
485
491
486
- Congratulations! You just _ refactored_ a function (_ signature_ ).
492
+ Congratulations! You just _ extended_ a function (_ signature_ )
493
+ without affecting any _ existing_ tests.
494
+
487
495
488
496
489
497
#### ` ADD ` item _ Test_
@@ -543,7 +551,18 @@ function update(action, model, data) {
543
551
```
544
552
the ` case 'ADD' ` is the _ relevant_ code. <br />
545
553
546
- > Was _ your_ implementation _ similar_ ...?
554
+ > Was _ your_ implementation _ similar_ ...? <br />
555
+ > If you were able to make it _ simpler_ ,
556
+ [ please share!] ( https://github.com/dwyl/learn-elm-architecture-in-javascript/issues/48 )
557
+
558
+ Once you have the test(s) _ passing_ e.g:
559
+ ![ todo-add-item-tests-passing] ( https://user-images.githubusercontent.com/194400/43678110-2688ea7a-9805-11e8-9003-97b5450d0cf1.png )
560
+
561
+ Let's move on to the _ next_ functionality!
562
+
563
+ <br />
564
+
565
+ ### ` ADD ` an ` item ` to the Todo List
547
566
548
567
549
568
@@ -557,5 +576,4 @@ If you feel _confident_ with your "TEA" skills you can _either_:
557
576
e.g: https://github.com/nelsonic/time-mvp
558
577
+ Move on and **Learn Elm**: https://github.com/dwyl/learn-elm
559
578
+ (Join the herd and) Learn & use React/Redux.
560
-
561
579
-->
0 commit comments