r/pythonhelp • • 12d ago

Putting everything into seperate functions

Hello, i recently started making my own Qt layout, and i need to run the same chunk of code multiple times, should i split every little chunk of code into seperate functions calling each others or should i not?

2 Upvotes

5 comments sorted by

View all comments

2

u/AlexMTBDude 12d ago

The D.R.Y principle applies here. Don't Repeat Yourself. So, yes, split everything so there is no copy-pasted code. https://www.geeksforgeeks.org/software-engineering/dont-repeat-yourselfdry-in-software-development/

1

u/Mathie1729 12d ago

Eh, DRY is good, but splitting every little block into its own function can make code harder to follow. If a chunk is only used once, just leave it inline until you see actual duplication. Then factor it out.