Programming : Atomic analogy of OOP Concept

Let us consider the Lewis Structure for the Water molecule. Lets define Lewis structure first – “Lewis Structures are visual representations of the bonds between atoms and illustrate the lone pairs of electrons in molecules.


Oxygen has 6 valence electrons and Hydrogen has 1; altogether water molecule has 8 valence electrons. If we pay attention and analyze individual atom, we see every atom has fulfilled it octet – Hydrogen has 2 electrons and Oxygen has 8 electrons(counting 2 it got from 2 Hydrogen atoms).

In chemistry, a valence electron is an electron that is associated with an atom, and that can participate in the formation of a chemical bond; in a single covalent bond, both atoms in the bond contribute one valence electron in order to form a shared pair.

My point

Consider the valence electrons as public methods and non-valence electrons as private/protected methods. OOP suggests to keep data at the core so that it is always private. So, consider private data as nucleus of the atom.

When two unstable atoms bond with each other to form a rather stable structure sharing their valence electrons, then yields more usable stable chemical structure. Now lets make analogy:

  • bonding                      –> message passing
  • unstable atoms            –> Individual software components (say classes) that need to cope with other entities to form a usable software.
  • valence electrons        –> Public methods (public API) that take part in assembly
  • lone pair of electrons –> Public methods that might not be used in that software at all.
  • core electrons               –> Private methods that do not take part in
  • Atom nucleus              –> Private data of object; never shared directly with other
  • Yielded usable stable chemical structure  –> A releasable software component

Atomic analogy of OOP



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s