JDK-6350740 : RFE: Add Property definition for the java language syntax
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1
  • CPU: x86
  • Submitted: 2005-11-15
  • Updated: 2010-04-04
  • Resolved: 2006-11-09
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
Add property definition syntax to the java language maby like C# has today (The one feature of the C# language I like). And add a value reserved word for the setter of the Property construct.

JUSTIFICATION :
I would like to see this functionality since it enhance readability when class properties are used in complex algorithms for instance:

Foo.Sum = Bar.Lenght *  (Bar.Mid = Foo.MFoo.Value2 - Bar.Value1);

These look like this in todays language construct:
Bar.setMid(Bar.Foo.getValue2() - Bar.getValue1());
Foo.setSum(Bar.getLength() * Bar.getMid());

A pure enhancement to make code management easier.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Language syntax:
public class Foo {
    private int someProperty;

    public int SomeProperty
        get {
            return someProperty;
        }
        set {
            someProperty = value;
        }
    }

Here i expect to get a property which I can manipulate with the normal operators instead of using methods to improve code readability.

The get section should return the value expected from the property while the set section should set the value through a typed value keyword containing the input value.

Foo.SomeProperty = 1;
Would trigger the setter section

System.out.println(Foo.SomeProperty);
Would trigger the getter section

ACTUAL -
  Today you use setters and getters to get the same functionability but today but this results in code that is not as readable as the property equivialent described here.

Comments
EVALUATION 6347784 expresses the idea of properties most concisely.
17-11-2006