wo80 / Triangle.NET

C# / .NET version of Jonathan Shewchuk's Triangle mesh generator.
463 stars 85 forks source link

code cleanup #36

Open MovGP0 opened 1 year ago

MovGP0 commented 1 year ago

did the following cleanup:

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

wo80 commented 1 year ago

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):

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

MovGP0 commented 1 year ago

The use of is not null instead of != null

Those have a different meaning:

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 commented 1 year ago

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:

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.