Jess Holle wrote:
> joncfoo wrote:
>> What's wrong with syntactic sugar and how is it holding it back? The
>> properties that C# sports are simple, concise, and easy on the eyes.
>> Why isn't the Java language picking up at least these basic features?
>>
> What clearly shows in the Tutorial below is that C# inherits
> Microsoft's horrible m_* naming convention from C++.
>
> What is also 100% clear is that such naming conventioned are
> absolutely necessary for clarity due to the way C# does its
> properties! The fact that C# uses "object.PropertyName" for access
> necessitates that either (1) you use a goofy m_* convention for fields
> or (2) you use the capitalized form for the property (Name) and the
> uncapitalized form for the field (name). (2) by itself is actually
> way too subtle in practice -- thus necessitating the goofy m_* convention.
To be clear, though I don't like the m_* convention, etc, there's a
bigger issue here for Java:
The convention all Java programmers have been trained with (and that
is in all books and training materials and IDEs) is simple
lower-case (leading lowercase and camel case thereafter) names for
/both /fields and properties (yes, Java *does* have properties;
JavaBeans may need improvement, but they're there).
Thus mixing Java's longstanding naming conventions with use of the "."
operator for property access is a recipe for confusion.
> Instead if Java does properties I hope it can just use "->" instead of
> "." -- making it 100% clear that this is a property rather than field
> access and leaving no such ambiguities.
>
> As for C#'s syntax for declaring properties -- I don't see any big
> step forward here except in the case of auto-implemented properties.
> Sure there's slightly less typing and you don't repeat yourself on
> getName() and setName(), but there's no big win in other cases.
>
> Of course the auto-implemented property example raises other issues in
> that once you need to move away from an auto-implemented property to
> one backed by a field you have to introduce the field and examine all
> usages of the property within your class that really should have been
> using the field. At this point once again you're back to m_*
> conventions if you want any sort of clarity in the code.
>
> Overall, I certainly wouldn't say Java should just copy C#'s
> properties! This is not rubber-stampable.
>
> --
> Jess Holle
>> On Feb 6, 1:16 pm, Reinier Zwitserloot <[email protected]> wrote:
>>
>>> "It is just syntactic sugar" gets you perl.
>>>
>>> That's what's holding it back.
>>>
>>> On Feb 6, 7:24 pm, joncfoo <[email protected]> wrote:
>>>
>>>
>>>> Regarding properties:
>>>> What is holding them back from implementing properties like they are
>>>> in C# since it could be implemented as syntactic sugar.
>>>>
>>>> Plenty of examples
>>>> here:http://www.csharp-station.com/Tutorials/Lesson10.aspx
>>>>
>>>> It would be nice to traverse large object graphs w/o having the ugly
>>>> getters.
>>>>
>>>> E.g.
>>>>
>>>> // before
>>>> obj1.getObject2().getObject3().getObject4().setSomeProperty(1234);
>>>>
>>>> // after
>>>> obj1.object2.object3.object4.someProperty = 1234;
>>>>
>>>> It is just syntactic sugar...
>>>>
>>>> Jonathan
>>>>
>>>> On Feb 5, 9:47 pm, Bill Robertson <[email protected]> wrote:
>>>>
>>>>> On Feb 4, 11:58 am, gafter <[email protected]> wrote:
>>>>>
>>>>>> Although I believe the syntax is not ideal in its current form, I'm
>>>>>> not going to spend more time on it until Sun formally decides they
>>>>>> want to move forward with it, and that's not going to happen in JDK7.
>>>>>>
>>>>> I certainly understand that position, but I think its worth
>>>>> considering syntax, even if only in a passive manner (i.e. just think
>>>>> about it). I've been dealing with C++ recently, and man oh man* I
>>>>> forgot what a pain that was after not having touched it in so long.
>>>>> Generics nudged Java syntax in this direction, and the little bits and
>>>>> bobs of closure syntax that I've seen so far (no specific proposal
>>>>> mind you), have left me with that same feeling. I hate to try to
>>>>> suggest answers when I don't believe I have good ones, but I also hate
>>>>> to just complain w/o offering suggestions. So I would like to offer
>>>>> up the suggestion of considering keywords rather than oddball
>>>>> symbols. e.g. lambda v.s. =>
>>>>>
>>>>> Thanks.
>>>>>
>>>>> *Not to be confused with, "OhmanOh Man," a lesser known super hero.
>>>>>
>>
>>
>>
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---