|
Joe Pluta skrev:As usual in the business world, it depends. If this is a discrete count, such as light bulbs or battleships, you could use an integer. But as soon as you move into measured quantities (pounds, feet, whatever), you usually need decimal places. Another reason I say that integer counts aren't found all that often in the business world.
In this case with an item count, what would you use then?
What type do you give monetary values (and how do you handle currencies)?Money, units, etc., I use BigDecimal. For a while I used IBM's BigDecimal because it was a LOT faster, but I think recent versions of the core BigDecimal class have gotten better. Currency codes are a string.
Depends on your needs. You can always for non-final classes make an anonymous class at assignment overriding the toString method providing better information (which is making a class for that single instance). That might be extremely helpful for post-mortem debugging with variable dumps.I don't use dumps a lot, so I'll take your word for it. In general, though, I don't do a lot of design based on how well the class dumps.
My personal opinion is that the JVM's these days support "plain Java" very well. Small methods are inlined. Garbage collectors are optimized to deal with lots of short lived objects. Classes are compiled to binary code unless redefined when they go back to interpretation and potential recompilation. The price: Memory usage unfortunately.No argument here, well written Java executes very well.
In my experience those Java applications which still have performance problems, do so to an algorithm which scales badly (sort cards? Throw them in the air and see if they fall down sorted, if not do it again), building extremely large data structures, doing work on the event thread, or doing much more than just one thing :)The biggest problems come from people reusing code in ways it was not intended, or people modifying routines that are being reused. If you're not careful, OO can get layered dozens of layers deep and suddenly you have routines that are doing lots of gyrations when they don't need to be. There is no cure for that other than good, upfront design. And the worst case is developers use third-party routines that they don't really understand. Open source in particular can bite you in this regard, although at least with open source you can go in and find the issues, but that of course requires that you learn the intricacies of the open source code, which defeats at least part of the purpose of using third-party packages in the first place :).
What have you found the usual performance problems to be and how did you fix them?
As an Amazon Associate we earn from qualifying purchases.
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.