useful links - joekrom/demo GitHub Wiki

  • Annotation in java

Annotations can be used in classes, methods , fields/variables, they are used to add metadata(information) that inform your java
and that are checked and executed during compilation time.

  • Reflection in java

Reflection is an API which is used to examine or modify the behavior of methods, classes, interfaces at runtime.

  • The required classes for reflection are provided under java.lang.reflect package.
  • Reflection gives us information about the class to which an object belongs and also the methods of that class which can be executed by using the object.
  • Through reflection we can invoke methods at runtime irrespective of the access specifier used with them.
  • reference link: https://www.geeksforgeeks.org/reflection-in-java

Reflection can be used to get information about 👍

  1. Class The getClass() method is used to get the name of the class to which an object belongs.
  2. Constructors The getConstructors() method is used to get the public constructors of the class to which an object belongs.
  3. Methods The getMethods() method is used to get the public methods of the class to which an objects belongs.
  • Dependency injection in java

When class A uses some functionality of class B, then its said that class A has a dependency of class B.
In Java, before we can use methods of other classes, we first need to create the object of that class (i.e. class A needs to create an instance of class B).
So, transferring the task of creating the object to someone else and directly using the dependency is called dependency injection.
You can think of DI as the middleman in our code who does all the work of creating the preferred wheels object and providing it to the Car class.
useful links :https://www.youtube.com/watch?v=Eqi-hYX50M .
the @Autowired annotation inform the Framework that the spring container service wil connect the object with a component. DI is also really important for testing purpose because when testin a Class , we will be able to test only our class
and not the object used within our class.