Github.com/Snailclimb/… : a lightweight HTTP framework that mimics but differs from Spring Boot

It has been half a month since I last reported the completion of the simple version of “Spring Boot” to my friends. How time flies!

01

In the last two weeks, my HTTP framework has support for AOP, interceptors (which is also a kind of AOP), property file reads, and more. 👏

At this point, the HTTP framework basically has all the functionality I originally set out to do. Well, it’s a promise fulfilled. It’s a good start.

The specific implementation of the function is as follows:

Many readers may find my writing easier. However, to be honest, I also encountered a lot of problems in the process of writing. I stayed up many nights and got up early many times to solve some of the problems I encountered writing the framework.

I’m not really an aspirant. Normally, I usually play king of Glory after 9:30pm and go to bed around 12pm. I usually get up around 8 o ‘clock in the morning. Almost every day.

However, while writing this HTTP framework, I remember staying up until around 2am on three occasions. On two mornings, I got up at 5am to write code because I was “inspired.”

I’m not saying this to make people think HOW hard I write, or to show how hard I work.

These are just common experiences! I think most programmers have experienced this:

  • In the dead of night, suddenly there is something wrong with the code I wrote, and I don’t want to go to sleep until it is solved.
  • One morning, I woke up, inspired, turned on my computer and started writing code.

However, I really don’t recommend staying up late! As for me, every time I stay up late, MY energy will be low the next day or even the third day, which seriously affects my efficiency. This is only the short-term effects of staying up late, long-term unhealthy work and rest, certainly the destruction of the body is particularly large.

I know, but most of us, like me, still stay up late occasionally.

02

The directory structure of the entire framework is as follows:

  • The realization part of the framework is organized according to different functional modules, which is more intuitive.
  • Complete framework usage examples are provided, and tests are written for it.

03

The beauty of open source is that people can give you feedback on your project and, if you meet friends who are interested in your project, they can help you improve and develop it.

Take jsonCat. After jsonCat was open sourced, a brother named “Hellohello-Tom” came in to help develop it.

Tom brother code is very good, help jsonCat to achieve a lot of functions! Thank you very, very, very much! Love you oh! Brother!!!

We often communicate with each other on wechat because of this project. Maybe this is the charm of programming. Ha ha ha!

I seldom chat on wechat, but because of this open source project and brother chat quite a lot.

Two random screenshots:

I think it’s taboo to be alone in a project. Everyone has limitations, and it’s hard to see where your code needs to be improved or where there are problems.

This is why Code Review is so important in the software development process.

Code Review can be very effective in improving the overall quality of Code because it helps us find bad smells in Code and areas where there might be problems.

04

In fact, the simple implementation of the function of the phone costs too much time. Most of my time was spent refactoring existing code.

After all, one of the main reasons I open source the HTTP framework is to teach it to people who need it. I have to make sure that the code I write is readable.

To this end, I set the following rules for myself as I wrote code:

  1. Keep things simple: If you can write clearly in the least amount of code, you should never use more than one line of code.
  2. Don’t abuse design patterns: When I first started writing code, I loved abusing design patterns. When you learn a design pattern, you immediately apply it to your project, even if it doesn’t fit in the current business scenario. This is really a bad habit, but I deliberately avoided it when writing this HTTP framework. Currently, the framework uses only singleton, factory, policy, and chain of responsibility patterns.
  3. Keep the structure clear: Open source code is written for people, and clarity makes it much easier for others to understand the code.
  4. Carefully draw utility classes: When I first wrote this framework, I drew a lot of utility classes. It turns out that many of the methods in the utility classes are actually only used in one place, and are likely to be used in one place in the future. At this point, I think the best thing to do is to put these utility class methods in the only class that uses this method. This will make the overall code structure clearer.
  5. Not showing off: When I first started writing code, I loved showing off. For example, before Java8 became popular, I always wrote code with the new features of Java8 such as Lambda expressions and functional interfaces. At that time, when I was working on a project with my teacher, other students thought my writing was really cool, because they thought it took them a long time to understand it. However, I now think there was a different nature of software development/programming. The nature of programming is not about reducing the amount of code, but writing code that others can understand, and writing systems that are easier to maintain. You don’t just write code for yourself, you write code for other people to understand, to reduce the cost of reading and learning. This does not contradict my first point about simplicity.

Let’s talk about these briefly today. It’s getting late too!

My open source project recommendation

  1. JavaGuide: “Java Learning + Interview Guide” covers the core knowledge that most Java programmers need to master. Prepare for a Java interview, preferably JavaGuide!
  2. Guide xml-rpc – framework: Implemented by Netty+Kyro+Zookeeper A Custom RPC Framework Implemented by Netty+Kyro+Zookeeper
  3. Jsoncat: a lightweight HTTP framework that mimics but differs from Spring Boot
  4. Advancement: Good Habits for Programmers + Essentials for Interviews
  5. Springboot-guide: Not only SpringBoot but also important knowledge of Spring
  6. Awesome – Java: Collection of Awesome Java Project on Github