I'm writing a class to insert users into a database, and before I get too far in, I just want to make sure that my OO approach is clean:
class User(object):
def setName(self,name):
#Do sanity checks on name
self._name = name
def setPassword(self,password):
#Check password length > 6 characters
#Encrypt to md5
self._password = password
def commit(self):
#Commit to database
>>u = User()
>>u.setName('Jason Martinez')
>>u.setPassword('linebreak')
>>u.commit()
Is this the right approach? Should I declare class variables up top? Should I use a _ in front of all the class variables to make them private?
Thanks for helping out.