Monday, 30 March 2015

Recursion Revisited: Back Down the Rabbit Hole

In my first review of recursion I discussed how I managed to wrap my head around the concept and how I was able to convince myself of the legitimacy behind the principle. However, that was just step one into the experience that is recursion. The next step is to take that knowledge and be able to apply it to actual problems, which is where the real fun begins.
Here we go again...
One of the important things that is used in most recursive applications is the creation of a base case which is a call on the function that completes without reaching the recursion stage. Getting the correct structure for your base case is important since it is what gathers the output for each stage of recursion. If you aren't careful with what you choose for the base case it might work for that one case but you may run into difficulties when you actually need to recurse.

Monday, 23 March 2015

OOP

Object Oriented Programming is one of the main things about Python that I find makes it much more user friendly. The pre-existing objects such as dictionaries and lists are well formatted and the ability to create your own object types is extremely helpful and allows for a much more dynamic range of applications.

You can assign the same functionality found in the built-in objects to your own objects. This includes the special __str__, __repr__ and __eq__ functions. In addition to this you can also assign any custom functions that would be helpful when manipulating or working with your objects.

I didn't really encounter any specific problems that gave me greater insight into object oriented programming but one of the more challenging aspects was creating the __str__ function for your custom object. I found it to be the most helpful part of understanding how your objects work because it forces you to think about what exactly you are attempting to represent.