3 ms·
Is OOP paradigm broken?
Can Python and Google App Engine experts take a look at these questions at Stackoverflow. (Links in comment) The whole thing makes me hate OOP. It may be my fault but a simple operation of writing a list to datastore and fetching it and printing the content of the list turns out to be so far impossible. Your comments would be greatly appreciated. I think the OOP paradigm is broken but that may be my own ignorance. Thanks.
- zeynel1 16y agohttp://stackoverflow.com/questions/4063767/what-does-fetch-fetch-in-gae http://stackoverflow.com/questions/4063767/what-does-fetch-f... http://stackoverflow.com/questions/4061986/is-there-a-way-to-print-the-elements-of-a-list-object-in-python http://stackoverflow.com/questions/4061986/is-there-a-way-to... http://stackoverflow.com/questions/4060924/google-app-engine-fetch-and-print http://stackoverflow.com/questions/4060924/google-app-engine...
- po 16y agoI'm not sure how your troubles here equate to a criticism of OOP. What language paradigm are you most familiar with? Procedural? Functional?
- zeynel1 16y agoI don't know enough of neither to give you a good answer. But there were two solutions to my question in Python group that helped me understand the issue: http://groups.google.com/group/comp.lang.python/msg/edf12c874e7b2733?hl=en http://groups.google.com/group/comp.lang.python/msg/edf12c87... http://groups.google.com/group/comp.lang.python/msg/439996871519514e?hl=en http://groups.google.com/group/comp.lang.python/msg/43999687... I would like to ask you , if you get a chance, to explain how the following situation is handled in procedural and functional languages: If you want to control how an object is represented when you put it in a template you should define a __str__ method: class Rep(db.model): # Properties ... # Representation def __str__(self): return "\n".join(self.replist) and You can apply a list method to a list object by actually getting the list object. You can't call a list method on a query object or a Rep object. Rep() = Rep object Rep.all() = Query object list(Rep.all()) = List of Rep objects. list(Rep.all())[0] = A single Rep object list(Rep.all())[0].replist = A list So once you have that last step, you have a list. Which you can manipulate like any other Python list. Thanks.
- po 16y agoPython can be used to write procedural, functional or OOP. It's a multi-paradigm language which means it's up to you to give the code the structure you think is best for the problem. For instance wikipedia has an example of the same problem written in python as functional or imperative style: http://en.wikipedia.org/wiki/Functional_programming#Coding_styles http://en.wikipedia.org/wiki/Functional_programming#Coding_s... If you're an absolute beginner to programming you should study a bit: http://learnpythonthehardway.org/ http://learnpythonthehardway.org/ If you've done some programming in the past, you should still study the fundamentals of the language you're using. Buy or borrow a python reference book and read through it. It looks to me like you're getting frustrated with not knowing what return types you're getting out of methods and functions. A reference book will help with that. You should also understand python's way of using duck typing: http://en.wikipedia.org/wiki/Duck_typing#In_Python http://en.wikipedia.org/wiki/Duck_typing#In_Python