Y
Y
yativ_sobb2020-12-17 11:42:26
Software design
yativ_sobb, 2020-12-17 11:42:26

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

2 answer(s)
Y
Yuriy Vorobyov, 2020-12-17
@yativ_sobb

Write a general function and two smaller ones that have differences. Then from the general call one of those two.

V
Victor P., 2020-12-17
@Jeer

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 question

Ask a Question

731 491 924 answers to any question