Objects - Entity with state & Behavior
Class - Bluepring of object
Inheritance - inherits properties from parents
Polymorphism - method overloading / overriding
Abstraction - Abstract/interface to hide details
Encapsulation - wrapping data into single unit
Coupling - Knowledge of another class or dependency
Cohesion - single well defined task
Association - One to One, One to Many, Many to One and Many to Many
Aggregation - has-a or is part of relation between classes
Composition - class contains another class as its state
S - Single Responsibility Principal
O - Open-close Principal
L - Liskov Substitution method (can be replaced with base class)
I - Interface Segregation Principal (have as many interface)
D - Dependency Inversion Principal(depend on inface not concrete class)
Collection
List
ArrayList
LinkedList
Vector
Stack
Queue
Set
HashSet
LinkedHashSet
SortedSet
Map
Liner
Array
Stack - LIFO
Queue - FIFO
Non-linear
Generics means parameterized types
class Test <T > {
T obj ;
Test (T o ) {
this .obj = o ;
}
public T get (){
return this .obj ;
}
//Uses
Test <Integer > iObj = new Test <Integer >(15 );
}
short block of code which takes in parameters and returns a value
parameter -> expression
(parameter1 , parameter2 ) -> expression
(parameter1 , parameter2 ) -> { code block }
contains only one abstract method
@FunctionalInterface
new Thread (new Runnable () {
@ Override
public void run () {
System .out .println ("asas" );
}
});
Consumer - Takes value(1/2) returns nothing
Consumer <Integer > consumer = (value ) -> System .out .println (value );
Consumer <Integer ,String > consumer = (val1 , val2 ) -> System .out .println (val2 + val1 );
Predicate - Retuns boolean
Predicate <Integer > isGreaterThanZero = (val ) -> val > 0 ;
Predicate <Integer , Integer > isGreaterThan = (val1 , val2 ) -> val1 > val2 ;
// Uses
isGreaterThanZero .test (100 );
Function
@ FunctionalInterface
public interface BiFunction <T , U , R >
{
R apply (T t , U u );
}
Supplier
@ FunctionalInterface
public interface Supplier <T >{
T .get ();
}
```java
Optional<String> empty = Optional.empty();
Optional<String> opt = Optional.of(name);
opt.isPresent()
Optional<String> opt = Optional.ofNullable(name);
Optional<String> opt = Optional.of("ayu");
opt.ifPresent(name -> System.out.println(name.length()));
String nullName = null;
String name = Optional.ofNullable(nullName).orElse("john");
```
Stream <String > streamEmpty = Stream .empty ();
Stream <String > stream = Stream .of (list );
Stream .iterate (40 , n -> n + 2 ).limit (20 );
Stream .generate (() -> "element" ).limit (10 );
IntStream .range (1 , 3 );
Creational Patterns
Factory design pattern
Creation logic is hidden
One class is responsible to create objects of different types
Builder design
Prototype design
Singleton design
Structural Patterns
Adaptor design
lets incompatible objects collaborate
Facade design
Proxy design
represents functionality of another class
Behavioural Patterns
Command pattern
Iterator pattern
Observer pattern
Strategy pattern
NFR- Non functional Requirement
Performance
Latency
Avalability
Depoyment time
etc
Testing(Unit testing tools, TTD)
E = Elasticsearch
Log everthing, json based search, indexing
L = Logstash
Data aggregation and processing
K = Kibana
Patterns(Euraka, Netflix, Zuul, Circuit Breaking)