This week we got our test and SLOG marks back. The test went okay, although not exactly great--I corrected one of my answers into a wrong one before handing it in thinking it's a better way to answer the problem, which doesn't end up being a smart move.
The mark I received for the SLOG is also pretty bad. I'm starting to get confused about the whole rubric for SLOG, so I'd appreciate it if the TA who marked my SLOG would give me a bit more feedback than "be more consistent" and "put more insight into problems or concepts encountered in the course" as that is pretty vague.
We've been learning about trees, which is another type of object based on queues that exists and becomes useful thanks to the idea of recursion. Assignment 2 is also posted.
We are supposed to talk about object-oriented programming this week.
During the first few weeks of this course, we investigated deeper into classes, which is python's version of object-oriented programming.
The concept of classes lets us define types of objects with whatever attributes we want them to have. Obviously this simplifies our code for programs, as functionally similar objects can be grouped into the same class which allows for reuse of code, and it's much easier to work with a class of objects defined as "dictionary with keys as strings and corresponding values as tuples of strings and lists and integers" than to define the abomination as such every time one encounters it. This also allows for simultaneously having multiple objects of a class, called instances of the class, and operating upon them using the same functions or methods.
Methods act like general functions that we've worked with in CSC108, but are defined within a specific class and operates on objects of the class. It can directly access the attributes of an object and work on such, but is otherwise pretty similar to general functions. The introduction of classes also expands the scope of the latter though, as classes of objects can be passed as parameters of functions, so functions can define interaction between objects of different classes.
Inheritance further classfies objects into subclasses of classes (so should subclasses be called orders or should superclasses be called phyla?). The objects in subclasses have some common attributes and methods covered in the superclass, and each subclass provides more detailed attributes and methods--often partially inherited from the superclass by declaring such--for the objects. Inheritance enables more reuse of code, as functionally similar types of classes of objects can also be grouped together and operated upon using the same code, only slightly changed in the specification for each subclass.
Right now the idea of classes feels mostly like an organization technique, as it organizes objects into classes and subclasses, and allows functions to be defined on the group of objects instead of individual objects themselves. As pointed out repeatedly, it greatly simplifies code, and allows for things that's difficult (or perhaps impossible) to be done with what we've learned before, so I suppose it's quite useful. We'll see what it can do.
No comments:
Post a Comment