uqbar-project / wollok

Wollok Programming Language
GNU General Public License v3.0
60 stars 16 forks source link

Alternatives to JavaBean accessors conventions / Question mark & bang conventions? #517

Closed flbulgarelli closed 5 years ago

flbulgarelli commented 8 years ago

A convention present on the Ruby and Elixir languages for messages is to append a question mark to those which return boolean values, and a bang for those which have effect.

I find this conventions quite helpful when teaching, since they allow you to easier reveal the intention of the code. For example, lets some selectors based on the token clear

It is less verbose the the JavaBeans convention - it seems wollok is following that convention currently:

Could we introduce this convention in the wollok lang?

PalumboN commented 8 years ago

Like!

flbulgarelli commented 8 years ago

I am generalizing this question even more: why are we using JavaBean conventions for accessors?

I understand that accessor discussion is a long standing open discussion, but in the meanwhile we are starting naming methods using that get/set/is convention, and I think it is not an organic decision, but inertia.

Examples:

JavaBeans convention - get/set/is prefixes - is known to be quite verbose, in particular in the case of the get: it is absolutely redundant to add it, it adds not expressiveness to the method:

Examples:

The is/set prefixes are more subtle. I think that something like 4.between?(4, 5) is as expressive as 4.isBetween(4, 5), perhaps a little more, but I agree like it is not so different and may be a matter of taste.

flbulgarelli commented 8 years ago

@faloi @fedescarpa @npasserini @javierfernandes @mfreyre @asanzo @gastonprieto

npasserini commented 8 years ago

I like it, in my courses I do not use pepita.getEnergia() but pepita.energia()

On Fri, Jan 1, 2016 at 2:13 PM, Franco Leonardo Bulgarelli < notifications@github.com> wrote:

@faloi https://github.com/faloi @fedescarpa https://github.com/fedescarpa @npasserini https://github.com/npasserini @javierfernandes https://github.com/javierfernandes

— Reply to this email directly or view it on GitHub https://github.com/uqbar-project/wollok/issues/517#issuecomment-168317551 .

matifreyre commented 8 years ago

I like the idea of avoiding get/set. I don't use those, like Nico... I like the Smalltalk convention more.

I do like the is* convention though, it makes it more like a question. I'm not a fan of having special characters as part of the selectors, but I won't be offended if we decide to use them.

asanzo commented 8 years ago

Ok, I'd like to give some structure to my answer, hope I'm brief.

About the third aspect (pedagogical) I feel I need more information. As soon as I read this paper: http://dl.acm.org/citation.cfm?id=2534973 I will give a better anwer. If we choose a special syntax , I'd like to choose it having in mind these questions: are side-effect methods vs question methods a big problem among our students? Are return types problems more common or less common compared to these? Can we have special syntax for each of these problems (for example, if something returns a collection end it with an asterisk (*))? ¿Will a type-inferent IDE change these answers?

I'll keep thinking :)

flbulgarelli commented 8 years ago

If we choose a special syntax , I'd like to choose it having in mind these questions: ¿are side-effect methods vs question methods a big problem among our students? ¿Are return types problems more common or less common compared to these? ¿Can we have special syntax for each of these problems (for example, if something returns a collection end it with an asterisk (*))?

Nice questions. I don't have a definitive answer to them, just tastes and biased thoughts. We should actually conduct experiments here.

¿Will a type-inferent IDE change these answers?

I would like to add another question, though: IDE is good and we want it, sure. But how dependent will us be of it? And what will we do on final exams that are paper based?

Perhaps the answer is as obvious and crude: we should not have paper-based programming exams any more. After the few days of experimentation in a Mumuki-based course, I am starting to get convinced that it is actually possible

npasserini commented 8 years ago

If the objective of wollok is to be widely used (which I think it is) we should keep the doors open. So, while I think that it is a good idea to have Mumuki-based exams, we have to think also for people for which this is not a possibility.

Either way, I do not think that type inference has a big impact in the examination process, since the type information is used to catch mistakes while you are learning, while you do not know. At the exam type inference could help but it should not be crucial.

Stil, I am not sure how type inference could change my naming conventions, I tend to think it would not.

On Fri, Feb 5, 2016 at 12:59 PM, Franco Leonardo Bulgarelli < notifications@github.com> wrote:

If we choose a special syntax , I'd like to choose it having in mind these questions: ¿are side-effect methods vs question methods a big problem among our students? ¿Are return types problems more common or less common compared to these? ¿Can we have special syntax for each of these problems (for example, if something returns a collection end it with an asterisk (*))?

Nice questions. I don't have a definitive answer to them, just tastes and biased thoughts. We should actually conduct experiments here.

¿Will a type-inferent IDE change these answers?

I would like to add another question, though: IDE is good and we want it, sure. But how dependent will us be of it? And what will we do on final exams that are paper based?

Perhaps the answer is as obvious and crude: we should not have paper-based programming exams any more. After the few days of experimentation in a Mumuki-based course, I am starting to get convinced that it is actually possible

— Reply to this email directly or view it on GitHub https://github.com/uqbar-project/wollok/issues/517#issuecomment-180415006 .

flbulgarelli commented 8 years ago

Finally we decided to use Smalltalk-style accessors:

peptia.energia(40);
pepita.energia();

@fdodino @npasserini @matifreyre @mmatos

This will apply for new methods from now on.

Old methods should be renamed iteratively.