× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Pete Hall skrev:
Thorbjoern Ravn Andersen wrote:
Unless you have good reason to, do not use double/float/int/ but instead
their object equivalents.

Thorbjoern, why do you say that?

I was actually wondering myself when I wrote it but could not crystalize out a reason then.

It is basically my personal experience in what gives the least resistance in the long run, where I have reached that conclusion.

Primitive types are not objects so they cannot be subclassed if different behaviour is needed. They cannot be used as parameters to methods expecting an object (like slf4j which I use a lot), and ALWAYS require special treatment everywhere. They cannot have a descriptive toString method!

(Autoboxing helps but is not available in 1.4 which we still need to target for some customers).

If you need to do lots of scientific calculations, fine thats what they were designed for. If you need to haul data around and present it, objects will do fine. Also please note that doubles and floats are not good for exact numbers - if rounding errors (e.g. on stock inventory) are a matter of concern you need something else. For objects you can change the underlying representation without changing the source everywhere it is used.

Please note that this goes for fields in classes, not counters in code etc.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.