By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,345 Members | 1,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,345 IT Pros & Developers. It's quick & easy.

Cause for using objects?

P: n/a
Given:
[{"mugshot": "nw_gradspeaker4_0608", "width": 67.0, "height": 96.0}, \
{"mugshot": "nw_gradspeaker2_0608", "width": 67.0, "height": 96.0}, \
{"freehand": "b1.developreport.0614", "width": 154.0, "height":
210.0}, \
{"graphic": "bz_cafeparadiso_0613", "width": 493.0, "height": 341.0}]

Return:
{"mugshot1": "nw_gradspeaker4_0608", "mugshot1.width": 67.0,
"mugshot1.height": 96.0,\
"mugshot2": "nw_gradspeaker2_0608", "mugshot2.width": 67.0,
"mugshot2.height": 96.0, \
"freehand1": "b1.developreport.0614", "freehand1.width": 154.0,
"freehand1.width": 210.0, \
"graphic1": "bz_cafeparadiso_0613", "graphic1.width": 493.0,
"graphic1.height": 341.0}

I'm trying to teach myself some OOP. Does grinding the Given above into
the Return seem like a good candidate?

John H.
Eugene, Ore.
jheasly at guardnet dot com

Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
John Heasly wrote:
Given:
[{"mugshot": "nw_gradspeaker4_0608", "width": 67.0, "height": 96.0}, \
{"mugshot": "nw_gradspeaker2_0608", "width": 67.0, "height": 96.0}, \
{"freehand": "b1.developreport.0614", "width": 154.0, "height":
210.0}, \
{"graphic": "bz_cafeparadiso_0613", "width": 493.0, "height": 341.0}]

Return:
{"mugshot1": "nw_gradspeaker4_0608", "mugshot1.width": 67.0,
"mugshot1.height": 96.0,\
"mugshot2": "nw_gradspeaker2_0608", "mugshot2.width": 67.0,
"mugshot2.height": 96.0, \
"freehand1": "b1.developreport.0614", "freehand1.width": 154.0,
"freehand1.width": 210.0, \
"graphic1": "bz_cafeparadiso_0613", "graphic1.width": 493.0,
"graphic1.height": 341.0}

I'm trying to teach myself some OOP. Does grinding the Given above into
the Return seem like a good candidate?


If that's all you're doing, and you must use that output format, then
I'd say no. OOP is not a panacea.

Now if you're going to *do* something with the return information, then
I would say yes. But in that case, don't use a single dict as a return,
use objects.
--
Michael Hoffman
Jul 19 '05 #2

P: n/a
>>>>> "John" == John Heasly <jh*****@guardnet.com> writes:

John> Given: [{"mugshot": "nw_gradspeaker4_0608", "width": 67.0,
John> "height": 96.0}, \ {"mugshot": "nw_gradspeaker2_0608",
John> "width": 67.0, "height": 96.0}, \ {"freehand":
John> "b1.developreport.0614", "width": 154.0, "height": 210.0}, \
John> {"graphic": "bz_cafeparadiso_0613", "width": 493.0,
John> "height": 341.0}]

John> Return: {"mugshot1": "nw_gradspeaker4_0608",
John> "mugshot1.width": 67.0, "mugshot1.height": 96.0,\
John> "mugshot2": "nw_gradspeaker2_0608", "mugshot2.width": 67.0,
John> "mugshot2.height": 96.0, \ "freehand1":
John> "b1.developreport.0614", "freehand1.width": 154.0,
John> "freehand1.width": 210.0, \ "graphic1":
John> "bz_cafeparadiso_0613", "graphic1.width": 493.0,
John> "graphic1.height": 341.0}

John> I'm trying to teach myself some OOP. Does grinding the Given
John> above into the Return seem like a good candidate?

John> John H. Eugene, Ore. jheasly at guardnet dot com

If your table of photo data has several types of photos, and you find
yourself saying

if is_mugshot:
#something
elif is_freehand:
#something
else:
#something

then OOP will help organize your code.
If it's just a flat table of data, and you lay down a deeply nested
hierarchy of stuff, you may have over-engineered.
Best,
Chris
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.