Class / Object / Instantiation question

I’m a old COBOL programmer working hard to comprehend OOP and am mostly there but still have gray areas.

In reference to encapsulation, say I have a class called clsEmployee and I want all updates to the employee object and the underlying SQL database record to be executed by a method attached to the class.

Since a method of a class can’t instantiate an object of the same class, do I instantiate the an object in another method and then call the class method and pass it the object?

Create a Shared Method on the class. This will allow what you want. It’s really the same thing as having a protected method in a module that does the same thing. We use this quite a bit in ActiveRecord for List and FindByID sorts of things.

@Bob Keeney, thank’s Bob

If you wanted to see it in action, download ARGen, connect up to a database with your tables and generate a project from it. The data class we generate will show this in action.