Blackbox and whitebox.

White box –

A system whose internals are known to the outer world is called a white box system. User knows about all modules defined inside the box (or solution or system).

See in figure below –
Think a system X which has 6 module in it (A, B, C, D, E, and F), all are open.

Why white box is bad design?

I am sure you must have used some external library in your project or while practicing programming. The library will give you only its public interface so that developer can call it, but it will not show its internals (the core logic how they are doing it). 

Now think if libraries’ modules are open to you. Now client/developer can call the core part of it. Sounds good but let me list out the drawback of it -
  1. You have to know all the internal modules and understand the flow. Before it was not our headache, we just called public interface.
  2. Any new changes in the library (introduced by third party), including new functionality or changes in behavior of core logic, will make us change our code accordingly and re-compile it (sometimes).
  3. It will become a highly coupled system, which is terrible.
  4. Client, as well as library provider, will not think to make changes and improve library functionality.

Black box –

A system whose public behaviors are open to the outer world and hide/abstract core logic of the system is called a black box system.
The funda is to take input from the outer world, process it, and give back the result, but how they handle it only they know. There would be N number of modules working to solve the problem, but those are not known to the client/user/outer world.

For external users, any system should be a black box system. The user should not have any ides about the inside logic of the system. He should know the only feature of the system (not the interior components of the system).


Thanks for reading it. To learn more about design patterns and basic design principles, please see my web page.

Comments

Popular posts from this blog

Non-virtual interface idiom (NVI)

Architectural patterns => Mud to structure => layers.

Architectural style -> Adoptable system -> Reflection.