Thursday, November 30, 2017

Case Study for MVCCE Design Pattern

In earlier posts, I published cheat sheet summaries of my MVCCE design pattern, which extends and refines the classic MVC design pattern. I present here an example of the use of that pattern.

For the web sites of the family of brands of a major retailer, I created a "widget" to handle site search requests that used several interactive animations and responsive behavior, including type-ahead suggestions gathered via AJAX interaction with backend servers.

This configurable standalone GUI widget was written in essentially raw JavaScript, and it used the MVCCE design pattern.

Below is the design diagram (click to expand)  that was the blueprint for that widget.


Click to Expand

Following the "single flow" of data from left to right,
  1. User Actions (i.e. things a user wants to do, use cases, etc),
  2. are invoked by the user causing DOM Input Events (by clicking or typing or moving cursor),
  3. which are caught by Controllers,
  4. which decide which Command to invoke, with which parameters to send,
  5. which uses Model APIs to manipulate/update the widget's (and/or application's) state,
  6. which causes Update Events to be sent to Views which are "Observing" those Models,
  7. and those Views use the DOM APIs to manipulate/update the browser display.
This widget, at the "compound" level, did not happen to generate Output Events for other Controllers to subscribe to.

As can be seen, several models, views, controllers are "composite" containing sub-components.

While it is less obvious from the diagram, the AJAX interactions with the server-side, result in Input Events from the async replies to data requests (e.g. type-ahead suggestions), which update the Models, which in turn cause the Views to update themselves (including the loading of images that correspond with the type-ahead suggestions).

Tuesday, July 14, 2015

The many spellings of Nurd (or is it Nerd?)

As the bombs burst outside for Bastille Day, I commemorate something completely different...

While bored in 10th grade history class, I wrote a little treatise on the many ways to spell "nurd". I had come up with 742 different spellings. This post commemorates the 45th anniversary of that event, and is the first time I've attempted to recreate the list since then. This new compendium has a new total spellings count of 910!

Today we all know what a "nerd" is, and how most people spell it. But 45 years ago, it was in its primordial beginnings with no set meaning, nor an agreed upon spelling.

The spelling "nurd" was actually the preferred one in my high school circles in 1970. And the meaning was basically the punchline to a joke. A "nurd" (circa 1970) is someone who farts in the bathtub and bites the bubbles. While nerd/nurd has lost that meaning, it is interesting to see that there are other related words that still have that same meaning (according to the Urban Dictionary),
and the same early 1970s date is even referenced as well. See the definitions for dork, gorp, fonzanoon, etc.

But, a winner to competing spellings emerges from the mist, with "nerd" gaining traction just as the word itself starts getting increasingly used. See this Google NGRAM graph of the historical usage of the two spellings, showing a clear upswing in usage and spelling preference starting in the late 1970s. For me, it is no coincidence that the date corresponds to the advent of home computers, e.g. the Apple ][ in 1977.  [BTW, if you are wondering why usage might have plateaued, see how Asperger's has overtaken it.]


The irony is that the word nerd would eventually take on the meaning that describes the very kind of person who would take on a project of enumerating hundreds of its spellings.

The Rules

In 1970, thinking of the two spelling alternatives, I noticed that nurd is a unique combination of sounds, each of which has an unusually large number of possible spellings, hence the combinatorics explode. There is the starting "n" sound, followed by the "ur" sound, followed by a hard "d" sound, each of which has multiple spellings (in English).

So, I grabbed the biggest dictionary I could find, and at my desk (with the history teacher droning on), I enumerated all the variations (in a matrix, by hand, in pen, mind you) and came up with a total of 742. I am afraid I've lost track of that historic document. So, herewithin, I will attempt to recreate the set of rules, and the list of spellings generated by them.

An "n" sound at the beginning of a word, has an unbelievable number of spellings in English.
They are:
  1. "n" as in nerd.
  2. "gn" as in gnat.
  3. "kn" as in know.
  4. "cn" as in cnemis (I'm not making these up…look them up in the dictionary)
  5. "mn" as in mnemonic.
  6. "pn" as in pneumonia.
  7. "nn" based on the logic that double letters can be used in the beginning, like "aa" in aardvark, or "ll" in Lloyd

The "urd" sound also has a huge number of spellings:
  1. "urd" as in kurd.
  2. "erd" as in herd.
  3. "ird" as in bird.
  4. "ord" as in word.
  5. "oard" as in cupboard
  6. "ard" as in standard, awkward.
  7. "ered" as in blinkered.
  8. "eard" as in heard.
  9. "irred" as in stirred.
  10. "urred" as in blurred.
  11. "erred" as in deterred.
  12. "ored" as in flavored, armored (hey, I was in the South, we pronounce 'em that way)
  13. "ured" as in featured
  14. "yred" as in martyred
  15. "yrd" as in (lots of people with last name) Byrd, and Lynyrd Skynyrd (I said it was the South, plus its got nyrd twice!)

The hard consonant ending, has a few variations too:
  1. a single consonant, as in mud, hence a "d" ending
  2. a double consonant, as in odd, add, hence a "dd" ending
  3. with a silent "e" and single consonant, as in facade, avant-garde, hence a "de" ending
  4. with a silent "e" and double consonant, as in dradde, and (ye olde) shoppe, hence a "dde" ending
Ok, so thats 7 times 15 times 4 giving 420 …hmmm… I kinda remember some not-quite-silent "h"s thrown in, as in nhurd (it sounds the same!), and nurdhe as in "sadhe" (yes, it is! Merriam-Websters). So now 7 times 30 times 5 giving 1050.
But I think I threw out the "h" in front of "ord" and "ored" and "oard" and "ard" since that seemed stretching it even for me. So back down to 7 times 26 times 5 giving 910.


The Spellings
Count
_n...d
_nh...d
_n...dd
_nh...dd
_n...de
_nh...de
_n...dde
_nh...dde
_n...dhe
_nh...dhe
1
nurd
nhurd
nurdd
nhurdd
nurde
nhurde
nurdde
nhurdde
nurdhe
nhurdhe
11
cnurd
cnhurd
cnurdd
cnhurdd
cnurde
cnhurde
cnurdde
cnhurdde
cnurdhe
cnhurdhe
21
gnurd
gnhurd
gnurdd
gnhurdd
gnurde
gnhurde
gnurdde
gnhurdde
gnurdhe
gnhurdhe
31
knurd
knhurd
knurdd
knhurdd
knurde
knhurde
knurdde
knhurdde
knurdhe
knhurdhe
41
mnurd
mnhurd
mnurdd
mnhurdd
mnurde
mnhurde
mnurdde
mnhurdde
mnurdhe
mnhurdhe
51
nnurd
nnhurd
nnurdd
nnhurdd
nnurde
nnhurde
nnurdde
nnhurdde
nnurdhe
nnhurdhe
61
pnurd
pnhurd
pnurdd
pnhurdd
pnurde
pnhurde
pnurdde
pnhurdde
pnurdhe
pnhurdhe
.
71
nerd
nherd
nerdd
nherdd
nerde
nherde
nerdde
nherdde
nerdhe
nherdhe
81
cnerd
cnherd
cnerdd
cnherdd
cnerde
cnherde
cnerdde
cnherdde
cnerdhe
cnherdhe
91
gnerd
gnherd
gnerdd
gnherdd
gnerde
gnherde
gnerdde
gnherdde
gnerdhe
gnherdhe
101
knerd
knherd
knerdd
knherdd
knerde
knherde
knerdde
knherdde
knerdhe
knherdhe
111
mnerd
mnherd
mnerdd
mnherdd
mnerde
mnherde
mnerdde
mnherdde
mnerdhe
mnherdhe
121
nnerd
nnherd
nnerdd
nnherdd
nnerde
nnherde
nnerdde
nnherdde
nnerdhe
nnherdhe
131
pnerd
pnherd
pnerdd
pnherdd
pnerde
pnherde
pnerdde
pnherdde
pnerdhe
pnherdhe
.
141
nird
nhird
nirdd
nhirdd
nirde
nhirde
nirdde
nhirdde
nirdhe
nhirdhe
151
cnird
cnhird
cnirdd
cnhirdd
cnirde
cnhirde
cnirdde
cnhirdde
cnirdhe
cnhirdhe
161
gnird
gnhird
gnirdd
gnhirdd
gnirde
gnhirde
gnirdde
gnhirdde
gnirdhe
gnhirdhe
171
knird
knhird
knirdd
knhirdd
knirde
knhirde
knirdde
knhirdde
knirdhe
knhirdhe
181
mnird
mnhird
mnirdd
mnhirdd
mnirde
mnhirde
mnirdde
mnhirdde
mnirdhe
mnhirdhe
191
nnird
nnhird
nnirdd
nnhirdd
nnirde
nnhirde
nnirdde
nnhirdde
nnirdhe
nnhirdhe
201
pnird
pnhird
pnirdd
pnhirdd
pnirde
pnhirde
pnirdde
pnhirdde
pnirdhe
pnhirdhe
.
211
nord
.....
nordd
.....
norde
.....
nordde
.....
nordhe
.....
216
cnord
.....
cnordd
.....
cnorde
.....
cnordde
.....
cnordhe
.....
221
gnord
.....
gnordd
.....
gnorde
.....
gnordde
.....
gnordhe
.....
226
knord
.....
knordd
.....
knorde
.....
knordde
.....
knordhe
.....
231
mnord
.....
mnordd
.....
mnorde
.....
mnordde
.....
mnordhe
.....
236
nnord
.....
nnordd
.....
nnorde
.....
nnordde
.....
nnordhe
.....
241
pnord
.....
pnordd
.....
pnorde
.....
pnordde
.....
pnordhe
.....
.
246
noard
.....
noardd
.....
noarde
.....
noardde
.....
noardhe
.....
251
cnoard
.....
cnoardd
.....
cnoarde
.....
cnoardde
.....
cnoardhe
.....
256
gnoard
.....
gnoardd
.....
gnoarde
.....
gnoardde
.....
gnoardhe
.....
261
knoard
.....
knoardd
.....
knoarde
.....
knoardde
.....
knoardhe
.....
266
mnoard
.....
mnoardd
.....
mnoarde
.....
mnoardde
.....
mnoardhe
.....
271
nnoard
.....
nnoardd
.....
nnoarde
.....
nnoardde
.....
nnoardhe
.....
276
pnoard
.....
pnoardd
.....
pnoarde
.....
pnoardde
.....
pnoardhe
.....
.
281
nard
.....
nardd
.....
narde
.....
nardde
.....
nardhe
.....
286
cnard
.....
cnardd
.....
cnarde
.....
cnardde
.....
cnardhe
.....
291
gnard
.....
gnardd
.....
gnarde
.....
gnardde
.....
gnardhe
.....
296
knard
.....
knardd
.....
knarde
.....
knardde
.....
knardhe
.....
301
mnard
.....
mnardd
.....
mnarde
.....
mnardde
.....
mnardhe
.....
306
nnard
.....
nnardd
.....
nnarde
.....
nnardde
.....
nnardhe
.....
311
pnard
.....
pnardd
.....
pnarde
.....
pnardde
.....
pnardhe
.....
.
316
nered
nhered
neredd
nheredd
nerede
nherede
neredde
nheredde
neredhe
nheredhe
326
cnered
cnhered
cneredd
cnheredd
cnerede
cnherede
cneredde
cnheredde
cneredhe
cnheredhe
336
gnered
gnhered
gneredd
gnheredd
gnerede
gnherede
gneredde
gnheredde
gneredhe
gnheredhe
346
knered
knhered
kneredd
knheredd
knerede
knherede
kneredde
knheredde
kneredhe
knheredhe
356
mnered
mnhered
mneredd
mnheredd
mnerede
mnherede
mneredde
mnheredde
mneredhe
mnheredhe
366
nnered
nnhered
nneredd
nnheredd
nnerede
nnherede
nneredde
nnheredde
nneredhe
nnheredhe
376
pnered
pnhered
pneredd
pnheredd
pnerede
pnherede
pneredde
pnheredde
pneredhe
pnheredhe
.
386
neard
nheard
neardd
nheardd
nearde
nhearde
neardde
nheardde
neardhe
nheardhe
396
cneard
cnheard
cneardd
cnheardd
cnearde
cnhearde
cneardde
cnheardde
cneardhe
cnheardhe
406
gneard
gnheard
gneardd
gnheardd
gnearde
gnhearde
gneardde
gnheardde
gneardhe
gnheardhe
416
kneard
knheard
kneardd
knheardd
knearde
knhearde
kneardde
knheardde
kneardhe
knheardhe
426
mneard
mnheard
mneardd
mnheardd
mnearde
mnhearde
mneardde
mnheardde
mneardhe
mnheardhe
436
nneard
nnheard
nneardd
nnheardd
nnearde
nnhearde
nneardde
nnheardde
nneardhe
nnheardhe
446
pneard
pnheard
pneardd
pnheardd
pnearde
pnhearde
pneardde
pnheardde
pneardhe
pnheardhe
.
456
nirred
nhirred
nirredd
nhirredd
nirrede
nhirrede
nirredde
nhirredde
nirredhe
nhirredhe
466
cnirred
cnhirred
cnirredd
cnhirredd
cnirrede
cnhirrede
cnirredde
cnhirredde
cnirredhe
cnhirredhe
476
gnirred
gnhirred
gnirredd
gnhirredd
gnirrede
gnhirrede
gnirredde
gnhirredde
gnirredhe
gnhirredhe
486
knirred
knhirred
knirredd
knhirredd
knirrede
knhirrede
knirredde
knhirredde
knirredhe
knhirredhe
496
mnirred
mnhirred
mnirredd
mnhirredd
mnirrede
mnhirrede
mnirredde
mnhirredde
mnirredhe
mnhirredhe
506
nnirred
nnhirred
nnirredd
nnhirredd
nnirrede
nnhirrede
nnirredde
nnhirredde
nnirredhe
nnhirredhe
516
pnirred
pnhirred
pnirredd
pnhirredd
pnirrede
pnhirrede
pnirredde
pnhirredde
pnirredhe
pnhirredhe
.
526
nurred
nhurred
nurredd
nhurredd
nurrede
nhurrede
nurredde
nhurredde
nurredhe
nhurredhe
536
cnurred
cnhurred
cnurredd
cnhurredd
cnurrede
cnhurrede
cnurredde
cnhurredde
cnurredhe
cnhurredhe
546
gnurred
gnhurred
gnurredd
gnhurredd
gnurrede
gnhurrede
gnurredde
gnhurredde
gnurredhe
gnhurredhe
556
knurred
knhurred
knurredd
knhurredd
knurrede
knhurrede
knurredde
knhurredde
knurredhe
knhurredhe
566
mnurred
mnhurred
mnurredd
mnhurredd
mnurrede
mnhurrede
mnurredde
mnhurredde
mnurredhe
mnhurredhe
576
nnurred
nnhurred
nnurredd
nnhurredd
nnurrede
nnhurrede
nnurredde
nnhurredde
nnurredhe
nnhurredhe
586
pnurred
pnhurred
pnurredd
pnhurredd
pnurrede
pnhurrede
pnurredde
pnhurredde
pnurredhe
pnhurredhe
.
596
nerred
nherred
nerredd
nherredd
nerrede
nherrede
nerredde
nherredde
nerredhe
nherredhe
606
cnerred
cnherred
cnerredd
cnherredd
cnerrede
cnherrede
cnerredde
cnherredde
cnerredhe
cnherredhe
616
gnerred
gnherred
gnerredd
gnherredd
gnerrede
gnherrede
gnerredde
gnherredde
gnerredhe
gnherredhe
626
knerred
knherred
knerredd
knherredd
knerrede
knherrede
knerredde
knherredde
knerredhe
knherredhe
636
mnerred
mnherred
mnerredd
mnherredd
mnerrede
mnherrede
mnerredde
mnherredde
mnerredhe
mnherredhe
646
nnerred
nnherred
nnerredd
nnherredd
nnerrede
nnherrede
nnerredde
nnherredde
nnerredhe
nnherredhe
656
pnerred
pnherred
pnerredd
pnherredd
pnerrede
pnherrede
pnerredde
pnherredde
pnerredhe
pnherredhe
.
666
nored
.....
noredd
.....
norede
.....
noredde
.....
noredhe
.....
671
cnored
.....
cnoredd
.....
cnorede
.....
cnoredde
.....
cnoredhe
.....
676
gnored
.....
gnoredd
.....
gnorede
.....
gnoredde
.....
gnoredhe
.....
681
knored
.....
knoredd
.....
knorede
.....
knoredde
.....
knoredhe
.....
686
mnored
.....
mnoredd
.....
mnorede
.....
mnoredde
.....
mnoredhe
.....
691
nnored
.....
nnoredd
.....
nnorede
.....
nnoredde
.....
nnoredhe
.....
696
pnored
.....
pnoredd
.....
pnorede
.....
pnoredde
.....
pnoredhe
.....
.
701
nured
nhured
nuredd
nhuredd
nurede
nhurede
nuredde
nhuredde
nuredhe
nhuredhe
711
cnured
cnhured
cnuredd
cnhuredd
cnurede
cnhurede
cnuredde
cnhuredde
cnuredhe
cnhuredhe
721
gnured
gnhured
gnuredd
gnhuredd
gnurede
gnhurede
gnuredde
gnhuredde
gnuredhe
gnhuredhe
731
knured
knhured
knuredd
knhuredd
knurede
knhurede
knuredde
knhuredde
knuredhe
knhuredhe
741
mnured
mnhured
mnuredd
mnhuredd
mnurede
mnhurede
mnuredde
mnhuredde
mnuredhe
mnhuredhe
751
nnured
nnhured
nnuredd
nnhuredd
nnurede
nnhurede
nnuredde
nnhuredde
nnuredhe
nnhuredhe
761
pnured
pnhured
pnuredd
pnhuredd
pnurede
pnhurede
pnuredde
pnhuredde
pnuredhe
pnhuredhe
.
771
nyred
nhyred
nyredd
nhyredd
nyrede
nhyrede
nyredde
nhyredde
nyredhe
nhyredhe
781
cnyred
cnhyred
cnyredd
cnhyredd
cnyrede
cnhyrede
cnyredde
cnhyredde
cnyredhe
cnhyredhe
791
gnyred
gnhyred
gnyredd
gnhyredd
gnyrede
gnhyrede
gnyredde
gnhyredde
gnyredhe
gnhyredhe
801
knyred
knhyred
knyredd
knhyredd
knyrede
knhyrede
knyredde
knhyredde
knyredhe
knhyredhe
811
mnyred
mnhyred
mnyredd
mnhyredd
mnyrede
mnhyrede
mnyredde
mnhyredde
mnyredhe
mnhyredhe
821
nnyred
nnhyred
nnyredd
nnhyredd
nnyrede
nnhyrede
nnyredde
nnhyredde
nnyredhe
nnhyredhe
831
pnyred
pnhyred
pnyredd
pnhyredd
pnyrede
pnhyrede
pnyredde
pnhyredde
pnyredhe
pnhyredhe
.
841
nyrd
nhyrd
nyrdd
nhyrdd
nyrde
nhyrde
nyrdde
nhyrdde
nyrdhe
nhyrdhe
851
cnyrd
cnhyrd
cnyrdd
cnhyrdd
cnyrde
cnhyrde
cnyrdde
cnhyrdde
cnyrdhe
cnhyrdhe
861
gnyrd
gnhyrd
gnyrdd
gnhyrdd
gnyrde
gnhyrde
gnyrdde
gnhyrdde
gnyrdhe
gnhyrdhe
871
knyrd
knhyrd
knyrdd
knhyrdd
knyrde
knhyrde
knyrdde
knhyrdde
knyrdhe
knhyrdhe
881
mnyrd
mnhyrd
mnyrdd
mnhyrdd
mnyrde
mnhyrde
mnyrdde
mnhyrdde
mnyrdhe
mnhyrdhe
891
nnyrd
nnhyrd
nnyrdd
nnhyrdd
nnyrde
nnhyrde
nnyrdde
nnhyrdde
nnyrdhe
nnhyrdhe
901
pnyrd
pnhyrd
pnyrdd
pnhyrdd
pnyrde
pnhyrde
pnyrdde
pnhyrdde
pnyrdhe
pnhyrdhe

...with the final total: 910