Weak 4 (intentional)
It is currently Friday, January 31st, as in the last day of January, as in there are no more days left in January, so it's now February and time for exam season to start and never end until May *cry*. It's a good day to start indenting paragraphs for my SLOG with 4 spaces like a boss. It's also the start of a new Lunar Year, the year of the horse. I guess I should put my hoof down and stop horsing around in school.
This week's exercise was due yesterday. My program worked fine when I tested it, so I wrote them docstrings and submitted both parts. And then I just realized that I forgot to indent my docstring for E2b, which prevents the program from compiling. I hope I don't end up getting a 0 for that...
I'm actually having trouble following what goes on in class. Maybe signing up for the evening class right after my anatomy practical wasn't such a good idea, since that always gets my brain fried just in time for lecture. Fortunately, the content isn't super hard yet, also Google/online Python documentation/Stack Overflow exist which together will save my life as I sit down, write code for 5 minutes, then work out error after syntax error for an hour (are there any questions that HAVEN'T been asked on stack overflow?). On the bright side, my code is looking a lot cleaner and more organized than the embarrassments to humanity I've tried to pass off as scripts at work (I 'work' for free in a human psychology lab). Hopefully I will have reason to sing further of the joys of Object-Oriented Programming in the coming weeks.
Friday, 31 January 2014
Object-Oriented Programming
Like Java, Python is an object-oriented language, which allows the creation of abstract, user-defined data types to store information and useful built-in functions. Being able to define concepts, name them, and define the information stored within them helps a lot with making code easier to read and understand, which in turn will help the programmer himself understand his own code by defining it in his own terms.
This allows the existence of more complicated programs in the same way that going to school makes you smarter. Teachers at school may define a complicated theory or mathematical concept by explaining the reasoning behind them in detail, then they will condense all of that reason under a name or formula. Taking all the reasoning behind the theory and condensing it under one name allows you to 'chunk' it into a piece of data that can be operated on - because a name will take much less of your attention span to think about than a full theory, you free up more of your mind to operate on that name in a broader context, which allows you to produce more complicated ideas.
Object-oriented code will look much the same way. Instead of having one gigantic block of text splatted onto one text file, you can now package smaller data types into single words or names, that are then associated with an underlying data type. For example, instead of looking at the size, speed, color, fuel capacities, models, etc. of each car laid out on a gigantic amalgamation text on a road, you may look at a road with many 'car' objects racing along, and then look specifically at one 'car' object to find all the data associated with it.
It is this packaging of complicated data types under a name, or 'object,' that makes object-oriented programming so powerful.
Like Java, Python is an object-oriented language, which allows the creation of abstract, user-defined data types to store information and useful built-in functions. Being able to define concepts, name them, and define the information stored within them helps a lot with making code easier to read and understand, which in turn will help the programmer himself understand his own code by defining it in his own terms.
This allows the existence of more complicated programs in the same way that going to school makes you smarter. Teachers at school may define a complicated theory or mathematical concept by explaining the reasoning behind them in detail, then they will condense all of that reason under a name or formula. Taking all the reasoning behind the theory and condensing it under one name allows you to 'chunk' it into a piece of data that can be operated on - because a name will take much less of your attention span to think about than a full theory, you free up more of your mind to operate on that name in a broader context, which allows you to produce more complicated ideas.
Object-oriented code will look much the same way. Instead of having one gigantic block of text splatted onto one text file, you can now package smaller data types into single words or names, that are then associated with an underlying data type. For example, instead of looking at the size, speed, color, fuel capacities, models, etc. of each car laid out on a gigantic amalgamation text on a road, you may look at a road with many 'car' objects racing along, and then look specifically at one 'car' object to find all the data associated with it.
It is this packaging of complicated data types under a name, or 'object,' that makes object-oriented programming so powerful.
Subscribe to:
Posts (Atom)