in reply to FileHandle objects as data members of another object
From what you say, its possible that the object has been created to break up a long subroutine, pushing some of the sub locals into object member vars. If so, bear in mind that the original solution had the sequencing of operations and that is lost (except at the calling site) by this refactoring. Since the ordering is part of the object's knowledge, it should live within it (as a class method) and not at the call site.
Lastly, it can be worth thinking of the member vars as 'has-a'. If the object *has* filehandles, then make them member vars (e.g. a logging class). If it just interacts with them (e.g. opens file so object can be serialised) then perhaps that resource is better owned by something else and passed in as a parameter.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: FileHandle objects as data members of another object
by blazar (Canon) on Oct 22, 2006 at 16:59 UTC | |
by jbert (Priest) on Oct 23, 2006 at 08:16 UTC | |
by blazar (Canon) on Oct 23, 2006 at 08:43 UTC | |
by jbert (Priest) on Oct 23, 2006 at 09:09 UTC | |
by Anonymous Monk on Oct 24, 2006 at 13:40 UTC | |
by blazar (Canon) on Oct 24, 2006 at 14:13 UTC |