Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code cleanup #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

code cleanup #36

wants to merge 1 commit into from

Conversation

MovGP0
Copy link

@MovGP0 MovGP0 commented Apr 19, 2023

did the following cleanup:

  • enabled nullable checks
  • added missing private/internal keywords
  • fixed autoproperties
  • fixed nullable warnings
  • removed unused namespace imports
  • cleaned up namespace imports
  • removed redundant type declarations
  • fixed some inheritdoc attributes where there is no doc to interit from
  • added .idea folder to gitignore

Note: additional cleanup is required to fix all the nullable issues

@wo80
Copy link
Owner

wo80 commented Apr 20, 2023

Thanks, @MovGP0

Massive pull request, a lot of stuff going on here! Some stuff I'd be glad to merge, other that I don't like too much. Was this done by some kind of automated code correction?

From skipping over parts of the code, here are the things I dislike (basically my personal coding style preferences):

  • The use of is not null instead of != null
  • Using var for basically everything. Especially on types like int, float and double I like to be explicit. And for (var i = 0; ...) instead of for (int i = 0; ...) just doesn't feel right :-)
  • I do like the nullable .NET feature, but having >1k warnings about it is rather annoying. Who's gonna fix this? Enabling the feature for new projects makes sense, but not so much for old projects.

I'll have a second, closer look at this PR in the next days.

@MovGP0
Copy link
Author

MovGP0 commented Apr 21, 2023

The use of is not null instead of != null

Those have a different meaning:

  • is not null checks if the variable is null
  • != null uses the overload of the != operator to check against null, but it's not ensured by the runtime that this is correct.

Therefore, the is not null operator is recommended.

Using var for basically everything.

The use of var is recommended because it makes refactorings easier. The type is still shown by modern IDEs, so no information is lost. Just might take some time to get used to it.

having >1k warnings about it is rather annoying

Nullability-bugs are the most common form of bugs in code. Unfortunately, the nullability issues won't get fixed without those warnings.

@wo80
Copy link
Owner

wo80 commented Apr 26, 2023

Therefore, the is not null operator is recommended.

Agree.

The use of var is recommended because it makes refactorings easier. The type is still shown by modern IDEs, so no information is lost. Just might take some time to get used to it.

I do use var all the time, but not on the value types mentioned. Especially for numeric types, writing the type explicitly makes the code easier/faster to comprehend (at least for me).


I had a detailed look at all the code changes. I hope we agree, that opening such a large pull request without prior discussion is not optimal. Having coding style changes that we partly disagree on as main content, I think I'm not going to merge at this point. I'm not sure if it makes sense trying to fix these issues, but here are few more things I noticed:

  • Why move enums from Enums.cs to Enums subdirectory?
  • The use of using without fully qualified namespace (I know it works, but I prefer writing the full namespace).
  • While fixing inheritdoc, why not provide proper documentation?
  • Why specify internal for classes whilst not necessary?
  • Applying nullable scheme where it doesn't make sense (Vertex? in TriangleWriter.WriteElements()).
  • Inconsistent use of var with struct types (default vs default(Otri) in many places).
  • Adding if (edge is null) continue; in DcelMesh.IsConsistent() changes semantics of the method (should return false or throw to match previous behaviour).
  • Removing a method that was commented out in BoundedVoronoi (I actually forgot it was there, so thanks for the reminder).

As mentioned in my first comment, I would like to apply parts of the changes. Let me know what you think would be the best way to proceed, so that your contribution doesn't go unnoticed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants