Newby Coder header banner

Package

What is a package in programming

Packages are namespaces which contain modules and packages(sub-packages)

They are simply directories

A package allows a developer to group classes or modules together

Programmers also typically use packages to organize classes belonging to the same category or providing similar functionality

Python package

Each package in Python is a directory which MUST contain a special file called __init__.py

This file can be empty, and it indicates that the directory it contains is a Python package, so it can be imported the same way a module can be imported

Packages allow for a hierarchical structuring of the module namespace using dot notation

In the same way that modules help avoid collisions between global variable names, packages help avoid collisions between module names

Java Package

A package in Java is a folder in a file directory, used to group related classes

Packages are used to avoid name conflicts, and to write a better maintainable code

Node Packages

In Node, a package is a file or directory that is described by a package.json file

Node has a package manager called npm, whose registry contains packages, many of which are also Node modules, or contain Node modules

A package must contain a package.json file in order to be published to the npm registry

What are package dependencies

A package is dependent on another package, if it uses one or more modules of that package

Apart from the modules provided by a programming language, a program might be required to do various other stuff