Skip to main content
Code Review

Return to Answer

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

I would prefer the first one for a few reasons.

  1. It's more readable and easily understandable in my opinion.
  2. There's only one string, so less overhead. (Which is negligible unless this is being called a lot.)
  3. There's only one array. Reverse creates a second array.

That being said, an actual review is in order.

  • Methods that return a boolean value should have names of the form IsSomething or HasSomething. A great name would be IsPalindrome.
  • Neither method accepts anything but a string. Numbers can be palindromic too. Wouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling .ToString() before passing it in that is.)
  • I like that you're only checking for i < j instead of i <= j. It saves a useless iteration when there are an odd number of characters.
  • I also like the while loop. It's a lot cleaner than the for loop suggested by another answer.
  • I won't speak much on the second method, because I think @elios provided a nice implementation of it @elios provided a nice implementation of it.

I would prefer the first one for a few reasons.

  1. It's more readable and easily understandable in my opinion.
  2. There's only one string, so less overhead. (Which is negligible unless this is being called a lot.)
  3. There's only one array. Reverse creates a second array.

That being said, an actual review is in order.

  • Methods that return a boolean value should have names of the form IsSomething or HasSomething. A great name would be IsPalindrome.
  • Neither method accepts anything but a string. Numbers can be palindromic too. Wouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling .ToString() before passing it in that is.)
  • I like that you're only checking for i < j instead of i <= j. It saves a useless iteration when there are an odd number of characters.
  • I also like the while loop. It's a lot cleaner than the for loop suggested by another answer.
  • I won't speak much on the second method, because I think @elios provided a nice implementation of it.

I would prefer the first one for a few reasons.

  1. It's more readable and easily understandable in my opinion.
  2. There's only one string, so less overhead. (Which is negligible unless this is being called a lot.)
  3. There's only one array. Reverse creates a second array.

That being said, an actual review is in order.

  • Methods that return a boolean value should have names of the form IsSomething or HasSomething. A great name would be IsPalindrome.
  • Neither method accepts anything but a string. Numbers can be palindromic too. Wouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling .ToString() before passing it in that is.)
  • I like that you're only checking for i < j instead of i <= j. It saves a useless iteration when there are an odd number of characters.
  • I also like the while loop. It's a lot cleaner than the for loop suggested by another answer.
  • I won't speak much on the second method, because I think @elios provided a nice implementation of it.
typo fix
Source Link
Pimgd
  • 22.5k
  • 5
  • 68
  • 144

I would prefer the first one for a few reasons.

  1. It's more readable and easily understandable in my opinion.
  2. There's only one string, so less overheardoverhead. (Which is negligible unless this is being called a lot.)
  3. There's only one array. Reverse creates a second array.

That being said, an actual review is in order.

  • Methods that return a boolean value should have names of the form IsSomething or HasSomething. A great name would be IsPalindrome.
  • Neither method accepts anything but a string. Numbers can be palindromic too. Wouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling .ToString() before passing it in that is.)
  • I like that you're only checking for i < j instead of i <= j. It saves a useless iteration when there are an odd number of characters.
  • I also like the while loop. It's a lot cleaner than the for loop suggested by another answer.
  • I won't speak much on the second method, because I think @elios provided a nice implementation of it.

I would prefer the first one for a few reasons.

  1. It's more readable and easily understandable in my opinion.
  2. There's only one string, so less overheard. (Which is negligible unless this is being called a lot.)
  3. There's only one array. Reverse creates a second array.

That being said, an actual review is in order.

  • Methods that return a boolean value should have names of the form IsSomething or HasSomething. A great name would be IsPalindrome.
  • Neither method accepts anything but a string. Numbers can be palindromic too. Wouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling .ToString() before passing it in that is.)
  • I like that you're only checking for i < j instead of i <= j. It saves a useless iteration when there are an odd number of characters.
  • I also like the while loop. It's a lot cleaner than the for loop suggested by another answer.
  • I won't speak much on the second method, because I think @elios provided a nice implementation of it.

I would prefer the first one for a few reasons.

  1. It's more readable and easily understandable in my opinion.
  2. There's only one string, so less overhead. (Which is negligible unless this is being called a lot.)
  3. There's only one array. Reverse creates a second array.

That being said, an actual review is in order.

  • Methods that return a boolean value should have names of the form IsSomething or HasSomething. A great name would be IsPalindrome.
  • Neither method accepts anything but a string. Numbers can be palindromic too. Wouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling .ToString() before passing it in that is.)
  • I like that you're only checking for i < j instead of i <= j. It saves a useless iteration when there are an odd number of characters.
  • I also like the while loop. It's a lot cleaner than the for loop suggested by another answer.
  • I won't speak much on the second method, because I think @elios provided a nice implementation of it.
Minor clarification
Source Link
RubberDuck
  • 31.2k
  • 6
  • 74
  • 176

I would prefer the first one for a few reasons.

  1. It's more readable and easily understandable in my opinion.
  2. There's only one string, so less overheard. (Which is negligible unless this is being called a lot.)
  3. There's only one array. Reverse creates a second array.

That being said, an actual review is in order.

  • Methods that return a boolean value should have names of the form IsSomething or HasSomething. A great name would be IsPalindrome.
  • Neither method accepts anything but a string. Numbers can be palindromic too. wouldn'tWouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling .ToString() before passing it in that is.)
  • I like that you're only checking for i<ji < j instead of i <= j. It saves a useless iteration when there are an odd number of characters.
  • I also like the while loop. It's a lot cleaner than the for loop suggested by another answer.
  • I won't speak much on the second method, because I think @elios provided a nice implementation of it.

I would prefer the first one for a few reasons.

  1. It's more readable and easily understandable in my opinion.
  2. There's only one string, so less overheard. (Which is negligible unless this is being called a lot.)
  3. There's only one array. Reverse creates a second array.

That being said, an actual review is in order.

  • Methods that return a boolean value should have names of the form IsSomething or HasSomething. A great name would be IsPalindrome.
  • Neither method accepts anything but a string. Numbers can be palindromic too. wouldn't it be nice if we could pass an integer to it as well? (Without explicitly calling .ToString() before passing it in that is.)
  • I like that you're only checking for i<j instead of i <= j. It saves a useless iteration when there are an odd number of characters.
  • I also like the while loop. It's a lot cleaner than the for loop suggested by another answer.
  • I won't speak much on the second method, because I think @elios provided a nice implementation of it.

I would prefer the first one for a few reasons.

  1. It's more readable and easily understandable in my opinion.
  2. There's only one string, so less overheard. (Which is negligible unless this is being called a lot.)
  3. There's only one array. Reverse creates a second array.

That being said, an actual review is in order.

  • Methods that return a boolean value should have names of the form IsSomething or HasSomething. A great name would be IsPalindrome.
  • Neither method accepts anything but a string. Numbers can be palindromic too. Wouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling .ToString() before passing it in that is.)
  • I like that you're only checking for i < j instead of i <= j. It saves a useless iteration when there are an odd number of characters.
  • I also like the while loop. It's a lot cleaner than the for loop suggested by another answer.
  • I won't speak much on the second method, because I think @elios provided a nice implementation of it.
added 881 characters in body
Source Link
RubberDuck
  • 31.2k
  • 6
  • 74
  • 176
Loading
Source Link
RubberDuck
  • 31.2k
  • 6
  • 74
  • 176
Loading
lang-cs

AltStyle によって変換されたページ (->オリジナル) /