Answer the question
In order to leave comments, you need to log in
Tree calculator, C#. I'll be happy to hear why I'm wrong (about the quality of the code)?
I wanted to write a calculator: paste.org.ru/?nnq9gg
Surprisingly, it works, it passes many of my tests. But I don't like the code. There is no beauty.
What to do?
Answer the question
In order to leave comments, you need to log in
Strictly my preferences.
It is not clear at first glance which variable has which level (global public, global private, local, method parameter). There are some naming rules in this regard, for example, global for the class private string _nameOfVariable
, public string NameOfVariable
,
local just with a small letter, as well as method parameters.
The style of names is different everywhere - either m_Value or lexemType.
The names of the methods, for my taste, should still reflect what action they perform. For example, there is a LexemType() method. You will see this and you need to get into the code to understand what it does. It would be better, for example, GetLexemType() or GetLexemByChar(), but basically you stick to this scheme.
The class names are very short. For me, the names Expression, ExpressionVariable, ExpressionTree and so on are more informative. No need to guess what the author meant there and what abbreviation he came up with.
Why assign 0 to double as 0.0? The type is already there.
Extra method calls. Why do Name.ToString() if Name is already a string ?
Directly opening class fields is also not good. You can make a property, well, that is, like this, public string Name {get; set;}
or write a couple of methods GetName () and SetName ()
Well, this is what immediately caught my eye. On the implementation itself, I can unsubscribe later, if there is time.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question