overwrite a class in memory?

  • Thread starter Thread starter not_a_commie
  • Start date Start date
N

not_a_commie

I have a fat class. I have lots of other classes that reference it. I
want to make a new fat class without requiring everyone to update
their references to it. Am I crazy? Any idea on how to pull this off?
 
not_a_commie said:
I have a fat class. I have lots of other classes that reference it. I
want to make a new fat class without requiring everyone to update
their references to it. Am I crazy? Any idea on how to pull this off?

Do you really mean "class", or do you mean "object"? You can simply alter an
objects fields to update it without having to change any references. You can
provide a convenience method that overwrites the fields by copying them from
another instance of the same class, so you effectively "overwrite" the
object with another.

If you do mean "class", you want a dynamically typed language, not a
statically typed language like C#. Those require that types are fully
specified at compile time and do not change at runtime. While you can get
around this with code generation and reflection, the resulting code would be
impossible to maintain, and it requires everyone to be aware of the
approach, so don't even go there.

You could conceivably mean something different altogether when you're
talking about "updating references", so do clarify.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top