Closed jwjacobson closed 8 months ago
Yes, any duplicated code should ideally be abstracted into functions, classes, etc.
Related: Extract Method Refactoring Example in Python: https://www.youtube.com/watch?v=N9sqd1-0_qk
Although checking it now, this video is more about breaking out code into multiple functions, but the principle is the same: take the duplicated code, move it into a new function, remove the other copy, then call the new function in both places.
I've reduplicated the same long block of code in my list and play views, it might be nice just to isolate that out as a basic_search() function that is then called by the relevant views. Is there any downside to this?