talexb has asked for the wisdom of the Perl Monks concerning the following question:
I'm building a Librarian module -- it has a couple of methods for basic object creation, getting, setting and cleanup. These objects are actually used to access documents in a file system.
So far I have a new method that creates a new object with a supplied name if that name is available. If the name's not available, the new method fails.
I'm doing development by testing, so as I add more code I write tests, and continue when the tests pass. It's a very neat way to develop code, but now I want to add tests that try to access an object that already exists, and the current new method won't allow that -- so I've figured I want to write an init method that will also be a method constructor, but only for names that already exist.
Obviously there's some common functionality between the two methods .. I'm not concerned about that. But is there a usual and customary naming convention or approach to do this in Object Oriented Programming?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Determining what new and init methods do
by dragonchild (Archbishop) on Oct 26, 2007 at 14:59 UTC | |
|
Re: Determining what new and init methods do
by eric256 (Parson) on Oct 26, 2007 at 15:42 UTC | |
by talexb (Chancellor) on Oct 26, 2007 at 15:45 UTC | |
|
Re: Determining what new and init methods do
by ikegami (Patriarch) on Oct 26, 2007 at 16:00 UTC |