Some differences in the Java and. NET development process

Source: Internet
Author: User
Developed in the C # language under the. NET Platform for a long time, the recent project began to be developed in Java, this article through their own experience in the development process of the different points in the specific development process, due to the limited experience of knowledge, This article can only be used to illustrate the differences that I see from the comparison surface and the function points that I use most often.

I am using VS2008 and VS2010 to develop. NET programs, through the MyEclipse8.5 development of Java programs, the following from the IDE, language, plug-in different points to do a simple explanation.

Different points of the IDE:

The first thing that's ever happened to me is myeclipse. It is also very convenient to write the view code in the development process, even with a lot of features that are not available with VS, here are some of the different points that you now encounter:

1, a Variable field is selected, the other use of the field of the background color automatically highlighted, easy to see where the use of this variable, VS2010 before the function.

2, for a curly brace or parenthesis of the code snippet, double-click the symbol, then automatically check the parentheses inside the code snippet, this can easily see a code snippet, vs does not have such a function.

3, MyEclipse not like the #region in the VS, #endregion一样的代码段区域, in a method or class, you can #region function points ... #endregion这样把代码片段折叠起来, MyEclipse unless you use some other plug-ins to achieve this effect.

4, Ctrl+alt+t and ctrl+alt+r shortcut keys, this shortcut key in MyEclipse is very useful, you can quickly find the work space in the type or resource, you can quickly blur matching to find a file or a type of file, and vs did not find such a function.

5, MyEclipse Smart reminder By default is relatively simple, as long as the input. After the automatic reminder, you can window->preferences->java-editor->contenet The auto activation triggers for assist tab in the Auto-activation box Java is set to. abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz, this setting, the input of any letter in the MyEclipse can prompt, but it is case-sensitive, unlike the VS input lowercase A can also be smart hints of the beginning of a change in capital a Volume types, and so on.

6, MyEclipse often encounter coding problems, for beginners very inconvenient, it is divided into file open garbled, and submit request Chinese content garbled two cases. When the workspace includes multiple projects, it is possible that one item is encoded with GBK and the other is UTF-8, which results in a single file garbled, setting the entire project code in window->preferences->general-> Workspace Select the other setting in the text file encoding, and select the other setting in the text file encoding for a separate project in project right Properties->resource. For JSP and other submission request content default encoding is iso-8859-1, also often lead to garbled, you can set the text in Windows->preferences->general->content types different file encoding. However, vs does not have so many garbled problems, the novice is not prone to garbled problems.

7, MyEclipse often prompt memory overflow and other related memory problems, for beginners is also more confused about things, often is not enough memory default configuration caused by, Modify Myeclipse.ini-vmargs The following configuration parameters, such as-xmx912m represents the maximum allocated heap memory 912m,-xx:maxpermsize=556m represents the maximum allocation of non-heap memory 556M, this can make myeclipse memory possible enough. However, some memory overflow may be the JVM memory consumption overflow, you need to set the JVM memory parameters separately, in the Window->preferences->java->installed JRE, select the default JDK, and then select Edit, Configure the relevant parameters in the default VM arguments. If the running program is a Web program, you may also need to set Tomcat's memory settings, in Window->preferences->myeclipse->servers->tomcat, select the corresponding version of Tomcat, Then select the JDK node inside and set the memory parameters in the optional Java VM arguments. VS will not be so troublesome to deal with, generally do not set the memory parameters.

8, when debugging code, VS will show more powerful than myeclipse, they can modify the value of the existing variables at the breakpoint, but vs in the monitoring temp variable box input variables can also be smart to write code, and MyEclipse can't automatically remind, and VS can drag breakpoints to already running code, which is very powerful and useful when debugging problems, but myeclipse cannot drag breakpoints.

9, the default CTRL + Left click, you can quickly locate the field or type of definition, and F3, but I think Ctrl + Left button development process more comfortable, than the default F12 fast positioning in VS will feel more convenient, and it integrates with spring, CTRL + The left button can choose to navigate to the child implementation code of the injected interface, which makes it easy to see the implementation code, while VS is not available when using spring.net integration.

10, MyEclipse Right-click-source, can have a lot of more convenient functions, such as generating getter,setter and inheriting interface parent class method.

11. The Java project is opened by importing, instead of opening the entire project by double-clicking the. sln or. csproj file like vs. But once opened, the next time you open MyEclipse, it will automatically load the items that have already been opened. VS is one solution that can only be opened at a time, with different projects included in the solution. If a new solution is added, the next time you need to open it separately.

12, MyEclipse import New project, if the JRE version is different, you need to choose to use the local JRE version, project right->build path->configure build Path->libraries->java Build Path modifies the JRE version, but sometimes there is a compilation problem, because there is no option to compile the JDK version, and the project right-click->build path->configure Build Path->java Modify compiler compliance level in compiler. For VS, the high-version code turns on the low-version code, is automatically upgraded, or manually selected in the. NET which version of the compilation, it will be more convenient.

13. MyEclipse Double-click the tab bar of the file in the Code edit box to toggle the full-screen code edit block and multi-frame display, which is more convenient than VS, there is a link Vith editor button next to the Package explorer box, Can quickly locate the location of the file in the package, this is more convenient, but a file in the VS right-click can directly choose to open the corresponding physical file directory, in the MyEclipse does not have this function.

Different points of language:

The Java language is very similar to the C # language, although there are many differences in the internal, the API is not the same, but the idea of developing a specific function point is often the same, due to the relatively new technology and characteristics of the development process of not much contact, I encountered different points include:

1, the Java package name is corresponding to the physical file location one by one, C # namespace can be casually written, and the compiled assembly can be arbitrarily changed, can not be consistent with the namespace, the assembly and Java in a separate jar package is similar meaning.

2. A Java file can have only one public class, while C # can have multiple public classes in a file.

3, if found a jar package, Java view the new Jar Package Method field description, need to have a separate corresponding JAR package doc document, to see the interface call parameter description, otherwise it looks not intuitive, but if there is a source code out of the jar package, debugging can easily see the source of the package. NET as long as the DLL file, you can easily see the method metadata call parameters, but see the parameters in detail, or need the corresponding DLL XML document.

4, for web development, Java Filter,servlet,listener is very common, The filter in Java can be used in. NET to implement some functions, but filter can make the function request scope, module is the global control; the servlet is equivalent to a specific handler that can process the request, Listerner can use the AP in. Net Plication_start to complete some features, but Java integrates some of the default Listerner, which is executed when the Web application starts. Their specific execution flow is: When the web starts, listener's Contextinitialized method, all the filter's init (regardless of the value of filter-mapping) All init methods configured with a servlet of load-on-startup greater than or equal to 0 (regardless of the value of servlet-mapping), the specific request is: Init for the specific servlet (only once)->filter DoFilter (value of filter-mapping requested configuration)->servlet service; the last site release execution order is: Filter destroy-Listener contextdestroyed.

5, the final keyword in Java, when given a field, indicating that the field can not be modified, the constructor can not be modified, this and C # Const a bit like, but the const default is static. and C # ReadOnly are also more like, but ReadOnly can be modified in the constructor. When it is used as a modifier of a method, it class tries C # 's sealed class and cannot override it.

6, there is no static constructor in Java, if you want to implement some initialization work, you need to use static code block, static{...}, input content, C # only static constructor.

7, Java has a constant pool concept, and heap, the stack is not the same area, although the same as in C # string has the strings reside mechanism, but and. NET is not the same again. Therefore, the string comparison in Java is best compared with equals, otherwise there may be a problem. For example, "a" + "B" string in the constant pool, if they compare with "AB" will be equal, but "a" +b,b is a variable, it will be put into the heap, if also use = = "AB" Judgment will return false, so Java as far as possible to use equals to determine the string, but. NET does not involve this problem, the computed string, = = Results will also be equal.

8, every file in Java as long as there is the main method entry, it can run, and. NET needs to modify the project type to the console application, and then have a main method to act as a carrier.

9, byte type of the number range is not the same, Java is 128 to 127,. NET is 0-255, generally need to exchange data and processing are converted to 16 binary, and then take 8bit after 2 bit, so that their values are the same, convenient synchronous encryption decryption or related processing

10, Java recommended to use the Get,set method to assign values and get the value of internal variables. NET can be obtained with the field get,set, and can be directly get;set after vs2008, with the help of syntax sugar, the compiler will automatically generate equivalent Get,set internal fields.

11, the Java file is saved by default automatically compiled, but this also thanks to it to compile each Java file into a class file. NET needs to compile the project individually each time, because it is a project one DLL file, if you save one of the. cs files are compiled, then the workload is too large to affect the development speed.

12, the Java list is an interface, this pair in C # used to the list collection, the new list has been error, and their generics are not the same, C # is the CLR layer of generic support, Java generics are not supported by the JVM, so the performance is relatively non-elevated.

13, the default modifier in Java is visible within the package (corresponding to the same folder directory, not the project large jar package), the protected variables and methods are within the package and the child class is visible. NET is only visible to itself and subclasses. The default modifier for the net class is internal, which is accessible within the assembly. The method and the word defaults are considered private and are not visible in the Java default package.

http://lawson.cnblogs.com/

Different points of the plugin:

1, MyEclipse itself is a plug-in, which integrates a large number of open-source framework, and VS is a Microsoft Unification IDE, to use other open source plug-ins, need to be downloaded separately and individually configured.

2, Java implementation of webservice many methods, in addition to the JAVAX.JWS package only the Jax-ws,java WebService specification comes with the version, there axis,xfire WebService open source implementation, axis including AXIS1, Axis2,xfire has been renamed to CXF, but various implementations vary, in and. NET release of WebService call each other, often encountered some problems, in general, Java to the WSDL format requirements more stringent.

Above are their own recent development process in accordance with the problems of their analysis and collation of the results, involving a limited number of aspects, need to constantly improve the relevant technical points, and the collation and understanding of the results may not be completely accurate, if there is a problem, please correct me.

  • 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.