In my posts or my linked-in profile, you probably come across the word Framework constantly. If you are used to Java technology, you know what I am referring to. But, if you are coming from the world of APIs and Libraries, then you may have some surprise.
What is a Framework?
A framework is a collection of objects (or more correctly, classes) that are put together as a package for you to use. It’s just like a library in that sense. But that’s where the similarity ends. Library is simply a collection of objects that have a common theme, but they may not interact with each other. You can use individual components in library, without having to use the entire package. But, a framework, on the other hand, is a partially constructed application – sort of like a template for your application. The classes in a framework are typically related and interact with each other. You are expected to inherit/extend the base classes in the framework to achieve customization and full blown application.
A typical phrase you will hear about frameworks is that “You call the library, where as the framework calls you!”. This is also called inversion of control, as your program is no longer in control with the framework. The framework designer put in hooks and templates that you inherit from – sort of plugging in your methods by overriding, overloading and extending functions in the original framework. Because of dynamic binding nature of Java, your new functions get called instead of the templates in the framework, thus overriding the functionality. See here for a good explanation. This post on the same site explains a simple framework design. I think, this Stackoverflow post explains it all nicely.
Vertical or Horizontal?
Traditionally, frameworks are defined as either vertical or horizontal. If you see this nice Quora post on Horizontal and Vertical markets, you will see what these mean.
A Vertical framework thus is meant for one particular industry where as, a horizontal framework can work in different industries. Typically, common services like GUI, Security, logging etc can be part of any application and thus will be part of horizontal framework. Most of the frameworks are horizontal in nature – they are very generic and thus can be used to build any kind of applications for any industry. For Java, Apache Struts, Spring, ADF etc fall in this category. Because of its widely used nature, even a specialized library like Credit card processing library could fall under this.
There is not a lot of vertical frameworks nowadays, but in early 2000s IBM brought out a powerful Framework call IBM San Francisco. San Francisco was unique in that, it contained both vertical and horizontal layers. In the vertical area, it covered Ledger, warehouse etc. I had the luxury of working with SF framework in the early 2000s. But, I don’t think such frameworks are developed anymore. It is hard to maintain vertical and horizontal aspects within a single package. That’s probably why that died down.
Modern frameworks tend to be more layered and thus can be used at different levels. The Java JDK has different levels – standard, J2EE or J2ME to develop standard, server based and mobile platforms. Even the Standard package contains several parts. For e.g., it contains AWT, Swing for building GUI applications. It has JDBC for the database connectivity. Similarly, Spring has a suite of projects called Spring Framework, Spring Boot, Spring MVC etc. The advantage of this is that you can replace a layer with something else. For e.g., Spring application can work with Struts. You also have packages like log4J (Logging), Hibernate, iBatis (Persistence) loosely termed frameworks.
There are other frameworks exist for Java, such as, Vaadin, Play etc. See here. But, Java is not the only language that uses such frameworks. .Net frameworks is popular on Windows systems and is available to all the .Net languages like VB.Net, C# etc. And almost every language with some object flavor has some frameworks available for it. Django for Python, Ruby on rails, Cake PHP are some of the other popular frameworks. See here for more on this.To be contd…