views:

365

answers:

8

Before the introduction of annotations in Java, how was the same functionality achieved?

Such a huge portion of what I do every day in Java involves annotations that I can't imagine what it would be like to program without them.

What would be an alternative way of achieving the same functionality without annotations?

+6  A: 

Alex, I would take XML for $400.

Alexander Pogrebnyak
@Peter: I think he is referring to Jeopardy
Shervin
the famous gameshow Jeopardy? I for one think it a creative answer and it deserves an upvote just for humor. :)
Chris Aldrich
@Shervin: Correct. You now have control of the board. ;)
R. Bemrose
+3  A: 

By writing a lot of xml configuration files.

gedim
+2  A: 

I don't know what you mean; I don't use annotations, but here I am still alive as ever.

jonescb
You're actually undead, you just don't realize it.
Michael Borgwardt
I don't use annotations, I don't use XML (except for XHTML). I also avoid Ant and Maven.
Thomas Mueller
+5  A: 

They where two techniques:

  • One was to use XML configuration files, related to your Java classes (an example is JPA XML configuration files).
  • In some cases, where your just needed a marker on a class, marker interfaces where used. Is consists in having an interface with no methods, and you can check at runtime if a given object implements this interface. One pretty common sample is Serializable.
Vivien Barousse
+2  A: 

Other ways (beside XML config files--which probably also includes use of Spring) would be lots of properties files.

Chris Aldrich
+3  A: 
  • XDoclet - basically a code generator that takes information from the Java source code and custom javadoc tags.
  • Marker interfaces like Serializable
  • Naming conventions (test methods in JUnit)
  • And yes, lots of XML config files. Be very glad you haven't had to live with those.
Michael Borgwardt
A: 

They are very nice features but they are creating more confusion for me as I used to define them in comments e.g. @author, @return, and @deprecated etc. I skip most of the comments and therefore, It creates more confusion rather than a convenience for me.

Ibrahim
Annotations and Javadoc tags are two totally different things even though they look similar. A good editor should use syntax highlighting to make them look clearly different.
Michael Borgwardt
I know they are different and coloring them might work for some people, but I also do programming in Perl and my eyes are trained for symbols like @, $, and %. It is because of this @ that ignore some important piece of code.
Ibrahim
+2  A: 
  • Properties file.
  • XML configurations
  • Text-based custom files.
  • Interface class file with many constant fields....
The Elite Gentleman