A talk on Java Learning (vii)

Source: Internet
Author: User

Finally calm down to continue to write the sequel of this topic, the first six main topics of some j2se experience and feelings, now Java application scope has been occupied by a considerable area of EE, some people even claimed that Java was replaced by EE. I do not know how to understand the so-called Java EE (Java2 Enterprise Edition), that is, the enterprise-class application?

The author's view is that the development of technology is to adapt to the changing trend of the world, from C/S transition to B/s mode, from the angle of the client to consider enterprise-class applications or E-commerce domain is not concerned about client maintenance issues, this task has been given to any PC will have browsers to maintain; In the past, the TCP/IP protocol implementation carrier ServerSocket was replaced by Web Server container, such as Tomcat, JBoss, WebLogic and so on. In short, all the changes are to make Java technology to better serve the human production and life.

Some people will ask, directly to learn the J2SE skip the line? The author is definitely not in favor of, in fact, someone to go this way, but the author's own experience is precisely because the foundation of the J2SE is very strong, will lead to the study in the Java-EE on the road on the wind, the knowledge point will not have anything to confuse the place. Let's give you a simple example:

The author has discussed the difference between the following two kinds of writing with college students:

ArrayList list=new ArrayList (); The author does not say objection but at least disapprove

List list=new ArrayList (); The author supports

I have been arguing with my classmates for hours, he said the first one is more scientific, the second is completely unnecessary. I can't completely convince him, but I think good habits and consciousness are at any time should be programmed for the interface to achieve the goal of decoupling and scalability. Let's start with the interface into the world of Java:

1.j2ee and interface

Each version of the Java EE corresponding to a certain version of the jdk,j2ee1.4 corresponding Jdk1.4, now relatively new is JDK5.0, naturally there will be 5.0. In fact, the author has been using the j2ee1.4, but it does not matter, we can next any version of the Java EE API for a little browsing. I would like to first declare a concept, Java-EE is also derived from JavaScript, so the underlying operation is still called to many J2SE library, so we suggest that we first firmly grasp the mainstream J2SE technology.

Java-EE API has a feature, we are more familiar with a few packages java.jms, Javax.servlet.http, JAVAX.EJB and so on are mostly interface, less implementation classes. In fact, we are really in use when more than 60% are repeatedly looking at the Javax.servlet.http this package of several implementation classes of API functions, the other packages rarely. The author suggests that before learning a technology, it is necessary to have an understanding of the overall framework, which is designed to standardize the implementation through interface declarations, and any third-party vendors who want to provide their own brand implementations are also following the rules defined by these interfaces. If the interface is well understood on the previous J2SE learning path, the experience here will be profound, with a simple example:

public interface mp3{

public void play ();

public void record ();

public void Stop ();}

If I define this simple interface, publish it, and stipulate that any third party company that wants to launch its own name for MP3 must implement this interface, which is to provide at least a concrete implementation of the methods in the interface. This meaning has been far more than the object-oriented polymorphism, only vendors follow the interface definition of Java EE, the world's Java-EE programmers can design for a unified interface, and ultimately do not have to change the code just because of the use of different vendors to implement classes and have different characteristics of it, essentially said, No matter what kind of vendor implementation has completed the work within the scope of responsibility. This is what I want to always emphasize, for the idea of interface programming.

What good is an interface? We imagine, now have APPLEMP3, SONYMP3, SamsungMp3 have realized this MP3 interface, so all have play, record, stop these three functions. We will Mp3 the product seating a component without knowing its implementation, as long as you see the interface definition to know that the object has 3 functions to use. Then a business like the one below can be extended from 3 brands to any brand at any time, to make a joke, the project manager is above the 10-interface method statement, and then throws it to the programmer to write the details, because the interface is unified (that is, each method passed in and out of the format has been unified , the manager can take a cup of coffee every day by focusing on the overall business:

Public Mp3 Create ();

public void Copy (MP3 mp3);

Public Mp3 getMp3 ();

Finally, a simple example to illustrate the interface: a 5th battery flashlight, can be loaded into any brand of battery 5th, as long as it conforms to the specification of the 5th battery, after loading any can not see what brand, can only feel the flashlight in the completion of its function. Then the manufacturer of the flashlight and the manufacturer of the number 5th battery can completely release the dependence, can each freely develop their own products, because they are in accordance with the 5th battery should be the shape, positive and negative position and other conventions. Can we have a little more experience with the interface?

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.