As long as you are willing to be serious and disciplined, Java can also become dynamic and flexible. The benefits of movement are the benefits of stillness. As the saying goes, there is nothing without rules, but life is precious and the price of love is higher. Freedom means both can be thrown away. So where should we go as citizens who are busy in the world of programming art? Go to the dynamic language camp or continue to fight in the stable Java field? In my opinion, there is a golden mean point to move or not to move
Looking for the golden point between movement and immobility
Two years ago, a group of masters represented by Martin Fowler suddenly collectively defected to the dynamic language camp, holding the nuclear weapon RoR and shouting for destruction. To replace Java, looking back now, dynamic language has indeed brought us some revolutionary ideas, but at the same time, we also found that we were fooled by the masters
For the strongly typed Java language Compared with a real dynamic language, it is indeed much more restricted. In my opinion, to borrow the metaphor of a certain master, Ruby's agility is quite cursive, while Java is block letters. The programs written by ten programmers in Ruby have ten styles. This is related to our article. It's the same, and Java is a well-formed, Song-style square character. Which stroke should be written first, which stroke should be written horizontally or vertically? Everything is stipulated. A strongly typed static language has established a relatively stable set of rules from the bottom of the grammar. The rule system is therefore more standardized. In the long run, or for large projects, there must be regulations and strict regulations, which are much better in terms of scalability and maintainability than those with loose regulations.
Dynamic languages ??and strongly typed static languages ??each have their own specialties. In the field of enterprise-level applications, the advantages of JavaEE are not established in a day or two. In fact, dynamic languages ??have been around for a long time and are the best. I think it should be JavaScript. Think about it, I used asp in the past. JS is used to write program server and client scripts. It is really comfortable for small applications. In the past two years, due to the popularity of Ajax concept stocks, JavaScript has become more popular. A batch of Ajax frameworks and engines such as prototype JS have combined the OO and JavaScript of JavaScript. Taking full advantage of dynamic characteristics. For the fierce RoR, in my opinion, it is best to compete with similar competitors such as php and Python for a few years. If they are not destroyed by them, then study how many light years it will take to destroy them. A proposition like java
For small-scale applications, small, flexible and simple dynamic languages ??will definitely have certain advantages in getting ahead, but for large-scale enterprise-level applications, dynamic languages This kind of cleverness and arbitrariness happens to be its disadvantage. The reason is that in addition to its limited capabilities (multi-core thread system resources, etc.), it is too sloppy and is also the reason that limits its development. Facts have proved that dynamic languages ??can do what we static languages ????use our brains a little. It can be done with some adjustments, such as Groovy; while dynamic languages ??cannot do what static languages ??can do, unless it becomes a static strongly typed language, such as multi-core threaded two-stage distributed transactions. If it can be done, it may not only be It is a dynamic language
There are advantages to movement and there are benefits to stillness. As the saying goes, there is no circle without rules. But life is precious and love is more valuable. If you are free, you can throw away both. Then as a busy person, Where should we go, people in the world of programming art? Should we go to the dynamic language camp or continue to fight in the stable Java field?
In my opinion, there needs to be a golden section to move or not, and the reason why EasyJWeb To provide support for some dynamic features is to find such a dividing point, analyze and weigh the benefits of dynamic and static, and then let JavaEE application development
It has become easier to work hard to find such a golden section to provide application-level support for some very good dynamic features and ideas, while insisting on promoting applications for some features that must be standardized to be efficient. Many people in the Java community are looking for it. Java itself has been aware of this and has added support for some excellent dynamic language features in its new version
Of course, for those of us who have always felt restricted, It is a very happy thing to be able to do some cursing when you want to do it. Therefore, EasyJWeb has done some work based on Java, a standardized platform and environment, so that we can also do it within a certain range. Move flexibly and grass casually so that we can let go of our hands and move forward easily and boldly. Below I will illustrate with some examples
Variety of CmdAction AbstractCmdAction
New in EasyJWeb The Action base class of the Command type, namely AbstractCmdAction, provides enough flexibility so that you can write Java Web Action like Tantric Boxing. You can write the mand in Action like using a dynamic language according to your different application scenarios.
If we want to perform a create operation in a module, the following method signatures are legal
? public?Page?doCreate(WebForm?form Module?module) public?Page? doCreate(WebForm?form) public?Page?doCreate(Module?module) public?Page?doCreate(); public?void?doCreate(WebForm?form Module?module) public?void?doCreate(WebForm?form) public?void ?doCreate(Module?module) public?void?doCreate();
In addition, the system can also recognize the method name if it is changed to create.
? public?Page?create(WebForm ?form Module?module) public?Page?create(WebForm?form) public?Page?create(Module?module) public?Page?create(); public?void?create(WebForm?form Module?module) public?void ?create(WebForm?form) public?void?create(Module?module) public?void?create();
We can use xxx ejf?easyJWebCommand=create to call this method or use xxx ejf?cmd=create. We can even call it in the form of /ejf/xxx/create
This flexible naming method in Action can make the code more concise and easier to maintain. It also makes our code look cooler. Another main reason is that it makes it very easy for us to write the test code for these methods. We can run the EasyJWeb unit without any web container.
Test
Look at Struts where every method must be mechanically generated to generate the following method
public?ActionForward?mand(ActionMapping?mapping?ActionForm?form?HttpServletRequest?request?HttpServletResponse ?response)? {…}
Comparing the ever-changing Command method signatures provided in EasyJWeb, do you feel that the world is moving forward?
More dynamic areas
If you want to move, just move. It is not only reflected in the way the method is written. This dynamic feature is used in many places in EasyJWeb. For example, the multiple calling methods provided by the forward and go methods verify tags with natural language as the main body. Dynamic parameter configuration information reflects the dynamic characteristics of EasyJWeb
Taking verification as an example, we can tell EasyJWeb that we need to verify in many ways. For example, I can target one or more attributes in @FormPO See examples for specifying validation rules
@FormPO(name= person validators= {@Validator(name= required field= name sex heigth borndate) @Validator(name= range field= borndate value= min:;max: )}) public?class?Person {…attributes and getter/setter methods}
You should have guessed that in the above tags, we specified the name, sex, height, borndate and other attributes of the Person object as required attributes for verification. In the RangeValidator of the data range, you don't have to worry about whether the target type to be verified is Integer, BigDecimal or Date. As long as it can be compared, you can apply the validator to verify its value range to ensure that our domain model gets a reasonable value. Value
When identifying verification, you can set custom verification prompt information. For example, you can use the following method to identify a range verification
@Validator(name= range field= borndate value = min: ; max: ; min_msg: The date of birth cannot be less than the year; max_msg: The date of birth cannot be greater than the year! ) lishixinzhi/Article/program/Java/hx/201311/25663