How do We Wash the Clothes
In my earlier post we sorted our clothes in the appropriate loads. We realized we don't all sort the same way and we don't have to. Some of us have two loads to wash ( white, dark). Some of us have three (White, dark, color) and some of us could have more (white, dark, color, delicates). Regardless of the number of loads we have to know how to wash them.
In coding there are things called functions and they take inputs. Functions are directions on how to do something. The directions for how to wash our different loads may not be the same. Let's look at whites. In order to wash the whites, we have to separate the balled up socks, do some pre-wash stain treatment, set the water on hot and we could even add an extra wash. These would be instructions we include in a function.
So what are the inputs? Sometimes a function needs some inputs so it can run. It's great to have a function that washes clothes but if we have no load to wash the function can't do anything. If we named a function Washing white clothes we would know right away, we need a load of white clothes. Sometimes functions have more than one input. For our wash the white clothes functions we could need bleach, detergent, stain treatment and maybe even fabric softener.
You can see how we could have a lot of instructions and a lot of inputs. From coder to coder and washer to washer these things could vary. Just to make sure we understand how functions ( instructions) work let's look at dark clothes.
The function is called wash the dark clothes. The instructions in the function read:
-empty pockets
-turn dark clothes inside out
-unroll socks
-pre-treat
-cold only water.
Now the inputs for this function could be: dark clothes load, detergent, stain treatment. With these inputs when we run this function it will have what it needs to wash the dark clothes.
Keep Learning,
Chad