What is Frameworks in Programming?
-
Frameworks
Most guys specially 😎 beginners asked me What is framework?
They said, that they read so many articles but still they are confused 😵 .Let's Imagine,
You need to drive a car, So First you should start the car, Then put the correct gear, then you need to change the gear in correct order.
But, If you take auto-gear car, You just wanna start and press accelerator only,
The gear will be changed automatically.So they build a environment for this specific scenario. It will handle the gear, No trouble for us.
Like that,
If you wanna build a software, That is a huge process (Except Development),
When you come to code a software, You need to
- Design Views.
- Setup environment.
- Install Dependencies.
- Define Modals.
- Write Logic.
- Bind Modals with Databases.
And other Blah Blah things.
The Frameworks are helping us to done these jobs easily, quickly and perfectly.
⁉ ⁉ Why Frameworks?
As I mentioned, Frameworks are making our tasks easy. So we can save a lot of development time.
And also, If you follow your own structure It will be little hard to follow to your co-developers. Because everyone have their own style. But If you use a framework, That will have a standard pattern,
So the whole development should follow the same standard, And any developer who knows that framework standard can understand the code.
So, It will increase the code maintainability
🧐 How?
Structures
Framework has a well defined environment and structure, We need to just follow their manual and put correct files in correct places, That's all, It will bind it automatically.
PHP - Laravel Framwork Folder Sructure
Routers
All the Web Frameworks have Routers, Which will Route a request to a handler / controller.
In web applications, If we want to add routing based URL we need to configure a lot of things.
For Example : -
In Apache and PHP, We need to configure .htaccess file to redirect requests to a specific PHP file, And then we need write logic in PHP file to handle the incoming requests.
But in frameworks, They will have a specific file for Routing. You just need to add,
Which URL -> where to go
. Thats it.Laravel Framework Router
Built-In functions
Most of the frameworks have some awesome built-in functions to make our work much easier.
Example (PHP)
//Traditional Way to set and get a Session. session_start(); $_SESSION['username'] = 'John'; $username = $_SESSION['username'];
//Using Laravel Framework. session('username','John'); $username = session('username');
//Validation in Traditional way public function login() { $username = (isset($_POST['username'])) ? $_POST['username'] : null; $password = (isset($_POST['password'])) ? $_POST['password'] : null; if(!empty($username) && !empty($password) && (strlen($username) <= 10)) { //valid } }
//Validation in Laravel Framework public function login(Request $request) { $validatedData = $request->validate([ 'username' => 'required|max:10', 'password' => 'required', ]); }
How simple, Frameworks have a lot of awesome functions ❤!
Conclusion
Frameworks are well planned and structured setup for build a software.
It handles more than 50% of development procedures and saves our time. -
nice explanation bro... :hearts:
-
@dev_lak 👍👍👍
-
wow b6 brooo , wonderful
-
@Malith thx bro
-
Thnks bro..
-
@thilina 👍👍👍
-
wow b6, your an amazing article writer i ever seen.
-
@root but didn't upvote yet 😜😜😜
-
Thank u bro