Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

So, I work at a company that uses Java for all its server-side technology (~2 million lines today), but we don't use annotations for code-gen. Can someone explain to me why I would want to do that instead of a hypothetical IDE feature/plugin?


Assuming you don't use annotations at all...

* DRY for cross-cutting concerns, like database transactions, logging, dependency injection, serialization, validation, web controllers/endpoints... basically, macros for Java.

* Less code means less chance for error - even if that code was generated at some point in the past, it will need to change in the future, and the future developer may do the change manually and might introduce mistakes. Using annotations can help enforce patterns.


We use annotations for some things, but they're either used at runtime for configuration or things like the lovely @Deprecated.


Another advantage of using annotations to generate code at compile time, is that any (simple) errors get detected at compile time instead of runtime. So, potentially less tests you need to write.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: