complexvariables / conformalmapping

Conformal mapping toolkit for MATLAB
Other
11 stars 9 forks source link

Underscore property names versus variables. #12

Closed tobydriscoll closed 10 years ago

tobydriscoll commented 10 years ago

I appreciate the convenience of having underscore-trailing property names to avoid clash with internal names. However, those properties are exposed to the user. Wouldn't it be better to reverse and use the underscores with the internal names?

ehkropf commented 10 years ago

I now remember another reason I was using the underscores. Say a class has a property foo. Let C be an instance of that class. You also want a function with the same name as the property to access it via the syntax foo(C). Using the classdef syntax precludes having the property with the same name as the function.

The current mess is partly due to the conversion. For example, in an effort to make the polygon class behave as it did before it was converted, I needed to salvage functions such as alpha and vertex, but I was in a rush (lazy?) and just stuck the underscores on the property names. I believe I thought at the time the rule should be "if there is a function to read the property, or if the property probably won't be accessed directly by the user that often, then the property gets an underscore." It clearly wasn't well thought out.

Having said that, I'm still not sure that's the wrong way to look at it. It seems to be "the matlab way" to access properties with the foo(C) syntax, though of course I can't think of an example this second which makes my case.

tobydriscoll commented 10 years ago

I don't disagree regarding the matlab way, though one irritation is that properties get tab completion whereas the older syntax does not.

Let's do nothing about this for now.

ehkropf commented 10 years ago

Tab completion with the classdef syntax is completely broken. It occasionally works if you have an instance of a class in memory, but if not you get nothing.

ehkropf commented 10 years ago

Closing as subsumed under #27.