1

私はJavaが初めてです。コードの再利用のために注釈とリフレクションを使用する方法を誰かが説明できますか? この技術を利用して、JDBC で CRUD 操作を実装する簡単なコンソール プログラムを作成したいと考えています。

4

1 に答える 1

3

If you are new to Java, you still have at least a couple thousand hours of coding (perhaps more) before you are experienced enough to write your own code that uses reflection paired with annotations to achieve code reuse (in a sane way). It is a very uncommon way of writing Java programs and - as such - it is mainly used in infrastructure code: libraries and frameworks. Even if some technology expects programmers to write their own annotations, (like in BVF or CDI), they are only used within the constraints of the framework.

There is little sense in writing annotation/reflection code before you have used many such libraries and have gathered enough experience as a user of such code. And when you do, you will not need to ask questions.

于 2013-06-21T21:26:11.797 に答える