I don't think I gave this topic much consideration, a passing reference at best I think, the abstract data type. The foundation for my intro to comp science course, it is how the house is put together on top of an existing foundation.
Back at the beginning of the course I didn't really give much thought to why this concept was so important. I could see how it worked, making a new data type that is specific to a group of programs that is a modification of an existing set of functions. This seems to be most effective when dealing with an object that has a set of common internal values like a flight that has seats, passengers etc. Before I gave this much thought I had moved on to object orientated programming.
Through the course assignments where we got to play with games I started thinking about the data type more. Being able to pack a bunch of reusable code in an object with properties that can be referenced is very helpful. It took a while for me to get my head transitioned from creating functions to creating methods. I am sure my life in this course would have been easier if I had come to this epiphany earlier. Guess that is the learning process.
This became a particular problem in dealing with the recursion of objects. I was constantly trying to pull the properties out of an abstract data type and forcing changes to them while passing them through recursive method calls. This turned out to be a very bad idea! Glad I have turned the corner now and now I let my abstract data type do the work for me. I guess sometimes you have to touch the stove when it is hot to know that isn't a good idea. Onward I go, putting my best abstract data type muscles to work in finishing off the course!
Tuesday, 31 March 2015
Monday, 23 March 2015
Getting my rhythm back
Finally starting to recover from the obsessiveness that was assignment number two. Still have ideas of how I can improve the resulting code but it is time to move on. Every week we learn some info that gives new insight into previous assignments/tests/labs. I plan on reviewing the course problems from the beginning and see what I would have done differently if I had only known more stuff. Should be fun.
This week was a switch of gears. No more new code, time to look at how to construct test cases. The hardest part seems to be in the determination of what an effective test case looks like. I was used to boundaries and combinations. Now additions to use predictive results based the probability of a function/method being correct. The idea is to isolate the return value in enough cases to be confident that the result is not random. Never really thought of it this way, will take some time to bed it down.
Difficulty at this point in the course is keeping the school being out of the work place. Sometimes it all gets a bit muddled and will have to make sure that I can shut down school brain when work needs to get done. Not a big issue at this point but something to be conscious of. So off into the last few weeks of intro to computer science!
This week was a switch of gears. No more new code, time to look at how to construct test cases. The hardest part seems to be in the determination of what an effective test case looks like. I was used to boundaries and combinations. Now additions to use predictive results based the probability of a function/method being correct. The idea is to isolate the return value in enough cases to be confident that the result is not random. Never really thought of it this way, will take some time to bed it down.
Difficulty at this point in the course is keeping the school being out of the work place. Sometimes it all gets a bit muddled and will have to make sure that I can shut down school brain when work needs to get done. Not a big issue at this point but something to be conscious of. So off into the last few weeks of intro to computer science!
Monday, 9 March 2015
Tough week
Had my first difficult week of my return to school adventure. Got caught up in trying to solve a specific problem with an assignment and lost track of time. It is a bit disappointing since I had a working version of the assignment two days before it was due. Needless to say during the week the new material in lecture got me thinking about a better way of doing a major part of the assignment. Difficulty being I didn't have enough time to finish the new version and ran up against the deadline.
Lessons learned. The day an assignment is due is for perfecting only, no new designs allowed! Perfection is great but sometimes good will suffice. Given an infinite amount of time you can always improve something but an infinite amount of time is never available.
All that being said, I did finish the assignment post deadline to see if what I was trying was really better. Good news is that it worked much better than I thought it would and it was elegant as well. I like elegant. Not sure I get any bonus points for that.
This week is a reset. There is a test that I need to get my head into. I have to drop my obsessing over an assignment that is in the past and start looking forward again. So head first into binary trees and linked lists. I like the potential, especially of breaking a tree into a series of linked lists. It is the concept that got me into trouble on last weeks assignment.
Time to be a better more pragmatic student!
Lessons learned. The day an assignment is due is for perfecting only, no new designs allowed! Perfection is great but sometimes good will suffice. Given an infinite amount of time you can always improve something but an infinite amount of time is never available.
All that being said, I did finish the assignment post deadline to see if what I was trying was really better. Good news is that it worked much better than I thought it would and it was elegant as well. I like elegant. Not sure I get any bonus points for that.
This week is a reset. There is a test that I need to get my head into. I have to drop my obsessing over an assignment that is in the past and start looking forward again. So head first into binary trees and linked lists. I like the potential, especially of breaking a tree into a series of linked lists. It is the concept that got me into trouble on last weeks assignment.
Time to be a better more pragmatic student!
Saturday, 7 March 2015
Recursion, thoughts
If it is good to do it once, doing it again must be better right? Hence the efficacy of recursion. I always wondered how to travel down a path when you don't know where it stops. It reminds me of the excitement when I was a child in wondering into a forrest or a field with no idea where it was taking me but I knew would lead me to someplace interesting. I liken recursion to getting to that interesting place.
Of course there is an imminently practical need for recursion. I come across it a lot in my day job, the need to fit everything into a pre-defined box whether it makes sense or not. How do you draw the box if you don't now how big or what shape the box is? It is nice that in programming there is a way to resolve this problem.
The key element to make this work is defining the correct base case. In learning this construct I spent a lot of time hitting the escape button while my little program went into an infinite loop. Not unlike when I started using where clauses (I still mess these up more than I care to admit). I think the key is knowing when to use recursion and when too much of something isn't necessarily a good thing (see opening statement).
As in all things it is important to know when it applies. Dealing with aggregated data is always problematic. Recursion is a great solution in dealing with data that is in a ragged hierarchy where base data is at different depths (how many levels of summation are required). One approach is to convert all of the data to the same structure. Not ideal but it is the most common approach I see. I like that recursion can remove this very painful step.
The most difficult part at the outset was determine when recursion was the right solution. I have a tendency to try to apply a new concept to everything. It is my way of determine the boundaries of a particular approach. I wrote quite a few instances of recursive silliness in the process. I think I have the handle on it now but I know there will be many instances of wrongly applied recursion in my future. I like the idea of drawing a picture of what I need from a program before I start typing. This seems to mitigate choosing the wrong programming construct.
So my conclusion on recursion, it is a great solution to many problems but make sure you draw a picture first!
Of course there is an imminently practical need for recursion. I come across it a lot in my day job, the need to fit everything into a pre-defined box whether it makes sense or not. How do you draw the box if you don't now how big or what shape the box is? It is nice that in programming there is a way to resolve this problem.
The key element to make this work is defining the correct base case. In learning this construct I spent a lot of time hitting the escape button while my little program went into an infinite loop. Not unlike when I started using where clauses (I still mess these up more than I care to admit). I think the key is knowing when to use recursion and when too much of something isn't necessarily a good thing (see opening statement).
As in all things it is important to know when it applies. Dealing with aggregated data is always problematic. Recursion is a great solution in dealing with data that is in a ragged hierarchy where base data is at different depths (how many levels of summation are required). One approach is to convert all of the data to the same structure. Not ideal but it is the most common approach I see. I like that recursion can remove this very painful step.
The most difficult part at the outset was determine when recursion was the right solution. I have a tendency to try to apply a new concept to everything. It is my way of determine the boundaries of a particular approach. I wrote quite a few instances of recursive silliness in the process. I think I have the handle on it now but I know there will be many instances of wrongly applied recursion in my future. I like the idea of drawing a picture of what I need from a program before I start typing. This seems to mitigate choosing the wrong programming construct.
So my conclusion on recursion, it is a great solution to many problems but make sure you draw a picture first!
Subscribe to:
Posts (Atom)