I've adopted a new philosophy, at least at the time, when it comes to programming. I will begin this post with the 25 words or less statement: When coding, think about what a function does and when to use it rather than how it works.
Let me explain. I have over analyzed things for as long as I can remember. Sometimes the endless circles of analyzation can drive a person mad. I believe that is how I was when coding. Any function, library, or package, I wondered how it worked. What process was the computer going through to execute what I commanded it to do? I think I meditated too deeply on such things. To write a functioning program and knowing what tools(methods/functions) to use does not require knowing exactly everything going on in its minutest detail.
I will say that kind of deep analyzation has its place. Memory allocation for example is important to how smoothly a computer can execute a program and knowing how a function works could probably aid in making the most of memory. (I know memory allocation isn't that deep of a concept, but when I was doing a little C++ the way it was explained in the lesson made it seem difficult) And if you were to write a framework or package I'm sure knowing more of how computers work would be beneficial. Certainly computer science degrees and courses can make one a better programmer. It has to right? I've heard podcasts where some with CS degrees said programming is a different animal, but I can't imagine CS knowledge not being incredibly useful to programing.
I came to this conclusion as I finished the Python track from Treehouse. Some of the concepts in the functional Python course could have meant endless analyzation as to what was going on. Then it clicked that when I'm writing code, knowing how the method/function is coming up with the data behind the scenes is likely irrelevant. I only need to know what it does and how to use it.
Take the map() function for example. I need to know what parameters pass into it and what kind of data will be returned. The function call is this: map(function, iterable). I know that it will take the iterable through the function and return an altered list of that data. I don't need to know how map() does this, only what parameters to put into it and having it return the data I need passed through the function. Especially since I would have likely written the function to alter the data.
Again, knowing what exactly is going on has its place. However if you are overly concerned about how certain functions and packages work you may never progress, and thus never write a program in a reasonable amount of time. That is the current mindset I will be proceeding with right now.
For future reference:
altered_list = map(function, iterable)
true_item_list = filter(function, iterable)
cumulative_data = reduce(function, iterable)
returned_data = g = lambda x: x**2
The 'function' in each of these functions can be replaced with a lambda.
Also of note, it would be nice if the word 'iterable' was recognized by my computer so I could type it without it auto correcting to 'utterable'.
No comments:
Post a Comment