Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Spring Notes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

JAVA THUMB RULES

1. In class every class is having public default constructor.


access modifier of the constructor -> non-static.
2.new operator-> 1.it creates object for the class
2.it returns the address of the same object
3.abstract class -> A class declared with abstract keyword.
1. can contain only abstract methods
2. can contain only concrete methods
3. can contain both -> abstraction
4.abstract class i having public default constructor
->it helps for the constructor chaining.
5. interface do not contain any constructor -> using interface we cannot
achieve constructor chaining.
6.we can overload the methods present in same class or different class -
>no changes
7.we can change the access specifier of the over-riding method
1.superclass->pkg-level
2.subclass->public -> visibility should be high
8.constructor declaration is binded to definition at compile time and it
completely depends upon arguments.
9. Run time polymorphism
steps to achieve -> inheritance
Method overriding
Typecasting->upcasting
10.In java anything started with uppercase with paranthesis-> constructor.
11. In java anything started with lowercase with paranthesis-> method
12. LHS = RHS
Demo ref = new Demo();
Demo->concrete class
13. Run ref = new Demo();
Run->interface, abstract class, concrete class
14. finally block
try
{
line1
}
catch(Exception ex)
{
alternate code ->exception
}
finally
{
line3
}
1. Finally block get executed irrespective of occurrence of exception.
2. If we wants to execute statements written after catch block those
statements should be written in finally block if only catch block
statements are also throwing exceptions.
Solid Principles
-used to make an application more robust(dynamic) and elegant(stylish).

There are 5 solid principles


1.S - Single Responsibility principle (SRP)
Every software component should have one and only one
responsibility.
2.O - Open-closed principle (OCP)
Every software component is closed for the modification and open for
the extension.
3.L - Liskev Substitution principle (LSP)
Objects can be replaceable with their subtypes(interface) without
affecting the correctness of the program.
4.I - Interface Segregation Principle (ISP)
Segregation-> dividing
-> Segregate single interface into multiple interfaces based on the
requirement of the implementation classes.
5.D - Dependency Inversion principle (DIP)
->High-level module should not depend upon the low-level module but
both can depend upon the abstraction.
MAVEN PROJECT
- It is one of the powerful project management tool.
- It is used for
1. the projects to build
2.dependency
3.documentation
- It makes completely the projects easy to build.
Maven follows some steps to build the project
1. Generate the source code (auto-generated code is used).
2. Generate documentation from source code.
3. Compile the source code.

SPRING FRAMEWORK
- Spring is a dependency injection framework helps to injecting of
dependencies required by the bean class.
Dependencies - data members in bean class
bean class – 1. declaring data member as private
2. provide access through getters and setters

Advantages of Spring framework


- Light weight
- Powerful abstraction framework
- Spring injects any number of dependencies to bean class
There are 3 types of dependencies are injected
1. Primitive type
2. collection type
3. Reference type

Steps to work with Spring Framework


1.Create bean class or POJO class (plain old java object).
2.Create XML configuration file to configure the dependencies.
3.Create test dependent class.

Dependency injection
There are 3 types of dependency injection
1.Setter injection
2.Constructor injection
3.Interface injection

You might also like