Changes

Jump to: navigation, search

Rchan sandbox

1,556 bytes added, 13:26, 3 November 2019
Overview
: Object-oriented programming is conceptually one level higher than simply structured programming style as you've experienced in Bash or C. In this lab, we're going to study some features of classes and programmer-defined objects by looking at a few object-oriented programming examples using the Python language.
: First of all, let's review some of the basic concepts about class in Python.
:: A class is a type, a description of a thing, the definition of what it should look like (data attributes) and what we can do about it (function attributes).
:: An object is an instance of a class, an individual entity described by a class, a specific stuff with properties (aka attributes) defined by a class.
:: Type exact definition of the type and what you would expect to store in objects of that type is up to you - the programmer. You would want to design your classes so that you can manage data in your program/script/application as easily as possible.
:: A few points about the mechanics of implementing classes:
:::* A class name typically starts with a capital letter, and object names should start with a lowercase letter.
:::* Just as you can define a function in a separate python file from where you use it - you can do the same when defining a class. In fact, it's even more common with classes since your're more likely to need to use them in multiple places.
:::* The names of the class files are by convention all in lowercase and short - but that's just because most programmers are lazy typists. Feel free use longer file name so you can tell what they are without opening them.
:: As you try to design the classes, you will quickly realise that there is a potentially infinite number of properties (attributes and methods) that any class can have. What you choose to include in your class definition should be guided by what you intend to do with it.
==Reference==
1,760
edits

Navigation menu