To be completely honest, I still don't understand too well about Object-Oriented Programming. But I will try my best to demonstrate what it is and its concepts.
I believe Object-Oriented programming is basically programming on objects. Objects represents both data type and the functions to interfere with the data type. For instance, when we design a class, we can design the data type of the class, as well as the set of methods to perform in the class.
It is considered an object because it has both data and a function, thus a complete object. For instance, we can create the object called 'book', which has data type of string, and takes methods such as 'write' or 'read'. After defining, 'book' will have both a type and a method, which allows it to be considered an object in nature.
We can also interact objects with other objects. Perhaps we can link our object 'book' with another object called 'novels'. In this case we can make our object inherit certain methods from the other object, which allows them to interact.
In my opinion, Classes and sub classes are most important elements of OOP. This is because they allow the programmers to actually create the object/module, and combine them to create a functioning program.
2015年2月16日星期一
2015年2月9日星期一
CSC148 WEEK 5
I actually wrote about recursions last
week, but I suppose I will write it again just to meet up with the topic. The
concept of recursion is very interesting and useful. By allowing functions to
call itself, many sophisticated problems can be solves this way.
The most astonishing fact I find about recursion is that it is able to conduct an infinite number of computations with a finite statement.I also find it astonishing that how recursion is able to solve an apparent logical paradox. The paradox is that whether the method is defined before it is called within himself? Or does it exist after the return function?
For instance the method sum_list(L) is written as follows:
def sum_list(L)
if isinstance(L, list):
return sum([sum_list(x) for x in L])
else:
return L
So is the method sum_list(L) defined in the second line of the code when it is called? If it's not then why wasn't the function producing an error? If it was then what is sum_list before it is even defined?
It is interesting how the computer was able to operate under such paradox, and still produce a result.
The application of recursion is almost everywhere in the world of computer science. For instance, we are about to learn the class tree which will extensively use recursions. I am looking forward to that!
Many of my peers found recursions to be hard. I find it easy. This is perhaps because I have strong mathematical background, and recursion is a concept that is more closely related to logic than programming. The harder part for me is probably the programming part. I am falling behind in programming because I didn't study hard for the first couple weeks, and I better catch up soon!
The most astonishing fact I find about recursion is that it is able to conduct an infinite number of computations with a finite statement.I also find it astonishing that how recursion is able to solve an apparent logical paradox. The paradox is that whether the method is defined before it is called within himself? Or does it exist after the return function?
For instance the method sum_list(L) is written as follows:
def sum_list(L)
if isinstance(L, list):
return sum([sum_list(x) for x in L])
else:
return L
So is the method sum_list(L) defined in the second line of the code when it is called? If it's not then why wasn't the function producing an error? If it was then what is sum_list before it is even defined?
It is interesting how the computer was able to operate under such paradox, and still produce a result.
The application of recursion is almost everywhere in the world of computer science. For instance, we are about to learn the class tree which will extensively use recursions. I am looking forward to that!
Many of my peers found recursions to be hard. I find it easy. This is perhaps because I have strong mathematical background, and recursion is a concept that is more closely related to logic than programming. The harder part for me is probably the programming part. I am falling behind in programming because I didn't study hard for the first couple weeks, and I better catch up soon!
Also, I find the test to be particularly hard. I came from the evening session and everyone said it was hard. Mean while the morning session thought it was easy! This is so unfair!!
订阅:
博文 (Atom)