2016-207-19 Essays

Source: Internet
Author: User

What is an enterprise application?
Enterprise applications meet a few points: 1. Concurrency support 2. Things support 3. Interactive support 4. Cluster Support 5. Security Support 6. Distribution Support 7.wed Support

Problems with EJB development:
1. Editing, compiling, debugging period of 2. Code sinks in, tedious 3. Data transfer objects must be written

What is a lightweight framework?
Lightweight frame: not dependent on the container (easy to test, no need to start the server)

What is the use of MyBatis?
MyBatis is an excellent persistence layer framework that supports common SQL queries, stored procedures, and advanced mappings. MyBatis eliminates the manual setting of almost all JDBC code and parameters and retrieves the result set. MyBatis can use simple XML or annotations for configuration and raw mapping, mapping interfaces and Java Pojo (Plain old Java Objects, ordinary Java objects) to records in a database. Each MyBatis application is centered on an instance of a Sqlsessionfactory object. An instance of the Sqlsessionfactory object can be obtained through the Sqlsessionfactorybuilder object. The Sqlsessionfactorybuilder object can be constructed from an XML configuration file, or from an instance of a configuration class that has been prepared in the past using the conventions to build sqlsessionfactory objects.

MyBatis: The encapsulation of a durable framework:
1.JDBC Connection Package (MyBatis already done)
Encapsulation of 2.SQL statements (still need to write on MyBatis)
If only two are satisfied with the fully automatic package

MyBatis versions available in three languages: Java, net, and Ruby

Advantages of MyBatis semi-automation:

1. Flexible SQL statements you can write your own SQL statements because of the semi-automatic

2. Efficient and effective because the statements of the fully automated query are *

Configuration class:
1. Data source configuration information: MyBatis, config, xml
2.SQL Mapping configuration information

What is the use of unit testing?
Unit test: It is convenient to test test with the smallest class

Assert represents the assertion mechanism if the assertion mechanism does not pass, then he will not execute the following code

MyBatis Dynamic SQL statements:
1.foreach
2.where if
3. Inclube-sql
4.set if
5.trim if
6. Choose when

Class-To-Class relationships:
Inheritance: Subclass Inherits Parent class
Implementation: Implementing Class-to-interface implementations
Associations: Relationships between classes are owned by
Aggregation: The interpretation of combinatorial similarity reference combinations
Combination: The relationship between the whole and the part is not present after the aggregation is separated from the whole.
Dependency: The relationship used to be used

Six major design principles:
① Single Duty principle:
Sometimes developers have problems designing interfaces, such as the user's attributes and the user's behavior being placed in an interface statement. This causes the business objects and business logic to be put together, which causes the interface to have two responsibilities, the interface responsibility is not clear, according to the SRP

Righteousness violates the single principle of responsibility of the interface. Single Responsibility Principle, abbreviated as SRP.
② Richter Replacement principle:
1. Subclasses can implement the abstract methods of the parent class, but cannot override the non-abstract methods of the parent class.

2. Subclasses can add their own unique methods.

3. When a method of a subclass overloads a method of the parent class, the method's preconditions (that is, the parameter of the method) are more lenient than the input parameters of the parent class method.

4. When a method of a subclass implements an abstract method of the parent class, the method's post-condition (that is, the method's return value) is stricter than the parent class.

Summary: Try not to rewrite the parent class's already implemented methods, you can use the interface and other methods to bypass
③ Interface Isolation principle:
The client should not rely on interfaces it does not need, and the dependency of one class on another should be based on the smallest interface. The problem is that class A relies on class B through interface I, Class C relies on class D through interface I, and if interface I is not the smallest interface for Class A and Class B, then Class B and Class D must implement methods that they do not need.
A word summed up: like fish and people two categories, fish is swimming and gills breathing two movements, people are walking and eating two movements, these actions can not be written in an interface, the four actions are included. To be split into two interfaces specifically for fish and people.
④ Dimitri rule (know least principle):
The Dimitri rule is also known as the least known principle, which was first proposed by Ian Holland of the American Northeastern University in 1987. In layman's terms, it is a class that knows as little as possible about the classes it relies on. That is to say, for a dependent class, no matter how complex the logic, as far as possible to encapsulate the logic inside the class, outside the public method provided, not to disclose any information.
⑤ Dependency Inversion principle:
The essence of the dependency inversion principle is that the implementation of each class or module is independent of each other by abstraction (abstract class or interface), and the loose coupling between modules is realized. But this principle is also the most difficult to achieve in the 6 design principles, if not to achieve this principle, then it means that the open and close principle (for extended development, to modify the closure) also can not be achieved. Dependency inversion primitive (dependence inversion Principle), referred to as dip

⑥ Opening and closing principle:
Open and close principle is the first 5 principles of an abstract summary, the first five kinds of closed-closed principle of some concrete implementation, so if the use of open and close principle, in fact a bit virtual, because it does not have a fixed pattern, but the final guarantee is to improve the program reusability, maintainability and other requirements.

MyBatis Cache:
What is a cache?
A cache is a piece of space that acts as a temporary container for a database in memory to reduce interaction with the data

As with most persistence layer frameworks, MyBatis also provides support for first-level caches and level two caching:

1. First level cache: Perpetualcache-based HashMap local cache, its storage scope is session, when the session flush or close, all the caches in the session will be emptied.
  
2. The level two cache is the same as the first-level cache, and by default it uses Perpetualcache,hashmap storage, except that it has a storage scope of Mapper (Namespace) and can customize the storage source, such as Ehcache.

3. For the cache data update mechanism, when a scope (cache session/level two cache namespaces) has been c/u/d, the cache in all select in the default scope will be clear.

MyBatis What data can be put into the cache?
You need to meet the criteria:
1. Small amount of data
2. Less data changes
3. Less data concurrency

Spring Framework:
In 03, the spring Framework was released, and through more than 10 years of development, the spring framework has evolved into a very important framework in Java EE development. Although there are still companies that use their own way to deal with the problem of coupling between the code, the way they are used is still the basis of the spring framework, namely: Factory mode and service locator mode.
Spring is a lightweight solution for enterprise application development, including: core mechanisms based on dependency injection, declarative transactions based on AOP (Lenovo programming transactions), integration of multiple persistence layer technologies, integration of many excellent web MVC frameworks, etc.

Spring Framework Features:
Lightweight-Spring is lightweight, both in terms of size and overhead. The full spring framework can be published in a jar file with a size of more than 1MB. and the processing overhead required by spring is negligible. In addition, spring is non-intrusive: Typically, objects in spring applications do not depend on a particular class of spring.

Control reversal--spring facilitates low coupling through a technique called inversion of Control (IoC). When an IOC is applied, other objects that an object relies on are passed in passively, rather than the object itself creating or locating dependent objects. You can think of the IOC as opposed to Jndi--not the object looking for dependencies from the container, but the container actively passing the dependency to it when the object is initialized without waiting for the object to be requested.

Facet-oriented--spring provides rich support for aspect-oriented programming, allowing for the development of cohesion through the separation of application business logic with system-level services such as auditing (auditing) and transaction (transaction) management. The Application object only implements what they should do-complete the business logic-that's all. They are not responsible (or even conscious) for other system-level concerns, such as log or transaction support.

The container--spring contains and manages the configuration and lifecycle of the Application object, in this sense it is a container, and you can configure how each of your beans is created-based on a configurable prototype (prototype), Your bean can create a separate instance or generate a new instance each time it is needed-and how they relate to each other. However, spring should not be confused with traditional heavyweight ejb containers, which are often bulky and cumbersome and difficult to use.

Framework--spring can be used to configure and assemble simple components into complex applications. In spring, application objects are combined declaratively, typically in an XML file. Spring also provides a number of basic functions (transaction management, persistence framework integration, etc.), leaving the development of application logic to you.

The role of mvc--spring is to integrate, but not just to integrate, the Spring framework can be seen as an enterprise solution-level framework. The client sends the request, the server controller (implemented by Dispatcherservlet) completes the forwarding of the request, and the controller invokes a class handlermapping for the mapping, which is used to map the request to the corresponding processor to process the request. Handlermapping maps the request to the corresponding processor controller (equivalent to action) in spring if you write some processor components, generally implement the Controller interface, in the controller can call some service or DAO for data manipulation Modelandview is used to hold data taken from the DAO, and it can hold some data from the response view. If you want to return the processing results to the user, a view component, Viewresolver, is provided in the spring framework, which finds the corresponding view based on the indicator returned by the controller, and returns the response response to the user.

All of these features of spring enable you to write cleaner, more manageable, and easier-to-test code. They also provide basic support for the various modules in spring.

What is a spring container?
The spring framework is made up of one component of the application, and the spring container is the management of the lifecycle of these components and the maintenance of relationships, which is the spring's core idea, the IOC.

Spring IOC:
The property value of an object instance is not set by the program, but is injected by the spring container.

The caller relies on the container to set properties or inject references to other beans in this way, which we often call "dependency injection" or "inversion of control", or SPRINGIOC. The so-called dependency injection, when the program is running, if you need another object collaboration (call its method, access its properties), do not need to create the callee in code, but rely on the injection of external containers.

Dependency injection is by far the best decoupling method, and dependency injection lets spring beans be organized together in configuration files, rather than being coupled in a hard-coded fashion.
Dependency Injection is an excellent decoupling method. 3 basic points of the SPRINGIOC container are analyzed:
1. The components of the application are interface-oriented programming. Interface-oriented programming can prompt the coupling between the components to the interface level, which facilitates the later development of the project.
2. The components of the application are no longer actively generated by the program, but are generated and initialized by the spring container.
3, Spring uses a configuration file, or annotation to manage the bean's implementation class, dependencies, and the spring container creates instances based on the configuration file, leverages reflection, and injects dependencies into them.

Dependency injection usually has the following two ways:
Set value injection: The IOC container uses the setter method of the property to inject the dependent instance.
Construct injection: The IOC container uses constructors to inject dependent instances.

Set Value injection:
SetPoint injection refers to an IOC container that uses a setter method of attributes to inject a dependent instance. This injection method is simple and intuitive, so it is used extensively in spring's dependency injection.

Construction Injection:
There is also an injection method that, when constructing an instance, has completed the initialization of dependencies for it. This method of using constructors to set dependencies is called construct injection.


2016-207-19 Essays

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.