P
pgrazaitis
I cant seem to get my head wrapped around this issue, I have myself so
twisted now there maybe no issue!
Ok so I designed a class X that has a few members, and for arguments
sake one of the members Y is the location of a file to be read. The
original design assumes that this class will be instantiated and each
instance will happily mange its own members. (ie One file location
per instance...no thread-safety).
Now another class A comes along and makes an instance of this class as
a static readonly member B. Do I now have "implied staticness" on the
original class design? Ok, I cant change the actual pointer to the
instance of Class X; however, through class methods I can change the
make-up of this object. In my case I can use methods in class X to
change the file to be read.
If all of this is true so far, I can now change the file to be read so
that all instances of A must read the same configuration file. Per
the original design of class X, the class invariant is ok. However,
with "implied staticness" I have a potential issue in its use.
So this is the Pandora's box I have been forced to use. I am forced
to create this object as static due to a static method
signature...still dont fully understand that architecture yet.
-Is "implied staticness" true?
-Does this force a refactoring of class X to account for static usage/
thread safety/static based invariants?
*Im implied to say no and these questions are directed towards my
design of class A
-Are there better patterns or best practices I should use to vet my
class design?
-Should I reconsider the design of class A for static usage/thread
safety/staticbased invariants?
*In this case I guess I would have to include additional overhead to
check certain settings before resetting.
*Could create a factory...hmmm thats probably really what should be
done anyways..huh?
Thanks in advance for reading my rumblings,
-Pete
twisted now there maybe no issue!
Ok so I designed a class X that has a few members, and for arguments
sake one of the members Y is the location of a file to be read. The
original design assumes that this class will be instantiated and each
instance will happily mange its own members. (ie One file location
per instance...no thread-safety).
Now another class A comes along and makes an instance of this class as
a static readonly member B. Do I now have "implied staticness" on the
original class design? Ok, I cant change the actual pointer to the
instance of Class X; however, through class methods I can change the
make-up of this object. In my case I can use methods in class X to
change the file to be read.
If all of this is true so far, I can now change the file to be read so
that all instances of A must read the same configuration file. Per
the original design of class X, the class invariant is ok. However,
with "implied staticness" I have a potential issue in its use.
So this is the Pandora's box I have been forced to use. I am forced
to create this object as static due to a static method
signature...still dont fully understand that architecture yet.
-Is "implied staticness" true?
-Does this force a refactoring of class X to account for static usage/
thread safety/static based invariants?
*Im implied to say no and these questions are directed towards my
design of class A
-Are there better patterns or best practices I should use to vet my
class design?
-Should I reconsider the design of class A for static usage/thread
safety/staticbased invariants?
*In this case I guess I would have to include additional overhead to
check certain settings before resetting.
*Could create a factory...hmmm thats probably really what should be
done anyways..huh?
Thanks in advance for reading my rumblings,
-Pete