![]() |
|
URL of the article:
IntelliJ IDEA 6.0
Demetra
Michael Hüttermann
JetBrains, the software forge, published version 6.0 of its software development environment, IntelliJ IDEA, at the beginning of October 2006 – code named: Demetra. The question is, “is it worth it to upgrade?” In October 2006 JetBrains published the last major release of its award-winning, commercial, integrated development environment. They’ve added countless new features, but if you’ve got 5.0, does an upgrade to 6.01 pay off? In the following I discuss their essential innovations. In the year 2000, JetBrains established its headquarters in Prague and its Research & Development center in St. Petersburg. With their products, especially IntelliJ IDEA, they built a very good reputation in the development world. Despite their big-league commercial competitors and free alternatives like Eclipse and NetBeans, IntelliJ IDEA won countless awards. For example, Germany’s JavaMagazin placed IDEA 5.0 second in the Reader’s Choice – Best Development Environment 2006 category (behind JBuilder), Java Developers Journal presented IntelliJ IDEA 5.0 with their "Editors’ Choice" Award 2006, as well as the Best Java IDE in their Reader’s Choice Awards. Is IntelliJ IDEA 6.0 also able to win awards? JetBrains added new functionality in many different areas and boosted some old ones. Let's have a look at the new version in detail. IntelliJ IDEA 6.0: Scope of innovations
IntelliJ’s first eye catcher is the further improved JavaScript support. The already existing services like code completion, error highlighting, refactorings, code formatting, find and highlight usages, code folding, goto and label support, and the helpful structure view have been further enhanced. New refactorings, quick fixes and smart completions on "detection patterns" have been implemented. These patterns are based on static declarations which recognize common models and make third party libraries testable. All people developing complex web applications for different target platforms (i.e. browsers) will appreciate the browser-specific code completion. It works wonders while working with different DOM derivates; icons are displayed beside the code to document the browser support of individual properties and methods in Internet Explorer, Mozilla, Opera and Safari (Illustration 1). Furthermore browser-specific warnings also exist: cross-browser-scripting made easy. ![]() Illustration 1: JavaScript support: Lookup on DOM, browser-specific A web developer will not only appreciate the JavaScript support; new code inspections and search & replace support now exist for HTML and XML as well. Also, CSS doesn’t miss out when it comes to inspections. The XML DocBook format is supported now, so whoever wants to create their documentation in this format can do it with IDEA. Overall, IDEA provides broad AJAX support, though some critics suggest that AJAX is simply old wine in new barrels. The inclined IDEA developer can get a picture of supported frameworks like Dojo, Bindows and Prototype as well as the new GWT-support quite easily. It also contains a runtime and debug environment as well as the renowned IDEA code assistance which is also available for embedded JavaScript. So what does it look like on the server? A clear signal benefiting the Struts framework has been the included support in IntelliJ 6.0. As soon as your web model is prepared for Struts development via the context menu, all the necessary artifacts are automatically downloaded from ibiblio.org. Every Maven 2 user knows that URL back to front, but it’s nice to have the IDE go out of the way to make life easier. The Struts assistance also contains features like Tiles, Validator and Struts-EL Taglibs, visual editing of the configuration, a properties inspector and the common and well-known IDEA features like context-sensitive refactorings, quick fixes and highlighting. Not least, with the new orientation to JSF (catchword: Shale) and the fusion with WebWorks, Struts has gone through the necessary trend-setting steps, and its future is further ensured with IntelliJ’s support. IDEA's support for JEE 5 with the Java enterprise components EJB, Servlet, JSP and JSF has been updated. Beside the EJB-specifications from version 1.1 on, EJB 3.0 is supported now, including full annotations support. In mixed mode, EJBs can be declared via annotations as well as with descriptors. While developing Entity Beans, Message-Driven Beans and Session Beans, extensive refactorings, quick fixes and inspections are available, which are all EJB-aware and can be used inside Java artifacts and deployment descriptors. A "Persistance Unit" can be understood as an abstraction of a DB schema. It can be generated out of a concrete DB schema quite simply: first, a data source has to be configured via Tools | Data Sources. Then, tables have to be mapped on the EJB module inside a dialog via Generate Persistence Mapping | By database schema. A persistence diagram can be created, and pressing F4 on a dedicated persistence unit is enough to do it. Furthermore, entities can be generated out of Hibernate and JDBC sources. Also very interesting and helpful is the migration support: IDEA 6 provides the functionality to migrate legacy EJBs to EJBs in version 3. Part of this is to move descriptors to annotations and transform and clean up classes and interfaces. It is also possible to transfer Entity Beans to CMP. To call the assistance, right click on the bean or on the whole EJB module, then select the menu item: Apply EJB 3.0 style. They’ve extended their application server support from the IntelliJ 5.0 base of Tomcat and Weblogic 8.x to integrated deployment and debugging with IDEA 6.0 on Weblogic 9.x, Websphere, JBoss, Geronimo, and Glassfish. Going above and beyond the mainstream support of JBoss and Websphere is quite remarkable, especially in the case of Geronimo and Glassfish, the latter of which has been growing more and more popular since it has been called "production stable" recently. JSF is now supported with version 1.1, and it’s not necessary to have a dedicated module is designated for the JSF development, since usage is detected automatically inside the web module. A module can be made "JSF-enabled", so that IDEA can download the necessary libraries from JetBrains sites. Dependent on the individual user preferences, the module is prepared for development according to JSF 1.0 or 1.1 as well as the JSF implementation RI or Apache MyFaces. Development itself, using a formular-based configuration editor for the faces-config.xml and including error highlighting and code completion, does not leave any wishes unfulfilled. Just in case you need them, the JSF navigation diagrams are on-hand and the page flow can be modeled graphically and transformed to code automatically. Invalid JSF navigation rules are criticized and can be fixed with a double-click, then optimized via the structure tabulator. Combination and integration are handled quite comfortably: JSF inside JSP pages with JSF EL support, JSF specific checks and even JBoss Seam support. The JSF support is very diversified and we can possibly expect even more in the future. JUnit 4 + Test CoverageCertainly, a highlight of this release is the JUnit 4 support linked with the code coverage functionality. IDEA 6.0 supports JUnit 4 completely, so test classes can be created with the help of annotations very conveniently. The example in illustration 2 shows how the framework is notified to test the method simpleAdd() by using the annotation @Test. This small case study is based on a simple inner class which contains a constructor, a getter, some exemplary business methods and overrides equals and hashCode. As shown in the snippet this way, object equality can be checked while using the method assertTrue. After adding JUnit to the classpath, a runtime configuration can be created via Run | Edit Configurations. Here the class being tested has to be declared, and configured - if the check should include test coverage. In this case, the unit test has run successfully, which can be monitored in the JUnit status area on the bottom of illustration 2. It is recommended to activate some JUnit inspections in the project settings. ![]() Illustration 2: JUnit 4 support and test coverage IntelliJ IDEA’s code coverage support is based on "Emma", the free framework, and the integration succeeded quite nicely: unit tests and tests for simple applications with a main method can be processed. The code coverage examination is done on-the-fly and does not need any class pre-scanning. Statistics are viewable under View | Show Code Coverage Information for classes or whole packages. In the left area of the gutter, a colored bar is displayed: a red bar means: no coverage, a yellow bar: partial coverage (e.g. because of if-branches where only a part of all possible paths through the program have been crossed) and a green bar: complete coverage. This is a nice enhancement for fans of test-driven development that does not use the complex TestNG (which will be supported in the future too). Enhanced Swing GUI DesignerIn IDEA 6.0, the GUI designer was enhanced so that during UI creation it’s possible to choose from a big palette of layout managers. Beside the standard Swing managers, a JGoodies layout manager (who really wants to miss out on FormLayout?) and their own JetBrains "GridLayoutManager" can be used. IDEA 6.0 is set on top of Java 5 so it is no surprise that Java 5 is a precondition for running the IDE. However, it is a bummer that the GroupLayout available with Java 6 is not usable. By pulling graphical Swing components onto the form work space, "grids" are built up automatically. Grid rows and columns can be moved by drag & drop or can be deleted easily. "Morphing" allows the conversion of components into new classes while keeping the properties unchanged. Single components can be embedded into others quickly (e.g. a JPanel or a JScrollPane). The distinction between the UI layout and the functionality itself is remarkable, including the support of nested forms (UI forms can be put into one another). All this can be done quickly, comfortably, and intuitively, via keyboard. ![]() Illustration 3: UI designer form und class: resolve the hard-wired string into a resource bundle. Choosing and assigning a listener. All people who’ve done manual internationalization (I18N) and localization (L10N) from scratch will really appreciate the IDEA support: from inside the UI designer, property keys can be created and managed directly and "Locales" can be switched on design time. The UI designer supports a multiplicity of new components like JToolBar or JProgressBar as well as new functionality like button groups and border types. Migration aid also deserves a mention here: both manually coded UIs and forms created by other UI designers can be imported. Therefore, the layout and component properties are captured in part or as a whole. The quality of your code is not left to chance while designing user interfaces. Inspections and quick fixes are available for many different scenarios: missing mnemonics, double mnemonics (you could of course develop your own button traversal), a radio button which does not belong to a group, a button group only containing one button, a component without a label and a scrollable component which is not placed inside a ScrollPane: all these "design flaws" are detected and solutions are offered. Further support includes the creation of listeners (hit CTRL | O on the selected component), fast navigation between forms and classes, as well as little tricks like the creation of a main() method to make a form executable. Illustration 3 shows an OK-Cancel dialog which was completely built with the UI designer. In the upper view the form is visible, in the lower one the generated class which is bound to the form. There, the bounded components and their types are transparent with icons on each line. Also, the names map to the settings inside the form. Currently a hard-wired string is released with the help of a resource bundle. Furthermore, a separate working step was included in this illustration which shows a choice of usable listeners. The general usage of UI designers is discussed very often, and it seems like while 50% of developers like them the other half never use them. At least for prototyping purposes, quick drafts with the designer are very useful. With the immense number of refactorings and assistants, the broad Swing component support, support for layout managers, and the form migration support, little is left to be desired – assuming your UI consists of standardized components conforming to the JavaBean specification. Skeptics who want to see the generated code themselves have the choice to mark single components to be excluded from automatic generation or guide its processing manually. Productivity and Editing FeaturesMany features were added, dedicated to further improving your productivity. For example, "Intention Actions" (assists which offer help by trying to predict the intention of the developer and provide possible next steps in his work), a lot of refactorings, and code analysis features including JavaDoc inspections with editor highlighting. Project-wide error highlighting: files with compilation errors are marked in the project and package window - i.e. packages, and the whole project are marked as flawed (with a wavy line under their names) if even one class inside the package/project contains an error. The settings dialog is browse-able: just insert a search token into the search field. IDEA 6.0 supports more compilers now e.g. the Eclipse compiler. The already monumental number of inspections (600) was further increased and can be extended by the developer individually using the structural search & replace template. Inspections can be scoped on single projects or parts of them. With the new navigation bar, a nice alternative to the traditional project view now exists. Also, JetBrains' extensions to type systems are dedicated to improve productivity. Extended Type System: quality improvement with @Nullable and @NotNull The java type system can be extended with the creation of new classes more or less. However, no compiler rules are changeable and no new compiling checks can be implemented. With Java 5, annotations are commonly used for code generation and specification of runtime behaviour. The early discovery of NullPointerExceptions with the help of JetBrains' annotations @NotNull and @Nullable is a scenario to improve quality while using annotations. Generally it is best practice to check on null but what happens if null is returned by a method which is not allowed to return null? Where we do not expect null to be returned? An Assert is not a perfect solution because an assertion error is only a bit better than an NPE. The annotations can validate if a method body returns null, even if someone changes the code later. It is directly documented, identifying if the method is allowed to return null or not at a glance. In this context the annotation is practical meta-information which documents, checks on runtime, and creates additional value. ![]() Illustration 4: Usages and support of @Nullable and @NotNull annotations Illustration 4 demonstrates the usage where, with the annotation @Nullable, the annotated method nullableMethod is used. The compiler now knows that an NPE can be thrown. Accordingly, a hint is given (via the tool bar and coloring) that the method call can produce an NPE. The second scenario which is illustrated is the usage of the @NotNull annotation. If the "@NotNull" annotated statement is evaluated to null on runtime an exception is thrown. This happens during the start of the class: the method splitName is called with the parameter null, which is forbidden according to the method's signature. A call delivers the following exception: com.intellij.rt.execution.application.AppMain com.huettermann.TestingNullable What has to be done to profit from these annotations? Since this feature is not a Java standard, it is delivered as part of the annotations.jar included in the redist-folder of IDEA's installation directory. The jar-file has to be added to the classpath and the compiler must be told to evaluate the annotations. JetBrains works actively on JSR 305 – the development of standard annotations. A further case study for the usage of annotations is the localization of strings: some hard-wired strings have to be localized, while others do not. In this context, IDEA provides two annotations: @Nls and @NonNls (NLS is taken from the Microsoft world and means "National Language Support"). You can configure it so that you have to localize all strings except those which are annotated with @NonNls. @Nls is the default assignment whose usage only fulfills documentation purposes. JSR 305: „Annotations for Software Defect Detection“ and JetBrains support
IDEA 6.0 contains integration with TeamCity. TeamCity is a new JetBrains product which was also released back in October. It can be connected to IDEA with the help of a plugin and is available out-of-the-box. It supports "Continuous Integration", effective build management, server-side code coverage and code analysis and a sexy delayed commit feature in order to avoid the dreaded "5 o'clock check-in". TeamCity is configurable via web interface and provides integration to common build systems, unit testing frameworks and version control systems. Furthermore, a Jabber integration is available with IDETalk. The instant messenger supports the exchange of messages from inside the IDE, a view on the activity state of other developers, user group management and searchable message histories. With a single click, a code pointer can be sent to peers. Code pointers are references on opened code snippets, a stacktrace or a diff. This is a big benefit because you bypass the central repository while synchronizing with peers (no "updates" are needed for this anymore). Also, the quality of the supported version control systems was improved. Countless improvements for Visual SourceSafe, StarTeam and Subversion are included in the release. As a further benefit for team collaboration: run configurations can be stored in a project file and can be distributed. ConclusionWith IntelliJ IDEA 6.0, JetBrains again present a release full of new and usable functionality. The extensions strengthen core competences like in the context of the UI designer or with annotations. Existing functionality is updated to remain state-of-the-art, as happened with application server support and the EE features. JetBrains started up in the whole software life-cycle beginning with UI design over localization to a broad support of agile development through refactorings and documentations in DocBook format. With JUnit 4 and the validating of test coverage there is a charming support of test-driven development available. Even if IDEA comes along with all the features needed for most projects, right out-of-the-box JetBrains is focusing more and more on an Open API. Plugin developers are now able to extend the static code analysis while coding global inspections themselves. Also, support for injected languages is possible (e.g. embedding SQL into Java sources). The work on DSL (domain specific language) is an enduring topic for JetBrains. Over 300 plugins are available, some with moderate quality, while others are promoted and recommended as Companion Plugins. Using the plugin manager, plugins can be installed and uninstalled easily. JetBrains tries to keep close to the end-user in order to catch their needs and wishes and to detect room for improvement. If IDEA startup time is sub-optimal, try increasing the size of the heap in the file bin/idea.exe.vmoptions. A new IDEA 6.0 Commercial license costs . It is a "Per Concurrent User" license and can be used on different machines concurrently while being active on one. An upgrade to 6.0 costs . At the moment of writing this article, the last update version of IDEA was 6.0.5 which brings new minor features, bug fixes and performance optimizations. The author helped improve IDEA directly by using it excessively and actively working in the JetBrains bug tracking system. Errors are directly sent to JetBrains online and filed to the IDEA bug tracking database. Altogether the release makes a very good and stable impression and the support is good. Some people may search for support for Groovy, AOP, Velocity, Hibernate and Spring in vain. Some of these frameworks, concepts and languages are planned for 7.0. IntelliJ IDEA is definitely a pleasure to work with for its fans and it makes a critic’s job quite challenging, given the strength of the tool. I want to finish this review with the answer of Sun Java Champion, Dr. Heinz Kabutz to my question about his favourite IDE for working productively: "My favourite is IDEA. But more or less it is unimportant which IDE you use, you only have to do it right." Sun Java Champion Michael Hüttermann is a self-employed consultant, developer, architect and coach on Java/JEE and agile development. He is a tutor with his own seminars, writes articles in magazines continuously and is currently finishing his book „Agile Development with Java“ which will be published by O'Reilly. Michael is the founder and leader of the Java User Group Cologne and one of three JUG Community Leaders worldwide. You can reach him at michael@huettermann.net. |
||
|