Java webapplication - properties file nightmare - java

I recently started working on a POORLY designed and developed web application.. I am finding that it uses about 300 properties files, and all the properties files are being read somewhat like this:
Properties prop= new Properties();
FileInputStream fisSubsSysten = new FileInputStream("whatever.properties");
prop.load(fisSubsSysten);
That is, it is reading the properties files from current working directory.. Another problem is the developers have chosen to use the above lines multiple times within the same java file. For example if there are 10 methods, each method will have the above code instead of having one method and calling it wherever necessary..
This means, we can NEVER change the location of the properties files, currently they are directly under the websphere profiles directory, isn't this ugly? If I move them somewhere else, and set that location in classpath, it does not work.
I tried changing the above lines like this using Spring IO utils library:
Resource resource = new ClassPathResource("whatever.properties");
Properties prop = PropertiesLoaderUtils.loadProperties(resource);
But this application has over 1000 files, and I am finding it impossible to change each file.. How would you go about refactoring this mess? Is there any easy way around?
Thanks!

In these cases of "refactoring" i use a simple find and replace approach. Notepad++ has a " find in files" feature but there are plenty of similar programs.
Create a class which does the properties loading with a method probably with a name parameter for the property file.
This can be a java singleton or a spring bean.
Search and replace all "new Properties()" lines with an empty line.
Replace all "load..." lines with a reference to your new class/ method. Notepad++ supports regex replacement, so you can use the filename as a parameter.
Once this is done go to eclipse and launch a "cleanup" or "organize imports" and fix some compile errors manually if needed.
This approach is quite straight forward and takes no more than 10min if you are lucky or 1 hour if you are unlucky, f.e. the code formatting is way of and each file looks different.
You can make your replace simpler if you format the project once before with a line length of 300 or more so each java statement is on one line. This makes find and replace a bit easier as you dont have newlines to consider.

I can only agree that I find your project a bit daunting, from your reference.
However, the choice of how to maintain or improve of it is a risk that merely needs to be assessed and prioritised.
Consider building a highrise and subsequently realising the bolts that holds the infrastructure have a design flaw. The prospect of replacing them all is indeed daunting as well, so considerations into how to change them and if they really, really needs to be replaced, few, many or all.
I assume it must be a core system for the company, which somebody built and they have probably left the project (?), and you have consideration about improvement or maintaining them. But again, you must assess whether it really is important to move your property files, or if you can just for instance use symbolic links in your file system. Alternatively, do you really need to move them all or is there just a few that would really benefit from being moved. Can you just mark all places in the code with a marker to-be-fixed-later. I sometimes mark bad classes with deprecation, and promise to fix affected classes but postpone until I have other changes in those classes until finally the deprecated class can be safely removed.
Anyway you should assess your options, leave files, replace all or partials, and provide some estimation of cost and consequences, and ask your manager which course to take.
Just note that always overestimate the solution you don't want to do, as you would be twice as likely to stop for coffee breaks, and a billboard of told-you-so's is a great leverage for decision making :)
On the technology side of your question, regex search and replace is probably the only option. I would normally put configuration files in a place accessible by classpath.

You can try using eclipse search feature. For example if you right click on load() method of the properties class and select References -> Project it will give you all location in your project where that method is used.
Also from there maybe you can attempt a global regex search and replace.

Related

Java Annotation processor check for full rebuild

I am creating an Annotation Processor in Java and I want to be able to check if the user triggers a full rebuild.
I want to be able distingush between a full rebuild and just building a few files.
Is this possible? Or are there any workarounds for this?
Edit1:
I am going to explain what I want to achieve. I have an annotation processor and 10 annotations. 8 of these Annotations generate a config file called plugin.yml. 3 of these annotations (one annotation is used in both processes) are used to generate a sourcefile called AutoRegister.java. This works like a charm when I trigger a full rebuild and all my annotations get processed. Now the problem arises when I only compile, lets say 3 of the 15 classes using my annotations. Then the plugin.yml and the AutoRegister.java get generated based on the Annotations of the 3 files, thus beeing incomplete.
My workaround is to create a cache file, which contains information about all the other classes, which need to be insertet to the two files plugin.yml and AutoRegister.java. This somewhat works but makes it impossible to remove data from the cache, for example when I remove an annotation from a class. So the only way to remove data from the cache is to remove the cache file and to trigger a full rebuild.
I don't think the term 'workaround' means what you think it means. If there was a way to distinguish, that would just be 'the answer', not 'the workaround'. If you elaborate on WHY you need this, perhaps a different solution is available, that is NOT directly detecting 'full rebuild' versus 'incremental build', which nevertheless is sufficient for your needs. That'd be a workaround, but you'd have to explain why you need it in order for us to try to help you out.
Here's the most common reason I can think of for why you need this:
Let's say your AP will scan all source files, and distill some sort of list from it. For example, all classes that implement com.derteufelqwe.MyAwesomeInterface. Then, it writes this list someplace. Say, META-INF/services/com.derteufelqwe.MyAwesomeInterface. The problem is: During incremental builds, you only see a subset of all sources, therefore the list is incomplete, then you write it where ever it needs to be written and now you have a broken list (as it is incomplete).
The fix for this is that you can ask the Filer for a source file or class file; even if it is not part of the compilation run it is still on the source path or class path and you get a result. Thus, IF you can read the existing list, and you can extract, per entry, the source or class file that is responsible for it (which in our hypothetical case where you are creating a services file, is trivial: The very entry is itself a fully qualified class name you can ask the Filer to find) you can then query the filer if that resource is still around. If yes, keep it, if not, delete it. Now you can update (instead of regenenerate and replace) your list.

Is it possible to add custom metadata to .class files?

We have used liquibase at our company for a while, and we've had a continuous integration environment set up for the database migrations that would break a job when a patch had an error.
An interesting "feature" of that CI environment is that the breakage had a "likely culprit", because all patches need to have an "author", and the error message shows the author name.
If you don't know what liquibase is, that's ok, its not the point.
The point is: having a person name attached to a error is really good to the software development proccess: problems get addressed way faster.
So I was thinking: Is that possible for Java stacktraces?
Could we possibly had a stacktrace with peoples names along with line numbers like the one below?
java.lang.NullPointerException
at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372:john)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121:mike)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232:bob)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173:bob)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87:bob)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862:john)
That kind of information would have to be pulled out from a SCM system (like performing "svn blame" for each source file).
Now, forget about trashing the compilation time for a minute: Would that be even possible?
To add metadata to class files like that?
In principle you can add custom information to .class files (there's and attribute section where you can add stuff). You will have to write your own compiler/compiler extension to do so. There is no way to add something to your source code that then will show up in the class file.
You will also have major problems in practice:
The way stack-traces a built/printed is not aware of anything you add to the class file. So if you want this stuff printed like you show above, you have to hack some core JDK classes.
How much detail do you want? The last person who committed any change to a given file? That's not precise enough in practice, unless files are owned by a single developer.
Adding "last-committed-by" information at a finer granularity, say per method, or even worse, per line will quickly bloat your class file (and class files are limited in size to 64K)
As a side note, whether or not blaming people for bugs helps getting bugs fixed faster strongly depends on the culture of the development organization. Make sure you work in one where this helps before you spend a lot of time developing something like this.
Normally such feature can be implemented on top of the version control system. You need to know revision of your file in your version control system, then you can call blame/annotate command to get information on who has changed each individual line. You don't need to store this info into the class file, as long as you can identify revision of each class you deploy (e.g. you only deploy certain tag or label).
If you don't want to go into the version control when investigating stack trace, you could store line annotation info into the class file, e.g. using class post processor during your build that can add a custom annotation at the class level (this is relatively trivial to implement using ASM). Then logger that prints stack trace could read this annotation at runtime, similarly to showing jar versions.
One way to add add custom information to your class files using annotations in the source code. I don't know how you would put that information reliably in the stack trace, but you could create a tool to retrieve it.
As #theglauber correctly pointed out , you can use annotations to add custom metadata. Althougth i am not really sure you if you cant retrieve that information from your database implementing beans and decorating your custom exceptions manager.

How to find all initializations of instance variables in a Java package?

I'm in the midst of converting a legacy app to Spring. As part of the transition, we're converting our service classes from an "instantiate new ones whenever you need one" style to a Springleton style, so I need a way to make sure they don't have any state.
I'm comfortable on the *nix command-line, and I have access to IntelliJ (this strikes me as a good fit for Structural Search and Replace, if I could figure out how to use it), and I could track down an Eclipse install, if that would help. I just want to make absolutely sure I've found all the possible problems.
UPDATE: Sorry for the confusion. I don't have a problem finding places where the old constructor was being called. What I'm looking for is a "bullet-proof" why to search all 100+ service classes for any sort of internal state. The most obvious one I could think of (and the only one I've really found so far) is cases where we use memoization in the classes, so they have instance variables that get initialized internally instead of via Spring. This means that when the same Springleton gets used for different requests, data can leak between them.
Thanks.
In Eclipse you can just right click on a variable/type and there is an option for References (or Declarations) -> (Workspace / Project / Hierarchy) which can help you find all instances of it neatly.
I would suggest using Eclipse's built in refactoring tool, it will do its best to change every instance associated to the class accordingly. I would go a step further and rename the class of that you want to change so, at worst case, a full compile would fail and you can easily fix any of those issues.

Is there a way to get all the classes that implement a certain method?

The title speaks for itself. The language is Java.
Yes, there is. This is however a tedious and expensive work. You need to crawl through all class files and all JAR files with help of ClassLoader#getResources() and a shot of java.io.File and load all classes of it with help of Class#forName() and finally check if the method is there by Class#getMethod().
However, there are 3rd party API's which can take the tedious work from hands, but it is still expensive, because loading a class would cause its static initializers being executed.
A cleaner way is to make use of annotations and annotate the methods in question and then make use of libraries which searches for classes/methods/fields based on the annotations, such as Google Reflections.
On the other hand, if the entire package name or the JAR file name is known beforehand, then the work will be less tedious and expensive (no need to do stuff recursively nor to load the all of the classes of entire classpath).
Update: I remember, I ever wrote sample code to achieve something like that, you can find it here. It's good to start with, you only need to change it a bit to check the method.
No, you can't, in general. If you could get a complete list of available classes you could check each of them using reflection - but you can't ask a classloader for a list of everything that's available. (For instance, it may be fetching classes over HTTP, and may not know all the files available.)
If you knew that you were interested in classes in a jar file, however, you could open the jar file, find all the class files within it and ask the classloader for those classes. It would be somewhat fiddly.
What's the bigger picture here? There may be a better way to approach the problem.
Also, in Eclipse, you can simply ask for this :
Clic on the method, and type Ctrl-T.

Things possible in IntelliJ that aren't possible in Eclipse?

Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
I have heard from people who have switched either way and who swear by the one or the other.
Being a huge Eclipse fan but having not had the time to try out IntelliJ, I am interested in hearing from IntelliJ users who are "ex-Eclipsians" some specific things that you can do with IntelliJ that you can not do with Eclipse.
Note: This is not a subjective question nor at all meant to turn into an IDE holy war. Please downvote any flamebait answers.
CTRL-click works anywhere
CTRL-click that brings you to where clicked object is defined works everywhere - not only in Java classes and variables in Java code, but in Spring configuration (you can click on class name, or property, or bean name), in Hibernate (you can click on property name or class, or included resource), you can navigate within one click from Java class to where it is used as Spring or Hibernate bean; clicking on included JSP or JSTL tag also works, ctrl-click on JavaScript variable or function brings you to the place it is defined or shows a menu if there are more than one place, including other .js files and JS code in HTML or JSP files.
Autocomplete for many languagues
Hibernate
Autocomplete in HSQL expressions, in Hibernate configuration (including class, property and DB column names), in Spring configuration
<property name="propName" ref="<hit CTRL-SPACE>"
and it will show you list of those beans which you can inject into that property.
Java
Very smart autocomplete in Java code:
interface Person {
String getName();
String getAddress();
int getAge();
}
//---
Person p;
String name = p.<CTRL-SHIFT-SPACE>
and it shows you ONLY getName(), getAddress() and toString() (only they are compatible by type) and getName() is first in the list because it has more relevant name. Latest version 8 which is still in EAP has even more smart autocomplete.
interface Country{
}
interface Address {
String getStreetAddress();
String getZipCode();
Country getCountry();
}
interface Person {
String getName();
Address getAddress();
int getAge();
}
//---
Person p;
Country c = p.<CTRL-SHIFT-SPACE>
and it will silently autocomplete it to
Country c = p.getAddress().getCountry();
Javascript
Smart autocomplete in JavaScript.
function Person(name,address) {
this.getName = function() { return name };
this.getAddress = function() { return address };
}
Person.prototype.hello = function() {
return "I'm " + this.getName() + " from " + this.get<CTRL-SPACE>;
}
and it shows ONLY getName() and getAddress(), no matter how may get* methods you have in other JS objects in your project, and ctrl-click on this.getName() brings you to where this one is defined, even if there are some other getName() functions in your project.
HTML
Did I mention autocomplete and ctrl-clicking in paths to files, like <script src="", <img src="", etc?
Autocomplete in HTML tag attributes. Autocomplete in style attribute of HTML tags, both attribute names and values. Autocomplete in class attributes as well.
Type <div class="<CTRL-SPACE> and it will show you list of CSS classes defined in your project. Pick one, ctrl-click on it and you will be redirected to where it is defined.
Easy own language higlighting
Latest version has language injection, so you can declare that you custom JSTL tag usually contains JavaScript and it will highlight JavaScript inside it.
<ui:obfuscateJavaScript>function something(){...}</ui:obfuscateJavaScript>
Indexed search across all project.
You can use Find Usages of any Java class or method and it will find where it is used including not only Java classes but Hibernate, Spring, JSP and other places. Rename Method refactoring renames method not only in Java classes but anywhere including comments (it can not be sure if string in comments is really method name so it will ask). And it will find only your method even if there are methods of another class with same name.
Good source control integration (does SVN support changelists? IDEA support them for every source control), ability to create a patch with your changes so you can send your changes to other team member without committing them.
Improved debugger
When I look at HashMap in debugger's watch window, I see logical view - keys and values, last time I did it in Eclipse it was showing entries with hash and next fields - I'm not really debugging HashMap, I just want to look at it contents.
Spring & Hibernate configuration validation
It validates Spring and Hibernate configuration right when you edit it, so I do not need to restart server to know that I misspelled class name, or added constructor parameter so my Spring cfg is invalid.
Last time I tried, I could not run Eclipse on Windows XP x64.
and it will suggest you person.name or person.address.
Ctrl-click on person.name and it will navigate you to getName() method of Person class.
Type Pattern.compile(""); put \\ there, hit CTRL-SPACE and see helpful hint about what you can put into your regular expression. You can also use language injection here - define your own method that takes string parameter, declare in IntelliLang options dialog that your parameter is regular expression - and it will give you autocomplete there as well. Needless to say it highlights incorrect regular expressions.
Other features
There are few features which I'm not sure are present in Eclipse or not. But at least each member of our team who uses Eclipse, also uses some merging tool to merge local changes with changes from source control, usually WinMerge. I never need it - merging in IDEA is enough for me. By 3 clicks I can see list of file versions in source control, by 3 more clicks I can compare previous versions, or previous and current one and possibly merge.
It allows to to specify that I need all .jars inside WEB-INF\lib folder, without picking each file separately, so when someone commits new .jar into that folder it picks it up automatically.
Mentioned above is probably 10% of what it does. I do not use Maven, Flex, Swing, EJB and a lot of other stuff, so I can not tell how it helps with them. But it does.
There is only one reason I use intellij and not eclipse: Usability
Whether it is debugging, refactoring, auto-completion.. Intellij is much easier to use with consistent key bindings, options available where you look for them etc. Feature-wise, it will be tough for intellij to catch up with Eclipse, as the latter has much more plugins available that intellij, and is easily extensible.
Probably is not a matter of what can/can't be done, but how.
For instance both have editor surrounded with dock panels for project, classpath, output, structure etc. But in Idea when I start to type all these collapse automatically let me focus on the code it self; In eclipse all these panels keep open leaving my editor area very reduced, about 1/5 of the total viewable area. So I have to grab the mouse and click to minimize in those panels. Doing this all day long is a very frustrating experience in eclipse.
The exact opposite thing happens with the view output window. In Idea running a program brings the output window/panel to see the output of the program even if it was perviously minimized. In eclipse I have to grab my mouse again and look for the output tab and click it to view my program output, because the output window/panel is just another one, like all the rest of the windows, but in Idea it is treated in a special way: "If the user want to run his program, is very likely he wants to see the output of that program!" It seems so natural when I write it, but eclipse fails in this basic user interface concept.
Probably there's a shortcut for this in eclipse ( autohide output window while editing and autoshow it when running the program ) , but as some other tens of features the shortcut must be hunted in forums, online help etc while in Idea is a little bit more "natural".
This can be repeated for almost all the features both have, autocomplete, word wrap, quick documentation view, everything. I think the user experience is far more pleasant in Idea than in eclipse. Then the motto comes true "Develop with pleasure"
Eclipse handles faster larger projects ( +300 jars and +4000 classes ) and I think IntelliJ Idea 8 is working on this.
All this of course is subjective. How can we measure user experience?
Idea 8.0 has the lovely ctrl+shift+space x 2 that does the following autocomplete:
City city = customer.<ctrl-shift-space twice>
resolves to
City city = customer.getAddress().getCity();
through any number of levels of getters/setters.
Don't forget "compare with clipboard".
Something that I use all the time in IntelliJ and which has no equivalent in Eclipse.
My favorite shortcut in IntelliJ that has no equivalent in Eclipse (that I've found) is called 'Go to symbol'. CTRL-ALT-SHIFT-N lets you start typing and glob up classes, method names, variable names, etc, from the entire project.
I tried to switch to IntelliJ because of the new Android Studio. But I'm very disappointed now. I'm using Eclipse with the Code Recommanders Plugin. Here is a simple example why Eclipse is so awesome:
I want to create a new SimpleTimeZone. SimpleTimeZone has no Constructor with zero arguments.
Ctrl + Space in Eclipse
Ctrl + Space in IntelliJ
In IntelliJ I get no informations what kind of constructors SimpleTimeZone has.
After Enter in Eclipse
I get the previously selected constructor filled with predefined variable names. And I can see the type of every argument. With Code Recommanders Eclipse guesses the right constructor by the previously defined variable types in the current scope and fills the constructor with these vars.
After Enter in IntelliJ nothing happens. I get an empty constructor. I have to press Ctrl + P to see the expected arguments.
If you have the cursor on a method then CTRL+SHIFT+I will popup the method implementation. If the method is an interface method, then you can use up- and down- arrows to cycle through the implementations:
Map<String, Integer> m = ...
m.contains|Key("Wibble");
Where | is (for example) where your cursor is.
IntelliJ has some pretty advanced code inspections (comparable but different to FindBugs).
Although I seriously miss a FindBugs plugin when using IntelliJ (The Eclipse/FindBugs integration is pretty cool).
Here is an official list of CodeInspections supported by IntelliJ
EDIT: Finally, there is a findbugs-plugin for IntelliJ. It is still a bit beta but the combination of Code Inspections and FindBugs is just awesome!
Far, far, far more refactorings.
One thing I use regularly is setting a breakpoint, but then controlling what it does. (At my last job, most everyone else used Eclipse... I remember being surprised that no one could find how to do this in Eclipse.)
For example, can have the breakpoint not actually stop, but just log a message to the console. Which means, I don't have to litter my code with "System.out.println(...)" and then recompile.
There are many things that idea solves in a much simpler way, or there's no equivalent:
Autocomplete actions: Doing ctrl+shift+a you can call any idea action from the keyboard without remembering its key combination... Think about gnome-do or launchy in windows, and you've got the idea! Also, this feature supports CamelCasing abbreviations ;)
Shelf: Lets you keep easily some pieces of code apart, and then review them through the diff viewer.
Local history: It's far better managed, and simpler.
SVN annotations and history: simpler to inspect, and also you can easily see the history only for such a part of a whole source file.
Autocomplete everywhere, such as the evaluate expression and breakpoint condition windows.
Maven integration... much, much simpler, and well integrated.
Refactors much closer to the hand, such as loops insertion, wrapping/casting, renaming, and add variables.
Find much powerful and well organized. Even in big projects
Much stable to work with several branches of a big project at the same time (as a former bugfixer of 1.5Gb by branch sources, and the need to working in them simultaneously, idea shown its rock-solid capabilities)
Cleaner and simpler interface...
And, simpler to use only with the keyboard, letting apart the need of using the mouse for lots of simple taks, saving you time and giving you more focus on the code... where it matters!
And now, being opensource... the Idea user base will grow exponentially.
Structural search and replace.
For example, search for something like:
System.out.println($string$ + $expr$);
Where $string$ is a literal, and $expr$ is an expression of type my.package.and.Class, and then replace with:
$expr$.inspect($string$);
My timing may be a little off in terms of this thread, but I just had to respond.
I am a huge eclipse fan -- using it since it's first appearance. A friend told me then (10+ years ago) that it would be a player. He was right.
However! I have just started using IntelliJ and if you haven't seen or used changelists -- you are missing out on programming heaven.
The ability to track my changed files (on my development branch ala clearcase) was something I was looking for in a plugin for eclipse. Intellij tracks all of your changes for a single commit, extremely easy. You can isolate changed files with custom lists. I use that for configuration files that must be unique locally, but are constantly flagged when I sync or compare against the repository -- listing them under a changelist, I can monitor them, but neatly tuck them away so I can focus on the real additions I am making.
Also, there's a Commit Log plugin that outputs a text of all changes for those SCCS that aren't integrated with your bug tracking software. Pasting the log into a ticket's work history captures the files, their version, date/time, and the branch/tags. It's cool as hell.
All of this could be supported via plugins (or future enhancements) in eclipse, I wager; yet, Intellij makes this a breeze.
Finally, I am really excited about the mainstream love for this product -- the keystrokes, so it's painful, but fun.
The IntelliJ debugger has a very handy feature called "Evaluate Expression", that is by far better than eclipses pendant. It has full code-completion and i concider it to be generally "more useful".
Well, for me it's a thousand tiny things. Some of the macros, the GUI layout in general in Eclipse I find awful. I can't open multiple projects in different windows in Eclipse. I can open multiple projects, but then it's view based system swaps a bunch of things around on me when I switch files. IntelliJ's code inspections seem better. Its popup helpers to fix common issues is nice. Lots of simple usability things like the side bar where I can hover over a hot spot and it'll tell me every implementing subclass of a method or the method I'm implementing and from where.
Whenever I've had to use, or watch someone use, Eclipse it seems like they can do most of the things I can do in IntelliJ, but it takes them longer and it's clunkier.
Introduce variable. (Ctrl+Alt+V on Windows, Cmd+Alt+V on OSX)
Lets say you call a method, service.listAllPersons()
Hit Ctrl+Alt+V and Enter, and variable for return value from method call is inserted:
List<Person> list = service.listAllPersons();
Saves you typing, and you don't have to check the return type of the method you are calling. Especially useful when using generics, e.g.
new ArrayList<String>()
[introduce variable]
ArrayList<String> stringArrayList = new ArrayList<String>();
(of course you can easily change the name of the variable before hitting Enter)
IntelliJ has intellisense and refactoring support from code into jspx documents.
For me, it's IDEA's maven support, especially in version 9 is second to none. The on-the-fly synchronizing of the project to the maven model is just fantastic and makes development pleasant.
Intellij has a far superior SVN plug-in than either Subversive or Subclipse and it works! The amount of time we've wasted merging source files using Eclipse doesn't bear thinking about. This isn't an issue with IntelliJ because the plugin helps you much more.
Also the Subclipse plugin is unreliable - we regularly have instances where the plugin doesn't think there has been any code checked in to SVN by other developers, but there has - the CI server has processed them!
VIM Emulator. This plugin provides nearly complete vi/vim/gvim emulation while editing files in IDEA.
The following functionality is supported:
Motion keys
Deletion/Changing
Insert mode commands
Marks
Registers
VIM undo/redo
Visual mode commands
Some Ex commands
Some :set options
Full VIM regular expressions for search and search/replace
Macros
Diagraphs
Command line history
Search history
Jumplists
VIM help
some comments about this plugin from http://plugins.jetbrains.net/plugin/?id=164
I can't see ever going back to any other ide because of this plugin..
Best of both worlds... Awesome!.
that's what i was lacking in all IDEs.
One of the good points in my opinion is the Dependency Structure Matrix:
http://www.jetbrains.com/idea/features/dependency_analysis.html#link0
There's a good introduction to DSM usage and benefits in Lattix' website (a standalone product):
http://www.lattix.com/files/dl/slides/s.php?directory=4tour
A few other things:
propagate parameters/exceptions when
changing method signature, very
handy for updating methods deep
inside the call stack
SQL code validation in the strings passed as arguments to jdbc calls
(and the whole newly bundled
language injection stuff)
implemented in/overwritten in icons for interfaces & classes (and their methods) and
the smart implementation navigation
(Ctrl+Alt+Click or Ctrl+Alt+B)
linking between the EJB 2.1 interfaces and bean classes
(including refactoring support); old
one, but still immensely valuable
when working on older projects
Two things that IntelliJ does that Eclipse doesn't that are very valuable to me:
Method separators: those faint gray lines between methods make code much more readable
Text anti-aliasing: makes code look so nice in the IDE
One very useful feature is the ability to partially build a Maven reactor project so that only the parts you need are included.
To make this a little clearer, consider the case of a collection of WAR files with a lot of common resources (e.g. JavaScript, Spring config files etc) being shared between them using the overlay technique. If you are working on some web page (running in Jetty) and want to change some of the overlay code that is held in a separate module then you'd normally expect to have to stop Jetty, run the Maven build, start Jetty again and continue. This is the case with Eclipse and just about every other IDE I've worked with. Not so in IntelliJ. Using the project settings you can define which facet of which module you would like to be included in a background build. Consequently you end up with a process that appears seamless. You make a change to pretty much any code in the project and instantly it is available after you refresh the browser.
Very neat, and very fast.
I couldn't imagine coding a front end in something like YUI backing onto DWR/SpringMVC without it.
Preamble to my answer: My use of Eclipse is limited. We needed a Java IDE to work on both Windows and Mac and the Mac port slowed down day by day. This was years ago and I'm sure it's OK now. But that is what got us to switch to IntelliJ and we've been happy with it.
Now for my answer: One big difference I haven't seen mentioned yet is that tech support is better with IntelliJ/Jet Brains. We send an e-mail to JetBrains and get a definitive answer back in less than an hour. Looking for answers to Eclipse problems results in the usual, "You stupid idiot" answers (usually a small number of the replies) along with the much larger number of insightful, helpful replies. But it takes some sorting through to get the real answer.
Something which I use in IntelliJ all the time is refactoring as I type. I have re-written classes from a printout (originally written in eclipse) using both IDEs and I used about 40% less key strokes/mouse clicks to write the same classes in IntelliJ than eclipse.
I wouldn't want to use Eclipse until they support as much refactoring with incomplete pieces of code.
Here is a longer list of features in IntelliJ 8.0/8.1 [http://www.jetbrains.com/idea/features/index.html]
There is one thing that IntelliJ does much much better than Eclipse and that is empty your pockets!
I do however prefer using it and one big advantage it has over Eclipce is the way it synchronises with the file system, for big projects and slow computers (yes in work environments the PC's are a lot slower than our ones at home) Eclipse seems to struggle where IntelliJ seems to be quicker albeit with a slower initial indexing time.
IntelliJ Community edition obviously makes using it free but you soon want those extra refactoring and nice little goodies not included in the CC edition.
In my opinion, its generally a better user experience but whether its worth the cost is a question for each developer to answer themselves.
But lets be grateful we have up to three great IDEs for Java right now with NetBeans getting better all the time.
Data flow analysis : inter-procedural backward flow analysis and forward flow analysis, as described here. My experiences are based on Community Edition, which does data flow analysis fairly well. It has failed (refused to do anything) in few cases when code is very complex.
First of all I love intellij. There are at least a hundred features it has that eclipse lack. I'm talking magnitudes better in reliability and intelligence that no hyperbole can describe when it comes to refactoring, renaming, moving and others which have already been mentioned.
BUT, there is one thing that intellij does not allow which eclipse does. It does not allow running multiple projects at once under the same vm.
When you have separate projects for the front, middle, core, agents..etc, where they all have to interact with each other, you can not quickly modify and debug at the same time, afaik. The only way I current cope with this is to use ant scripts to deploy and update jars in dependent projects, or use maven.
Eclipse allows multiple projects to be debugged under one ide vm instance.

Categories

Resources