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

What is a Platform?

We will start with a few words on Platform Business to avoid confusion with the main focus area of this write-up.

Platform Business Model

Platform in Software Development

  1. When the program is run, the platform execution service will locate the Entry Point and start program execution.

  2. 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.

What is a Framework?

Sample Code

Code is in Java and Spring Boot but it should be easy to understand as other frameworks also have a similar mechanism.

  1. The platform calls the Entry Point to start the Application.
  2. The Entry Point then loads the Framework. Frameworks are hosted within an Application only.
  3. The Framework then goes through a Discovery process to find its Plugins
    • User class is a Plugin because it is annotated with @RestController. This tells Spring Framework that this is a Plugin.
      • In some cases, the plug-in may be identified by the implementation of an interface. The interface is declared by the Framework.
    • The Spring Framework discovered that there 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.
  4. When there is an API request with a URL http://localhost:8080/user/AARE2212, Spring will call the get method on an object of class User
  5. The Framework and the Application both may use Platform services.

//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;
  }
}

Platform-as-a-Service (PaaS)

Hope you have found this helpful. Please share your feedback in the comments.