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

[CodeQuality] (WIP) #46

Closed
3 of 12 tasks
Bia10 opened this issue Aug 13, 2021 · 0 comments
Closed
3 of 12 tasks

[CodeQuality] (WIP) #46

Bia10 opened this issue Aug 13, 2021 · 0 comments

Comments

@Bia10
Copy link
Contributor

Bia10 commented Aug 13, 2021

I will write down issues here relating to code quality which i think could be done better or require an explanation.

  • Reduce branching/nesting where possible
    There are areas where unnecessary branching/nesting is introduced. Ultimately as complexity of the code grows so does the overhead introduced by these control flow features. If we assume a ideal Combat Class which manages from lvl 1 to top tier raids. Its likely in current style of code it would include thousands of control structures in case of need to handle every unique case that may happen during various states of execution. This would result in a lot of time spent traversing branches. A rewrite in well written behavioral trees approach would greatly reduce this overhead and make code much more readable.

  • Variable/parameters/args naming conventions
    Some variables/parameters/args conform neither to PascalCasing nor to camelCasing conventions.

  • For loops where foreach loop suffices
    Some for loops actually don't have any need for use of the index, the item of foreach loop suffices
    This is adressed in for loops/nesting reduction #114

  • Variables can be just var
    Depends on consensus i am fine with vars where the underlying type is obvious from context
    There are many places where variable type is apparent no need to speficy, like:

int totalSeconds = (int)totalTime.TotalSeconds;
  • Separate code and data constants
    It would be great to isolate various magic numbers, scripts, texts from code into data constants

  • Some namespaces are incorrect
    This is resolved in fix namespace issues #111

  • Project structural problems
    Combat classes do not belong to engines, however moving them proper namespace would trigger instantiation of abstract classes and therefore compilation would fail.

  • Enforce line ending
    Matter of consensus indeed however according to theory by Markus Itkonen, Typography and readability
    the optimal size of a single line should be 40 to 90 characters wide, historicaly programmers have been biased since ancient times to magically decide the number to be 80, Its hard to read file compares when lines are too long.

  • No need to introduce nesting on control flow feature which is followed only by one statement
    This depends on consensus (IDE0011) but i vote for
    csharp_prefer_braces = when_multiline or multi-conditional or linq-foreachloop

if (true)
{
   Something();
}

just

if (true) Something();
  • Use simple 'using' statement
    again as above (IDE0063) i vote for
    csharp_prefer_simple_using_statement = true
using var a = b;
@Jnnshschl Jnnshschl closed this as not planned Won't fix, can't repro, duplicate, stale Jan 14, 2024
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

No branches or pull requests

2 participants