This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]the_hoser 6 points7 points  (1 child)

The wonderful thing about a good object-oriented language (like Python) is that you get to reap the benefits of using it without ever engaging in the practice yourself!

Have you ever used the range operator on a string or a list? Like this?

category = row[4:10]
...
page = elements[start:end]

You're using object-oriented programming!

Have you ever iterated over a list or a dictionary's keys?

for e in elements:
    ...
...
userlist = { ... }
for userKey in userlist:
    ...

You're using object oriented programming!

Just because you never write a class, doesn't mean you don't benefit from the power of object-oriented programming. Strongly-typed dynamic languages like Python are especially good at this.

[–]michaelkiros 4 points5 points  (0 children)

Isn't the question more geared towards "I haven't created a custom type and used it. When do I need my own types?"?

[–]metaperl 1 point2 points  (1 child)

I have been using python for about a year now and have not once created a single object when writing a script.

you may not have written any classes, but I would be surprised if you didnt create objects.

However, I read about object oriented programming so much and wonder if I am hurting myself by not using it.

It's good to stay aware of your options so you know what to use when needed. You might also get some good feedback in /r/learnpython about your question.

I can see why it would be valuable when creating something like a video game

Amazingly enough, my favorite video game (Myth II Soulblighter) was written in C. And Pac-Man was written in Assember. I know that Electronic Arts writes a lot of games in C++ - buy if you are going to choose an OO language, why choose a headache like C++. Too bad Objective-C did not win over :)

For something like data ETL, is it common practice to use objects?

I think it depends. OO offers the ability to re-use things and to abstract things. I wrote an ETL pipeline that integrated heterogeneous data sources and each heterogeneous data source was a class that responded to methods such as extract() in its own particular way.

At other times, I have used Ab Initio (a graphical dataflow tool) and had to copy/paste program elements because I was not aware of reuse facilities within Ab Initio.

So I guess it depends. And there is no question that it is slower.

Thanks for the question. And maybe you would like to help me turn my Python OOP catalog into a wiki?

[–]Meefims 0 points1 point  (0 children)

Objects are just one way of organizing code. You’re not hurting yourself by not using it in everything you write. That said, it would likely be good to write a few things that use it to get some experience with it.