Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

On the overall, your code looks ok. Some points you could improve:

  • Be more consistent with indentation (you use 2 spaces and 4 spaces inconsistently. I would suggest using 4 spaces everywhere).
  • Be more consistent with spacing. Around the + operator, you sometimes use spaces and sometimes not. I would suggest always using spaces.
  • You should add error handling when reading data from stdin (the call to cin can fail).
  • Try not to use abbreviations when not necessary; it lowers the readability of your code. sdk is typically used for "software development kit". I would suggest naming your function readSudoku instead of read_sdk.
  • Send error messages to cerr, and normal log messages to cout. For small programs this does not change a lot, but for big programs it is useful to be able to print errors only.
  • Do not write if conditions on a single line; this lowers readability: (if (...) return false). It is easier to read when this is on two lines.
  • Do not use single letter names for parameters like sdk v. Now your code is very small so this does not change a lot, but v does not have any meaning. Naming it e.g. grid would be a lot better.
  • Do not use and, or and not. Prefer &&, || and ! (the written versions of the operators exist only for backwards compatibility and historical reason, they should not be used in new code, see this this).

On the overall, your code looks ok. Some points you could improve:

  • Be more consistent with indentation (you use 2 spaces and 4 spaces inconsistently. I would suggest using 4 spaces everywhere).
  • Be more consistent with spacing. Around the + operator, you sometimes use spaces and sometimes not. I would suggest always using spaces.
  • You should add error handling when reading data from stdin (the call to cin can fail).
  • Try not to use abbreviations when not necessary; it lowers the readability of your code. sdk is typically used for "software development kit". I would suggest naming your function readSudoku instead of read_sdk.
  • Send error messages to cerr, and normal log messages to cout. For small programs this does not change a lot, but for big programs it is useful to be able to print errors only.
  • Do not write if conditions on a single line; this lowers readability: (if (...) return false). It is easier to read when this is on two lines.
  • Do not use single letter names for parameters like sdk v. Now your code is very small so this does not change a lot, but v does not have any meaning. Naming it e.g. grid would be a lot better.
  • Do not use and, or and not. Prefer &&, || and ! (the written versions of the operators exist only for backwards compatibility and historical reason, they should not be used in new code, see this).

On the overall, your code looks ok. Some points you could improve:

  • Be more consistent with indentation (you use 2 spaces and 4 spaces inconsistently. I would suggest using 4 spaces everywhere).
  • Be more consistent with spacing. Around the + operator, you sometimes use spaces and sometimes not. I would suggest always using spaces.
  • You should add error handling when reading data from stdin (the call to cin can fail).
  • Try not to use abbreviations when not necessary; it lowers the readability of your code. sdk is typically used for "software development kit". I would suggest naming your function readSudoku instead of read_sdk.
  • Send error messages to cerr, and normal log messages to cout. For small programs this does not change a lot, but for big programs it is useful to be able to print errors only.
  • Do not write if conditions on a single line; this lowers readability: (if (...) return false). It is easier to read when this is on two lines.
  • Do not use single letter names for parameters like sdk v. Now your code is very small so this does not change a lot, but v does not have any meaning. Naming it e.g. grid would be a lot better.
  • Do not use and, or and not. Prefer &&, || and ! (the written versions of the operators exist only for backwards compatibility and historical reason, they should not be used in new code, see this).
added 29 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

On the overall, your code looks ok, some. Some points you could improve:

  • beBe more consistent with indentation (you use 2 spaces and 4 spaces inconsistently,. I would suggest using 4 spaces everywhere).
  • beBe more consistent with spacing, around "+". Around the + operator, you sometimes use spaces and sometimes not,. I would suggest always using spaces.
  • youYou should add error handling when reading data from stdinstdin (the call to cincin can fail).
  • tryTry not to use abbreviations when not necessary,necessary; it lowers the readability of your code. "sdk"sdk is typically used for "software development kit",. I would suggest naming your function "readSudoku"readSudoku instead of read_sdkread_sdk.
  • Send error messages to cerrcerr, and normal log messages to coutcout. For small programs this does not change a lot, but for big programs it is useful to be able to print errors only.
  • doDo not write ifif conditions on a single line,line; this lowers readability: ("if (...) return false"if (...) return false). It is easier to read when this is on two lines lines.
  • Do not use single letter names for parameters like "sdk v", nowsdk v. Now your code is very small so this does not change a lot, but vv does not have any meaning. Naming it e.g. "grid"grid would be a lot better.
  • Do not use "and"and, "or"or and "not"not. Prefer "&&" "||"&&, || and "!" !(the written versions of the operators exist only for backwards compatibility and historical reason, they should not be used in new code, see http://stackoverflow.com/questions/2376448/the-written-versions-of-the-logical-operatorsthis).

On the overall, your code looks ok, some points you could improve:

  • be more consistent with indentation (you use 2 spaces and 4 spaces inconsistently, I would suggest using 4 spaces everywhere)
  • be more consistent with spacing, around "+" operator, you sometimes use spaces and sometimes not, I would suggest always using spaces
  • you should add error handling when reading data from stdin (the call to cin can fail)
  • try not to use abbreviations when not necessary, it lowers the readability of your code. "sdk" is typically used for "software development kit", I would suggest naming your function "readSudoku" instead of read_sdk.
  • Send error messages to cerr, and normal log messages to cout. For small programs this does not change a lot, but for big programs it is useful to be able to print errors only.
  • do not write if conditions on a single line, this lowers readability: ("if (...) return false"). It is easier to read when this is on two lines.
  • Do not use single letter names for parameters like "sdk v", now your code is very small so this does not change a lot, but v does not have any meaning. Naming it e.g. "grid" would be a lot better.
  • Do not use "and", "or" and "not". Prefer "&&" "||" and "!" (the written versions of the operators exist only for backwards compatibility and historical reason, they should not be used in new code, see http://stackoverflow.com/questions/2376448/the-written-versions-of-the-logical-operators)

On the overall, your code looks ok. Some points you could improve:

  • Be more consistent with indentation (you use 2 spaces and 4 spaces inconsistently. I would suggest using 4 spaces everywhere).
  • Be more consistent with spacing. Around the + operator, you sometimes use spaces and sometimes not. I would suggest always using spaces.
  • You should add error handling when reading data from stdin (the call to cin can fail).
  • Try not to use abbreviations when not necessary; it lowers the readability of your code. sdk is typically used for "software development kit". I would suggest naming your function readSudoku instead of read_sdk.
  • Send error messages to cerr, and normal log messages to cout. For small programs this does not change a lot, but for big programs it is useful to be able to print errors only.
  • Do not write if conditions on a single line; this lowers readability: (if (...) return false). It is easier to read when this is on two lines.
  • Do not use single letter names for parameters like sdk v. Now your code is very small so this does not change a lot, but v does not have any meaning. Naming it e.g. grid would be a lot better.
  • Do not use and, or and not. Prefer &&, || and !(the written versions of the operators exist only for backwards compatibility and historical reason, they should not be used in new code, see this).
Source Link
Étienne
  • 223
  • 1
  • 6

On the overall, your code looks ok, some points you could improve:

  • be more consistent with indentation (you use 2 spaces and 4 spaces inconsistently, I would suggest using 4 spaces everywhere)
  • be more consistent with spacing, around "+" operator, you sometimes use spaces and sometimes not, I would suggest always using spaces
  • you should add error handling when reading data from stdin (the call to cin can fail)
  • try not to use abbreviations when not necessary, it lowers the readability of your code. "sdk" is typically used for "software development kit", I would suggest naming your function "readSudoku" instead of read_sdk.
  • Send error messages to cerr, and normal log messages to cout. For small programs this does not change a lot, but for big programs it is useful to be able to print errors only.
  • do not write if conditions on a single line, this lowers readability: ("if (...) return false"). It is easier to read when this is on two lines.
  • Do not use single letter names for parameters like "sdk v", now your code is very small so this does not change a lot, but v does not have any meaning. Naming it e.g. "grid" would be a lot better.
  • Do not use "and", "or" and "not". Prefer "&&" "||" and "!" (the written versions of the operators exist only for backwards compatibility and historical reason, they should not be used in new code, see http://stackoverflow.com/questions/2376448/the-written-versions-of-the-logical-operators)
lang-cpp

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