2015年2月15日星期日

CSC148 SLOG for week6

This week we were asked to make a summary of Object-Oriented Programming(OOP). My first impression on OOP was that it means ‘class’. However, it has a much more formal and detailed definition on wikipedia: Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which are data structures that contain data, often known as attributes; and code, often known as methods. In CSC108, most of time, we were using procedural programming, another paradigm. While procedural programming pays attention to writing procedures(or functions) implement on data, OOP mainly focuses on objects which contain both data and functions.

There are several essential concepts covered by OOP:
Objects: Instances of classes. Simply speaking, it stores properties of a thing in a class to some  location.
Class: A blueprint of a program. It’s like to describe something you want in your own way. To make a class, it’s important to form a delicate structure first. Given an ultimate goal, you need to figure out attributes(usually noun) and behaviors(usually verbs) and assign accurate types for them to accomplish your goal in a better way.
Methods: Operations on objects. You can change some of properties of an object through some methods you create by yourself.
Inheritance: Preserve properties. When you are creating a subclass, you can use inheritance to maintain the same properties between superclass and subclass which can simplify your code to some extent.

没有评论:

发表评论