[Tutor] Flow charts

Alan Gauld alan.gauld at btinternet.com
Thu Jan 10 10:30:19 CET 2013


On 10/01/13 02:26, Ed Owens wrote:

First, please start a new thread for a new topic, don't reply to an 
existing one. Threaded mail/news readers are not fooled by a simple 
change of subject so your post gets buried deep in an old thread.
Just create a brand new mail to the list address.
Anyway...

> 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.

Us a message sequence chart(MSC). A vertical line represents an object. 
Draw arrows between the lines to represent the messages passing between 
them. Messages correspond to function calls in procedural programming.

MSCs are a very old design tool from the communications world but 
adopted by OOP and included in UML (see below)

> 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.

OMG (Object Management Group) is a body overseeeing many things OO 
based. Design tools, integration technologies, languages  and 
specifications etc.

UML is a design language that, if used to its limit, can be used to 
generate working code. As a result it has a lot of stuff in there to 
represent fine grained detail. So yes, it is as complex as code because 
in a sense that's what it is. Graphical code.

In addition UML is designed to completely represent a large software 
system so it includes notations for designing networks and data centres 
as well as application code.

The good news is that most people don't use UML like that and only use 
about 20% of UML or less. The main diagrams you are likely to use as a 
Python programmer are class diagram, MSC, activity diagram(flow charts!)
and state charts. Focus on those areas and don't obsess on the details 
and UML becomes useful to ordinary mortals. I use UML in the v3 version 
of my tutor in the OOP topic, the examples there hopefully show how UML 
can be used even in simple designs.

> It there a technique that people use to figure out how do design OOP
> models, objects, and the information flow?

There are lots of them, that's why UML was invented to bring the best 
bits together into a single Unified Modelling Language.

But OOP is more about a different way of thinking about the problem.
You have to start thinking about objects and their responsibilities.
Objects own data and provide services. Other objects use those services 
to provide their services and so on. So we tend to get a bottom up style 
of design. Build (or select from the library) the lowest level
objects then build the next layer up that consume those. Don;t be scared 
to split objects into two(or more) if they start to get unweildy or to 
combine two (or more) if they don;t seem to have a purpose or are 
duplicating services.

CRC cards - not part of UML - are a good place to start when building 
OOP systems. A very easy technique that does not require any fancy tools.

HTH,

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list