2015年2月23日星期一

Week 6: Object-Oriented Programming

To be honest, I am really not good at summary of concepts and ideas. Moreover, I only have a vague understanding about what Object-Oriented Programming is. However, based on what I have been working on through these few weeks, the building of data structure, such as a class, and the fucntions that data structure can work with, which is called the methods, is usually a pretty clear task. As far as a programmer has a complete plan of what the required information and the form of manipulating and modifying on it, the process of actually writing the codes is not hard anymore. Therefore, the most important thing is to make it clear to oneself that what the expected product is, before actually start to program.

Consequently, it is important to think in the way that computers do. Do it frequently while you are writing the codes help you find some flaws you do not notice before and bring you better codes that reach your goal. In short, keep asking yourself what you want and do the codes you have written reach it. For instance, when building a __init__ method for a class, I always ask myself "What are the necessary property of this class? What does this class mean?" and this will lead me to the constructions of the attributes. Then it becomes a problem of what the cases the class instances are expected to deal with, which will make other methods.

Eventually, you will have codes that reach your expectation, but there are still things to do. After making sure there is no more bugs, ones can always think about how they can improve their codes. Some good questions are, what lines of the codes are possible to be repalced by shorter codes? What kind of change or new codes will make the program not only reach the goal but also cover more unexpected situations? There are always place to develop.

没有评论:

发表评论