This was the first week of CSC148. We were all excited to start the course and got a warm welcome by professor Diane Horton. I found her very passionate about teaching CSC148. We were introduced with the course outline and syllabus. Then we discussed about Object Oriented Design. We did a short CSC108 basics recap as in string concatenation, lists, checking equality and checking types of data. Then we started designing classes, but before this we used decision analysis to decide for class name using nouns, methods using verbs, attributes using less common nouns. Then followed design recipe to write methods. . We learned about two kinds of comparisons that is with 'is' and '=='
and learned the difference between two. In first week I got recap and quick recap of some topics from 108 with a prospective of a different professor so it made me more confident with the topics I was unsure about. In 108 I started coding in python using design recipe and then suddenly left it when I felt comfortable with it but 148 made me use design recipe again, it showed how design recipe make it easier to design functions and programs.
WEEK 2 - January 12th - January 16th
Second week of CSC148 came with a bunch of new special methods that is__init__() to initialize attributes, __str__() to return a string representation of self, __repr__() to return a string representing self that produces an equivalent python object when evaluated in python, __eq__ to check equality of two objects when compared using '=='. We learned about ADT's like stack and learned about it's push, pop and is empty operations We also learned about client code and interface which made us realize we can't go back and change our docstrings and the tasks our methods performs as billions of clients are using our user interface. This also raise a problem that clients code see and modify our variables, which we tend not to happen. So then we came up with a solution of using property mechanism of python to resolve the issue which we planned of discussing next week.We also had our first lab were we wrote a RaceRegistry() to register runners according to speed category. we had methods to get the category, to get runners according to category and method to register runners. The main concept or the idea which I got confused was the word self, why was it required but all doubts were gone when I started playing with my code, that is trying working without self or with different names so I learned the meaning of self in relevance to classes. __repr__() was something I got but i didn't I understand why was it required until I researched and learned that it is used by web developers.
WEEK 3 - January 19th - January 23th
Third week of CSC148 we were provided with the solution raised in week3 with help of property mechanism. We defined methods set_x() and get_x() to prevent the attributes from being modified and changed. We starting defining parent class employee and then created subclasses HourlyEmployee and SalariedEmployee which inherited methods and attributes from parent class. Then we realized there were some methods that could not be implemented in parent class as they were specific to different subclasses so defined those methods in parent class and raised exceptions using raise Exception(' Defined in a subclass'). This made us realize the power of inheritance and we traced inheritance using some code to learn the idea better. We also also learned some cool python features namely list comprehensions, class zip and function all. In the lab we made a class GradeEntry, LetterGradeEntry, NumericGradeEntry which involved the use of inheritance. One small phrase which I made to learn inheritance was that the child always knows more than the parent and the each child has same features of the parent but in addition its own specific features.
WEEK 4 - January 26th - January 30th
What we learned in week 4 was a completely new topic recursion. That is calling a function within itself. It came as a surprise that such thing can happen and it was hard to believe before we actually traced after tracing we got a sense that it is possible. This is also involved use of list comprehensions which we learned earlier. I also learned a thing myself after the lecture and lab that the functions written using loops are long but the same function can be reduced using recursion. This is the code for my lab03 the same function is written using seven lines with loop and only three lines using loops. So this gives me a reason why recursion is a better alternative.