[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] In regards to the setProperty Method



ok thanks for the detailed reply : )



On Mar 11, 2009, at 7:33 PM, James Harkins <jamshark70@xxxxxxxxx> wrote:

On Mar 10, 2009, at 10:07 PM, Sam Ingrassia wrote:
Thanks to everyone in advance -

can I use setProperty with all the GUI.* classes or is it part of all objects? If not is there similar functionality available?

I don't believe there's any global setProperty method. Nor, really, should there be. Part of the way object oriented programming works is by organizing objects' behavior into interfaces, which define what kinds of things an object is able to do for a client, and also what kinds of things it is not allowed to do. The things that the object isn't allowed to do are just as important as those that are permitted -- it's about controlling access to the object's internals. Ideally in OOP, objects should have an external interface that is (relatively) stable. The internals might change, but if the interface remains compatible, then other parts of the system using those objects don't have to care about the changes in implementation details.

If supercollider had a way to mark some methods as private (like Java), probably setProperty would be a private method of SCView. Then no object except a subclass of SCView would have access to it.

Suppose (hypothetically) that Apple changes the name of a property of some cocoa widget. If your code uses setProperty all over the place and refers to the old name, it will break... but, if you use the normal, "public" interface, your code wouldn't have to change.

So you "could" use setProperty directly on SCViews, but probably shouldn't.

hjh



: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman