Friday, 13 March 2015

Creativity In Programming

While working through lab 7, I had the benefit of experiencing a brief "aha" moment that I am less familiar with in my humanities experience. Sitting with a problem, deliberating to the point of diminishing returns, taking breaks, and finally having the solution "emerge from the ether" has an inherent pleasure that makes me begin to understand how it is that so many accomplished scientists have forgone much of 21st century Western leisure in exchange for vocational commitment.

In computer science, this takes an interesting form: Elegant solutions to seemingly unsolvable problems. These elegant solutions, when combined, give us the sophisticated functionality that takes from Abstract Data Structures right through to cars that can drive themselves. In the case of linked lists, the example I am writing about is fairly simple: How it is that one programs into a data structure the capacity to add or remove data elements. We take the apparent simplicity of this problem for granted, because (as introductory programmers) we are so used to having this problem handled for us in pre-implemented data structures. However, when creating data structures from scratch one has to do the creative heavy lifting oneself.

The elegance lies in a simple trick: Point the prior element's "next" property past the current element to delete the current element. Garbage collection handles the rest. These "out of the ether" solutions take a creative form, and are incredibly powerful. Another one, discussed last class, allows us to delete elements from a Binary Search Tree: Either replace the deleted element with the rightmost element in the left sub-tree, or the leftmost element in the right sub-tree. This is another clever solution that allows data structures to perform in intuitive ways for clients, and allows them the benefit of taking the creativity on the back-end for granted. The extent to which our clients can do this can be framed as a measure of our success as developers. 

No comments:

Post a Comment