If you can post other people's essays on the publisher's blog, it would be better, at least. The following article describes the development experience of ext and J2EE. It is good for J2EE developers to learn how to combine ext with ext. Originally posted in the JS Hall, the article is good, and now some friends need to look at it, plus it is all insights. Now, let's turn around ~~ The beauty of the attacker should also be discussed out of courtesy.
Summary of extjs and background (J2EE) development experience and experiences.
Author: andy_ghg
Source: JS Hall
I have been developing extjs for a year and a half, and I am working on extjs while working on java. I also mentioned a revised Chinese resource package in extjs's official international resource file. Now the international resource file in the latest 3.1.0 version is the revised version I mentioned last year.
I have accumulated a lot of failed experiences and experiences in the project. Our company should be the first company in China to use extjs to develop large projects. We started preparing for the project about two years ago.
So let me give a brief introduction to some difficulties and problems I encountered during extjs development and some conflicts in front and back-end matching.
1. Insufficient investment in the Early Stage
What should I do? I did not pay enough attention during the preliminary research. I always thought extjs was nothing more than controls and things. A new window can be used. A grid is required.
Add a GRI
D. As a result, code execution efficiency is extremely low, and variable names are not properly managed. It uses procedural programming instead of OO ideas. This is the biggest failure. This problem has not been solved so far (when I went to work, they had written n lines of code, and refactoring was unrealistic .). Many companies still think that extjs is JavaScript.
Well, it's also Javascript in Niu. Finally, after the problem arises, I began to say: "extjs is too slow to tolerate. It is not suitable for large-scale projects ."
2. Lack of knowledge about APIs and lack of information.
This directly leads to N useless code. I have seen that ComboBox does not use displayfield or hidden.
Field
To get the value and rawvalue, but where I wrote n multiple lines of code to get the two values. (However, we should also realize that extjs was rarely written in China at that time.
Yes, it's not bad .) This type of paranoia leads to frequent errors and unexpected errors in your code. Suddenly, Baidu or Google
This information is available. Suddenly realized. Later, there was a growing amount of online information and new problems emerged, which are the problems to be discussed below.
3. Do not trust your own capabilities, over-reliance on Baidu and Google
When I first entered the organization, I wrote an inheritance (ext
End ).
Question: "What is this? I have never seen it. I have never seen it on Baidu or Google. Can I write it like this ?". This idea was generated not because of anything else, but because it was not valued at the early stage of development.
Extjs, a paranoid attempt to write its own code, causes a lot of losses and then begins to become unconfident. In this way, when a problem occurs, you do not have to reflect on why the problem occurs.
Open a post to ask someone else, Baidu, and Google. The API and its source code are not given priority. This leads to self-confidence. I think that if the code copied from Baidu cannot run, it is others' fault.
Is your own error. The code written by others has never been seen on Baidu or Google. Think twice.
4. Disputes between the front-end and backend
As you know, to display a lot of data in extjs, you must have a field corresponding to the background data, such as columnmodel in the grid. I have an ID at the front end, And the backend also needs to transmit
The ID field is used to display data. But in actual development, a problem occurs. When creating databases and tables in the background, I have never consulted the presentation layer, and I think it is almost paranoid that the creation of databases and tables has nothing to do with the presentation layer.
When processing, you just need to plug it into the front-end so that they can display it. The presentation layer is so bitter that the field does not correspond to the foreground when a piece of data comes up. What should I do? For example, the fields in the front-end grid display the year, month, and day, while
In the database
Medium
The year, month, and day are three fields (just for example), so I will splice the fields in action. In this step, it should be spliced during data query (this should be done at the business logic layer in reality)
). What is the result? Actions are filled with a lot of stringbuilder and loops, making them messy. It's easy to find a good one.
Only JSON-lib can be converted. Unfortunately, there are sensitive fields such as length. Depressed. To ensure data compatibility among multiple tables (for example, Tables A and B must be displayed in
The fields in Table A and table B are inconsistent. Of course, there may be some problems I described here. The difficulties in actual development are really just plain words ......
5. Unclear page logic and background Logic
For the simplest example, I need to take a screenshot of a video and extract it for playback. Where should I do this logic? Page? I don't think so. javascript can be used for time.
Computing, but this operation will eventually pass the computing result to the background, and then the background will send the cut video stream to the foreground. Why can't we complete this logic in the background? Javascript is not good
To process the logic. Once an exception occurs, JavaScript always takes more time to handle the exception. On the contrary, Java is very good at doing this.
6. js debugging
In other words, because the presentation layer is not emphasized in the early stage (before I enter the company), and for various reasons. Some things cannot run on Firefox, so Firefox is abandoned, and we think that we only need to run things on IE.
I wrote a bunch of codes that are incompatible with Firefox. This is miserable. My dear Firefox and firebug left me and debugging became a topic we had to talk about every day after dinner. Finally, I found a compromise.
Method, commonjs plug-in for debugging, but for various reasons, the running effect on IE6 is not ideal. So I had to use log4javascript. Wasted time
. A waste of energy.
Next, I will give some development suggestions for some of the problems I have encountered.
1. ensure the naming rules of your code, and there should be no less comments in JS. Java can use eclipse to locate the file where the variable is located. js cannot be located even if you press control to death (spket
Only declarations can be located, but files cannot be located)
2. Ensure that the module you write can be run and tested separately. Modules and modules should not be coupled too closely. Excessive coupling makes it very difficult for me to replace a module.
3. When discussing the database, backend, and overall process, the presentation layer must be ears-up. Do not perform table join queries in action because a field is missing from the database.
4. to let others know, JS is actually not as simple as they think.
5. Look at the API more, look at the source code, less Google and Baidu. Do not copy existing online examples for your own use.
6. Check the cause and take more notes. The error will not appear only once.
7. Take care of your own JS files and use one to the West. It will be painful for you to give your name a bad word.
8. You are not fighting alone. You are not writing extjs in a learning mindset. You are using it to create value. A person's strength is weak.
I personally feel that the cooperation between struts1 and extjs is not very satisfactory. In comparison, struts2 is better (in fact, Struts is no longer necessary)
.). I think the current version of struts2 is too low, so it is best to replace it
The latest version of jsonlib. In addition, if there are no special requirements on the front-end, use HTML pages. jsp also needs to be compiled. The first time it runs slowly, and development is almost the first time
Line. This can reduce the time.
Code that can be saved should be saved as much as possible. Excessive code will only increase your bug, without any benefit.
Dare to doubt, many times (especially 2.0 ). Some bugs are caused by extjs itself, not because of code writing problems. Therefore, it is important for you to understand what is wrong.
Extjs is based on JavaScript. Maybe you don't think javascript can write a window at all. But you are wrong.
Understanding, you will never stop writing, but will not go up to the level of how to write better. If you just want to escape the tedious CSS, Dom, and JavaScript
Extjs. I suggest you take the time to understand it. I will not harm you, rest assured.
Don't be paranoid. If you are a researcher (Manager or supervisor) who is preparing to use extjs to develop this article, I hope you will pay enough attention to it. extjs is not well written, you will be disappointed. Necessary energy and capital investment are required. In addition, the development cycle should be slightly longer.
Extjs is like EJB. How is the path to the future. The reason for existence is that ejbs are rotten, and ejbs are still applied in many places. Extjs is not suitable for large projects. It can be used only after a trial. Lightweight and heavyweight advantages and disadvantages, please consider it yourself.
I also hope that experts can share their experiences and experience to benefit me. However, you are not welcome to follow the post to discuss the issue. Objective evaluation.
Thank you.