Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [higgins-dev] Java 5, going once...

Those are the big three and indeed they make life for developers simpler.

Tony, why do you not agree that these make life simpler?  Or is it just a matter of detailing Java 5 features for those who haven't done development using Java 4 followed by 5?

Tom
 
>>> "Markus Sabadello" <msabadello@xxxxxxxxxxxxx> 11/28/08 11:26 PM >>> 
Here are Higgins- related examples for the three best- known 1.5 features:

1. Generics
-----------------
Generics provide a way for you to communicate the type of a collection
to the compiler, so that it can be checked. Once the compiler knows
the element type of the collection, the compiler can check that you
have used the collection consistently and can insert the correct casts
on values being taken out of the collection.

Let's say I want to get the first value of an attribute. This is a
common operation since most attributes are single- valued.

Today I would have to do this:

IAttribute attribute = ...;
IAttributeValue value = (IAttributeValue) attribute.getValues().next();

With 1.5 I could do this:

IAttribute attribute = ...;
IAttributeValue = attribute.getValues().next();

- > It's more convenient to write
- > It's less error- prone, because the return type is checked at
compile time, therefore I don't have to cast and can avoid a potential
ClassCastException

2. Foreach Loop
------------------------
The foreach loop is used to access each successive value in a
collection of values.

Let's say I want to enumerate over all context types of a context factory.

Today I would have to do this:

IContextFactory contextFactory = ...;
for (Iterator i=contextFactory.getTypes().iterator(); i.hasNext(); ) {
  String type = (String) i.next();
  System.out.println(type);
}

With 1.5 I could do this:

IContextFactory contextFactory = ...;
for (String type : contextFactory.getTypes()) {
  System.out.println(type);
}

- > It's a lot shorter
- > It's much more readable... You immediately know the purpose of the loop

3. Autoboxing
--------------------
Autoboxing is the automatic conversion the Java compiler makes between
the primitive (basic) types and their corresponding object wrapper
classes

Let's say I have an attribute value of type xsd:int, and I want to add
1 to that value.

Today I would have to do this:

ISimpleAttrValue age = ...;
age.setData(new Integer(((Integer) age.getData()).intValue() + 1));

With 1.5 I could do this:

ISimpleAttrValue age = ...;
age.setData((Integer) age.getData() + 1);

- > Again, much shorter and more readable

The remaining Java 1.5 features (Typesafe Enums, Varargs, Static
Imports, Annotations) are used less often, but I could think of
Higgins- related examples for them as well.

Markus

On Sat, Nov 29, 2008 at 3:27 AM, Anthony Nadalin <drsecure@xxxxxxxxxx> wrote:
> Don't agree that life is simpler, please give examples of why this should be
> changed
>
> Anthony Nadalin | Work 512.838.0085 | Cell 512.289.4122
>
> "Markus Sabadello" --- 11/28/2008 08:06:10 PM--- I think both developers and
> users of Higgins would agree that 1.5
>
>
> From:
> "Markus Sabadello" <msabadello@xxxxxxxxxxxxx>
> To:
> "Higgins (Trust Framework) Project developer discussions"
> <higgins- dev@xxxxxxxxxxx>
> Date:
> 11/28/2008 08:06 PM
> Subject:
> Re: [higgins- dev] Java 5, going once...
> ________________________________
>
>
> I think both developers and users of Higgins would agree that 1.5
> makes life a lot simpler.
>
> As a developer, I can write my code faster and make it much more
> readable and less error- prone.
>
> As a user, it's much more convenient to get e.g. a List<IEntity> than
> just a List.
>
> Markus
>
> On Thu, Nov 27, 2008 at 11:27 PM, Anthony Nadalin <drsecure@xxxxxxxxxx>
> wrote:
>> Since the current build is on 1.4 so what is the rational to change ? I'm
>> not seeing the motivation to change or do we just change things ?
>>
>> Anthony Nadalin | Work 512.838.0085 | Cell 512.289.4122
>>
>> Paul Trevithick --- 11/26/2008 08:46:29 AM--- I've been waiting to see if
>> anyone will step forward and argue for why they require 1.4.X support for
>> Higgins 1.1 (specificall
>>
>>
>> From:
>> Paul Trevithick <ptrevithick@xxxxxxxxx>
>> To:
>> higgins- dev <higgins- dev@xxxxxxxxxxx>
>> Date:
>> 11/26/2008 08:46 AM
>> Subject:
>> [higgins- dev] Java 5, going once...
>> ________________________________
>>
>>
>> I've been waiting to see if anyone will step forward and argue for why
>> they
>> require 1.4.X support for Higgins 1.1 (specifically). As we discussed in
>> the
>> F2F if someone requires 1.4.X they at least have the option of using
>> Higgins
>> 1.0. Not a great option because so much is progressing in 1.1, but it's
>> something. Historically Tony of IBM has put forward IBM's requirement for
>> 1.4.X, but they have been silent on the issue of late.
>>
>> Unless we hear soon from IBM or others on this point, we'll take one last
>> poll, and then move to Java 5 for Higgins 1.1.
>>
>> - Paul _______________________________________________
>> higgins- dev mailing list
>> higgins- dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/higgins- dev
>>
>>
>> _______________________________________________
>> higgins- dev mailing list
>> higgins- dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/higgins- dev
>>
>>
> _______________________________________________
> higgins- dev mailing list
> higgins- dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/higgins- dev
>
>
> _______________________________________________
> higgins- dev mailing list
> higgins- dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/higgins- dev
>
>
_______________________________________________
higgins- dev mailing list
higgins- dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/higgins- dev



Back to the top