I have an organization that has clients and students, every student begins as a client. If I have a Client class and a student class that inherits from client. How do I make a client a student?
+2
A:
Public Class Client
' code here...
End Class
Public Class Student
Inherits Client
' code here...
End Class
froadie
2010-04-27 17:07:48
After posting this I think I wasn't as clear as I should be. Every student starts out as a Client and may later become a student, how do I 'promote' a client to a student. Since all students already have client information how do I add only the necessary student info to an existing client info without creating a new client object.
Kevin
2010-04-27 17:15:40
A:
It sounds like your problem involves persistence more than inheritance. If you have a client, presumably the persistent data is stored in a client table. When this client becomes a student, you could create a record in a student table containing the student information and the id of the client record. A client object would be loaded from the client table, while a student object would pull data from both client and student tables. Relating the data means client info would never be duplicated, while making it simple to retrieve either client info, or student--including client--info.
Vincent
2010-04-27 17:30:25