Library - Framework and Toolkit

Shareable Code aspects

These days software applications are complex in their functions. It is an arduous task to build an application on top of all own handwritten code, and it is not advisable.

It is in practice to build applications by combining owned code with shared code to match up with the fast pace of world demand of software.

Code is distributed in a tangible form called Library.

Library

A Library can be a single compressed file or a directory containing executable code. The shape of Library might be decided by language specification, OS, or package manager.

Practical Examples:

  • Java ecosystem uses language standard defined layout for shared code in the archived file so-called .jar (“jar” - Java Archive).
  • C/C++ uses OS platform based file .so (shared object) on Unix and .dll (dynamic link library) on Windows.
  • JavaScript (Node Ecosystem) uses a directory-based mechanism for shared code.

Frameworks and Toolkits are aspects of Libraries.

Framework

A framework enforces you to write code in terms of framework elements and calls these engineered codes to do its business. You are never in-charge of calling these code chunks.

In essence, a Framework enforces to develop a mindset to write application code in term or base of the Framework. Might be this is the reason for the name “framework”.

Typically, you annotate or mark your code elements (classes, objects, method) with framework elements. Marking process may vary language to language.

In languages like Python, Ruby, JavaScript, You mark code by inheriting classes from framework-defined classes.

In languages like Java, you can mark your code by extending classes or by marking classes or methods with Java Annotations (see example below).

Some frameworks are based on configuration descriptors. Usually, these configuration descriptors are written in text files in standard format (JSON, YAML, XML, TOML) or custom text format.

Generally, A Framework follows best practices or design practices.


Framework Example

Hibernate (Java) is an Object Relational Mapping framework¹ (a technical style framework). You have to write entities, their relationships and DB configuration only in a declarative fashion. You annotate a class with @Entity to make it an entity.

@Entity
class Student {
  @Id
  private long id;
}

Framework Categorization

Scope Based

  • Technical Level Frameworks are focused on providing technical problems solutions. They are smaller in scope, thus permits you an option to combine with multiple frameworks to write an application. Typical Examples

    • Transactions (Spring [Java]),
    • Object Relational Mapping (Hibernate[Java], Sequelize [Node.js] ..)
    • Dependency Injection (Dagger, Spring IOC, Guice/Java)
    • Angular, React, Vue (Fronted frameworks)

frameworks

  • Domain-Level Frameworks are focused on business or domain level solutions. These are broader in scope than technical level frameworks.  Usually, these are termed as “platform”. e.g. Tuya is IoT platform

Practice Based

  • Opinionated Framework implements or enforces you to implement a certain kind of practices. 
    If domain level then it compels to implement industry practices.   If technical level then it enforces best practices of development.

  • Non-opinionated Framework - Probably, you guess it. These do not bind you to any practice. You are free to implement your way of doing things. Example: Express (JS@Node)

Toolkit

In simple words, a Toolkit is just a set of functions or code elements. Your application code calls these functions or elements. In other words, You are in full control of calling these functions. Typically, you combine multiple toolkits for writing an application.

Toolkit Example 

jQuery is a web library which provides DOM manipulation utilities.

// Application Code calls library code
$('#welcome').html('<b>hello world</b>')

Toolkits are generally written for:

  • Text or binary format parsing: XML, JSON, CSV, YAML, XLS, PDF…
  • Date and Time parsing, formatting, manipulation
  • Data Structure and utilities
  • Pooling: Connection, Thread
  • Protocol clients: HTTP, SMTP, FTP, MQ …

Takeaway

  • Code is shared in the form of libraries.
  • A library can be Framework or Toolkit.
  • A Framework enforces you write code in its term.
  • Frameworks call your annotated or marked code.
  • A toolkit is a set of functions.
  • Your code calls functions of a toolkit.

Foot Notes

  1. Object Relationship Mapping (ORM) Framework bridges gaps within DB model (concrete / physical model) and business entity (abstract /logical model).

Be Updated

Only articles are shared on Medium