[Tutor] LCM revisited + OOP

Ray Jones crawlzone at gmail.com
Wed Nov 28 02:13:52 CET 2012


Part I
I am a good way through MIT's Introduction to Computer Science and
Programming as offered through edX. I'm not certain I'm going to pass
the course this first time through, the major hangup being the
understanding of OOP.

Part II
When the LCM thread came through, I wrote some quick code do the
computation. I began by creating a function that generates a list of
primes and reversing the list high to low. Then I created a recursive
function to find the prime factors for each of the numbers and
manipulated the results to the LCM.

What do these two things have to do with each other? I can see some of
the vast power of OOP. Unfortunately I can't see when or why I would
create objects in my everyday programming. So I went back to look at my
LCM code to see if there a way to create better code by using OOP rather
than the functions I used. I can't see a better way. I know I can use
OOP - I just don't see how setting it up with a couple of classes would
make it simpler or better than the non-OOP way.

I'm not including code because I'm more interested in understanding the
whys and wherefores of using OOP vs. not using it than in receiving help
with my specific code. (And I'm not a particularly fine coder to begin
with... ;) ).


More information about the Tutor mailing list