+ 2
How program architecture should be?
Hey, I l recently came back to python and realised I have the above question. Should a program essentially run from function to function? In my mind I kind of see them doing the heavy lifting , before calling the next on waiting on input. Is the right?
2 Answers
+ 5
Generally speaking functions or methods should do one thing and do it really well. You don't want to have 'do-it-all' functions or methods. I don't think you should run function to function either. Typically you'll have your main function that calls the successive functions/methods and checks return values.
Having a single entry and exit point makes error handling a little easier and the overall project more maintainable and readable.
0
Ahhh so once a function/method ends it would call the next? I suppose thatâs what i thought when i said function to function. What about if it was a game for example where i would have a method for movement and spawn enemies simultainiously, or a program that is also running a clock whilst another operation? Ive heard of threading before, is that right? Thank you btw; can find alot on code but understanding good algerithems not so much.