rewrite implementation of existing method (fix) in another application

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

rewrite implementation of existing method (fix) in another application

Petr Fischer
Hello, can I rewrite implementation of existing method of existing class from base libraries in my own application?

For example, I need to fix existing method asByteArray of class String (defined in base CLDT app) and I want to automaticaly load this fixed method with my configuration map. This is example only (in fact, we need to fix something in old Oracle classes in VAST 7).

It's something like extending existing classes with new methods in another app - but is possible to rewrite/fix some existing method?

Thanks, Petr Fischer

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: rewrite implementation of existing method (fix) in another application

Louis LaBrunda
Hi Petr,

You can do what you want, I do it from time to time.  I don't like to because you do need to have your configuration map load your changed version of the app that contains the changed method.  This can be a maintenance problem if you upgrade VA Smalltalk and configuration maps change.  Since you are talking about old Oracle classes in VAST 7, I wouldn't expect things to change much if at all but they could and you would need to check that your changes are still being loaded.  Good luck.

Lou

On Thursday, September 21, 2017 at 8:48:08 AM UTC-4, Petr Fischer wrote:
Hello, can I rewrite implementation of existing method of existing class from base libraries in my own application?

For example, I need to fix existing method asByteArray of class String (defined in base CLDT app) and I want to automaticaly load this fixed method with my configuration map. This is example only (in fact, we need to fix something in old Oracle classes in VAST 7).

It's something like extending existing classes with new methods in another app - but is possible to rewrite/fix some existing method?

Thanks, Petr Fischer

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: rewrite implementation of existing method (fix) in another application

Wayne Johnston
In reply to this post by Petr Fischer
If I understand the question correctly, the answer is no.  You can change a method, but it could not be in your app.  The fix would be in a new version of that app.

Well yes you could have a new version of that app that removes the method, and then add the desired version of that method in an app of your own, but that would be extra work and I don't see a reason.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: rewrite implementation of existing method (fix) in another application

Marten Feldtmann-5
In reply to this post by Petr Fischer
I would not change any base methods - unless you have a *very*,*very* good reason to do so (e.g. really bug fixing).

Introduce a new method (in several class hierarchies) e.g. prefixAsByteArray and introduce the logic you want in this new method - you may call the original asByteArray within that method.

Marten

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: rewrite implementation of existing method (fix) in another application

Richard Sargent
Administrator
In reply to this post by Petr Fischer
Hi Petr,

Obviously, the other replies have good advice especially about replacing the implementation of methods in the base product. However, sometimes, it is unavoidable.

Some years ago, Paul Baumann created a solution for this that works well. It is based on the very nature of Smalltalk, so it is clean. I recommend it for those cases where correcting base product code adn relaying the change to Instantiations for inclusion in future versions just isn't practical.


Found this on http://ibm.software.vasmalltalk.narkive.com/pqq3TEL8/extending-a-class-and-overriding-an-existing-method. Paul's solution works well, with one caveat.  I recommend removing the installed overrides before saving an image and re-instating them after the save.

Paul Baumann
12 years ago

Post by Edmilson Bringel
It's possible to extend a class and override an existing class method (or
create an attribute) and save in My own Application?
Sorry to be late to the discussion.

You can easily change the behavior of existing methods with
PlbMethodOverrideSupport. Get the framework at
http://sourceforge.net/projects/methodoverride/. Load the
PlbMethodOverrideSupport application and then define #override_*
methods as extensions to the class from your own application code. The
override framework does a transient exchange of the methods and keeps
everything in sync whenever you recompile, load, unload, etc.. The old
method is available as #overridden_* and you can use that behavior.

You can extend attributes by using a reference collection. You'd define
methods on Object like #attributeAt: and #attributeAt:put: that refers
to a global weak key identity dictionary whose keys are objects with
extensions and whose values are attribute name/value pairs (a
dictionary). You'd also define getter and setter methods to access the
new variables using the new protocol. Simple.

Regards,

Paul Baumann

On Thursday, September 21, 2017 at 5:48:08 AM UTC-7, Petr Fischer wrote:
Hello, can I rewrite implementation of existing method of existing class from base libraries in my own application?

For example, I need to fix existing method asByteArray of class String (defined in base CLDT app) and I want to automaticaly load this fixed method with my configuration map. This is example only (in fact, we need to fix something in old Oracle classes in VAST 7).

It's something like extending existing classes with new methods in another app - but is possible to rewrite/fix some existing method?

Thanks, Petr Fischer

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: rewrite implementation of existing method (fix) in another application

Richard Sargent
Administrator
p.s. Paul, if you read this, it would be nice if you could publish your various tools in vastgoodies.com.


On Thursday, September 21, 2017 at 3:18:44 PM UTC-7, Richard Sargent wrote:
Hi Petr,

Obviously, the other replies have good advice especially about replacing the implementation of methods in the base product. However, sometimes, it is unavoidable.

Some years ago, Paul Baumann created a solution for this that works well. It is based on the very nature of Smalltalk, so it is clean. I recommend it for those cases where correcting base product code adn relaying the change to Instantiations for inclusion in future versions just isn't practical.


Found this on <a href="http://ibm.software.vasmalltalk.narkive.com/pqq3TEL8/extending-a-class-and-overriding-an-existing-method" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fibm.software.vasmalltalk.narkive.com%2Fpqq3TEL8%2Fextending-a-class-and-overriding-an-existing-method\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGMxJEDYNxvIqrszsx-mgmZDFSkJw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fibm.software.vasmalltalk.narkive.com%2Fpqq3TEL8%2Fextending-a-class-and-overriding-an-existing-method\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGMxJEDYNxvIqrszsx-mgmZDFSkJw&#39;;return true;">http://ibm.software.vasmalltalk.narkive.com/pqq3TEL8/extending-a-class-and-overriding-an-existing-method. Paul's solution works well, with one caveat.  I recommend removing the installed overrides before saving an image and re-instating them after the save.

Paul Baumann
12 years ago

Post by Edmilson Bringel
It's possible to extend a class and override an existing class method (or
create an attribute) and save in My own Application?
Sorry to be late to the discussion.

You can easily change the behavior of existing methods with
PlbMethodOverrideSupport. Get the framework at
<a href="http://sourceforge.net/projects/methodoverride/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fsourceforge.net%2Fprojects%2Fmethodoverride%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEmDGGmsIgus8ig6CsGCQl5TKrTZQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fsourceforge.net%2Fprojects%2Fmethodoverride%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEmDGGmsIgus8ig6CsGCQl5TKrTZQ&#39;;return true;">http://sourceforge.net/projects/methodoverride/. Load the
PlbMethodOverrideSupport application and then define #override_*
methods as extensions to the class from your own application code. The
override framework does a transient exchange of the methods and keeps
everything in sync whenever you recompile, load, unload, etc.. The old
method is available as #overridden_* and you can use that behavior.

You can extend attributes by using a reference collection. You'd define
methods on Object like #attributeAt: and #attributeAt:put: that refers
to a global weak key identity dictionary whose keys are objects with
extensions and whose values are attribute name/value pairs (a
dictionary). You'd also define getter and setter methods to access the
new variables using the new protocol. Simple.

Regards,

Paul Baumann

On Thursday, September 21, 2017 at 5:48:08 AM UTC-7, Petr Fischer wrote:
Hello, can I rewrite implementation of existing method of existing class from base libraries in my own application?

For example, I need to fix existing method asByteArray of class String (defined in base CLDT app) and I want to automaticaly load this fixed method with my configuration map. This is example only (in fact, we need to fix something in old Oracle classes in VAST 7).

It's something like extending existing classes with new methods in another app - but is possible to rewrite/fix some existing method?

Thanks, Petr Fischer

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: rewrite implementation of existing method (fix) in another application

Petr Fischer
In reply to this post by Richard Sargent
Thanks! pf

Hi Petr,

Obviously, the other replies have good advice especially about replacing the implementation of methods in the base product. However, sometimes, it is unavoidable.

Some years ago, Paul Baumann created a solution for this that works well. It is based on the very nature of Smalltalk, so it is clean. I recommend it for those cases where correcting base product code adn relaying the change to Instantiations for inclusion in future versions just isn't practical.


Found this on http://ibm.software.vasmalltalk.narkive.com/pqq3TEL8/extending-a-class-and-overriding-an-existing-method. Paul's solution works well, with one caveat.  I recommend removing the installed overrides before saving an image and re-instating them after the save.

Paul Baumann
12 years ago

Post by Edmilson Bringel
It's possible to extend a class and override an existing class method (or
create an attribute) and save in My own Application?
Sorry to be late to the discussion.

You can easily change the behavior of existing methods with
PlbMethodOverrideSupport. Get the framework at
http://sourceforge.net/projects/methodoverride/. Load the
PlbMethodOverrideSupport application and then define #override_*
methods as extensions to the class from your own application code. The
override framework does a transient exchange of the methods and keeps
everything in sync whenever you recompile, load, unload, etc.. The old
method is available as #overridden_* and you can use that behavior.

You can extend attributes by using a reference collection. You'd define
methods on Object like #attributeAt: and #attributeAt:put: that refers
to a global weak key identity dictionary whose keys are objects with
extensions and whose values are attribute name/value pairs (a
dictionary). You'd also define getter and setter methods to access the
new variables using the new protocol. Simple.

Regards,

Paul Baumann

On Thursday, September 21, 2017 at 5:48:08 AM UTC-7, Petr Fischer wrote:
Hello, can I rewrite implementation of existing method of existing class from base libraries in my own application?

For example, I need to fix existing method asByteArray of class String (defined in base CLDT app) and I want to automaticaly load this fixed method with my configuration map. This is example only (in fact, we need to fix something in old Oracle classes in VAST 7).

It's something like extending existing classes with new methods in another app - but is possible to rewrite/fix some existing method?

Thanks, Petr Fischer


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.