[Tutor] Code critique please (OOP strategy)
Roeland Rengelink
r.b.rigilink@chello.nl
Tue, 01 Jan 2002 11:53:26 +0100
Hi Timothy,
You have a working program and a feeling that it could be improved. This
is what refactoring is all about. A great page giving a detailed example
in Python (translated from the example in Java from the Refactoring book
by M. Fowler) can be found at:
http://www.hiper.com.br/python/refactor/
I'm sure you'll recognize several points from your own code.
Hope this helps,
Roeland
Timothy Wilson wrote:
>
> Hi everyone,
>
> I've done an object-oriented version of the stock portfolio tracking
> program I assigned to my students
> (http://www.isd197.org/sibley/cs/icp/assignments/portfolio_html). I plan
> to use this for comparison when we introduce OOP after the Winter Break.
>
> My version is available at http://www.qwerk.org/tim/
>
> I'd like to get some feedback on the code. I've created two classes
> here, Portfolio and Stock. I'm specifically interested in the way the
> main() function interacts with the class methods. I've got a strange mix
> of program logic stuck in a series of elif statements and in the class
> methods themselves. Something doesn't seem right about it.
>
> Is there a way to create a Menu class that would help?
>
> -Tim
>
> --
> Tim Wilson | Visit Sibley online: | Check out:
> Henry Sibley HS | http://www.isd197.org | http://www.zope.com
> W. St. Paul, MN | | http://slashdot.org
> wilson@visi.com | <dtml-var pithy_quote> | http://linux.com
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
--
r.b.rigilink@chello.nl
"Half of what I say is nonsense. Unfortunately I don't know which half"