Skip to content

Commit de9797e

Browse files
committed
finish writeup on ADD new todo item to list. #48
1 parent a19da15 commit de9797e

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ the Elm ("Model Update View") Architecture in "_plain_" JavaScript.
1414
> We think Elm is the _future_ of Front End Web Development <br />
1515
for all the _reasons_ described in:
1616
[github.com/dwyl/**learn-elm#why**](https://github.com/dwyl/learn-elm#why) <br />
17-
_However_ we _acknowledge_ that Elm is _not_ for _everyone_! <br />
17+
_However_ we _acknowledge_ that Elm is "_**not everyone's taste**_"! <br />
1818

1919
> What [_many_](https://youtu.be/VNGFep6rncY)
2020
Front-End Developers _are_ learning/using is

todo-list.md

+28-10
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ _by_ far the most _used_ feature of a Todo List. <br />
386386
#### `ADD` item _Acceptance Criteria_
387387

388388
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 />
390390
Such that the `model` is transformed (_data is added_) in the following way:
391391

392392
_BEFORE_:
@@ -406,7 +406,9 @@ _AFTER_:
406406
}
407407
```
408408

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)
410412

411413
While considering the "Acceptance Criteria"
412414
for adding an item to the Todo List,
@@ -429,14 +431,14 @@ function update(action, model) {
429431
does not have a **parameter** for passing in the Todo List item Text (`title`),
430432
i.e. how do we add "data" to the `model`...?
431433

432-
We don't want to "mess with" either of the other two parameters,
433-
both `action` and `model` have clearly defined
434-
435434

436435
That's "_Oh kay_"! (_don't panic_!) <br />
437436
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)
440442

441443
As you are _about_ to see, we can _easily_ change the function signature,
442444
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,
456458
safe in the knowledge that all your _existing_ tests still pass.
457459
i.e. the _rest_ of the app "**still works**" **_exactly_ as expected**.
458460

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+
459465
With that in mind, let's _amend_ the `update` **`JSDOC`** comment
460466
and function signature to:
461467

@@ -483,7 +489,9 @@ node test/todo-app.test.js
483489
_Everything_ should still pass:
484490
![update-default-branch-test-passing](https://user-images.githubusercontent.com/194400/43581137-c6aa236e-964f-11e8-96d0-ef724659761e.png)
485491

486-
Congratulations! You just _refactored_ a function (_signature_).
492+
Congratulations! You just _extended_ a function (_signature_)
493+
without affecting any _existing_ tests.
494+
487495

488496

489497
#### `ADD` item _Test_
@@ -543,7 +551,18 @@ function update(action, model, data) {
543551
```
544552
the `case 'ADD'` is the _relevant_ code. <br />
545553

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
547566

548567

549568

@@ -557,5 +576,4 @@ If you feel _confident_ with your "TEA" skills you can _either_:
557576
e.g: https://github.com/nelsonic/time-mvp
558577
+ Move on and **Learn Elm**: https://github.com/dwyl/learn-elm
559578
+ (Join the herd and) Learn & use React/Redux.
560-
561579
-->

0 commit comments

Comments
 (0)