Introduction to the concept of spring and your own feelings

Source: Internet
Author: User
The core of spring is lightweight.
(Lightweight) Container
(Container), which implements IOC
(Inversion of control) Containers, non-invasive
(No intrusive) framework and Provides AOP
(Aspect-Oriented
Programming) provides support for persistence and transaction and MVC.
The implementation of wexiele haojiu B Framework and
Provides consistent model encapsulation and is a comprehensive application framework (application ).
In addition, spring also provides integrated solutions for existing frameworks (such as struts, JSF, and hibernate.
For people like me who have very little knowledge about frameworks, to understand the text above, you need to explain the terms well. Terms:
1) Lightweight-lightweight

Compared with some heavyweight containers (such as EJB containers), the spring core package has less than 1 MB in file capacity, the use of spring core packages requires a small amount of resources, and you can even use spring core packages on small devices.
PS: Java is just getting started. I have no idea about EJB at all. There are many things to watch. In addition, I have been wondering whether these so-called lightweight or heavyweight standards are uniform.
Swing is a lightweight GUI package (it fully uses resources of its own virtual machines instead of system resources, such as paint brushes, and does not know whether to understand it or not ), the lightweight concept here refers to the content.
A small number of Development kits. 2) Non-invasive)

 
The original purpose of the framework is to provide an architecture implementation so that developers can quickly develop applications that follow the architecture on the basis of the framework. However, once some frameworks are used, the application corresponds
The framework is dependent, for example, a large number of framework APIs are used, or APIs are inherited directly.
Some types of, will make the application components and framework dependencies, and cannot be independent from the framework, let alone the components can be directly reused in another application.
 
One of spring's goals is to achieve a non-invasive (No
(Intrusive) framework, hoping to make applications almost unable to feel the existence of the Framework, reduce the burden of application migration in the framework, and further increase the reusability of application components.
(Reusability), simply put, some components in the application can be directly used in another application or framework using spring. PS: this is definitely a highlight of the WebNMS platform we are currently using (I don't know how to implement it ). The company said that the next version would move out of this platform, and I cannot imagine this process now-maybe I am not familiar with this platform. 3) Container)

 
Spring
Provides the container function. containers can manage the lifecycle of objects and dependencies between objects. You can use a configuration file (usually XML ), define the object name and how to generate the object
(Prototype or Singleton
Method), which object must be set to the attributes of an object after it is generated, etc. After the container is started, all objects can be directly accessed without writing any line of program code to generate objects, or create an object.
Dependencies with objects.
To put it bluntly, the container is a Java program. You must write the program to manage the object relationship. Now the container will automatically help you.
PS: seeing this, we can find that the original web NMs that we have been disgusted with has such a shining point. In this era where XML technology is everywhere, there are inevitable factors to think about the emergence of this technology. However
WebNMS seems to have done too much, so that you have to modify the original code of a WebNMS that is not expected to be modified (the first experience is to modify the toolbar of the main interface ). This seems to be an easy-to-use
And complexity. 4) IOC (inversion of control)


 
The most important core concept of spring is inversion of control.
Injection, which is often translated as "dependency injection" in Chinese. With Spring, you do not have to maintain the object dependency in the program code. You only need to set it in the configuration file.
The core container automatically injects the specified object according to the configuration. In the next section, the inversion of control and dependency are also described in detail.
Injection concept.
PS:
I have been paying attention to the OO design principles and finally saw the principle of inversion. I feel that these principles are nothing more than the basic principles of GRASP. This famous principle is the two principles of low coupling and interface programming.
. I have read the Agile Software Development-principles, models and practices, and Java and patterns. This kind of principle (or pattern) is not like the gof pattern, the latter is on you
Reading a book once or accidentally seeing it in the code can be deeply rooted in the hearts of the people, but these models are widely used and many may be used (your own experience ).
For example:
Single Responsibility Principle: This principle is very simple. Simply put, each class of you is only responsible for your own tasks. In reality, this is often the case you used to do ), it is often a very stingy class. When a new function needs to be added, it is often considered in which class, so there are often some high coupling, which is not conducive to future maintenance. For example, there is an object factory,
Procuctfactory {
Public Product createproduct (INT producttype ){...}
}
When there is a need to maintain the product list, you should not feel that productfactory controls the production of the product, and add the maintenance method to the factory.
Procuctfactory {
Public Product createproduct (INT producttype ){...}
Public list getproducts (){...}
Public Boolean tackleproducts (){...}
}
This obviously undermines this principle and will make users think differently. The correct approach is to set up an after-sales service system specifically to maintain the products that have been created (new classes are generated in the software to maintain the product, and its responsibility is to maintain the product, production is the responsibility of the factory ). -- The example that comes to mind within three minutes may be unconvincing. The principle of opening-closing: Closing modification and opening expansion are difficult to understand. (at least a year ago, I never understood this sentence when I first paid attention to it, in addition, I was confused when I checked a lot of information. At that time, I was also confused by the following sentence: do not implement the interface, but program the interface, there are many classic articles on the internet ....... In addition, I remember the Monkey King asked me how I learned my model. I said I was just getting started. He said that he got the answer. I don't know what it means, but here we will talk about vertices.
I remember the model I was just in touch with last year,
The first problem I encountered was: what is the mode? Language-level idioms? Enterprise-level framework? Software Engineering?

I think many people who are new to the model have this problem. In fact, the concept of the model is very broad. from the definition of the model, you can understand it (just find a network article with an explanation:
Http://www.javafan.net/article/20041123142039257.html

),
It is infiltrated in various aspects, including the language-level idioms of specific languages. Many enterprise-level frameworks are actually built by a variety of models. Therefore, if someone says that he understands patterns, then he is not a tiniu, he is
Cainiao does not understand the basic concepts of models. The pattern we talk about in general refers to the gof pattern (the pattern mentioned in the Design Pattern written by the four-person gang published in 1995 ).
It is often discussed in this regard. There are basic classic books in this regard: the first book is of course the original book of gof, which has been among the top in Amazon for 10 years. In addition, this is the recent head first craze.
DP, a simplified mode, is a classic entry book.
But the pattern is not just that, it covers all aspects, such as Oo (of course, gof also belongs to this type), there is a famous grasp design pattern, in addition, some well-known oo principles (listed above) should also be attributed to this type. In addition, there is a special design model in the network, and the precedent for this should be Ace. Books are:
Http://www.dearbook.com.cn/book/12515

, "Pattern-Oriented Software Architecture Volume 2: The pattern for concurrent and networked objects" (Volume 1 refers to the system pattern and part of the conventional usage. Today, we can also see the pattern, as if it was about the software engineering management model), the author also became a world-class master in the model field. There are also models for multithreading, such as: Java multithreading design mode (
Http://www.dearbook.com.cn/book/33881

), Written in a small Japanese company. I 've been reading it recently. It's pretty good. In addition, J2EE also has a pattern ......
Therefore, pattern penetration is generally attributed to software engineering and specific fields. Another question is: how to learn? (For the gof mode, because we generally refer to it)

This is a different saying. Some people say they read the classic book, some say they read more code, and some say they learn the Library (such as the classic ace library ).
Me
I think that (although I am also very general, but it is a person who has gone through hardships, let's talk about some experience): first, you need to understand some basic knowledge of OO, this does not mean inheritance, polymorphism, and so on, but some
Oo's design principles are like grasp. After learning this, you will understand and understand the learning mode, because the gof mode is nothing more than a specific application of these basic principles. Second, you need to have
This is not the case with a gof book. hfdp is said to be good, and streamlining is the best (BS borrowed books here, and the model is for reference at hand, it should be a must-have copy for the case ).
Java and pattern are good. They not only introduce the basic design principles, but also explain the application of pattern in Java. Third, write your own code. If there is no place for application, write your own sample code. The other question is: how to get started?

Its
I don't know whether I am an entry-level engineer, but I am sure that if you are still the same as before when writing code, there is definitely no entry-level engineer, if you think about how to design the code
To make it easy to maintain and use, it indicates that you are already aware of this. If you are reading code or technical books, there are often: "Oh, here is an application of a certain model! ", Then you have compared the mode.
Familiar. If you want to modify a piece of code (You Need To Know How To modify it and have enough reasons to modify it), it means you have some skill. If your BS has many popular frameworks, feel like you
If you can write better, it means you are a master. -- Hey, you have to get rid of it again! (I guess it is in this conscious state ).
In addition, Mao and I often encounter: I don't know how to do it (that is, I know how to implement it, but I'm not sure whether my design is robust or perfect )? I don't know if this is an over-design question that is often mentioned in the book. Sometimes you need to be confident in writing code, and how to do it. 5) AOP (Aspect-Oriented Programming)

 
On the other hand, spring is most valued by support for the implementation of AOP (Aspect-Oriented Programming). However, AOP
The framework is only a sub-framework supported by spring. It is said that the Spring framework is not an appropriate description of the AOP framework. People's attention to AOP is reflected in spring.
So that people focus on Spring's AOP framework. Although there are some misunderstandings, it also highlights another interesting feature of spring.
An actual example is used to illustrate one of the functions of AOP. If you have a logging requirement, you do not need to modify any line of program code, you can add this requirement to the original application. If you want to, you can also remove this log feature without modifying any program.
 
The implementation of spring's IOC container function and AOP function is the focus. In spring, the persistence layer, MVC Web framework, and APIs of various enterprise services are implemented.
Encapsulation. Some of their implementations depend on Spring's IOC container and AOP functions, and spring's sub-frameworks or encapsulated APIs.
Functions can be independent from each other, or can be replaced with other framework solutions. Spring wants to provide one-stop shop framework integration solutions.  
PS: AOP is one of the most popular technologies recently. With AOP, SOA has set off a thousand waves. I have never studied it. For our new Java beginners, invest in technology (if so
Well, SOA (or AOP) is a good land. Because there are too many J2EE experts and there is a good saying, don't pull fashion's tail, technology is also, when a technology is new
Xingshi (of course, SOA has been concerned for about five years now, although there are real products only in the past two years). If you think it is good, you must be brave enough to invest in it, the author of "Programmer Cultivation" said: 10 years ago
Java programmers are now leading the Java World. However, I still think the Foundation has to be enhanced. 6) Persistence Layer
Spring provides integration of the persistent layer, such as encapsulation and simplification of JDBC usage, transaction management, and integration of the O/R Mapping Tool (Hibernate and ibatis, spring also provides a solution. PS: when I spoke about the O/R Mapping Technology in the OO class, I was very confused. Why is it even harder for teacher OO to explain it? The reason for this idea is that I don't know how important databases are in enterprise application development, and how high the database maintenance cost is. I have to learn hibernate when I have time.
Here, by the way, I want to write about how I treat technical knowledge. (I feel like I am talking about it, but let's look at it from the East and the West, so let's clarify it ):
My principle is very simple. I think like this: if suddenly, I need to lead a project team (and this project team may lack anyone) to develop the project, there should be no helpless situations. So,
 
0. first, I will focus on some basic knowledge, at least some basic network, operating system, security, algorithm knowledge. these are very weak because they have not paid special attention to them before they have been studied in the university.
But I have never experienced it, and Ms needs it most (this time it's miserable) to find a job ). therefore, I have always wanted to buy a book on the elevation level. I don't want to research it, but want to sort out my basic knowledge.

1. I will pay attention to Oo, because it is related to software maintenance and improvement as a programmer's self-cultivation;
2. I will pay attention to a language. I will keep getting familiar with it and be involved in every aspect, such as: the most basic GUI, thread, util. if there is a customer interaction part
Don't pay attention to it (almost every program design competition has set up an award in this respect _ For example, trend million competitions), and pay attention to interface design (some people do not pay attention to interface design by nature and are doomed to fail, in this regard, many of them are from the present
What the company feels-the first time I found that a single interface could be done by so many people/day, it was very enlightening.) I also learned a relatively small language.
3. I will try my best to care about the framework and open-source projects and tools related to the language I care about. As a project owner, the most important thing I think is to know what tools can help you, which of the following tools is best for you?
Taking Java as an example, I should at least know how to use ant to configure the project environment, how to use CVS to manage versions, how to use Bugzilla to manage project bugs, and how to use
Xplanner or teamwork is used to manage the project progress. How can we use wiki to share Team Information and interactions? 4. I will focus on testing, from initial (close to programmers) unit testing, to integration testing, system testing, and other testing methods, as well as white box black boxes, and how to plan and write test cases, as well as regression testing, which cannot be ignored, is why I have always wanted to do a good test;
5. I will focus on project process management. iterative development is very classic, and the XP principle is very charming. Although I have never used it anywhere, I believe that as long as you pay close attention to it, there is still no problem with using them.
What I feel in my team is that there is no real name. For example, in the implementation of iterative development, it is clearly pointed out that the requirements do not need to be completely completed before the iteration starts (this is not possible). Generally, only 20% of the requirements at the start of iteration are
It is clear, but at the same time, it should be noted that for the first iteration, the demand must be clear (this is a misunderstanding of many people ), however, the demand for iteration changes greatly, which can be called overlap.
Development on behalf? This can only be said to be a repetition of waterfall development. A development process is mechanically split into N relatively independent fragments, and then marked with the version number to get only N waterfall development! Is this possible? In addition, XP
One of the principles advocated is "sustainable speed", and there are also the principles that must be followed in the agile Declaration: the agile process advocates sustainable development speed. Owners, developers, and users should be able to maintain a long
Constant development speed. I don't think overtime is one of them. Some people will argue that it is a task that the programmer has not completed the assignment. This is a proper task (here I tell you, this is not a programmer.
This is the manager's reason. This is because the programmer's technical level does not properly participate. As a manager, you are fully obligated to understand this, and then give him a slightly loose task to make the entire team
Otherwise, he is not a competent manager or manager. This is actually a pair of programming advantages. The consequence of habitual overtime is that we are only tired of project development (what's more, obviously only
If half of the Members do not complete the task, but the entire project team is working overtime), the project team will lose charm over time.
6. I would like to pay attention to one direction: I always feel that there is no way to work on projects from the east to the west. What I bring will only make your knowledge more extensive, and you are not an expert in every specific field. therefore, you must select a custom
I have prepared to devote myself to my life. I remember some articles mentioned that if you enter a specific field in an industry, you will become an expert in this field, this is the case for many people in our company, but I don't know him.
Are aware of this. as for my direction, I thought it was a network before entering the lab, but now I feel a little shaken. I also think that enterprise information management is good (because my finance degree certificate is getting rusty, I cannot
Bai Xue, Bai Xue must be able to afford 6 K of money), but this aspect also has its particularity (often not in the quality of software, but in the implementation level, as well as the attitude of the company's management, programmers alone
This is a blind spot for me.

7) Web Framework
Spring also provides MVC Web framework solutions. The advantage of using spring Web framework is that you can make good use of IOC and AOP features, and you can easily replace and use different view layer technologies, for example, using JSP, combining tiles, and using PDF as the screen technology presented to users.
You can also integrate the Web framework you are familiar with spring, such as Struts and JSF, with spring, which is applicable to the current applications.
PS: This is very attractive. I remember that Microsoft's approach to cracking down on other software vendors is often bundling sales. However, it is really hard to say that it does not support interaction and sharing with rival software (for example, saving some information, for example
Channel list), so other competitors want to compete with MS, the basic point is compatibility. This is also important in future software development. People do not have to support you, but you must support others. No wonder this is
A highlight of spring.
I have never understood spring, structs, and other frameworks. I have been thinking that it is very easy to get started after learning the language and OO well. As a result, I am not ready to get started yet. when are you free? Please pay attention to it. ms does not currently use these popular frameworks for projects. I started from scratch and wrote my own framework. MS was a little younger.
8) Encapsulation of other Enterprise Services
For some services, such as JNDI, mail, scheduling, and remoting, spring does not directly provide implementation, but encapsulates these services in an abstract layer, this allows these services to have consistent use models and simplify their use.  
PS: When you see this, you may find that Java is too weak to get started! (Alas, I saw a spring article in the column of Lin Xinliang (Liang Ge) on the RSS browser. I have always been confused about this concept. It is worth understanding, so now
Http://www.dearbook.com.cn/Book/108341

Li
In the first chapter of the following chapter, I want to record some of the content in this chapter (the content outside PS is in this book, which is recommended by many people in MS, in the future, I will also be able to remember it, and I feel that it is not easy to copy it.
Sorry, it took the last 3 hours, faint! If you haven't written a technical article for a long time, make up for it. However, there are also some complaints. The opinions here may be just a joke from a layman.
Looking for a job. Sorry!

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.