Thursday, 26 February 2015

Summary Of Object-Oriented Programming

Over CSC148 so far, I learned a lot of object-oriented programming concepts that I did not learn about in high school and programming on my own time. However, I did learn most of the simpler concepts in CSC108.

Objects are the most basic unit of object oriented programming. Objects are made up of data and functions that operate on data that are bundled as an unit. It is a unique instance of a data structure that's defined by its class. An object comprises class variables, instance variables and methods. A class variable is a variable that is shared by all instances of a class. Class variables are defined in a class. A instance variable is a variable that is defined inside a method and belongs only to the current instance of a class. Both these variables can be used in a method to adjust values and to return values. A method is a function that is defined in a class definition.

Classes were gone over in class too. When you define a class you define the instructions for an object, a python class has exact specifications. Classes may contain variable definitions and methods, or subroutines that can be run by the corresponding object. To create a class you write "class InsertNameHere():" and from there you can add methods to add additional function. The professor also taught inheritance. One of the most useful aspects of object-oriented programming is code re-usability. As it's name suggests inheritance is the process of forming a new class from an existing class that is from the existing class called as base class, new class is formed called as derived class. To declare that we are extending a super class we write "class NewClass(SuperClass):." We can also add methods and attributes to specialize the class. The base class is basically the parent and the derived class is the child.

Thursday, 12 February 2015

OOP Concepts

Over this course I learned a lot of object-oriented programming concepts.

Firstly, I will talk about objects. Objects are the basic unit of object oriented programming. Objects are data and function that operate on data that are bundled as an unit.

I learned about classes also. When you define a class you define a blueprint for an object, a python class has exact specifications. Classes may contain variable definitions and methods, or subroutines that can be run by the corresponding object. To create a class you write "class NewClass():" and from there you can add methods.

The class was taught inheritance also. One of the most useful aspects of object-oriented programming is code re-usability. As the name suggests inheritance is the process of forming a new class from an existing class that is from the existing class called as base class, new class is formed called as derived class. To declare that we are extending a super class we write "class NewClass(SuperClass):" we can also add methods and attributes to specialize the class.

I found all of these concepts very interesting and fun to learn.

Thursday, 5 February 2015

Tracing Recursion

This week in class we learned how to trace recursion. At first I thought it would be really complicated because I found it troubling to write recursive code in High school. But, after tracing code a couple times it turned out to be pretty easy. The thing that really helped was drawing a diagram and writing out the code that it goes through step by step.

Tracing the code during the lab was pretty simple too. Writing out all the steps on paper really helped too. Also I plugged in values of recursive calls that I have already solved.

The class also learned how do trace recursive functions involving the Tree ADT. At first I thought it would be really complicated because I didn't really know what Trees were, but after thinking about it a bit more I was a lot easier to understand. It turned out it wasn't as complicated as I thought it was. The main thing that really helped was drawing the Tree out, then actually tracing it.