Cause for using objects?

J

John Heasly

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
 
M

Michael Hoffman

John said:
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.
 
C

Chris Smith

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,252
Messages
2,571,267
Members
47,908
Latest member
MagdalenaR

Latest Threads

Top