Re: [JGIT PATCH v3 20/23] Added the class NoGitRepositoryFoundException.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Florian Köberle
Date: Sunday, June 8, 2008 - 9:14 am

Robin Rosenberg wrote:
 >> +		super(String.format("No repository found for file '%s'",
 >> +				fileWeSearchedRepositoryFor));
 >
 > This is any odd patterrn. Usually we use + to concatenate strimgs.

Hi Robin,

I know two good reason why you should use formating functions over 
string concatenation via the plus sign:

1.) formated strings are better translatable. e.g.
"The string '%s' is more then %s characters long"
is easier to translate then the three strings:
"The string '"
"' is more then "
" characters long"

2.) Whitespace mistakes are easier to see. e.g.
(i + "coins") and ("%scoins", i)

Sure you can make the mistake to provide not enough arguments, but 
that's not so worse:
a.) Some IDEs, like Intellij IDEA warn you if you call a formating 
function with to few arguments.
b.) A exception will be thrown at the time the function is called, if 
there are not enough arguments. Thus you will notice your mistake very soon.

Best regards,
Florian
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[JGIT PATCH v3 02/23] Added the class FileNameMatcher and ..., Florian Koeberle, (Fri May 23, 1:34 pm)
[JGIT PATCH v3 03/23] Added the interface FilePattern., Florian Koeberle, (Fri May 23, 1:34 pm)
[JGIT PATCH v3 04/23] Added the class Rule., Florian Koeberle, (Fri May 23, 1:34 pm)
[JGIT PATCH v3 05/23] Added the iterface Rules., Florian Koeberle, (Fri May 23, 1:34 pm)
[JGIT PATCH v3 06/23] Added the class FileNamePattern., Florian Koeberle, (Fri May 23, 1:34 pm)
[JGIT PATCH v3 07/23] Added the class FilePathPattern., Florian Koeberle, (Fri May 23, 1:34 pm)
[JGIT PATCH v3 08/23] Added the class IgnoreRuleListFactory., Florian Koeberle, (Fri May 23, 1:34 pm)
[JGIT PATCH v3 12/23] Added the class AddRuleListFactory., Florian Koeberle, (Fri May 23, 1:34 pm)
[JGIT PATCH v3 13/23] Formatted Constants class., Florian Koeberle, (Fri May 23, 1:34 pm)
[JGIT PATCH v3 15/23] Added class AddRulesFactory., Florian Koeberle, (Fri May 23, 1:34 pm)
[JGIT PATCH v3 17/23] Added class LightFileTreeIterable., Florian Koeberle, (Fri May 23, 1:34 pm)
[JGIT PATCH v3 18/23] Added path related constants to the ..., Florian Koeberle, (Fri May 23, 1:34 pm)
[JGIT PATCH v3 21/23] Formatted Repository class., Florian Koeberle, (Fri May 23, 1:34 pm)
Re: [JGIT PATCH v3 05/23] Added the iterface Rules., Robin Rosenberg, (Thu Jun 5, 5:22 pm)
Re: [JGIT PATCH v3 06/23] Added the class FileNamePattern., Robin Rosenberg, (Thu Jun 5, 5:22 pm)
Re: [JGIT PATCH v3 21/23] Formatted Repository class., Robin Rosenberg, (Thu Jun 5, 5:23 pm)
Re: [JGIT PATCH v3 20/23] Added the class NoGitRepositoryF ..., Florian Köberle, (Sun Jun 8, 9:14 am)