I more than half way through the book "Python programming for the absolute beginner" 2nd Ed. and things are really starting to get hairy. The book has me to write some code just before or after explaining each part. But I have to really concentrate on the paragraph I'M reading and jump back a few pages to see how and what part my code is doing in another part of the program. And I still sometimes get very frustrated and confused. Classes, Objects, Attributes, Constructors, privet & public??? I think they need to brake programming books into at least two parts. The first without any OOP but that goes all the way through what it take to write programs, and a second one that teaches OOP and builds from the last book.
Does anyone have any good suggestions how how to learn this material? I feel like I need to see all the code beside the output/end result with lines going everywhere to I can follow every line of code.
I'M just tired of getting this frustrated. I gave up on C++ a long time ago. I think I gave up when I got to pointers but I know I was long lost before that. Thanks.

Edited 7 Years Ago by lewashby: n/a

Here is a quick example of a class and some attributes:

You can see A and B are unique entities, but use a common class.

# A class
class example(object):
    attribute1 = 1
    attribute2 = 2
    
    def example_method(self):
        return 'method function'


A = example()
B = example()


# Some output:
>>> A.attribute1
1
>>> B.attribute1
1
>>> A.example_method()
'method function'
>>> B.example_method()
'method function'
>>> A.attribute1 = 2
>>> A.attribute1
2
>>> B.attribute1
1

Object oriented programming is designing and coding software based on objects. Classes are a conceptual abstraction (a way of representing a complex idea with a simpler idea) that have properties. Classes serve as blueprints for the creation of objects. Objects are the actual items in a program. A object's properties are its attributes, which are characteristics of the object, and its methods, which represent things the object can do or how it can interact with other objects. Objects have the ability to message other objects. This is the way an objects methods are invoked or data is sent to the object.

Another object oriented programming feature is inheritance. Classes can inherit properties and methods from other classes. This allows for specialized objects that have their own attributes as well as general attributes that they share with other objects.

Object oriented programming supports hiding the complexity of a method or object with abstraction and encapsulation. Using abstraction, a programmer can focus on interfacing working components instead of focusing on the internal workings of each component, and using encapsulation, a programmer can use encapsulation to ensure that only the appropriate objects can message an object.

The final major feature of object oriented programming is polymorphism. Polymorphism is the ability of an object to respond to method calls using its own appropriate method.

I'll answer questions now.

If you are not feeling confident in the material you have learned up to this point. Then start writing lots of code to practice those parts until you understand them as well as you understand english, then move on to the next concept. Sometimes when you are in a hurry to learn you wind up frying your brain, take a break for a few hours and come back to it. Alot of times you will find by that time you have processed the information and it might all of the sudden make perfect sence to you.

This article has been dead for over six months. Start a new discussion instead.