Monday, February 23, 2015

Week 6 Summary of Object-Oriented Programming concepts

For last week, a new method Tree had been lead into our world of knowledge. Also the tracking recursive functions help us a lot in coding. Mr. Heap said we have learnt all the knowledge we need in assignment 2, there is a bit regret that our team just missed 3 docstring in the last 3 functions which made TA took away 2.5 points in our total marks. However it`s good enough for me and our team will try our best in assignment 2 to get a full mark.

Summary of Object-Oriented Programming concepts

After the learning of chapter 1, as the name indicates that the object-Oriented Programming working around the objects but not the functional action. 
I`ve found some interesting graph on this website:
(www.ldodds.com/lectures/intro2java/OOP_Terms.doc)

Saturday, February 7, 2015

Week 5

Week 5
This week I did not learn so much because of the first term test was hold on Wednesday night. I took the early course which taught by Mrs. Diane but not Mr. Heap because I had to take MAT137 test that night. Mrs. Diane told us about the unit test, which we`ve learned in CSC108. She show us an example of insert_after (L, n1, n2) and run it in unit test. The function was like this:
def insert_after(L, n1, n2):
    """
    (list, int, int) -> NoneType
    
    After each occurrence of n1 in L, insert n2.
    
    >>> L = [5, 1, 2, 1, 6]
    >>> insert_after(L, 1, 99)
    >>> L
    [5, 1, 99, 2, 1, 99, 6]
    """
    
    i = 0
    while i < len(L):
        if L[i] == n1:
            L.insert(i+1, n2)
            i += 1
        i += 1

if __name__ == "__main__":
    import doctest
    doctest.testmod()

The unit test is this:
import unittest
from insert import insert_after

# Note: this test suite does not contain a complete set of test cases.
# Challenge: Extend it to the point that either you are convinced the
# function works as advertised in the docstring, or you have demonstrated
# that it doesn't.

class TestInsertAfter(unittest.TestCase):

    def test_insert_after_at_front(self):
        """ Test insert_after with one occurrence of n1 in L, at the front."""

        input_list = [0, 1, 2, 3]
        return_value = insert_after(input_list, 0, 99)
        expected = [0, 99, 1, 2, 3]
        self.assertEqual(input_list, expected)    
        self.assertEqual(return_value, None)
        
    def test_insert_after_at_back(self):
        """ Test insert_after with one occurrence of n1 in L, at the back."""

        input_list = [0, 1, 2, 3]
        return_value = insert_after(input_list, 3, 99)
        expected = [0, 1, 2, 3, 99]
        self.assertEqual(input_list, expected)    
        self.assertEqual(return_value, None)
        
    def test_insert_after_middle(self):
        """ Test insert_after with one occurrence of n1 in L, not on 
        either end."""

        input_list = [0, 1, 2, 3]
        return_value = insert_after(input_list, 1, 99)
        expected = [0, 1, 99, 2, 3]
        self.assertEqual(input_list, expected)    
        self.assertEqual(return_value, None)
        
if __name__ == '__main__':
    unittest.main(exit=False)

Unit test is not hard enough but it was always the necessary one in function testing. Wish I can get a good mark in test.

Saturday, January 31, 2015

Week 4

The assignment one was due on Thursday night and I handed it in with my workmates on time. We worked on it for more than 2 days, During we were working on it, we smashed it once because we found a extremely mistake which may ruin the game. Really, the progress was painful but we have to do it unless we will fail the first assignment. Although I was sure there must have some mistake in the program(maybe not) will pull the grade down, we were still happy because our game can run in regular way. If you are really thinking about it, I am pretty sure you will be the winner of our game. 
This is week four`s out line, The most important we learn in this week is how to use the subclass. The picture blow can tell us how subclass worked:
In assignment one, we use some subclass in it because we have to guide the function in our program. It was useful and will be the main force in future programming. Not only subclass, raise was also a new knowledge of week 4. sum_list was the new method which was telling us how computer tracing the method. Actually we can realized the answer in our mind, but we still need to know the rules and procedures of computers because we need to be a computer scientist but not a mathematician.

Saturday, January 24, 2015

Week 3

Why geeks should write?

Nowadays, the youth with clear writing style and distinct thought has become less and less, the youth who had grandiose aims but puny abilities become more common. More writing practice can give us a great help in our university life. So why should us, the geeks, need start writing our own blog now? 

Generally, writing blog have a lot of advantages. For instance, you can use your blog to record the valuable idea which was just like a spark, bright and transient. Write it down can make you keep it in mind longer. It does not matter if you forget it, you can still recheck it on your blog. Let somebody read your blog publicly can bring them more idea and thought. Also you can read their blog to absorb other idea that you have ever had before. You may find someone who have the same idea with you and in this case, you can make friend with him or her. Over the network we can find more friends, blog is one of the best idea to find like-minded friend.

Writing is in order to better thinking. Same as memorizing words, watch-only cannot memorized them very well, writing and reading are more helpful to our remember. Although the blogs are posting on the website, not on newspapers or magazines, it is still perfect because of the wide transmission. Besides, teach is the best learn. Once you find you do not know some strange question which you cannot find the answer of it in both book and asking experts. It means your friend zone is not big enough and you need to post your question online, there are more and more talent people can help you. They may teach you how to solve it and finally you learn the knowledge. 

Communicate is an extremely well self-examination. After you absorb the knowledge and solve a question that worried you a lot, you may feel happy and tell your friend who is also confused on this question or the one who is in the same level of thought with you. In fact, if you publish your idea, you must find some other different idea than you. After compared your idea with them, you may find the origin of their answer is totally different than you. So where is the difference? In further communication, both of your guys can compel other sides to give out more deep level reason. The result is both of your guys can learn more and more knowledge which is out of the origin question.

Overall, writing blog can also teach you how to continue a thing in a persistent way. It is hard for me but I will try my best to finish it.