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.
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 ** ...?
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.
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 ...?
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.
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