The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Annotations are great ! Really ?

http://jroller.com/page/agoncal?entry=annotations_are_great_really

Good post on the java endgame in metaprogramming.

<quote>
And there is no way that in 6/7 years we will end up coding this:

@Entity
@Name('componentName')
@Inheritance
@Scope(ScopeType.CONVERSATION)
@Logger('loggerName')
@TransactionAttribute(NEVER)
@Remote({examples.Animal.class})
@ExcludeDefaultInterceptors
@NamedQuery(name='findAllAnimals')

class Animal extends Creature (

@Id
@SequenceGenerator(name='ANIMAL_SEQ', allocationSize=25)
@GeneratedValue(strategy=SEQUENCE, generator='ANIM_SEQ')
@Column(name='ANIM_ID') private String id
@AssociationOverride
@Enumerated
private Owner owner

@Deprecated
@AroundInvoke
@Version
static void deprecatedMethod() (...)

@Override
@JoinTable
Hay getPreferredFood() (...)

@Intercept(InterceptionType.ALWAYS)
@Ignore
void intercepts (...)

@SuppressWarnings('deprecation')
@In(required=false)
@ExcludeClassInterceptors
@PreDestroy void useDeprecatedMethod() {...}
)

</quote>
son of parnas
Friday, July 21, 2006
 
 
Well, .NET has had attributes from the beginning, so there's almost six years, and, no, most .NET code doesn't look like that so Java should probably be safe.
SomeBody Send private email
Friday, July 21, 2006
 
 
And his example is very misleading.  A few lines of attributes/annotations don't look so bad taken in the context of full source code and not with big chunks of code replaced by "{...}".
SomeBody Send private email
Friday, July 21, 2006
 
 
If not abused they could be useful. I would like to see some Vault like features implemented with annotations.


Vault:

interface IO {
  type FILE;
  tracked($F) FILE open_read(string)  [ new $F @ readable ];
  tracked($F) FILE open_write(string) [ new $F @ writable ];
  char read (tracked($F) FILE)        [ $F @ readable ];
  void write (tracked($F) FILE, char) [ $F @ writable ];
  void close (tracked($F) FILE)      [ -$F @ _ ];
}


with Java annotations

interface IO {
  @after( assert($return instanceof FileInputStream) )
  InputStream open_read(String name);

  @after( assert($return instanceof FileOutputStream) )
  OutputStream open_write(String name);

  @before( assert($1 != null && $1 instanceof FileInputStream) )
  void write(InputStream f, char value);

  @before( assert($1 != null && $1 instanceof FileOutputStream) )
  char read(OutputStream f);

  @after( assert($1.isClosed() )
  void close(Stream f);
}
Dino Send private email
Tuesday, July 25, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz