1.
SOLID principles
These are some principles tell us how to write code that's easy to maintain, extend and
understand
The porpuse of solid is to make your code more maintainable and easy to extend
@Working a legacy code
@Hard to understand what a method does
@Spending a lot of time to fix a minor bug
@you spend more time reading than writing code
1. Single Responsibility
@A class have to have just one responsibility
@A class should have one and only reason to change
@Make just one thing, for example if you have a class User, and its class has a method to
create users and in the same method you all the logic to cript the passwrod, thats is wrong
because you have to separate that in two class one of them to Cript and then other one to create
the user
2. Open/ Closed Principle
@An entity should be open for extension but close for modification
@Extend functionality by adding new code instead of changing exiting code
@Open Source library, some time you have to changes how is it work adding new
functionality but maybe no changing the core
3. Liskov Substitution principle
@if S is a subtype of T, then objects of type T may be replaced with objects of type
S
Good example
public class Bird{
}
public class FlyingBirds extends Bird{
public void fly(){}
}
public class Duck extends FlyingBirds{}
public class Ostrich extends Bird{}
4. Interface segregation
@No cliente should be force to depends on method it does not use
@Replace fat interface with small interface
5. Dependencia Inversión
High-level modules should not depend on low level. Both shuld depend on
abstraction clas
Able to change an implementation easily without altering the high level code
OOPs Concepts
Before of OOP was Procedural programming
6. Encapsulation
a. The whole idea about encapsulation is to hide the implementation details from
user. If a data member is private it means it can only be accessed whit in the same
class
b. The modification in the data will be by methods nobody can enter in the attributes
of the class directly
c. Reduce complexity + Increase reusability
7. Abstraction
a. Is the process of hiding details and show only essential information to the user
b. Abstraction can be achieved with abstract classes or interfaces
c. Reduce Complexity + isolate impact of changes
8. Inheritance
a. The process by which one class acquires the properties and functionalities of
another class is called inheritance. The main idea is to provide the reusability of
code so that class has to write only the unique features and rest of the common
properties and functionalities can be extending from another class.
b. Eliminate redundant code
9. Polymorphism.
a. that mens many forms, that allows us to perform a singles action in different way
(Refactor ugly switch cases/case statement)
1. Data Structures
Is a particular way of organized data in a computer so that can be used effectively they collect data
in a different way, we have?
Linear data structure, Binary tree, Binary search Tree, Graphs
Java we have Collection where we can have different ways of holding data
List.
o ArrayList
o LynkedList
Set
o SortedSet
o HashSet
o TreSet
o LinkedHashSet
Queue
Map
o SortedMap
o HashMap
o TreeMap
o LinkedHashMap
Algorithms
Depth First Search
Breadth First Search
Matching Parenthesis
HashTables
Variable Pointer Manipulations
BigO notaction the time that takes to one algorithm to be executed
Linear time O(n)
Constant time O (1)
Cuadratic time O (n2)
The @SpringBootApplication is in fact combination
of @Configuration, @ComponentScan and @EnableAutoConfiguration annotations.
You can also check Spring Boot MasterClass to learn more about this annotation and it's used.
Creational Design Patterns
These design patterns provide a way to create objects while hiding the creation logic,
In Factory pattern, we create object without exposing the creation
logic to the client and refer to newly created object using a common interface.
Abstract Factory patterns This factory is also called as factory of factories
Builder pattern builds a complex object using simple objects and using a step by
step approach. This builder is independent of other objects.
Prototype pattern refers to creating duplicate object while keeping performance in
mind.
Singleton pattern Una instance in all the application
Structural Patterns
Explain how to assemble objects and classes into larger structures while keeping these
structures flexible and efficient.
Decorator pattern allows a user to add new functionality to an existing object
without altering its structure. All the wrappers
Adapter pattern works as a bridge between two incompatible interfaces.
Bridge patter is used when we need to decouple an abstraction from its
implementation
Proxy pattern a class that represent the functionality of another class, that means
object cannon consume directly to the target object , something in the middle
Behavioral Patterns
These design patterns are specifically concerned with communication between
objects.
Observer pattern one object is modified; its dependents objects are to be notified
automatically
Chain of Responsibility that lets you pass requests along a chain of handlers and every
class decide if have to pass the request or process
Command turns a request into a stand-alone object that contains all information about
the request. This transformation lets you parameterize methods with different requests,
SQL
INNER JOIN: returns rows when there is a match in both tables.
LEFT JOIN: returns all rows from the left table, even if there are no matches in the right
table.
RIGHT JOIN: returns all rows from the right table, even if there are no matches in the left
table.
FULL JOIN: It combines the results of both left and right outer joins.
What are the features of Kubernetes?
The features of Kubernetes, are as follows:
}
Java 8 ships with several new features but the most significant
are the following:
Lambda Expressions − a new language feature allowing
treating actions as objects
Method References − enable defining Lambda
Expressions by referring to methods directly using their
names
Optional − special wrapper class used for expressing
optionality
Functional Interface – an interface with maximum one
abstract method, implementation can be provided using a
Lambda Expression
Default methods − give us the ability to add full
implementations in interfaces besides abstract methods
Nashorn, JavaScript Engine − Java-based engine for
executing and evaluating JavaScript code
Stream API − a special iterator class that allows
processing collections of objects in a functional manner
Date API − an imp
Method References
Object::toString();
String::new;
String::valueOf;
Optional
encapsulates an optional value Stream.min() method calculates
the minimum value in a stream of values. But what if the stream
is empty?
Functional Interfaces
All functional interfaces are recommended to have an
informative @FunctionalInterface annotation. This not only
clearly communicates the purpose of this interface, but also
allows a compiler to generate an error if the annotated interface
does not satisfy the conditions.
Any interface with a SAM(Single Abstract Method) is a functional
interface, and its implementation may be treated as lambda
expressions.
Default Method
public interface Vehicle {
public void move();
default void hoot() {
System.out.println("peep!");
}
}
Lambda Expressions
Lambda expressions introduce functional style processing in
Java and facilitate the writing of compact and easy-to-read code.
lambda expressions are a natural replacement for anonymous
classes as method arguments. One of their main uses is to
define inline implementations of functional interfaces.
Streams
stream is an iterator, set of actions to apply on each of the
elements it contains. which supports aggregate operations, so
we can use methods like map and flatMap for performing a
declarative processing.