On 01/09/2013 09:26 PM, Ed Owens wrote: > I'm working my way through Chun's book "Core Python Applications > Programming" and can't get one of the examples to actually work. In > trying to analyze the problem (good learning approach) I had troubles > understanding the interactions between the two classes of objects. As > an old FORTRAN programmer, I picked up my pencil to flowchart the > code, then realized I didn't know how to flowchart an OOP. > > Google led me to UML (Unified Modeling Language) and OMG (apparently > Oh My God!!!). Looks more complicated than the code I'm trying to > understand. > > It there a technique that people use to figure out how do design OOP > models, objects, and the information flow? > > Thanks for helping a newby. > Ed > ________
You're probably making it more complicated than it needs to be. A class is simply an organized way to associate a collection of data, with functions (methods) that operate on that data. You instantiate the class one or more times to create one or more objects. And when you invoke the method on a particular object, it has access to all the data in that particular object. Many times the class represents a bunch of data that is analogous to real life information. So a class might name a natural collection, like a person, and the data members of that class are attributes that exist for all persons, but have different values. So you might have an attribute for hair color, value brown, and an attribute for height, value 68 inches. A separate instance describing a different person would have the same attributes, but different values for them. A method on such a class is something that affects one or more attributes, or that returns information derived from one or more attributes. For example, the die() method might change the hair color attribute. Many times the class is more abstract than that, but the attributes still should be related to each other in some useful way. So a file class represents a file on disk, and contains attributes like filename, seek-position, mode, and buffer, and has methods like read, write, seek. HTH. -- DaveA _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor