Re: convert string to object?
Re: convert string to object?
- Subject: Re: convert string to object?
- From: "Janice M. Cheung" <email@hidden>
- Date: Tue, 02 Dec 2003 10:05:40 -0500
Thanks very much for your tips! I've made the adjustments as you
suggested. You've helped
save this befuddled programmer from fumbling even further into the
depths of development confusion.
Happy Holidays!
Janice :-)
Chris Hanson wrote:
On Dec 1, 2003, at 12:17 PM, Janice M. Cheung wrote:
values = (NSDictionary)array.objectAtIndex(i);
obj = values.objectForKey("DEPARTMENT_NAME");
strDeptName=obj.toString();
allDeptName.addObject(strDeptName);
A few tips from the Coding Style Police.
WebObjects builds heavily on Key-Value Coding, which relies on certain
naming conventions being followed. Specifically it relies on
smalltalkStyleNaming, where identifiers are mixed-case using internal
capitalization and start with a lower-case letter (possibly with a
leading underscore).
So for the above, I'd try to avoid using dictionaries with keys like
"DEPARTMENT_NAME" because it makes it harder to switch to using real
objects and accessing them via Key-Value Coding. So instead of
values.objectForKey("DEPARTMENT_NAME") I'd use
values.valueForKey("departmentName") and adjust the rest of my code to
match.
String qualifier;
qualifier = "institution.institutionLabel = ' " +
m_InstSelected + " ' and departmentName = ' " +m_strDvDeptSelected +
" ' ";
EOQualifier qual =
EOQualifier.qualifierWithQualifierFormat(qualifier, null);
I'd write the above as
EOQualifier = EOQualifier.qualifierWithQualifierFormat(
"institution.institutionLabel = '%@' and departmentName = '%@'",
selectedInstitutionLabel, selectedDepartmentName);
In particular, I strongly recommend *avoiding* the use of MFC-style
"m_blah" names when doing WebObjects and Cocoa development because
they won't work with Key-Value Coding.
I also strongly recommend spelling out words rather than abbreviating
them; a small amount of additional typing can save you *lots* of
maintenance effort in the future. Which is easier to understand at a
glance, "setM_dvDepts" or "setDepartments"?
-- Chris
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.