Simple derivation function summary

S1: analyzing the structure based on a metric
 

Unit1_task1

The operation is relatively simple, I directly use regular expressions to split items, and then turn the extraction coefficient and the number of each item, to store data in a binary group, and finally by the tuple

The number of times the level of sorting, merging the last adjacent item (here I did not use HashMap, HashMap because the operation is not familiar with). Wherein the method is for of collectpoly

Brief final expression, printPoly Term for outputting method, the method is to achieve the CompareTo Comparable interface Term class in order to use Collections.sort

Sorting, toString method is a method printPoly main portion, for converting the single string.

But the Input class ope of ration complexity is still high, mainly due to too many features and expressions written in the Input processing inside, out of mind still can not process-oriented programming

Led me in dealing with specific situations, created not by the corresponding class to handle, but by Method and create the appropriate function to deal with, but also lead to higher complexity class.

 

Unit1_task2 

f

The second job derivation trigonometric expression increased, but the first job and there is no essential difference, I directly based on the first code, the class Term storing data from Dual

Group into a quad, still used to store a plurality of Arraylist quad, this time is not used due to the HashMap value here is a ternary number, unlike direct task1 is an integer,

This leads to need two HashMap, more inconvenient. This time, the time is mainly spent on identifying Format, after consideration, I directly use a large regular and capture group to

Direct access times and each coefficient need.

Compared to the method in which task1 new methods and parseItem have check method, check method used to check whether the correct format, the new parseItem method is due to make this time

Using a large regular to resolve, with a formal presentation instructions, the code is more complex, so this function separately from the main extraction methods.

Here to see the complexity of the design and the complexity of the ring and my collectItems parseItem method are high, because I would derivation and simplification are placed collectItems implemented, no

Achieve a function corresponding to a method.

Considering the third time jobs related to the recursive derivation, and can no longer be tricky to store data using multivariate group, and I personally rewrite again task2, this time the derivation uses a recursive function

Methods (still not free from process-oriented way of thinking), is surprisingly simple to implement, so for the third time the job will have some clout (natural and eggs).

 

Unit1_task3 

 

The third operation allows nested expression factor, which leads to Taisho no longer use, so the first question is the format ahead of us, but also formatting problems I encountered in the job

The most difficult issues. By allowing the expression of nested parentheses, no longer be used to parse large regular format, I can only use the most primitive way, while being read to judge. A method for implementing the two add

The expression "+" is connected, for implementing the method Mult "*" is connected to a case where there is a comprehensive expression is 0 or 1, or null between the two expressions, the method is directed to degenerate Check

Single expression simplification, first check whether it complies with a relatively simple format, if carried out in line with the simplification (yes, here I am only the shape of taks2 expressions have been simplified partial),

checkbrackets method for checking logical expressions bracket legality, to prevent misjudgment when determining factor expression, the role of the other functions are the same in task2.

The complexity mainly in the diffsin and diffcos these two functions because I could not determine the format of questions alone will decouple out, it can only determine the format blend into the lead in seeking,

The expression peel layer, and finally determines whether to belong to the basic items, NO, return null.

Since task2 I will take into account the expansion task3, so in the derivation rules are not much of a problem, but who would have thought task3 most troublesome is not the derivation, but layer after layer of

Nested parentheses format resolve problems caused by it? I really still too young.

The biggest mistake a method to determine the format, I should be comprehensive judgments from both positive and negative aspects, and not just think about how to construct a proper format to be screened, while ignoring the use of the wrong format

Type to exclude, which led me to appear on the judging format of a huge mistake, leading to repeated writing code, code reuse rate, the higher the complexity of the Method.

 

S2: Self-bug analysis and bug excavation method   

In task1 and task2 stage, what bug none appear in the test and interoperability test in strong, centralized bug outbreak in task3, above in the analysis of the structure of the program also mentioned, led me in the task3

Analyzing the complexity of the code format is straight up, and due to the high complexity of the coupling with other methods format judgment, leading to a major problem I in it, some of it should be determined

I was WRONG FORMAT is not identified, and some should be resolved correctly, and I identified as WRONG FORMAT, so strong in the test and interoperability test have been identified in the bug. to sum up

Look, for two reasons, one is not extracted out separately determining module format, resulting in a low rate of code reuse, modifications are relatively trouble; second format identification degree of coupling with other functions too, the guide

Guide each format recognition application scenarios are a problem.

Then it is a bug in the excavation. I'm usually the first based on more difficult issues I have encountered in dealing with, look at other people's means of settlement, if the others to solve this problem, a very

Excellent handling, that I naturally can learn from experience and make up their own mind short board; the other hand, if someone else has taken a long and complex handling, so when it comes to this part of the code

On the very issue that may arise.

After checking the code in this section, then using MetricsReloaded plug, for their dependencies and complexity analysis codes for a cyclic dependency occurs and high complexity case,

Focus look at this part of the code, for high cyclomatic complexity method, it focuses look at its branch statement to see if there are any omissions situation. These are the bug appeared the hardest hit.

S3: Application object creation mode

 

 From task2 came into contact with the factory pattern, but not to practice in my program, it now appears, use the factory pattern does simplify some code. If this approach is reconstructed

Consider creating a diffFactor (), create diffAdd (), diffmult (), diffsin (), diffcos (), diffpow () derivation of these classes, so not only easy to modify, increased code reuse rate, but also

Such programs more readable, and better encapsulation.

 

 

S4: with excellent contrast and code ideas

After the code with some excellent, my biggest feeling is I and their code style is a big gap, in the preparation of the program, my thinking is still biased in favor of object-oriented rather than process-oriented, which

Cause my conventional processing means are very different, I often also lead to a "main" in the end of the case, the code coupling high, the method is always the number of rows exceeds the limit, or even class lines lines out restrictions,

This is what I need to reflect on, multi-read Gangster code, change over as quickly as possible from the process-oriented thinking.

Followed by personal feelings and experiences, object-oriented this course really difficult, is the test of our programming level, but also closer to our actual future work, I should spend more time on this course.

In addition, when writing OO code, we must at the outset that a good general idea, which created several major categories, which are several methods to achieve, rather than experiencing the problem is to create a new method, which is very

Code easily lead to a high degree of coupling, and the need to continue to modify the method due to a bug, to patch, this is very time consuming.

 

Guess you like

Origin www.cnblogs.com/yixuanluo/p/12540645.html