Evaluation of Design 2 for Flexibility

Design 2 for reference

Design 2 for reference

What do you think.. whether the flexibility has improved, reduced or just the same?

As we know flexibility can be of two different types viz the Structural and Behaviorial Flexibility and hence we need to evaluate the two separately.

Evaluation wrt Structural Flexibility

What do you think.. whether the flexibility has improved, reduced or just the same?

Lets apply the first rule for structural flexibility.

"Any kind of internal structural change should never impact the user of the system"

As we can see since the structural complexity of the system/ domain entities are hidden from the user by the control entities, the first rule turns true.

The second rule says -

"For us to make the structural change, minimal number of structural components should get impacted, preferably the impact should be limited to a single component".

In the new design you can see, if I make any structural change.. the impact will only be limited to the corresponding control entities.

Hence, we can say, the moment we add a level of indirection called as Control Entities, the Structural Flexibility improves by a great factor as compared to the previous case.

Evaluation wrt Behavioral Flexibility

The first rule for behavioral flexibility says -

"Any kind of behavioral change should only be limited to those actors who should know about it and no one else."

Is this true in this design? I hope the answer is NO.

As we know in our current arrangement every other behavior is represented by a control entity and all the control entities are exposed to all the actors. Any behavioral change will mean that the control entities will either get added, removed or modified, which in turn will be known to all the actors.

Because of the above mentioned description we can see that the first rule for behavioral flexibility is not satisfied and continues to remain a problem.

Detailed Understanding of Flexibility

In this section, lets try to understand in detail as to what is the science behind increasing the flexibility of a system?

Flexibility

Lets understand the same with an example between Myself and my Friend X. Let say I and Mr X are friends and I want to interact with Mr X, but the problem is that I can only communicate in German while Mr X can only communicate in Spanish.

As we know, this a technical case of two objects with heterogeneous interfaces trying to communicate with each other and since the interfaces are heterogeneous, I cannot interact with Mr X without using a translator let say Mr Y.

For Mr Y to be a translator, the prerequisite is that he should understand both the interfaces or he should understand both the languages.As we introduce Mr Y as a translator in between myself and Mr X, I can pass my message to Mr Y in German while Mr Y can translate the same in Spanish and vice versa the communication can happen.

As we introduce Mr Y as a translator in between myself and Mr X, I can pass my message to Mr Y in German while Mr Y can translate the same in Spanish and vice versa the communication can happen.

Now, can you think as to what is the exact technical problem Mr Y is trying to solve in this situation?

Many times my participants say, Mr Y is acting as a Adapter. Agreed... but as an Adapter can you think about the exact technical problem My Y is trying to solve?

Lets understand the same using these fundamental rules.

What are the prerequisites for object1 to interact with other object2?

The following are the prerequisites for object1 to interact with other object2.

  1. Object 2 should be existing.
  2. Object 1 should know the address of Object 2
  3. Object 1 should know the type of Object 2

i.e. if Hemant has to interact with Mr X, the prerequisites are:

  1. Mr X has to exist.
  2. Hemant should know the address of Mr X.
  3. Hemant should now the type or the interface(language) of Mr X.

This means if any of these prerequisites are not satisfied that means, Hemant cannot interact with Mr X.

Don't you think, this is a highly inflexible communication model where in any change in any of these prerequisite means, "Hemant cannot interact with Mr X."

So now can you think as to what is the real technical problem Mr Y is solving.

I hope you will agree Mr Y as a Translator or an Adapter or as a Level of indirection is increasing the FLEXIBITY of this communication model by a set of parameters.

The moment we add a level of indirection called Mr Y as a translator:

  • No longer Hemant is dependent on the existence of Mr X or Hemant is flexible wrt the existence of My X.
  • No longer Hemant is dependent on the address of Mr X or Hemant is flexible wrt the address or location of My X.
  • No longer Hemant is dependent on the type or interface or the language of Mr X or Hemant is flexible wrt the interface or type of My X.

 

Lets try to understand the most important rule of this book.

"Flexibility of the system can be increased by increasing a level of indirection with in the system. The more the level of indirections, the more flexible your system will be, but every level of indirection will also reduce the performance of the system."

In the case mentioned above although Mr Y has increased the flexibility of the communication model by some parameters, but he has also reduced the performance by the same factor.

Because of the above mentioned rule,Please remember..

"Flexibility is inversely proportional to Performance and vice versa except for one situation".

It is not possible to design a system which is also highly flexible and also gives us high performance. If the system is highly flexible that is because of the level of indirections used with in the system and as we know every level of indirection will reduce the performance of the system.

A system is a high performance system because it has lesser number of indirections within the same.

The only exceptional situation wherein the flexibility and performance will both increase is when the level of indirection introduced to increase the flexibility is also capable of translating remote calls to local calls.

Now lets technically try to understand as to how a level of indirection can increase the flexibility of a system?

Remember this fundamental rule -

"Every level of indirection will always hide something and what ever the level of indirection hides it increases the flexibility wrt the same."

"More the level of indirections the more you can hide, the more you can hide, the more flexible your system. But the only flip side is that every level of indirection will keep reducing the performance of the system."

A level of indirection is also called as the level of abstraction.

If Mr Y is a level of indirection, then be assured Mr Y is hiding something and whatever is hidden by Mr Y, he is increasing the flexibility wrt the same.

In the case of the design of the Railway reservation system, when we say that Control Entities is a level of indirection, then be assured that the Control Entities are hiding something.

I hope you will agree that the control entities are hiding the Domain Entities or the Structure of the system and hence we can see that the structural flexibility of the system increases because of the control entities.

We can also consider it as a rule

"A level of indirection increases the usability, reduces the complexity, increases the flexibility but reduces the performance of the system"

So we can summarize that control entities as a level of indirection increases the structural flexibility of the system, but the behavioral flexibility continues to be a problem in this design.

 
Hemant Jha
Founder - VPlanSolutions
Researcher, Trainer

www.VPlanSolutions.co.in