The ObjAsm32 manual says that a StaticMethod can't be redefined at run-time and a DynamicMethod can be redefined at run-time.
What does 'redefine at run-time' mean, and why do you need it ?

Posted on 2004-03-24 20:34:26 by Jurgen
The following relates to my experiences with OOP not with objasm32 but with ATC and masm.
I apologise if anything I write here is inaccurate, these are personal observations.
Static Methods of a class can not be "overridden", but Dynamic Methods of a Class CAN be. What is this "overridden" thing? Imagine we have two classes, A and B, and that class B inherits from class A. Both of these classes contain some named functions. Now imagine that one or more function names exist in BOTH classes, for example A_SetName and B_SetName.
If we create an object of class B, it inherits class A's functionality.
If A_SetName is static, then calls to the SetName function will execute the code from Class A, since the function cannot be overridden by the function in B of the same name.
If A_SetName is dynamic, then calls to SetName will execute the code in the class B function, the lower class's function overriding the higher class's function.
Conclusion: Static and Dynamic can be thought of as being options for how name collisions are resolved.

Static and dynamic DATA fields in classes is a topic best handled in a separate reply, I'd be happy to elucidate on the difference, if you are interested let me know.
Posted on 2004-03-24 22:53:46 by Homer
EvilHomer2k is kinda correct,

The static method is used most often, and can be overidden if needed (in the ObjAsm32 model). However, your limited to having foreknowledge of what it is to be overidden into. Writing a new class that inherits another, and then overrides a method is an example of this, since before you compile your spelling out directly what this method should be overriden too.

The dynamic method is exactly the same in functionality, but it allows for you to give indirect code to spell out what the dynamic method would be overriden to if needed. Indirect would be coding it to be set to the contents of a method to say EDI. EDI is a run time value, say, an input from a user that sellects from a drop box what the class should be overridden to. This is what is ment as dynamic, since the vtables for this is set up to handle run-time changes. Static methods do not have a vtable with the same flexibility.

Personally, i havent had the need as of yet to use the DynamicMethod command, as most classes are sufficient with StaticMethods.

Hope this helps..
Posted on 2004-03-24 23:42:07 by NaN
Agree with you EvilHome2K.
In OOP a static function of a class just can use at that class level and can't be override in it's child . Please fix me if I'm wrong .
Ex in Java

class A {
public void test() { .. }
class B extends A {
public void test() {..}
runtime :
A a =new B(); ( downcast the class to it's child )

If A.test is 'static' , then instance 'a' always call the function from A , it's mean it's not "downcast" or "get override method" to child class . You can test it by change two test function to ' public static void '.

In ObjAsm32 it has a bit different .
Similar to ObjAsm32 , if you make a method in object is StaticMethod and then you create an instance for it .
Ex from Demo01 :

Object RectangleShape, RectangleShapeID, Shape
RedefineMethod GetArea ;Defines shape's abstract method.
StaticMethod GetPerimeter ;Defines a new static method.
DynamicMethod TestFunction ;Defines a dynamic method

If you try to change it's static method ( GetPerimeter ) to another method

OverrideMethod RectangleShape,GetPerimeter,pShape_3,IsQuad

, your program will error at run-time .
It called that "A static method can not be redefined at run-time at an object?s instance level."

To NaN :
So ObjAsm32 allow override a method in child class which defined static in parent class ???
I created a child class of a class which contains StaticMethod , I can overrided it though I was not redefine it .
Seems the state " can not be redefined at run-time at an object?s instance level " is very true :grin: :grin: :grin:
Whether it can be changed to " can not be redefined at run-time at an object?s instance level and it's child " in next ObjAsm32 , cause a static is a static , it can not change . Though , for MASM , it's enough great .
Posted on 2004-03-24 23:44:05 by dreamweaver
A classic use of a dynamic methods arises when you have 2 objects that are very similar and you don?t want to derive one from the other trough the normal inheritance way. Example: you define an object with a dynamic method and create the instances of this object. On those instances, that needs a special behavior you can override the dynamic method. This way you save memory, because you avoid the creation of a new object template, but the drawback is that the new behavior of the changed dynamic method can not the inherited because you have only a common base object. If you are looking on memory use, each dynamic method (pointer) is stored in the ?instance data?, so it takes 4 additional bytes for each instance. Static methods (pointers) are stored in the object template that is common to all instances and uses only 4 bytes for all instances of this object in the current process.

A dynamic method was used in the collection object to define the DestroyItem procedure to allow to handle special cases of freeing resources without the need to create a special object for this task.

I hope it helps!

Biterider :alright:
Posted on 2004-03-25 06:26:49 by Biterider