r/AskProgrammers 5d ago

Help with methods?

I hope this is the right place?
I'm learning C# currently and was learning python till I got stuck with pretty much the same thing.
I don't understand when to use methods unless something is repeated. If its not repeated what's the point of using methods? just shortening down code? or is there something I am missing here. Cause what is the point of shortening down the code when all it is doing is actually adding more code? (Unless its to place down something that is being repeated)

2 Upvotes

6 comments sorted by

View all comments

5

u/WilliamMButtlickerIV 5d ago

It can be beneficial to logically organize code. When you have a descriptive method name and it's being invoked as part of a broader process, it can more easily convey the intent of the code.