Answer the question
In order to leave comments, you need to log in
What's the best way to get a list of orders?
At the moment I am writing a function to receive orders for both sides. There was a question to use one method or for each role separate.
+ Use one method, shortens the code, and code repetitions
- Although now these functions are very similar, it may change a lot in the future
Or now use one method, but when the path is heavily branched, make two methods based on the primary method.
Answer the question
In order to leave comments, you need to log in
Write a general function and two smaller ones that have differences. Then from the general call one of those two.
Good afternoon,
The process you describe is called refactoring. I advise light reading on this topic refactoring.guru
Also, there are general tips, the so-called principles, here is the first link in Google , superficially, but should be clear.
In answer to your question, there should be no code duplication. Do one method. Then, if, suddenly, a branch appears, then in this function there is a common code and two others appear, in which there will be a different code
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question