2 Replies Latest reply: Sep 24, 2007 2:59 AM by 807605 RSS

    MessageFormat vs StringBuilder

    807605
      Hi all,

      I tried to find the answer and yet I don't think I got the right answer.
      What is more affective In the perform section MessageFormat or StringBuilder?


      Thanks all in advance,

      Sasi
        • 1. Re: MessageFormat vs StringBuilder
          Herko_ter_Horst
          No way to answer that question. You'll have to test the two approaches in your particular situation.

          Although I wouldn't even worry about it until you have properly profiled your application and this is shown to be the cause of any performance problems you might have.

          Until then, go for whatever code most clearly matches the intent and purpose of the solution.
          • 2. Re: MessageFormat vs StringBuilder
            807605
            I didn't get that. What's the perform section? What's affective? Do you mean efficient?

            There's no clear answer except this one: the difference in efficiency is not great enough for you to worry about in the vast majority of cases. Use the one that's more convenient for the situation. Even if you run into performance problems, a shift to either MessageFormat or StringBuilder is unlikely to solve it.

            I would consider MessageFormat more high-level, which would indicate that StringBuilder might be slightly faster in some situations, but it would depend, and there are probably exceptions where it's the other way around.

            HTH

            Edited by: OleVV on Sep 24, 2007 8:58 AM