Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #20622

Re: multi-line Strings

From Arved Sandstrom <asandstrom2@eastlink.ca>
Newsgroups comp.lang.java.programmer
Subject Re: multi-line Strings
References (13 earlier) <qdrd1mgseyq1$.1upmnl6v646ec$.dlg@40tude.net> <vEXzs.27998$tG.2948@newsfe15.iad> <50d25c08$0$282$14726298@news.sunsite.dk> <ybtAs.23610$411.13683@newsfe02.iad> <50d27cf0$0$294$14726298@news.sunsite.dk>
Message-ID <nlBAs.10835$tK1.6323@newsfe07.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2012-12-20 06:00 -0400

Show all headers | View raw


On 12/19/2012 10:50 PM, Arne Vajhøj wrote:
> On 12/19/2012 7:44 PM, Arved Sandstrom wrote:
>> On 12/19/2012 08:29 PM, Arne Vajhøj wrote:
>>> On 12/18/2012 5:34 AM, Arved Sandstrom wrote:
>>>> On 12/17/2012 10:13 PM, Peter Duniho wrote:
>>>>> On Mon, 17 Dec 2012 20:25:56 -0500, Eric Sosman wrote:
>>>>>
>>>>>> [...]
>>>>>>> If you are multiplying by a constant, there's a reason. Often, for
>>>>>>> example,
>>>>>>> you are converting units (hours per day, days per week, etc.,
>>>>>>> following
>>>>>>> your "date conversions" theme). The conversion itself is the correct
>>>>>>> name
>>>>>>> (e.g. "hoursPerDay", "daysPerWeek", etc.) in those examples. Similar
>>>>>>> logic
>>>>>>> can be applied to other values.
>>>>>>
>>>>>>     public static final int MILLIMETERS_PER_METER = 1000;
>>>>>>     public static final int MILLIGRAMS_PER_GRAM = 1000;
>>>>>>     public static final int MILLIAMPERES_PER_AMPERE = 1000;
>>>>>>     public static final int MILLISECONDS_PER_SECOND = 1000;
>>>>>>
>>>>>> Great aids to understanding, I'm sure.  (And stop calling me Millie!)
>>>>>
>>>>> I guess your intent is to be sarcastic. But personally, I think
>>>>> using a
>>>>> named constant does in fact make it clearer.
>>>>>
>>>>> I would not be a stickler for making those named constants, and of
>>>>> course
>>>>> have used literal values like those in code without naming them. But
>>>>> using
>>>>> them as a named constant would in fact make the code clearer.
>>>>>
>>>>> And of course, constants such as 100 or 400 (such as Arved mentioned)
>>>>> are
>>>>> even less obvious.
>>>>>
>>>>> As I said, there may be exceptions. SI units are notoriously easy to
>>>>> convert, so as long as your variables and methods are well-named (i.e.
>>>>> are
>>>>> clear about the units they represent), a named constant may not be
>>>>> called
>>>>> for when converting. So, fine...if you like, there's one of your
>>>>> exceptions.
>>>>>
>>>>> That doesn't take way from the more general validity of my comments.
>>>>>
>>>>> Pete
>>>>>
>>>> Pete, I know where you're coming from, but Eric more accurately
>>>> captured
>>>> the scenarios I was thinking of. Another example is the old-style and
>>>> somewhat language-agnostic pseudocode
>>>>
>>>> round(d*100.)/100.
>>>>
>>>> for rounding to 2 decimal places (substitute other powers of ten for
>>>> rounding to less or more decimal places). [*] Here there is no meaning
>>>> for those constants other than TEN or a HUNDRED.
>>>
>>> Really?
>>>
>>> FACTOR_FOR_ROUNDING_TO_TWO_DECIMALS seems as a name to me.
>>>
>>> If it was named FACTOR_FOR_ROUNDING it could even be changed to
>>> accommodate other roundings that to 0.01.
>>>
>>> I would never use the first.
>>>
>>> I am not even sure that I would use the last, but the last
>>> is not that bad.
>>>
>> If you absolutely had to have a name I suppose that's about as good as
>> it gets. But assuming that you're using this technique you might in one
>> spot want to round to 2 places, in another to 1 or 4 (not far-fetched
>> actually), if you *are* using named constants I think you'd have to go
>> with your first suggestion.
>
> If one need to do multiple roundings, then multiple constants would
> be needed.
>
> The first is still not good.
>
> The extended name should be related to the purpose not the factor
> to handle the case where a rounding is changed for some calculations.
>
> FACTOR_TO_ROUND_DOLLAR_AMOUNT
> FACTOR_TO_ROUND_DISTANCE_MEASUREMENT
> etc.
>
> Arne
>
One of the points I am trying to get across, Arne, is that (1) you may 
not know any of that, or (2) there may be no higher purpose than an 
arbitrary choice.

As far as #2 goes, that was sort of my Excel spreadsheet scenario. This 
is from real modernization and integration work I'm doing - in various 
reports and spreadsheets that we are looking to replace, percentages may 
be displayed let's say to one or two places. There is no reason given 
for this choice, the raw numbers involved would support more places 
actually. Since these percentages are used in various Excel tables and 
charts for executive reporting, probably the *only* reason years and 
years ago is that so many decimal places looked "good".

This is not an unusual scenario: display rounding of numbers with no 
natural "right" number of decimal places. You can, say, go to 4 or 5 
places by significant digits. But the table or chart gets too busy, 
people object, so you round to 1 or 2 decimal places - for the decent 
reason of effective presentation of information.

AHS

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

multi-line Strings bob smith <bob@coolfone.comze.com> - 2012-12-10 08:22 -0800
  Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-10 11:43 -0500
    Re: multi-line Strings Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-12-10 09:36 -0800
    Re: multi-line Strings markspace <-@.> - 2012-12-10 09:42 -0800
      Re: multi-line Strings Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-12-10 09:51 -0800
        Re: multi-line Strings markspace <-@.> - 2012-12-10 10:27 -0800
          Re: multi-line Strings Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-10 13:43 -0500
            Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-10 15:08 -0500
              Re: multi-line Strings markspace <-@.> - 2012-12-10 13:05 -0800
              Re: multi-line Strings Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-10 16:22 -0500
                Re: multi-line Strings markspace <-@.> - 2012-12-10 13:36 -0800
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-10 16:52 -0500
                Re: multi-line Strings Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-10 18:04 -0500
                Re: multi-line Strings Martin Gregorie <martin@address-in-sig.invalid> - 2012-12-11 00:17 +0000
                Re: multi-line Strings markspace <-@.> - 2012-12-10 17:35 -0800
                Re: multi-line Strings Martin Gregorie <martin@address-in-sig.invalid> - 2012-12-11 01:56 +0000
                Re: multi-line Strings markspace <-@.> - 2012-12-10 18:00 -0800
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-10 21:16 -0500
                Re: multi-line Strings Martin Gregorie <martin@address-in-sig.invalid> - 2012-12-11 22:21 +0000
                Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-10 22:12 -0600
                Re: multi-line Strings Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-12-11 05:01 -0400
                Re: multi-line Strings markspace <-@.> - 2012-12-11 09:46 -0800
                Re: multi-line Strings Martin Gregorie <martin@address-in-sig.invalid> - 2012-12-11 22:26 +0000
                Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-11 16:25 -0600
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-10 21:10 -0500
                Re: multi-line Strings Martin Gregorie <martin@address-in-sig.invalid> - 2012-12-11 22:31 +0000
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-14 22:30 -0500
                Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-15 03:35 -0600
                Re: multi-line Strings "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-12-15 11:54 +0000
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-15 08:53 -0500
                Re: multi-line Strings Jim Janney <jjanney@shell.xmission.com> - 2012-12-16 12:19 -0700
                Re: multi-line Strings "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-12-18 13:24 +0000
                Re: multi-line Strings Gene Wirchenko <genew@telus.net> - 2012-12-16 17:21 -0800
                Re: multi-line Strings "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-12-18 14:03 +0000
                Re: multi-line Strings Gene Wirchenko <genew@telus.net> - 2012-12-18 09:05 -0800
                Re: multi-line Strings Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-12-17 20:13 -0400
                Re: multi-line Strings "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-12-18 13:38 +0000
                Re: multi-line Strings Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-12-19 19:48 -0400
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 21:07 -0500
                Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-19 08:26 -0600
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-19 16:36 -0500
                Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-21 12:51 -0600
                Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-21 14:05 -0600
                Re: multi-line Strings "Peter J. Holzer" <hjp-usenet2@hjp.at> - 2012-12-15 18:22 +0100
                Re: multi-line Strings Robert Klemme <shortcutter@googlemail.com> - 2012-12-16 00:34 +0100
                Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-16 02:56 -0600
                Re: multi-line Strings Robert Klemme <shortcutter@googlemail.com> - 2012-12-16 14:07 +0100
                Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-16 13:44 -0600
                Re: multi-line Strings "Peter J. Holzer" <hjp-usenet2@hjp.at> - 2012-12-16 17:43 +0100
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-19 19:37 -0500
                Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-10 22:03 -0600
                Re: multi-line Strings Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-12-11 10:43 -0600
                Re: multi-line Strings Martin Gregorie <martin@address-in-sig.invalid> - 2012-12-11 22:44 +0000
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-10 21:09 -0500
      Re: multi-line Strings Sebastian <sebastian@undisclosed.invalid> - 2012-12-12 10:40 +0100
        Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-12 20:28 -0500
    Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-10 13:42 -0600
  Re: multi-line Strings "William Bonawentura" <nie@ma.mnie.pl> - 2012-12-11 07:58 +0100
    Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-11 10:08 -0500
      Re: multi-line Strings Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-12-11 09:41 -0600
      Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-11 15:02 -0600
        Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-14 22:27 -0500
        Re: multi-line Strings Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-12-14 23:23 -0600
          Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-15 02:56 -0600
    Re: multi-line Strings Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-11 16:31 -0500
      Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-11 17:07 -0600
        Re: multi-line Strings Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-12-11 15:31 -0800
          Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-11 19:41 -0600
      Re: multi-line Strings "William Bonawentura" <nie@ma.mnie.pl> - 2012-12-13 07:43 +0100
        Re: multi-line Strings Lew <lewbloch@gmail.com> - 2012-12-12 23:09 -0800
        Re: multi-line Strings Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-12-13 06:34 -0400
          Re: multi-line Strings "William Bonawentura" <nie@ma.mnie.pl> - 2012-12-14 07:35 +0100
            Re: multi-line Strings Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-12-14 02:44 -0600
              Re: multi-line Strings "William Bonawentura" <nie@ma.mnie.pl> - 2012-12-14 11:48 +0100
                Re: multi-line Strings Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-12-14 05:10 -0600
                Re: multi-line Strings Lew <lewbloch@gmail.com> - 2012-12-14 15:18 -0800
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-14 22:16 -0500
            Re: multi-line Strings Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-12-14 05:55 -0400
              Re: multi-line Strings "William Bonawentura" <nie@ma.mnie.pl> - 2012-12-14 11:50 +0100
                Re: multi-line Strings Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-12-14 05:12 -0600
                Re: multi-line Strings Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-12-14 11:24 -0800
                Re: multi-line Strings markspace <-@.> - 2012-12-14 11:47 -0800
                Re: multi-line Strings Gene Wirchenko <genew@telus.net> - 2012-12-14 12:26 -0800
                Re: multi-line Strings markspace <-@.> - 2012-12-14 12:53 -0800
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-14 22:36 -0500
                Re: multi-line Strings "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-12-15 12:06 +0000
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-19 19:23 -0500
                Re: multi-line Strings Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-12-15 08:16 -0600
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-19 19:24 -0500
                Re: multi-line Strings Lew <lewbloch@gmail.com> - 2012-12-15 13:36 -0800
                Re: multi-line Strings Gene Wirchenko <genew@telus.net> - 2012-12-16 17:36 -0800
                Re: multi-line Strings Gene Wirchenko <genew@telus.net> - 2012-12-14 12:30 -0800
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-14 22:43 -0500
                Re: multi-line Strings Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-14 17:36 -0500
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-14 22:46 -0500
                Re: multi-line Strings BGB <cr88192@hotmail.com> - 2012-12-16 04:29 -0600
                Re: multi-line Strings Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-12-17 20:45 -0400
                Re: multi-line Strings Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-12-17 17:11 -0800
                Re: multi-line Strings Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-17 20:25 -0500
                Re: multi-line Strings Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-12-17 18:13 -0800
                Re: multi-line Strings Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-12-18 06:34 -0400
                Re: multi-line Strings Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-12-18 10:54 -0800
                Re: multi-line Strings Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-12-18 18:57 -0400
                Re: multi-line Strings Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-18 20:02 -0500
                Re: multi-line Strings Lew <lewbloch@gmail.com> - 2012-12-18 17:13 -0800
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-19 19:35 -0500
                Re: multi-line Strings Gene Wirchenko <genew@telus.net> - 2012-12-18 15:12 -0800
                Re: multi-line Strings Gene Wirchenko <genew@telus.net> - 2012-12-19 10:00 -0800
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-19 19:31 -0500
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-19 19:29 -0500
                Re: multi-line Strings Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-12-19 20:44 -0400
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-19 21:50 -0500
                Re: multi-line Strings Lew <lewbloch@gmail.com> - 2012-12-19 23:15 -0800
                Re: multi-line Strings Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-12-20 06:00 -0400
                Re: multi-line Strings Gene Wirchenko <genew@telus.net> - 2012-12-20 08:56 -0800
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-19 19:33 -0500
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-17 21:43 -0500
                Re: multi-line Strings Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-12-17 22:09 -0600
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 20:59 -0500
                Re: multi-line Strings "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-12-18 13:22 +0000
                Re: multi-line Strings Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-12-18 07:52 -0600
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 20:58 -0500
                Re: multi-line Strings Gene Wirchenko <genew@telus.net> - 2012-12-18 09:10 -0800
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 20:56 -0500
                Re: multi-line Strings Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-12-18 19:05 -0400
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 20:42 -0500
                Re: multi-line Strings Jim Janney <jjanney@shell.xmission.com> - 2012-12-17 22:18 -0700
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-17 21:46 -0500
                Re: multi-line Strings Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-12-17 21:01 -0800
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 20:46 -0500
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-17 21:51 -0500
                Re: multi-line Strings Patricia Shanahan <pats@acm.org> - 2012-12-17 19:41 -0800
                Re: multi-line Strings Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-12-18 19:19 -0400
                Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 20:50 -0500
                Re: multi-line Strings Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-12-19 05:23 -0400
                Re: multi-line Strings Lew <lewbloch@gmail.com> - 2012-12-19 13:25 -0800
            Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-14 22:14 -0500
            Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-14 22:14 -0500
          Re: multi-line Strings Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2012-12-14 23:43 +0200
            Re: multi-line Strings Arne Vajhøj <arne@vajhoej.dk> - 2012-12-14 22:20 -0500
              Re: multi-line Strings Arved Sandstrom <asandstrom2@eastlink.ca> - 2012-12-17 20:47 -0400
  Re: multi-line Strings Jim Janney <jjanney@shell.xmission.com> - 2012-12-12 08:33 -0700
    Re: multi-line Strings Lew <lewbloch@gmail.com> - 2012-12-12 11:32 -0800
      Re: multi-line Strings markspace <-@.> - 2012-12-12 11:45 -0800
  Re: multi-line Strings Lew <lewbloch@gmail.com> - 2012-12-15 13:33 -0800
    Re: multi-line Strings Sven Köhler <remove-sven.koehler@gmail.com> - 2012-12-29 18:18 +0100

csiph-web