From: Roedy Green on
On Mon, 28 Sep 2009 11:34:58 -0700 (PDT), alexandre_paterson(a)yahoo.fr
wrote, quoted or indirectly quoted someone who said :

>
>Why not use real OO abstraction for the ISBNs?

In my particular case, that makes a lot of sense, instead of passing
around Strings, I need only pass ISBN objects around. If I need a
10-char, 13-char, 10-decorated, 13-decorated version, I decide at the
last minute with a get. It is also easier to maintain. If the HTML I
generate changes from 10 to 13, I change it in one place. I don't
have to modify the chain of parameter passings.
--
Roedy Green Canadian Mind Products
http://mindprod.com

When you are programming and you feel paralysis from overwhelm:
(o) Write down your worries in an electronic todo list, so you can temporarily stop thinking about them.
(o) Write smaller modules and classes so you don�t need to juggle many facts to complete the code.
(o) Do some necessary, but simple, clerical task.
(o) Solve some simple problem with at least some probability of being useful in the big solution. It will break the logjam.
~ Roedy
From: Tom Anderson on
On Mon, 28 Sep 2009, Michal Kleczek wrote:

> Roedy Green wrote:
>
>> Consider a program that uses a mixture of 10-character and 13-digit
>> ISBN numbers (International Standard Book Number). From Java's point
>> of view, they are all Strings.
>>
>> It would be nice if there were some mechanism to label Strings with a
>> light-weight type, probably a purely compile-time concept, similar to
>> generics. You would then label some string vars as ISBN13 and some as
>> ISBN10, and similarly parameters to methods. Then the compiler could
>> detect an improper passing of in ISBN13 string to an ISBN10 parameter.
>>
>> An extension of this idea is units of measure, so that you could not
>> pass a cm variable to an inch parameter (though possibly you could
>> with an automatic conversion applied).
>>
>> Think how many times you have wondered if a variable is measured in
>> seconds, ms, or ns. Here would be a formal way to specify and check
>> your assumption was correct.

Gosling keeps talking about adding this to java.

> That is not so easy to make it right. Read for example:
> http://research.sun.com/projects/plrg/Publications/p109-allen.pdf

If you want to be able to have arbitrary units which can be checked at
compile-time, sure, you need to add difficult stuff to the language. If
you can satisfy yourself with a fixed set of units, or runtime-only
checking, you can do it in java now.

tom

--
I am the best at what i do.
From: Jim on
On Mon, 28 Sep 2009 12:06:15 -0700, Roedy Green
<see_website(a)mindprod.com.invalid> wrote:

>On Mon, 28 Sep 2009 11:34:58 -0700 (PDT), alexandre_paterson(a)yahoo.fr
>wrote, quoted or indirectly quoted someone who said :
>
>>
>>Why not use real OO abstraction for the ISBNs?
>
>In my particular case, that makes a lot of sense, instead of passing
>around Strings, I need only pass ISBN objects around. If I need a
>10-char, 13-char, 10-decorated, 13-decorated version, I decide at the
>last minute with a get. It is also easier to maintain. If the HTML I
>generate changes from 10 to 13, I change it in one place. I don't
>have to modify the chain of parameter passings.

Roedy, Sounds like Pascal Type declarations, which is one of the
things I really miss in Java.

Jim
From: Kevin McMurtrie on
In article <alpine.DEB.1.10.0909282318480.8778(a)urchin.earth.li>,
Tom Anderson <twic(a)urchin.earth.li> wrote:

> On Mon, 28 Sep 2009, Michal Kleczek wrote:
>
> > Roedy Green wrote:
> >
> >> Consider a program that uses a mixture of 10-character and 13-digit
> >> ISBN numbers (International Standard Book Number). From Java's point
> >> of view, they are all Strings.
> >>
> >> It would be nice if there were some mechanism to label Strings with a
> >> light-weight type, probably a purely compile-time concept, similar to
> >> generics. You would then label some string vars as ISBN13 and some as
> >> ISBN10, and similarly parameters to methods. Then the compiler could
> >> detect an improper passing of in ISBN13 string to an ISBN10 parameter.
> >>
> >> An extension of this idea is units of measure, so that you could not
> >> pass a cm variable to an inch parameter (though possibly you could
> >> with an automatic conversion applied).
> >>
> >> Think how many times you have wondered if a variable is measured in
> >> seconds, ms, or ns. Here would be a formal way to specify and check
> >> your assumption was correct.
>
> Gosling keeps talking about adding this to java.
>
> > That is not so easy to make it right. Read for example:
> > http://research.sun.com/projects/plrg/Publications/p109-allen.pdf
>
> If you want to be able to have arbitrary units which can be checked at
> compile-time, sure, you need to add difficult stuff to the language. If
> you can satisfy yourself with a fixed set of units, or runtime-only
> checking, you can do it in java now.
>
> tom

Hopefully nobody 'solves' this by adding Generics to Strings. Java's
syntax is already going off the deep end. (And yet the simple things
like unsigned math and arrays of contiguous Object data are dismissed as
not worth the effort.)

--
I will not see your reply if you use Google.
From: Kenneth P. Turvey on
On Mon, 28 Sep 2009 23:25:39 -0700, Kevin McMurtrie wrote:

> In article <alpine.DEB.1.10.0909282318480.8778(a)urchin.earth.li>,
> Tom Anderson <twic(a)urchin.earth.li> wrote:
>
>> On Mon, 28 Sep 2009, Michal Kleczek wrote:
>>
>> > Roedy Green wrote:
>> >
>> >> Consider a program that uses a mixture of 10-character and 13-digit
>> >> ISBN numbers (International Standard Book Number). From Java's point
>> >> of view, they are all Strings.
>> >>
>> >> It would be nice if there were some mechanism to label Strings with
>> >> a light-weight type, probably a purely compile-time concept, similar
>> >> to generics. You would then label some string vars as ISBN13 and
>> >> some as ISBN10, and similarly parameters to methods. Then the
>> >> compiler could detect an improper passing of in ISBN13 string to an
>> >> ISBN10 parameter.
>> >>
>> >> An extension of this idea is units of measure, so that you could not
>> >> pass a cm variable to an inch parameter (though possibly you could
>> >> with an automatic conversion applied).
>> >>
>> >> Think how many times you have wondered if a variable is measured in
>> >> seconds, ms, or ns. Here would be a formal way to specify and check
>> >> your assumption was correct.
>>
>> Gosling keeps talking about adding this to java.
>>
>> > That is not so easy to make it right. Read for example:
>> > http://research.sun.com/projects/plrg/Publications/p109-allen.pdf
>>
>> If you want to be able to have arbitrary units which can be checked at
>> compile-time, sure, you need to add difficult stuff to the language. If
>> you can satisfy yourself with a fixed set of units, or runtime-only
>> checking, you can do it in java now.
>>
>> tom
>
> Hopefully nobody 'solves' this by adding Generics to Strings. Java's
> syntax is already going off the deep end. (And yet the simple things
> like unsigned math and arrays of contiguous Object data are dismissed as
> not worth the effort.)

Both of those are real annoyances... I've got one more though, closures.
Anonymous classes are ugly when unneeded.



--
Kenneth P. Turvey <evoturvey(a)gmail.com>
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12
Prev: Putting passwords in a properties file?
Next: Interview