Classes vs Functions

Thread Solved

Join Date: May 2008
Posts: 11
Reputation: ccandillo is an unknown quantity at this point 
Solved Threads: 0
ccandillo ccandillo is offline Offline
Newbie Poster

Classes vs Functions

 
0
  #1
Nov 20th, 2008
OK, this may be a dumb question but I'll ask anyway. I am starting to see the benefits of using classes. Most notably code reuse, inheritance and overloading. Shoud I still be writing fuctions in my scripts or do classes make them obsolete? Is there a rule of thumb that if your script has say 20 lines or more you should write a class?
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,019
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 931
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Classes vs Functions

 
0
  #2
Nov 20th, 2008
Classes don't make functions obsolete. The beauty of Python is that you can go either way. It's up to you, if a class makes sense, use it. I use classes in most GUI programs, using inheritance is very common. Also, the program looks more organized and simply makes life easier.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,011
Reputation: woooee is a jewel in the rough woooee is a jewel in the rough woooee is a jewel in the rough 
Solved Threads: 286
woooee woooee is offline Offline
Veteran Poster

Re: Classes vs Functions

 
0
  #3
Nov 21st, 2008
I use a class 99% of the time. Once the program gets beyond the simple function level, it organizes the code IMHO. Also, a class doesn't have any of the global variable problems.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 902
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 145
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is online now Online
previously paulthom12345

Re: Classes vs Functions

 
0
  #4
Nov 21st, 2008
I find functions still a great thing to have if you want to have something unrelated to either class. Personally i like to only have related functions in a class and if i want a function and there is no specific class that it fits into then i do not put it in a class and leave it out.
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,371
Reputation: evstevemd has a spectacular aura about evstevemd has a spectacular aura about evstevemd has a spectacular aura about 
Solved Threads: 127
evstevemd's Avatar
evstevemd evstevemd is online now Online
Nearly a Posting Virtuoso

Re: Classes vs Functions

 
0
  #5
Nov 22nd, 2008
+1 for Paul & Vega
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC