5.2 Web application Framework
A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs.
Web frameworks provide a standard way to build and deploy web applications on the World Wide Web. Web frameworks aim to automate the overhead associated with common activities performed in web development.
For example, many web frameworks provide libraries for database access, templating frameworks, and session management, and they often promote code reuse. Although they often target development of dynamic web sites, they are also applicable to static websites.
Most web frameworks are based on the model–view–controller (MVC) pattern. Model–view–controller (MVC)
Many frameworks follow the MVC architectural pattern to separate the data model with business rules from the user interface. This is generally considered a good practice as it modularizes code, promotes code reuse, and allows multiple interfaces to be applied. In web applications, this permits different views to be presented, such as web pages for humans, and web service interfaces for remote application.
Web frameworks must function according to the architectural rules of browsers and web protocols such as HTTP, which is stateless. Webpages are served up by a server and can then be modified by the browser using JavaScript. Either approach has its advantages and disadvantages.
Server-side page changes typically require that the page be refreshed, but allow any language to be used and more computing power to be utilized. Client-side changes allow the page to be updated in small chunks which feels like a desktop application, but are limited to JavaScript and run in the user's browser, which may have limited computing power. Some mix of the two is typically used.[18] Applications which make heavy use of JavaScript are called single-page
applications and typically make use of a client-side JavaScript web framework to organize the code.
Examples:
Server Side:
ASP.NET Core
CakePHP
Django
Laravel
Common web framework functionality
Client Side: ReactJS
Vue.js
AngularJS Backbone.js
Frameworks provide functionality in their code or through extensions to perform common operations required to run web applications. These common operations include:
∙ Web template system
∙ Web services
∙ Web resources
∙ RL routing
∙ Input form handling and validation
∙ HTML, XML, JSON, and other output formats with a templating engine ∙ Database connection configuration and persistent data manipulation through an object relational mapper (ORM)
∙ Web security against Cross-site request forgery (CSRF), SQL Injection, Cross-site Scripting (XSS) and other common malicious attacks
∙ Session storage and retrieval
Pros and cons of web framework:
Pros:
1. Faster Development & Prototyping:
2. Responsive By Default: These frameworks are responsive by default, the grid system that they come with because they use mobile first approach so they look good on mobile devices. So you usually don't have to write a lot of media queries for responsiveness. 3. Browser Compatibility:
4. Familiar To Other Developers: Basically most of the developers are aware of the core classes of a popular UI framework like bootstrap. So it's easier to work on with a team. 5. Javascript Widgets/Plugins: Javascript widgets & plugins like modal, carousels, accordions etc. are available.
6. Documentation & Support: Most of the documentation of these frameworks, is really good and it has some really good examples and a lot of times you can just copy and paste and change it to your liking.
Cons:
1. Less Customization: If you want your website to really different, you probably have to create your own UI and write your own custom CSS and you can't do it easily while using a framework.
2. Many sites look the same: If you don't customize it enough, then yes. You can easily spot a bootstrap site if you are just using all the default classes with all the default colors 3. Lots of overriding styles:
4. Dependence of jQuery for certain things: These frameworks have some dependence on jQuery for certain things like modals, carousels etc.
Django (Any example explanation):
Django is a Python-based web framework that allows you to quickly create efficient web applications. It is also called batteries included framework because Django provides built-in features for everything including Django Admin Interface, default database – SQLlite3, etc. When you’re building a website, you always need a similar set of components: a way to handle user authentication (signing up, signing in, signing out), a management panel for your website, forms, a way to upload files, etc. Django gives you ready-made components to use and that too for rapid development.