Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

Opinions requested on my blog post about primitive obsession.

Thread view: 
Daniel Pitts - 28 Oct 2007 20:23 GMT
So, I just finished the first draft of an article on the benefits of
avoiding primitive obsession.  I'd like some feedback on the article.
<shameless>Also, posting this message is a good way to promote my
blog.</shameless>
Any feedback is very welcome. Either using the comment system, or by
following up on this thread.  Comment system is preferred (think of it
as a followup-to header).
<http://virtualinfinity.net/wordpress/program-design/2007/10/28/primitive-obsession/>

Thanks,
Daniel.

P.S.  If anyone has an opinion, positive or negative, about my
"advertising" my blog-posts in this manor, feel free to let me know
here.  I don't want to be classified as a spammer, and I feel that I
contribute enough to this community that the occasional unsolicited
message is appropriate.  Let me know if you feel otherwise.

Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

Roedy Green - 29 Oct 2007 00:00 GMT
On Sun, 28 Oct 2007 12:23:37 -0700, Daniel Pitts
<newsgroup.spamfilter@virtualinfinity.net> wrote, quoted or indirectly
quoted someone who said :

>P.S.  If anyone has an opinion, positive or negative, about my
>"advertising" my blog-posts in this manor, feel free to let me know
>here.  I don't want to be classified as a spammer, and I feel that I
>contribute enough to this community that the occasional unsolicited
>message is appropriate.  Let me know if you feel otherwise.

the big advantage to your way, is you can modify your essay based on
the feedback.  If you do it via posts, your errors sit there forever
to mislead others.

So I figure anything more that a couple of paragraphs should be posted
as html.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Roedy Green - 29 Oct 2007 00:05 GMT
On Sun, 28 Oct 2007 12:23:37 -0700, Daniel Pitts
<newsgroup.spamfilter@virtualinfinity.net> wrote, quoted or indirectly
quoted someone who said :

><http://virtualinfinity.net/wordpress/program-design/2007/10/28/primitive-obsession/>

I have been lobbying since the 1970s  for units of measure as a built
in feature to create a friendly language for engineers.  

If you have both British and ISO measure in the same program, SO many
errors happen because of invalid assumptions about measure.  Even with
pure ISO, powers of 10 errors are easy to make.  

With declared units of measure you can have:
1. dimensionality consistency checks.
2. automatic unit conversion.

Units of measure are NOT classes. They are compile time modifiers to
primitives.  You could think of them as generics for primitives.

see http://mindprod.com/jgloss/unitsofmeasure.html
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Stefan Ram - 29 Oct 2007 00:22 GMT
>Units of measure are NOT classes. They are compile time modifiers to
>primitives.  You could think of them as generics for primitives.

 They can be used in Fortress

http://research.sun.com/projects/plrg/Fortress/overview.html

 Language Specification

http://research.sun.com/projects/plrg/fortress.pdf

 JVM-based interpreter for a subset of the language

http://fortress.sunsource.net/
Chris ( Val ) - 29 Oct 2007 05:37 GMT
On Oct 29, 10:05 am, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> On Sun, 28 Oct 2007 12:23:37 -0700, Daniel Pitts
> <newsgroup.spamfil...@virtualinfinity.net> wrote, quoted or indirectly
[quoted text clipped - 4 lines]
> I have been lobbying since the 1970s  for units of measure as a built
> in feature to create a friendly language for engineers.  

I understand completely :-)

Before I moved into the IT world, I spent many years in the
metal and engineering trades, converting between Metric and
Imperial units on a daily basis.

> If you have both British and ISO measure in the same program, SO many
> errors happen because of invalid assumptions about measure.  Even with
> pure ISO, powers of 10 errors are easy to make.  

Indeed.

> With declared units of measure you can have:
> 1. dimensionality consistency checks.
> 2. automatic unit conversion.
>
> Units of measure are NOT classes. They are compile time modifiers to
> primitives.  You could think of them as generics for primitives.

I don't see why the couldn't be represented as classes.
Units can be viewed as an abstraction to measurement types.

I haven't used AutoCAD in a while, but I'm reasonably sure that they
worked with units in such a way - You just specify the unit type and
begin drawing.

--
Chris
Roedy Green - 29 Oct 2007 13:24 GMT
On Sun, 28 Oct 2007 21:37:51 -0700, "Chris ( Val )"
<chrisval@gmail.com> wrote, quoted or indirectly quoted someone who
said :

>I don't see why the couldn't be represented as classes.
>Units can be viewed as an abstraction to measurement types.

If you make them a something like generics for primitives, they have
zero run time extra overhead.  This is important for
computation-intensive engineering programs.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Hunter Gratzner - 29 Oct 2007 07:58 GMT
On Oct 29, 12:05 am, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> On Sun, 28 Oct 2007 12:23:37 -0700, Daniel Pitts
> <newsgroup.spamfil...@virtualinfinity.net> wrote, quoted or indirectly
[quoted text clipped - 4 lines]
> I have been lobbying since the 1970s  for units of measure as a built
> in feature to create a friendly language for engineers.

And that's why people have developed frink. http://futureboy.homeip.net/frinkdocs/

It didn't take them 30 years of lobbying. Just some Java coding.

> If you have both British and ISO measure in the same program,

ISO? Do you mean SI? ISO doesn't do units.

> If you have SO many
> errors happen because of invalid assumptions about measure.  Even with
[quoted text clipped - 3 lines]
> 1. dimensionality consistency checks.
> 2. automatic unit conversion.

>From an interactive  Frink session (first line after an empty line is
the input, followed by Frink's response):

Frink
Copyright 2000-2007 Alan Eliasen, eliasen@mindspring.com
http://futureboy.us/frinkdocs/
Enter calculations in the text field at bottom.
Use up/down arrows to repeat/modify previous calculations.

var m is mass = 10 pounds
45359237/10000000 (exactly 4.5359237) kg (mass)

m = 11 pounds
498951607/100000000 (exactly 4.98951607) kg (mass)

m = 11 meters
BasicContext:  Cannot set symbol m, ContextFrame threw exception:
 Constraint not met--value must have dimensions of mass

m = 1 kg
1 kg (mass)

m -> pound
100000000/45359237 (approx. 2.2046226218487757)

10 volt
10 m^2 s^-3 kg A^-1 (electric_potential)

20 amp
20 A (current)

10 volt * 20 amp
200 m^2 s^-3 kg (power)

10 volt * 20 amp -> watt
200

10 volt * 20 amp -> meter
Conformance error
  Left side is: 200 m^2 s^-3 kg (power)
 Right side is: 1 m (length)

var p is power = 10 volt * 20 amp
200 m^2 s^-3 kg (power)

p = 10 watt
10 m^2 s^-3 kg (power)
Piotr Kobzda - 29 Oct 2007 11:48 GMT
> I have been lobbying since the 1970s  for units of measure as a built
> in feature to create a friendly language for engineers.  

The Measures and Units API (JSR-275) seems to be the answer to your efforts.

See introductory article:
<http://www.javaworld.com/javaworld/jw-10-2007/jw-10-jsr275.html>

As the article states, there is still no decision on inclusion of the
JSR-275 API in Java 7.  Up to now, there is also no mention of
'javax.measure' package in official list of Java 7 packages
(http://download.java.net/jdk7/docs/api/).  So, my guess is that we
should wait a bit longer for that...  Hopefully, intermediately we may
use mentioned in the article the reference "draft" implementation from
the JScience project (http://jscience.org/).

piotr
Roedy Green - 29 Oct 2007 13:23 GMT
On Sun, 28 Oct 2007 23:05:58 GMT, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :

>If you have both British and ISO measure
oops British and SI measure.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.