PHP Programmer for Fast Java development

Source: Internet
Author: User
PHP Programmers Fast Java development, as we take a magnifying glass in learning Java, Java after so many years of development, can be said to be very large. Learning a new language is the same, there are a lot of online tutorials, very chatty, the general system of learning 30-60 hours before the formal contact with the project development. The basics are important, but learning too much can make you lose the fun and confidence of learning. Many knowledge points can actually be completed after the project. Learning on demand is the best way to drive yourself to learn.

For example, hashmap hash distribution, hash collision, dynamic expansion, these are our later in-depth improvement needs to understand the content, at the beginning, we just need to know what to do with HashMap.

Guided by the realization of something familiar to him

For example, we do the Web backend API development, the first is the usual loop/iteration, conditional judgment, additions and deletions to change. So can you quickly use Java to implement these things we do with PHP very handy thing?

This helps us to improve our confidence quickly.

A learning approach using analogies

How PHP is implemented, re-implemented in Java again.

Finally in-depth system learning

When you have implemented some small demo to refer to other people's projects. If you look directly at someone else's project from the beginning, you probably don't know what others are doing at all. For example, others use the Concurrenthashmap, then to think about why I use HashMap he but with Concurrenthashmap, with questions, with thinking to see Open source code.

After you have completed some simple projects, you can go back to the systematic study. At this time there will be a different harvest.

Finally, when the project needs tuning, performance improvement, then conquer, in-depth learning, more targeted, more targeted.

The actual combat begins

We use Netty to provide high-performance Web services. Easy to use (Netty is not simple) and does not depend on other software. Then consider what essential components are required to complete a simple Web API server. (In fact, when you think about it, you have to memorize the simple architecture.)

I briefly summed up the following:

    1. Java Basic data type (Php also, not afraid)

    2. Java Collection Framework (PHP has an array, very powerful)

    3. First knowledge of Maven (PHP has composer)

    4. Reflection (frame Routing and other places to use, PHP also)

    5. Serialization (data transfer is used, PHP does not have complex data structures to be simple N times)

    6. JDBC (database operation to use, PHP has PDO)

    7. General knowledge of generics, annotations and other syntax (optional)

    8. Use Netty to develop a Web API service (PHP has swoole)

Java basic data structure, a variety of basic data types wrapper class

Java-collections Framework High Frequency class example

HashSet is a collection of elements that do not have duplicates. It is implemented by HashMap and does not guarantee the order of elements, meaning that the order in which the elements are inserted is inconsistent with the order of the outputs.

This is actually my old friend, Redis often use, such as we can it to implement a blacklist, so that the speed of the search is very fast, and do not have to remotely query Redis, directly in the current memory query.

ArrayList implements the function of a set based on an array, internally maintaining a variable-length array of objects, where all objects in the collection are stored in the array, and the dynamic scaling of the array length is realized.

Isn't this the usual index array in our PHP?

HashMap is implemented in a hash table data structure, where the object is evaluated by a hash function, which is designed for fast querying. The feature is fast, non-thread safe.

First knowledge of Maven

The rationale for Maven is simple, The jar files defined in the remote repository and the local repository and a core configuration file, Pom.xml,pom.xml, are downloaded from the remote repository to the local repository, each project uses the same local repository jar, the same version of the jar is downloaded only once, and avoids the need to copy the jar for each application.

This is similar to PHP's package management tool composer, or composer is designed with Maven in reference. MAVEN is more powerful, composer needs to be imported every project, maven, like Git, has a local repository, and third-party packages are not directly referenced to the project, but will be introduced when compiled (not very convenient). Maven, on the other hand, is not just a package management tool, but also a project management tool that integrates functions such as compiling, packaging, and unit testing.

To implement controller access

Specific requirements: Provide an API for users to specify user information

Define interfaces:

Http://localhost:10000/users/{id}http://localhost:10000/?method=user.get&id={id}

Perhaps now everyone is accustomed to the former RESTful API interface.

Because there needs to be a route mapping and HTTP method matching, considering the cost of learning, I didn't choose this way.

Our goal today is to achieve our functionality in the simplest and most effective way possible.

We start with the simplest way (in fact, the API without routing is the fastest, after all, it needs to do less judgment).

The above is how the PHP programmer quickly Java development, hope to help everyone.

Related Article

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.