To a non-technical outsider, programming somethings looks like black magic or some kind of dark art that mere mortals cannot possibly understand. There are times that I think that it is the programmers that concoct this mysticism to impress those around them. There can be no other logical explanation as to why we purposefully make things so confusing and complicated.
Take for example the concept of Methods in the Swift programming language. They are referred to as methods but to create one you use the keyword “func” which stands for function. To the ill-informed there would be an assumption that a method and a function are the same but they are not. Well technically they are but they aren’t. See what I mean by programmers creating a smokescreen to make themselves look smart and the code reader feel confused?
The subtle difference between a function and a method is that a method is a function that is within a Structure (struct). Perhaps William Shakespeare was actually a programmer when he wrote his famous line, “a rose by any other name would smell as sweet.” We should remember that this line came from Romeo and Juliet where Juliet is basically saying, “Dude, I really don’t care who your family is or what they smell like I know guys like you” or something like that.
So like in Romeo and Juliet, the concept is the same. They are basically the same thing the only difference is their address. If you are inside a structure you are a method; if you are not in a structure then you are a function which as we learned using Schoolhouse Rock is used for hooking up variables and loops and constants.
The next time one of your programming friends tries to strut his knowledge about methods and functions and asks if you know the difference, just ask him if he is inside or outside the Structure and watch his jaw drop open in amazement.
0 Comments