Ten sins of Java
Sorry, I made a mistake when "ABC" = "ABC" returns false. in Java, true is returned. I did not go through the experiment, sorry. The reason for this is that I do not remember which one, because I used = to compare the strings, and the results did not return the expected results. Then, ask the old man, the old saying goes: it is best to use equals for comparison instead of =.
Well, I know that many people can't help making bricks or saying they don't agree with the title. I accept it all.
When I encountered a problem, I asked some java friends for help and was able to solve it. What I want to say is that it cannot be solved. Most of them would say: "How can you do this? This cannot be done. First, you are wrong in thinking. We never do this .", For example, "We rarely use stored procedures. If you use so many stored procedures, we recommend that you use hibernate.CodeTo implement your business, rather than using Stored Procedures ", this problem occurs when I encounter some problems when calling the stored procedure with hibernate, and a friend of mine who is engaged in Java cannot solve this problem, he said so.
Java developers also like to say that this should not be completed by JDK or a framework, but by brave, hardworking, and intelligent users.
The following are some of the problems I encountered when developing a Java project, and some of them may be incorrect.
If you encounter many problems and cannot discuss them all at a time, you can just list a few questions.
1. "ABC" = "ABC" returns false. Many beginners need to waste a lot of time on this issue, because they are confident that true will be returned here, I don't even think the problem is here. I have posted a post on the Internet to discuss this question. What is Java a purely object-oriented language? The = Operator is a comparison address or something, while "ABC" is a reference, therefore, you cannot use the = Operator for comparison. Instead, you should use the equals Method for comparison. This error is probably because you are not well-founded, but Java is not. I saw an example by myself, which could express my feelings. I said: One day I went to a restaurant, because there was a beach of water at the door of the restaurant, which made the road slippery, I accidentally fell down, so I found the restaurant manager and held it accountable. As a result, the restaurant manager told me that this was because I had a wrong walking posture, so I slipped and had nothing to do with the restaurant.
2. Why is the getxx (); setxx () method used instead of the get; set; attribute not?
This method is widely used in struts, spring, and hibernate. For example, if the VO object in struts contains GetUserName (), you can use <s: property value = "username"/> to get the value. In the middle, I think we should use reflection to find the GetUserName () method and then obtain its value, this method is also widely used in spring and hibernate. I would like to ask, isn't reflection very inefficient?
3. creating a custom tag also requires writing a TLD configuration file by myself. Sometimes, when I read some java-related books that mentioned Zero Configuration, I think it is very ridiculous, I don't know what the spirit of Zero Configuration is like? It may not be that difficult to write a configuration file, but the key issue is that, technically speaking, this TLD is obviously usable, the TLD mainly describes the attributes and types of the tag names, which can be expressed in the class, as long as the class implementing the tag interface is automatically recognized as a custom tag, isn't that good? Identify getxx (); setxx (); (a better solution is get; set; Attribute) in the class to determine the attributes of the custom tag, what are the different types? Why do I need to create a TLD configuration file?
another problem is that if I write a mytag class that inherits a custom tag class, I also need to write a corresponding TLD configuration for mytag, I don't know whether other developers will inherit my mytag in the future. Maybe even if I warmly welcome others to inherit my mytag, but when someone else sees nearly 30 or 40 getxx (); setxx (); In My mytag, they want to write the corresponding TLD configuration file for it.
4. in my opinion, data access should be a very simple task. Simply put, it is to execute SQL statements. If it is more complex, it is added with Entity ing. All the problems solved by the Framework are solved, the first is to make it easy to use. After using hibernate, I feel that it is too complicated.. Net has a data access layer. You only need to configure the connection string in the specified configuration file, you can call dbhelper anywhere in the Program . execute (SQL), dbhelper. executedataset (SQL), dbhelper. executedatatable (SQL), which is very simple to use. Of course, there are also entity ing, dbhelper. save (entity), dbhelper. delete (entity or key), dbhelper. the Select (condition) method can operate on Object objects. Select returns the object list, and the object sets its associated Table and field, except for the connection string, there is no other configuration file. In contrast, why does hibernate need so many configuration files? I know that hibernate can also configure annotations, so that HBM configuration files are not needed. However, even so, as far as I know, many other related configuration files except connection strings are still needed.
5. it has been said that Java has been around for so many years, and hibernate has been around for so many years. Is it true that I will not use it, actually, stored procedures are not supported. Looking for hibernate to call stored procedures on the Internet, most of the answer is to get a connection from Hibernate and then call the stored procedure using JDBC, there is a problem in doing so, and the transaction cannot be controlled. As I am still confused, Hibernate's transaction control is implemented in a dark box, it seems that all the business code written in the service layer is in a transaction, so I cannot make my Stored Procedure Call and hibernate business code string in a transaction, in many cases, I want to make them all fail if they fail.
In addition, there are two methods to call the stored procedure without passing through hibernate. One is to write the configuration file, and the other is to have a returned result set, I am wondering why there must be a result set. Many of my stored procedures only process some data and do not need to return the result set, the most uncomfortable thing is that the stored procedure in Oracle does not actually support returned result sets. It must be returned using a abnormal cursor. In this case, I will feel terrible nausea. Another method is to modify the default behavior of an object during insert \ update \ Delete. For example, when I insert an employee, it should have been the execution of the SQL statement insert into employee values (?,?,?,?) You can modify the default behavior in the configuration file to {call myproc (?,?,?,?)}, This method is obviously not what I want. I just want to call a stored procedure and execute a business process. The above two methods are managed by a dark-box firm, but they cannot meet my needs. What should I do?
6. the result set objects of data access, such as resultset, rowset, and cachedrowset, are not widely used. The frameworks tend to support object lists, which leads to a problem, that is, I can only return the result set of a known structure. If you want to temporarily return something, you must add the corresponding property getxx (); setxx (); Method to the object, for example, in hibernate, to access the employee table, the employee table has only the Department ID and no department name. To have a department name, you must add a deptname attribute to the employee entity, it is painful to have all the results in a known structure. If the results are not returned to the object list, they can also be returned to the arraylist , but such data has no column name, I don't understand why I don't directly query the resultset, and then let more frameworks support the resultset, such as Struts. When writing a page using the struts tag, I can operate the resultset like an object list.
... , (it was originally supported, but I won't? Sorry !) I just want more frameworks to support result sets with unknown structures. It is very tiring for programmers to design the structure of result sets in advance, even if it is code generation, only the corresponding entities of each table in the database can be generated. However, we often need to select unkownschema from mytable to obtain the result set of the unknown structure, rather than select * each time *.
7. in addition, the resultset does not directly use this instead of using the object list. I think it is indirectly explained that the resultset class is not convenient to use ,. the dataset and able in. NET are widely used because they are convenient and practical. The biggest possible difference is that dataset is a disconnected micro-database in the memory, while resultset is just a connector database reader, which is equivalent. net datareader, must be connected to read data, I know that cachedrowset can be disconnected to store data in the memory, okay, this is not a problem. However, another problem is disturbing me. As a container for storing the result set, there are too few methods for us to operate on this result set, and even the method for getting the total number of rows of the result set, we all need to use our brains to write: Rs. last (); int COUNT = Rs. getrow (); RS. if the first () operator is responsible, it requires at least three codes to obtain the total number of rows. Maybe this is only a small problem. This may be accomplished by brave, hardworking, and intelligent people.
8. In my opinion, Struts makes every JSP page have a corresponding Java class method, that is, the action method. You will certainly tell me that struts is not just like this, but I said that the significance of Struts is just like this for many projects (small companies) I have seen, I imagine that there are thousands of companies in our country that use Java technology. The significance of struts to them is that JSP has background code. If this is the case, why can't JDK support be directly provided by the official team, so that struts can be advanced to make up for JDK lag? It is only intended to cover the details.
Or you will say that even if Struts provides a corresponding action Method for every JSP page, this is great, it has completely changed the way people develop web projects, from mixing the original business code and pages to decoupling, which is very successful. I would like to say, don't let me talk about it again today with the glory you have made ten years ago.
9. besides, myeclipse, this ide has almost become a standard in the Java System. All Java developers I have ever seen use this ide. However, it is much different from Visual Studio, performance is not enough. If optimization is not done, it is too slow to die. Why can't the default setting released by one of them be optimized? If we need any plug-in components and load them by ourselves, isn't that clear?
In addition, the plug-in Installation Method of myeclipse makes me feel ashamed. The plug-ins of 6.x, 7.x, and 8. X are installed in different ways. Why cannot I install them by double-clicking? To install vss2005, double-click it. So far, I have not figured out how to install the svn plug-in. Well, I am very confused. Sometimes, after installing the plug-in, you have to copy the file to the specified directory, and sometimes start myeclipse, select the software updates under the Help menu. Sometimes you need to select the myeclipse configuration center. Sometimes you need to connect to the Internet for online operations. What's more, you need to compile a Java file into a class file, then, follow the steps.
10. Out output parameters, partial categories, extension methods, and lamuda expressions are not available in Java, or will they not? Hope to confirm.
Spring, but I still don't know what it is. Well, it's my sin.
We hope that intense and hot discussions will be held. We can use various methods, such as the opening ceremony of the chamber, Wei Jie Zhao, ten-sided ambush, one-pick, and competition.