All software programs run on some Platform and most software applications today use some kind of Framework. We will try to understand the difference between a Platform and a Framework
We will start with a few words on Platform Business to avoid confusion with the main focus area of this write-up.
A Platform Business works as a platform for a network of people/participants to carry out some activity. Most platform business models are supported by a technology infrastructure. eBay, Shopify, Facebook, Uber, etc. are all examples of the Platform Business Models.
This is not the focus of this article.
A platform is a system that allows programs to be built and run on it. The platform provides services to make it easy to write a program.
Operating Systems Linux, Windows, Android, etc. are platforms. They allow programs to be built and run, and they provide services for storage, memory management, network access, etc. via their APIs.
The platform would need an Entry Point to run the program: main
method or similar mechanism. The platform calls the Entry Point and transfers the control of execution to the program. The program has control and it can do whatever it wishes using the services of the platform.
When the program is run, the platform execution service will locate the Entry Point and start program execution.
From Entry Point onwards the Application program has the control of execution. The platform does not enforce anything. Application may use the services of the platform.
Yes, they are platforms. They allow other programs to be built and run on them, and they provide services to simplify Application development e.g., File I/O operations using APIs in Java or .Net are easier than using Operating System APIs directly. Most of them are now Platform-independent Platforms because they can work on any Operating System.
A framework gives a pre-defined structure to the Application.
Frameworks are also an abstraction layer. They implement common repetitive tasks and allow the Application to focus on the problems it is solving. But still, they are different from Platform. The following diagrams explain it.
Code is in Java and Spring Boot but it should be easy to understand as other frameworks also have a similar mechanism.
User
class is a Plugin because it is annotated with @RestController
. This tells Spring Framework that this is a Plugin.
User
that should be called when there is an API request with HTTP GET verb and URL path matching /user/{id}
pattern.http://localhost:8080/user/AARE2212
, Spring will call the get
method on an object of class User
Frameworks implement the Inversion of Control pattern. it is called Inversion of Control because
HTTP GET /user/{id}
. If an event that the Plugin is interested in doesn’t occur, the Framework doesn’t call the Plugin.
As the Application written on a Platform grows in size and complexity, it requires Frameworks to have better Maintainability and Productivity - make changes faster with less effort.
Sometimes the concept of Framework can also be applied to the Application logic. Example:
FileProcessController
controls the whole processing and performs common tasks during the file processing. It calls Plugins to do the actual processing of a File of a type supported by the Plugin.IFileProcessor
.
//Common Type for data transfer between Framework and Plugin
public class FileProcessRequest {
private String type;
private String path;
}
//Plugins will implement this interface to declare they are a plugin
public interface IFileProcessor {
FileProcessResponse process(FileProcessRequest request);
}
//A file processor implements interface and declares the File Type it supports
@SupportedFileType("SALES")
public class SalesFileProcessor implements IFileProcessor {
@Override
public FileProcessResponse process(Framework.FileProcessRequest request) {
//perform some domain logic here
return null;
}
}
//Controller that controls the flow of whole workflow and performs common tasks required for all types of files.
public class FileProcessController {
public FileProcessResponse process(FileProcessRequest request) {
scanFile(request);
validateFile(request);
IFileProcessor processor = getProcessor(request);
if(processor != null) {
return processor.process(request);
} else {
//log error and send notification
}
return null;
}
}
Based on what we discussed above, PaaS can be thought of as a Platform to quickly build and run Distributed Applications.
PaaS offerings in Cloud provide various Compute, Storage, Networking, etc. services via APIs. An Application can be built and run using these services. If we take AWS for example,
Hope you have found this helpful. Please share your feedback in the comments.