Thursday, September 18, 2014

Plugin

Plugins are features added out of box. It is not needed to know all the internals of an application to write a new plugin. And the application does not need to know about the feature internals. The new plugin feature is called the extension to the existing software. To make the total thing work, the extensions are registered to an extension point.

There are two things that incorporate plugin.

  • Loadable separate code.
  • Features/extensions that are registered at some extension point.

Example of a plugin

Suppose there is a need for feature to share a webpage content as emails. The feature is to send email with less interaction from the user. The user does not need to open a web application interface in the browser to send email. The feature can be implemented by a email plugin of the browser. The email plugin may insert a ‘send page’ button through registering in menu-item-extension point. And when the user clicks the ‘send page’ button from the browser-menu it opens up few text-boxes. Eventually the user types the address and subject and presses the send button to send the email.

Here is a component diagram to demonstrate the idea,

This is an email sending feature that is implemented by email plugin. And the plugin registers in menu-item-extension point. The plugin know very little about the core features or other plugins. And the core application does not know the internals of the plugin at all.

Actually this type of plugin exists for firefox browser. For firefox the plugins are called addons. And there is an addon named send page. The code is available here.

<menupopup id="menu_FilePopup">
  <menuitem id="menu_sendpagebyemail" label="Send page by email..." key="spbe_sendPageKey" 
    oncommand="spbe_showDialog();" insertbefore="menu_sendLink" accesskey="e"/>
</menupopup>

The xul code above registers a menu-entry labeled ‘Send page by email…’ in popup menu.

Finally the addon is provided in distributable package which firefox can load easily on demand.

The plugin system makes it possible to implement the beautiful correlation above.

Modules and plugins

Plugins and modules come hand in hand. Both modules and plugins are pieces of code. Both of them emphasize on separation of concern. In a module certain things are grouped together for development-ease or other purposes. But in a plugin they incorporate a feature and the basic idea is separation from the core features.

Sometimes module loaders facilitate a way to load plugins. In this case modules are also special type of plugins. They are loaded in the invisible extension point of the application binary.

Advantages

Developing parts as plugins is a useful approach. It comes with some benefits.

Make little things work quickly and easily

Plugins are written to give some specific features. And their concerns are limited. So is the development time. This time-tuning is important because of human bias of instant gratification.

Additionally the separated code can be tested and debugged in absence of other features(of which it is not dependent). Thus separation helps development,debugging and testing units. For example, if it is needed to think of a feature to write a browser plugin to send email, then it is not needed to worry about other browser plugins like video player or something. In this way it is possible to be more focused and productive.

Plugins improve motivation

Plugins makes it possible to write a small separate segment of a big task. So it gives the satisfaction of achievement. Though it is a portion of big task, still it motivates to finish the unit. It helps the unit-bias of human psychology to finish an unit task.

Plugins and extension point mechanism makes things simple

Extending a big application is big cognitive load. To know all the internals is mandatory. Otherwise it can lead to bugs. And there is need to know the big APIs too. But in plugin the scope is small. It is not necessary to worry about the whole application but only the plugin-api. For example, to write an email sending feature for existing browser which has plugin support, it needs very little for the integration,

  • To know the plugin API. (To know the skeleton plugin that does nothing.)
  • To know how to add an extension.

Additionally, there are other things like showing an edit box and sending an email, but they have nothing to do with the core application.

OK, this is all about plugins now. In future, there will be discussions on how people facilitate plugins in their applications.

Wednesday, September 17, 2014

The extended mind

The brain and body is limited

Human has a limited brain and body. Though there are different thoughts and ideas that come into mind but pursuing them all is impossible. And even it is very difficult to reach a limited list of goals. One of the cause is the limited capability to remember all the tasks needed to be performed.

The brain is just like a computer

To a computer scientist the brain is comparable to a computer. And it has memory just like the computers. The memory can fall into two catagories,
- Short term memory or working memory(WM) in psychology is something more aligned to the RAM of the computer.
- Long term memory in psychology is like the hard disk.

On execution, thoughts and work processes are loaded in working memory to let it shuffle and get things done. For example, suppose a person is opening a lock with his key. At first, he thinks about the key in his pocket and grabs that in one hand, while he saves the goal(to open the lock) in the WM(working memory). And then he inserts the key into the lock to open it. This is easy.

Multitasking and context-switching problem

But the brain is not as good as the computer when it has to perform two cognitive tasks together. Suppose a person is thinking to open the lock and he has grasped the key in his hand. He has the goal to open the lock in his WM. At that very moment, someone calls him on the cell phone. The WM is full of the urgency of incoming call. As WM is limited, the thoughts to open the lock may be erased by the new information. He may mistakenly grab the key and put that in the ear. This may happen. Doing more than one cognitive task at a time may mess things up.

It is possible to extend the mind

For human it is hard to multitask. So the right thing is to do things one by one. If he has different things to do then it is helpful to maintain a list. A to-do-list. It is a small paper that holds your memory for future execution. In this way human can extend his mind.

People have used this idea of extended mind for long time. One of such extension is the written books. The books are the concepts of mind that are put into papers for recalling or for transmitting to people. Or the extended mind can be any written paper. Suppose someone wants to sum two big numbers (eg, 23874283 + 238479283742 = ? ). It may not be possible to do that using the WM only. But it is possible to do that easily using pencil and paper(like in the young days).

So it is a very old idea. Humans are curious about the inner working of themselves. To know the limitations is one way to know that. And to know the work-around is the novelty.