Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

###Interface

Interface

It's pretty common to order your interface from least to most restricting. I.e. public, protected, private. This way users of your class don't have to scroll all the way down only to see what methods you expose.

###vector<bool> is special

vector<bool> is special

It can have an impact on performance so you might want to reconsider its usage. If you do use vector make sure to use reserve to avoid unnecessary allocations.

###Early out

Early out

In many cases it's a good idea to opt for an early out if things go wrong.
So instead of:

if (condition) {
 // do things
}

prefer:

if (!condition) {
 return;
}
// other code here

This way you avoid arrow code that grows more and more to the right of your screen

###Misc.

Misc.

In some cases you still use foo & instead of the recommended foo&. Copy paste error?

Why do you use typedef and then continue to use Point in most cases? This seems inconsistent. You said Point is your own implementation so if you want a different name just rename the class/struct.

Interesting use of template. Is there a specfic reason why you don't just pass gridSize as a parameter?
On this note, if you intend to use this code to solve arbitrary sized grids you might blow up your stack.

###Interface

It's pretty common to order your interface from least to most restricting. I.e. public, protected, private. This way users of your class don't have to scroll all the way down only to see what methods you expose.

###vector<bool> is special

It can have an impact on performance so you might want to reconsider its usage. If you do use vector make sure to use reserve to avoid unnecessary allocations.

###Early out

In many cases it's a good idea to opt for an early out if things go wrong.
So instead of:

if (condition) {
 // do things
}

prefer:

if (!condition) {
 return;
}
// other code here

This way you avoid arrow code that grows more and more to the right of your screen

###Misc.

In some cases you still use foo & instead of the recommended foo&. Copy paste error?

Why do you use typedef and then continue to use Point in most cases? This seems inconsistent. You said Point is your own implementation so if you want a different name just rename the class/struct.

Interesting use of template. Is there a specfic reason why you don't just pass gridSize as a parameter?
On this note, if you intend to use this code to solve arbitrary sized grids you might blow up your stack.

Interface

It's pretty common to order your interface from least to most restricting. I.e. public, protected, private. This way users of your class don't have to scroll all the way down only to see what methods you expose.

vector<bool> is special

It can have an impact on performance so you might want to reconsider its usage. If you do use vector make sure to use reserve to avoid unnecessary allocations.

Early out

In many cases it's a good idea to opt for an early out if things go wrong.
So instead of:

if (condition) {
 // do things
}

prefer:

if (!condition) {
 return;
}
// other code here

This way you avoid arrow code that grows more and more to the right of your screen

Misc.

In some cases you still use foo & instead of the recommended foo&. Copy paste error?

Why do you use typedef and then continue to use Point in most cases? This seems inconsistent. You said Point is your own implementation so if you want a different name just rename the class/struct.

Interesting use of template. Is there a specfic reason why you don't just pass gridSize as a parameter?
On this note, if you intend to use this code to solve arbitrary sized grids you might blow up your stack.

Source Link
yuri
  • 4.5k
  • 3
  • 19
  • 40

###Interface

It's pretty common to order your interface from least to most restricting. I.e. public, protected, private. This way users of your class don't have to scroll all the way down only to see what methods you expose.

###vector<bool> is special

It can have an impact on performance so you might want to reconsider its usage. If you do use vector make sure to use reserve to avoid unnecessary allocations.

###Early out

In many cases it's a good idea to opt for an early out if things go wrong.
So instead of:

if (condition) {
 // do things
}

prefer:

if (!condition) {
 return;
}
// other code here

This way you avoid arrow code that grows more and more to the right of your screen

###Misc.

In some cases you still use foo & instead of the recommended foo&. Copy paste error?

Why do you use typedef and then continue to use Point in most cases? This seems inconsistent. You said Point is your own implementation so if you want a different name just rename the class/struct.

Interesting use of template. Is there a specfic reason why you don't just pass gridSize as a parameter?
On this note, if you intend to use this code to solve arbitrary sized grids you might blow up your stack.

lang-cpp

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