A — Dynamic Binding V. Static Binding Primer ; Java Based -Pt.2

Phyziro
5 min readOct 21, 2023

--

This image is provided courtesy of Wallpapercave.com

Understanding the Java Primitive Control Structure : Instantiated v. Uninstantiated Class Type Variables

Understanding how the Java primitive control structures executes and determines class precedence is essential to understanding how a variable with a class type definition will exercise a dynamic or static method.

First, we should clarify that a variable that is type defined by a class is not a variable that represents the class’s object, but is instead a representative of a variable with a type that is of the class prepended. Reiteratively, an defined variable with a class type definition simply infers that our variables type is that of the class; thus, the variable is subject to:

  1. The possibility of subsequently performing n > 0 constructor mutation(s) conforming to the class type definition of the variable, ultimately producing a polymorph class variable adherent to the defined class type upon constructor method instantiation not equal to that of the variables type definition; and,

2. The inability, without instantiation, to access the class’s method’s or constructor using the variable, even if the new keyword is prepended.

E.g. if c is of Class C type, c may undergo a number of constructor mutations that ultimately result in c storing a collection of executable constructor methods while executing the methods in conformity of Class C, using the logical method of execution illustrated in the logical diagram below — later in this document. Further, this means that a variable of some arbitrary class type has no access to the classes constructor, simply because the variable is of the type of the arbitrary class the class is not inherited by the variable; this means, C c; c = new c(); is invalid. Further, one should note that with each constructor mutation on the variable you are building a collection queue that is effectively taking up memory.

To assign a class object to a variable, you must first use the new keyword followed by the classes constructor method; the classes constructor method is the same as the class name e.g. Class C has a constructor method that is C(); Therefore the following is true:

Copyright of Phyziro, LLC, 2023 — free to use royalty free— Code is Free to Use under MIT License

Now that you understand the difference between a class type defined variable that is uninstantiated and one that is, we may now dive into how the the dynamic and static binding queue stack works logically.

Understanding the Logic of the Primitive Class’s Control Structure

Java uses the FIFO method (First In First Out) of precedence to determine which queued methods within a class will yield results during execution. This means that the most recent class’s method appended to a collection will take post-cedence to the first class’s methods that were appended to the collection. See the logic below:

Copyright of Phyziro, LLC, 2023 — free to use royalty free

The above illustrates how classes in Java handle extensions logically. But, how does this logic apply programmatically? See the output below:

Copyright of Phyziro, LLC, 2023 — free to use royalty free — Code is Free to Use under MIT License

This example is an advanced example of static binding and can be extremely confusing. At first glance when dissecting the program you may think that due to our initialization of the Class C object on a, the production of “Cat WomanLouis Lane” seems to violate the logical diagram illustrated above. The reason that this does not violate the logical diagram is due to:

  1. a is of Class A type — Static Binding is occurring here
  2. Because Class A extends Class B, Class B becomes a subordinate to Class A — where, Class A => Class B is Class A, is true but Class B => Class A is Class A, is false. Think of this in terms of ancestry, where a parent is extended to a child but a child may not extend the parent. The parent may create a child but a child may not create a parent. See images 1a. Class Inheritance and 1b. Class Inheritance below
  3. Class C is second subordinate to Class A, after Class B
1a. Class Inheritance — Copyright of Phyziro, LLC, 2023 — free to use royalty free
1b. Class Inheritance — Copyright of Phyziro, LLC, 2023 — free to use royalty free

Therefore, a will conform to Class A’s r() interpretation and Class B’s interpretation of method p(), due to static binding. Further, upon completion, of the linear execution of Class A and Class B methods, methods in Class C will exercise and return the final result.

That is how Static Binding works in Java. Next time we will cover Dynamic Binding.

If this is confusing Read Part 1 of this series by clicking me

Thank you, for reading. Don’t forget to give us a clap, share or comment.

Did you find this post useful? If so leave us a tip!

Did you find this post useful? If so leave us a tip!

We’ll have a newsletter coming soon that’s about more than Bitcoin, it’s just hot right now. 👨🏽‍💻⚡️

--

--

Phyziro
Phyziro

Written by Phyziro

0 Followers

Innovative software and hardware developer empowering the consumers we serve.

No responses yet