Talk:Hello World (AspectJ)

From LiteratePrograms

Jump to: navigation, search

(Editor's note... the whole point of this exercise is that you should be able to click 'download code' and get a working copy of the source code. But you can't :(. I'm sure it's something to do with the file extension syntax, >>+= which doesn't seem to work as documented. It doesn't work with the Factorials with prime factorization (Python) example either. I played around trying to fix it but the error messages weren't much use and after fiddling around for too long I gave up. Maybe it's a bug, or maybe my markup is wrong. if anyone can edit this page and fix it, I'd be grateful.

Sander 11:08, 3 March 2006 (PST): I changed the structure of the article so each piece is included once using >>=


For others who didn't spot my note in the public forum, note that this was resolved - it turned out that the documentation I wrote was mistaken and you really just need to use ">>=", not ">>+=". Deco 11:55, 3 March 2006 (PST)

I think its slightly better literate programming style if chunks are semantically complete. To this end I changed the code blocks

<<aspect>>=
public aspect HelloFromAspectJ {
:
<<close>>=
}
:
<<HelloFromAspectJ.aj>>=
aspect
pointcut
advice
close

to:

<<aspect>>=
public aspect HelloFromAspectJ {
  pointcut
  advice
}
:
<<HelloFromAspectJ.aj>>=
aspect

This avoids the hanging bracket problem that plagues mixed markup/programming languages like JSP and PHP.

In fact, having made this change, the last chunk

<<HelloFromAspectJ.aj>>=
aspect

is itself rather redundant, and you could express the whole aspect simply as:

<<HelloFromAspectJ.aj>>=
public aspect HelloFromAspectJ {
  pointcut
  advice
}

However, feel free to roll-back my edits if you don't agree!

Cpjobling 15:57, 8 February 2007 (PST)


I assume that the copyright notice is not embedded into the AspectJ code because the code generator doesn't recognise language="aj" and doesn't want to guess what commenting conventions would be appropriate. A work around would be to use language="java" as for the other code chunks. Or am I completely wrong and is the copyright notice only embedded in the first file?

Cpjobling 16:04, 8 February 2007 (PST)

The .aj extension was missing from the list of recognised extensions. I added it and now the copyright notice shows up using The /* ... */ format. Ahy1 16:26, 8 February 2007 (PST)
Personal tools