I recently ran across the AtomsFramework and wish to implement the persistence package in my web app. From reading your tutorials, I found that each class being persisted must inherit the CPersistentObject. Now, i've only started coding with VB.NET for a short while, but in the documentation it states that a class can inherit only one class. So if i had a class say user, and wanted to have two classes admin and manager inherit from user, i wouldn't be able to persist the admin and manager classes. Is my assumption correct?
Another related question is then, if i design user as an interface and implement it in admin and manager classes which will then inherit from CPersistentObject, then can i map both of these classes to one table in the XML file?
I hope this is not a dumb question, but i would really appreciate some feedback.
Thanks,
Bahman
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You're assumptions are slightly wrong. Yes you can only inherit from one class, but that is the nature of object orientation. However inheritance can be inherited - if you follow my meaning :-)
In your example, the user class would be an abstract (mustinherit) class with some basic details (eg name, id, etc) and it would inherit from the CPersistentObject. The admin and manager classes would inherit the user class.
Since the user class already inherits CPersistentObject the admin and manager classes also inherit CPersistentObject (via user) and can therefore be persisted.
As for the mapping, you would need a user table (maybe), an admin table and a manager table. The inheritance isn't yet designed to be able to handle subclassing in the one table.
Richard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for the advice, it helped greatly. Now that i've begun coding, i'm having trouble using the chunk of code that related to deleting an object. I think it has something to do with the fact that i'm creating an asp.net web app, where as in your tutorial your were building a winform application. So my problem is that when you get into the onDelete function, the compiler complains about a nullreference exception when you call the m_CCustomer.Delete() function. I'm creating an instance of the class exactly as in the tutorial (ie. in the load and save subs). The decleration of this m_CCustomer is within the scope of the class but it is instantiated in the load and save methods. Does this mean that the scope of the m_CCustomer is only in those respective Subs? And hence there is a difference with scope behaviour in a Web app and WinForm application? Right now to work around the situation, i'm finding the object first, and then deleting it. But this means that i'm also instantiating in the delete function, which is different from your example. Please advise.
thanks,
Bahman
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One of the problems with web based apps is maintaing the state of your variables between reloads of web pages.
I've not done any ASP.NET stuff so I don't know if there is a different way to do this, but you might find that you have to write your own delete function on your page to load the object , check it is persistent and then delete it, as maintaining the object reference across page loads might not work.
A few other people have used the framework on ASP.net and have said it works so it should be possible.
Let me know how you go.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I recently ran across the AtomsFramework and wish to implement the persistence package in my web app. From reading your tutorials, I found that each class being persisted must inherit the CPersistentObject. Now, i've only started coding with VB.NET for a short while, but in the documentation it states that a class can inherit only one class. So if i had a class say user, and wanted to have two classes admin and manager inherit from user, i wouldn't be able to persist the admin and manager classes. Is my assumption correct?
Another related question is then, if i design user as an interface and implement it in admin and manager classes which will then inherit from CPersistentObject, then can i map both of these classes to one table in the XML file?
I hope this is not a dumb question, but i would really appreciate some feedback.
Thanks,
Bahman
Hi Bahman,
You're assumptions are slightly wrong. Yes you can only inherit from one class, but that is the nature of object orientation. However inheritance can be inherited - if you follow my meaning :-)
In your example, the user class would be an abstract (mustinherit) class with some basic details (eg name, id, etc) and it would inherit from the CPersistentObject. The admin and manager classes would inherit the user class.
Since the user class already inherits CPersistentObject the admin and manager classes also inherit CPersistentObject (via user) and can therefore be persisted.
As for the mapping, you would need a user table (maybe), an admin table and a manager table. The inheritance isn't yet designed to be able to handle subclassing in the one table.
Richard.
Hello,
Thank you for the advice, it helped greatly. Now that i've begun coding, i'm having trouble using the chunk of code that related to deleting an object. I think it has something to do with the fact that i'm creating an asp.net web app, where as in your tutorial your were building a winform application. So my problem is that when you get into the onDelete function, the compiler complains about a nullreference exception when you call the m_CCustomer.Delete() function. I'm creating an instance of the class exactly as in the tutorial (ie. in the load and save subs). The decleration of this m_CCustomer is within the scope of the class but it is instantiated in the load and save methods. Does this mean that the scope of the m_CCustomer is only in those respective Subs? And hence there is a difference with scope behaviour in a Web app and WinForm application? Right now to work around the situation, i'm finding the object first, and then deleting it. But this means that i'm also instantiating in the delete function, which is different from your example. Please advise.
thanks,
Bahman
One of the problems with web based apps is maintaing the state of your variables between reloads of web pages.
I've not done any ASP.NET stuff so I don't know if there is a different way to do this, but you might find that you have to write your own delete function on your page to load the object , check it is persistent and then delete it, as maintaining the object reference across page loads might not work.
A few other people have used the framework on ASP.net and have said it works so it should be possible.
Let me know how you go.