[Definition] What is a framework?

Introduction

The framework definition part that is the subject of this article is in ** the second half of the article **, so you can skip the first half.

Transition to investigating the framework

When I was researching what venv was, I was told a site called "What to do when sharing Venv with Git with PyCharm". However, this was written in the introductory part at the beginning.

This time I decided to develop some service with my friend in Django of python, and I talked about using the VirtualEnv environment (hereinafter venv) as the environment!

Can venv be used when using Django ...

First of all, what is Django? Wikipedia says:

Django is a ** web application framework ** implemented in Python.

I've heard of web application frameworks. What was that… When I looked up Flask on Wikipedia, it said:

Flask is a lightweight ** web application framework ** for the programming language Python. He calls himself a "micro-framework" because it keeps the functionality provided as standard to a minimum.

That's it! Flask is also a web application framework!

How do you use flask ... For example ...

main.py


from flask import Flask

app = Flask(__name__, static_folder='.', static_url_path='')

@app.route('/')
def index():
    return app.send_static_file('index.html')

app.run(port=8000, debug=True)

that? In other words, is a web application framework a ** library ** ...?

Web application framework

So what is a web application framework? As usual [Wikipedia](https://ja.wikipedia.org/wiki/Web%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC% E3% 82% B7% E3% 83% A7% E3% 83% B3% E3% 83% 95% E3% 83% AC% E3% 83% BC% E3% 83% A0% E3% 83% AF% E3% 83% BC% E3% 82% AF) opened.

The Web Application Framework (Web Application Framework) is a ** application framework ** designed to support the development of dynamic websites, web applications, and web services.

Application framework ...? Read more for the time being.

The purpose of the framework is to ** reduce the effort associated with common tasks used in web development **. For example, many frameworks provide ** libraries **, ** template engines ** (→ Web templates), and ** session management ** for database access to promote code reuse. There are also things.

It's also a library, but it doesn't seem to be the only one.

Application framework (or framework)

What is an application framework for the time being, [Wikipedia](https://ja.wikipedia.org/wiki/%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1% E3% 83% BC% E3% 82% B7% E3% 83% A7% E3% 83% B3% E3% 83% 95% E3% 83% AC% E3% 83% BC% E3% 83% A0% E3% Read 83% AF% E3% 83% BC% E3% 82% AF).

An application framework (English: application framework) is a collection of ** libraries (subroutines, classes, etc.) used to implement the standard structure of application software in programming. Also called simply ** framework **.

After all it's a library! So why do you call it a framework ...?

What is the difference between "library" and "framework" [main subject]

That's how we came to investigate what a framework is. The answer to the question of what a framework is, as mentioned above, is ** "it's enough to recognize it as a collection of code written by someone, that is, a library" **.

However, it is normal to think that there is a difference when words are divided in this way. According to this article, the technical difference between the library and the framework is actually the term ** "with or without inversion of control" **. It is aggregated in. This is whether the initiative is in "we" or "a collection of classes and subroutines".

That is, when using a library, we decide when to use the features of the library, while when using the framework, the framework itself decides when to use the features. In other words, when using a framework, there is an "inversion of control" in which the person who controls the program is not the person who is using it, but the program itself.

If you read the Wikipedia article on the web application framework again,

The purpose of the framework is to ** reduce the effort associated with common tasks used in web development **. For example, many frameworks provide ** libraries **, ** template engines ** (→ Web templates), and ** session management ** for database access to promote code reuse. There are also things.

There is. In other words, in addition to providing the library, ** template engine ** (template engine is a software or software component that synthesizes a template called a template and input data represented by a certain data model and outputs a result document (from Wikipedia). )) And ** session management ** will be provided, which is a more framework-like part.

See this article for more detailed examples.

Parable

Finally, there is a quote (https://qiita.com/baby-degu/items/7dc4548bf7befc2671f4), which is an easy-to-understand analogy to the difference between a library and a framework.

I often use ** house ** as a metaphor for concepts in web development.

For example, a library is ** like going to IKEA **. You already have your own home, but you're a little short of furniture. But I don't feel like building a table from scratch. At that time, you can go to IKEA and bring back your favorite one from the many options. It is up to you to choose it.

On the other hand, the framework is ** like building a model house **. You can choose from a limited number of templates and designs. Basically you can only choose contractors and templates. The vendor will also pinpoint where you can intervene.

Recommended Posts

[Definition] What is a framework?
What is a distribution?
What is a terminal?
What is a pointer?
What is a decision tree?
What is a Context Switch?
What is a super user?
What is a system call
What is a callback function?
What is a python map?
What is a lexical scope / dynamic scope?
What is a Convolutional Neural Network?
What is namespace
What is copy.copy ()
What is Django? .. ..
What is dotenv?
What is POSIX?
What is Linux
What is the ETL processing framework clivoa?
What is klass?
What is SALOME?
What is a dog? Django installation volume
What is a dog? Python installation volume
What is Linux?
What is python
What is hyperopt?
What is Linux
What is pyvenv
What is __call__
What is Linux
What is Python
What is a dog? Django--Create a custom user model
What is a dog? Challenge Django templates! Volume
It's a Mac. What is the Linux command Linux?
What is a dog? Django--Create a custom user model 2
Tell me what a conformal map is, Python!
What is Piotroski's F-Score?
What is Raspberry Pi?
[Python] What is Pipeline ...
[PyTorch Tutorial ①] What is PyTorch?
What is hyperparameter tuning?
What is JSON? .. [Note]
What is ensemble learning?
What is TCP / IP?
What is Python's __init__.py?
What is an iterator?
What is UNIT-V Linux?
[Python] What is virtualenv
What is machine learning?
What is a dog? POST Sending Volume Using Django--forms.py
What is a dog? Django App Creation Start Volume--startapp
What is a dog? Django App Creation Start Volume--startproject
Basics of Python learning ~ What is a string literal? ~
What is a recommend engine? Summary of the types
What is God? Make a simple chatbot with python
To myself as a Django beginner (2) --What is MTV?
What is the difference between a symbolic link and a hard link?
What is Linux? [Command list]
What is Logistic Regression Analysis?
What is the activation function?
What is the Linux kernel?