Why do I have to write my own framework?

Source: Internet
Author: User
I think that the programming framework should be divided into: directly with the discard, and re-pick

A framework is a basic conceptual structure used to solve or deal with complex problems. This broad definition uses a very popular, especially in software concept. The frame can also be used for mechanical construction.

In fact, the framework is the use of other people made good wheels. In software development there is command+c/command+v.

First introduce myself, I am a letter Tube professional college students, from my professional can be seen that I am the future of the programmers in the mouth. Voluminous wrote some code, using some of the mainstream framework, now have some experience to share to everyone.

As a programmer to learn a new technology is exciting, and the question is how to quickly grasp the language? Many of the technology has been the same people have said: With others have been made good wheel, you see, much effort, in a long time ago I was a member of them, also like to use a lot of framework (JS has jquery, Express, socket.io.js, etc.) PHP Phpword, Yii, Laravel;html There are bootstrap, bootcss, normal). Once upon a time, I feel very excited, in such a short period can achieve this height, let me very happy. The development of the content is also fully in line with the needs of school applications. I became a "master" in the eyes of others.

But things do not go where they are imagined. Frame after a long time to find a problem: I really have studied it? What I've learned is really useful, and what's in these frameworks can help me in the future, and of course, it's not a day, it's a small story.

When using PHP to develop Web applications, as the well-known YII framework, the page has a large number of code for me to copy the paste, I use very cool, can in a short time to develop projects, Bootstrap can also help me in a short time to splice out a decent site, but also when the school's software development department in charge of the head. But when I was teaching development experience one day, when I was really quiet in front of everyone to write a class I need to show, I used so many frameworks before, I found that in front of so many people I can hardly write a right class!! It's not a problem to run, it's the wrong side. Originally in the past I only think how to use it, how to integrate other people's code, but forget a most real thing: Create! I almost lost the ability to program and became the code replicator in front of the computer.

The result was frustrating, and I was thinking about it the other day: What do I do in the future? is to continue to be a code replicator, or to play the spirit, to see what is behind these frameworks!

So I put into the ranks of the source: I opened the bootstrap, opened the YII framework of the Vender folder, opened the jquery, trying to open the package of black box, understand the wisdom behind these frameworks.

As you can see, the bootstrap of CSS is understandable, but the code of the other large frameworks is almost an insurmountable mountain. Just give up, continue to use, do not touch the forever mysterious box?

The answer is clearly not this, the final word of the film "Mars Rescue" is very good: you either resign or continue to work and solve them all.

And then I got a nap! Haha open a joke, no! I woke up, drank saliva, ran a step, immediately put into work, began to read! And found that I still can not understand it! What to do now, eh! I do not understand, I can follow their own understanding of the framework to write a framework Ah! So I immediately put into work, a large number of Google found not working, how to do! Smart I immediately think I do not write the entire framework, then I write part of the function is also possible, so there is my first framework of the extension: dbfactory.php file.

DBFACTORY.PHP[1]

DBFACTORY.PHP[2]

DBFACTORY.PHP[3]

I am very excited, because I finally began to create something out of it, although he is very basic, connected to the database, encapsulated a few methods, but I think this distance master and so a lost, every day is a lost, then I got haha?!

When you really start to want your code to become better, you will be able to master and learn more knowledge, time will be one day in a moment enlightened. This is the development of quantitative changes caused by qualitative change.

When writing this file, I was very excited, immediately shared out, the result is nothing happened, the world is still like that, I did not change handsome, that I have become a master of the road only a little progress, or simply no progress, just know a little more. So I started a new round of study, read a lot of books, one day I re-open the YII framework at the time I looked very difficult to understand the code when I found: I actually kind of understand how it works, know the overall architecture! I was so excited to find this, and one thought arose: Why didn't I start writing my own frame? Say dry, took a day to complete the basic class and code writing, including routing, model classes, control classes, some basic methods are encapsulated inside, I think I was too powerful, incredibly in my opinion can be perfectly run! I think it's ready, so I pushed it up (PS: Not with automatic require, just in the top of each file added), after constant testing found that there are bugs, there are! Require do not use absolute path is simply difficult to use, the whole frame want to disunity, not good at all, extensibility is almost no, I fell into a meditation. Where's the mistake? The real epiphany is in the most recent open Yii framework source code, saw AutoLoad after epiphany: In fact, can automatically load files according to demand, a lot of problems are solved, of course, this article also enumerates this issue, in fact, I encountered more than these problems, Many of the mistakes that were previously understood have been made correct with the writing of this framework.

is the architecture of my current framework. There's too much code, so don't show it.

Today's framework diagram. png

After the job is to make the framework more plump, dare not say that compared to some mainstream framework, to tell the truth can not compare with them, no matter from the structure, thinking or thinking, the mainstream framework is the true master. But through this I have at least my own thinking, looking back to their own creativity, so that the real master from the point of a little, I have to say that this progress is exciting. Is the JS frame I just started in the morning.

JS Frame

Finally, I think the benefits: 1, the overall structure of the thinking 2, improve their creativity 3, improve their ability to think independently 4, improve their ability to read other people's Code 5, use and know a lot of programming language built-in functions

Here is my little advice: if it is in the company, there must be a large number of business and needs to be realized, then directly to use, if you are a student, then you are lucky, you have a lot of time to learn, then start from now on your keyboard to start writing it! No matter how difficult, long time you will find that the overall thinking is more and more clear, clear!

Life, programming, I like programming, like to make good things after the sense of accomplishment, so I continue, have like-minded people to find me, can see the present people must be true love, thank you!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.