[Tutor] creating classes while coding

Japhy Bartlett japhy at pearachute.com
Mon Feb 21 03:52:33 CET 2011


I think OOP makes it easy for new programmers to set up programs, and
it can make for some pretty neat English looking code, but a more
functional approach generally makes for much leaner, faster performing
code.

I find them most useful when you have several functions that might
need to share some variables that the rest of the program doesn't care
about, especially if you might need to load that information at
run-time.

Just my two cents though, this is mostly a personal style thing, if
your code works. :)

- Japhy

On Sun, Feb 20, 2011 at 9:36 PM, Bill Allen <wallenpb at gmail.com> wrote:
> On Sun, Feb 20, 2011 at 19:59, Alan Gauld <alan.gauld at btinternet.com> wrote:
>>
>> "Bill Allen" <wallenpb at gmail.com> wrote
>>
>>> However, I do wonder a bit about the practice I have seen of some
>>> Python programmers to implement relatively short bits of code, that would
>>> be
>>> quite simple using functions and procedural code, with classes.
>>
>> OOP is often overkill, but if its the normal way of programming
>> - and for many recent students its all they get taught - then using
>> classes is the natural approach. "When all you have is a hammer
>> everything looks like a nail..." However, there may be good reasons.
>> Classes make reuse easier, in general, than functions. So if the
>> task may become a building block for a future project, or even
>> an extended version of the current one then building a class
>> makes sense.
>
> Thanks for the feedback.   Particularly when it comes to reuse of code, I
> can see it could be worth my time to look into designing classes a bit more.
>   I am starting to write enough code now that I am beginning to reuse some
> bits of it regularly.  I have not yet taken the reuse of code further than
> packaging up some functions into modules.  I'll look into this further.
>
> You mentioned the programming methods being taught programming students
> nowadays.   That OOP is a basic programming method being taught sure leaves
> me in the dust.   The last formal programming class I took in college was
> way back in the early 90s and it was to learn IBM 370 Assembly Language.
> OOP was not only not on the radar, it was not even in the same solar
> system!    :-D
>
> feeling kinda old, and I am not all that old...
>
> --Bill
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>


More information about the Tutor mailing list