I have a very simple question, but I’d like to know :
When and why it’s better to use simple functions, and when and why it’s better to use classes?
I have a very simple question, but I’d like to know : When and
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I have simple answer:
Use classes when you need to treat with objects, especially when you need to persist data while calling functions.
Use simple function when you have just output from input, without accessing any other variables.
Example:
versus