Sunday, November 17, 2019

Scope, for non tech folk

Just. Try. Make. Sense.

Scope is normally something you'd hear about in connection to a project, and the scope creeps, and scope-this and scope-that. As hard as we try, code nerds can't escape this scope crap either.

Here's an unexciting story involving scope to set the scene for the tech gibberish to follow.




Me: "Hon, where's my TODO list?"


Wife: "I left it on the Welsh Dresser"


Me: "Nope, it's not there. NOT THERE. I CAN'T FIND IT. THIS IS A CRISIS!!!"...
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.



Me "Oh, wait, FOUND IT!"



That was a story about an item, in an expected scope, how it was somewhere else, but how the meat-sack eventually found the data it was looking for. 


Below is NOT REAL CODE. Just some stuff to get the point across. But the idea stands.


The "It's on the Welsh Dresser" would look like this.

It's like, the { and } are setting boundaries. the "TODO" container is INSIDE the Welsh Dresser container, which is inside the House container, like it should be.


The crisis stage: Can't find the TODO list would now look like this.



Updating the model, you see the TODO list is on/in the floor scope. Floor is in the house scope, but it's not the same as the Welsh Dresser.

I know, I KNOW, the Welsh Dresser is actually on the floor in real life, and this whole thing is ridiculous. I put it together in 5 minutes, okay? Pretend the furniture all floats off the floor by a bit, like a bad 3d rendering.



Later on, if the dog gets hold of the TODO list.


Okay, enough, time to tie this all together. Remember: Computers are dumb. A computer, looking at welsh-dresser, would not think to look elsewhere unless programmed to do so. It's vital that the todo list is in the welsh-dresser scope for the computer to find it. Computers think, when the todo list is in the floor scope, or dog scope, it's a whole other thing. Completely different. Stupid machine.

This is why tech nerds are all, like "that data is in the wrong scope". They mean they haven't built the system smart enough to hunt elsewhere for the data the program is looking for. 

In a way, it's a good thing that the computer doesn't know how to hunt. Otherwise, we'd have a rise of the machines type deal, and very likely having to fight for our lives.








No comments: