Thread (41 messages) flat view 41 messages, 3 authors, 2016-06-15

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

From: Florian Köberle <hidden>
Date: 2016-06-15 22:44:42

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help