I have been developing with the C# language under the .NET platform for a long time. Recently, the project has started to be developed with JAVA. This article will talk about the differences in the specific development process through some of my own experiences during the development process. Due to the limited experience and knowledge , this article can only explain the differences I see from the superficial and commonly used functions.
I use VS2008 and VS2010 to develop .NET programs, and MyEclipse8.5 to develop JAVA programs. Here is a brief explanation from the differences in IDE, language, and plug-ins.
Differences in IDEs:
My first impression is that MyEclipse is very convenient for writing and viewing code during the development process. It even has many functions that VS does not have. Here are some of the differences I have encountered now:
1. After a variable field is selected, the background color of other fields used in this field will automatically highlight, making it easy to see where this variable is used. This function was not available before VS2010.
2. For a code segment in curly brackets or parentheses, double-click behind the symbol to automatically select the code segment inside the brackets. This makes it easy to view a code segment. VS does not have such a function.
3. MyEclipse does not have code segment areas like #region and #endregion in VS. In a method or class, you can #region function point... #endregion to fold the code snippets. Unless MyEclipse uses some other plug-ins To achieve this effect.
4. Ctrl+alt+t and Ctrl+alt+r shortcut keys. This shortcut key is very useful in MyEclipse. You can quickly search for type or resource in the workspace respectively, and you can quickly find files or a certain type by fuzzy matching. file, and VS did not find such a function.
5. MyEclipse smart reminder is relatively simple by default. It will automatically remind you only after you enter. Triggers for Java is set to .abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. After setting it like this, you can be prompted when you enter any letter in MyEclipse, but it is case-sensitive. Unlike VS, if you enter a lowercase a, you can also intelligently prompt variable types starting with capital A, etc.
6. MyEclipse often encounters coding problems, which is very inconvenient for novices. It is divided into two situations: garbled files when opening files, and garbled Chinese content when submitting requests. When the workspace includes multiple projects, it is possible that one project is encoded in GBK and the other is UTF-8, which will cause a single file to be garbled. Set the entire project encoding in Window->Preferences->General-> Select the Other setting in Text file encoding in Workspace, and for a separate project, right-click Properties->Resource on Project and select the Other setting in Text file encoding. The default encoding for submitted request content such as JSP is ISO-8859-1, which often results in garbled characters. You can set the encoding of different files in Text in windows->Preferences->general->Content Types. However, VS does not have so many garbled code problems, and novices are not prone to garbled code problems.
7. MyEclipse often prompts memory overflow and other related memory problems, which is also confusing for novices. It is often caused by insufficient default memory configuration. Modify the configuration parameters under -vmargs in myeclipse.ini, such as -Xmx912m means the maximum Allocate heap memory 912M, -XX:MaxPermSize=556m means the maximum allocated non-heap memory is 556M, this can make MyEclipse memory available. However, some memory overflows. It may be that the JVM memory usage overflows. You need to set the JVM memory parameters separately. In window->preferences->Java->Installed JRE, select the default JDK, then select Edit, and in Default Just configure the relevant parameters in VM Arguments. If the program you are running is a WEB program, you may also need to set the memory settings of Tomcat. In window->preferences->MyEclipse->Servers->Tomcat, select the corresponding version of Tomcat, and then select the JDK node inside. Set memory parameters in Optional Java VM arguments. Relatively speaking, VS does not have such troublesome processing, and generally there is no need to set memory parameters.
8. When debugging code, VS is more powerful than MyEclipse. They can both modify the values of existing variables at breakpoints, but VS can also intelligently prompt itself when entering variables in the monitoring temporary variable box. MyEclipse cannot automatically remind you of the code you have written, and VS can drag breakpoints to already running code. This function is very powerful and useful when debugging problems, but MyEclipse cannot drag breakpoints.
9. The default Ctrl + left click can quickly locate the definition of the field or type. It is the same as F3, but I think ctrl + left click is more convenient during the development process and feels more convenient than the default F12 quick positioning in VS. It is convenient, and after it is integrated with Spring, Ctrl+left click can choose to locate the sub-implementation code of the injected interface, so that you can easily view the implementation code. However, VS does not provide this function when using Spring.net integration.
10. Right-click-source in MyEclipse, you can have many convenient functions, such as generating getters, setters and inheriting interface parent class methods.
11. JAVA projects are opened through import. The entire project cannot be opened by double-clicking the .sln or .csproj file like in VS. But after opening it once, the next time you open MyEclipse, it will automatically load the projects that have been opened. VS can only open one solution at a time, and the solution includes different projects. If a new solution is added, it needs to be opened separately next time.
12. MyEclipse imports a new project. If the JRE version is different, you need to choose to use the local JRE version. Right-click on the project->Build Path->Configure Build Path->Libraries->Java Build Path to modify the JRE version. But sometimes there will be compilation problems. The reason is that the JDK version for compilation is not selected. Right-click the project->Build Path->Configure Build Path->Java Compiler to modify the Compiler compliance level. For VS, it will be more convenient to open the lower version code of higher version code and it will be automatically upgraded, or you can manually select which .NET version to compile under.
13. MyEclipse double-clicks the Tab bar of the file in the code editing box to switch between full-screen display of the code editing block and multi-frame display. This is more convenient than VS. There is a Link Vith Editor button next to the Package Explorer box, which can be quickly Locating the location of the file in the package is also more convenient, but in VS you can directly choose to open the corresponding physical file directory after right-clicking on a file. This function does not exist in MyEclipse.
Differences in languages:
Java language and C# language are very similar. Although there are many internal differences and the APIs provided are also different, the ideas for developing a specific function point are commonly used. Because of the I don’t have much exposure to relatively new technologies and features during the development process. The differences I encountered include:
1. The name of the Java package corresponds to the physical file location one-to-one. In C#, the namespace can be written casually. And the compiled assembly can be changed at will, and it does not need to be consistent with the namespace. The assembly has the same meaning as the jar package typed separately in JAVA.
2. A JAVA file can only have one public class, while C# can have multiple public classes in one file.
3. If a JAR package is found, Java will check the method field description of the new jar package. A separate doc document corresponding to the jar package is required to see the interface call parameter description. Otherwise, it will not look intuitive, but if there is source code, The source code of the generated jar package can be easily seen during debugging. As long as you have a dll file in .NET, you can easily see the method metadata calling parameters, but to see the detailed description of the parameters, you still need the xml document corresponding to the dll.
4. For WEB development, Filter, Servlet, and Listener in JAVA are very commonly used. Filter in Java can use modules in .NET to implement some functions, but Filter can set the scope of the request, and the module is globally controlled; Servlet is equivalent to a specific handler that can handle customized requests. Listener can use Application_Start in .NET to complete some functions, but JAVA integrates some default Listeners, which start executing when the WEB application starts. Their specific execution process is: when the WEB starts, the ContextInitialized method of the Listener -> the Init of all Filters (regardless of the value of filter-mapping) -> the init method of all Servlets configured with load-on-startup greater than or equal to 0 ( Regardless of the value of servlet-mapping), the specific request is: init of the specific Servlet (executed only once) ->Filter doFilter (requesting the value of the configured filter-mapping) ->Servlet service; The final execution order of website release is: Filter destroy-》Listener contextDestroyed.
5. The Final keyword in Java, when given to a field, means that the field cannot be modified, nor can it be modified in the constructor. This is somewhat similar to C#'s const, but const is static by default. It is similar to C#'s readonly, but readonly can be modified in the constructor. When it is used as a modifier of a method, it is similar to C#'s sealed class and cannot be overridden.
6. There is no static constructor in Java. If you want to implement some initialization work, you need to use a static code block, static{...}, and just enter the content inside. C# only has a static constructor.
7. There is the concept of constant pool in JAVA, which is a different area from the heap and stack. Although String has a string retention mechanism like C#, it is different from .NET. Therefore, it is best to use equals for string comparison in Java, otherwise problems may occur. For example, the "a" + "b" strings are in the constant pool. If they are compared with "ab", they will be equal. However, "a" + b, b is a variable and will be placed on the heap. If you still use == "ab" judgment will return false, so try to use equals to judge strings in JAVA, but this problem is not involved in .NET. The calculated strings will have equal results of ==.
8. In Java, as long as every file has a Main method entry, it can be run. However, in .NET, the project type needs to be changed to a console application, and then there is a Main method to serve as a running carrier.
9. The number range of Byte type is different. It is -128 to 127 in Java and 0-255 in .NET. Generally, data that needs to be exchanged and processed is converted into hexadecimal, and then the last 2 bits of 8 bits are taken. In this way, their values are the same, which is convenient for synchronous encryption, decryption or related processing
10. In Java, it is recommended to use the get and set methods to assign and obtain values to internal variables. In .NET, you can use the field get and set to obtain, and vs2008 Then you can directly get; set; with the help of syntactic sugar, the compiler will automatically generate equivalent get and set internal fields.
11. JAVA compiles automatically by default after saving files, but this is also due to the fact that it compiles each java file into a class file. In .NET, you need to execute the compilation project separately each time, because it has one dll file per project. If you save one of the .cs files and perform compilation, the workload will be too large and affect the development speed.
12. List is an interface in Java. For those who are used to using List collections in C#, new List will already report an error, and their generics are also different. C# is the generic support of the CLR layer, and JAVA’s Generics are not supported by the JVM, so there is relatively no performance improvement.
13. The default modifiers in JAVA are visible within the package (corresponding to the same folder directory, not under the large jar package of the project). Protected variables and methods are visible within the package and subclasses. In .NET, they are visible. Only visible to itself and subclasses. The default modifier of a class in .NET is Internal, which is accessible within the assembly. Methods and fields are private by default, which is different from being visible in the default JAVA package.
http://lawson.cnblogs.com/
Differences between plug-ins:
1. MyEclipse itself is a plug-in, which integrates a large number of open source frameworks, while VS is a unified IDE from Microsoft, and you need to use other open source Plug-ins need to be downloaded and configured separately.
2. There are many ways to implement webservice in Java. In addition to JAX-WS, which is only in the javax.jws package, the java webservice specification comes with its own version, and there are also the webservice open source implementations of axis and xfire. axis includes axis1, axis2, and xfire has been renamed. It is cxf, but various implementation methods are different. When calling each other with webservice published by .NET, we often encounter some problems. Generally speaking, Java has stricter format requirements for wsdl.
The above are the results of my recent analysis and compilation of the problems I encountered during the development process. The coverage is limited and I need to continue to improve the relevant technical points in the future, and the results of the compilation and understanding may not be completely accurate. If there is any problem, please correct me.