Midterm Flashcards
what does spring do
makes programming quicker, easier and safer.
Focuses on speed, simplicity and productivity
(Spring Boot) is a tool that makes developing web application and microservices with Spring Framework faster and easier through three core capabilities
autoconfiguration
an opinionated approach to configuration
the ability to create standalone applications
A ___ ___ is a single-tiered software application in which different modules are combined into a
single program
monolithic application
___ ___ is considered to be a traditional way of building applications. A monolithic application
is built as a single and indivisible unit. Usually, such a solution comprises a client-side user interface, a server
side-application, and a database. It is unified and all the functions are managed and served in one place
Monolithic architecture
monolithic applications
strengths
less ___-___ concerns - are concerns that affect the whole application such as logging, handling, caching and performing monitoring. In a monolithic application, this area of functionality concerns only one application so it is easier to handle it.
Easier ___ and ___ - because it is a single indivisible unit
simple to ___
simple to ___
less cross cutting concerns
easier debugging and testing
simple to deploy
simple to develop
monolithic applications weaknesses
______ - scaling up makes it complex
harder to __ __
____
new ___ ___ - whole application must be rewritten
understanding
make changes, changes can affect the whole system
scalability - cannot scale components separately, must be the whole applications
new technology barriers
A ___ ____breaks it down into a collection of smaller independent units. These units carry
out every application process as a separate service. So all the services have their own logic and the database as well as perform the specific functions.
independent modules communicate with each other through ___
microservices architecture
API
____ refers to the process of associating a URL (endpoint) with a specific handler method in a controller.
Mapping
___ __ is a fundamental concept in Spring Boot that plays a crucial role in achieving Inversion of Control (IoC).
Allows you to provide the dependencies that a class or component needs, rather than having the class create its dependencies.
This approach promotes ___ ___ and makes your code more modular and easier to maintain.
Dependency Injection (DI)
loose coupling
_____ - is an object or component that another piece of code relies on to
perform its tasks.
dependency
___ ___ ___ - In traditional programming, your code controls
the flow of execution, including the creation and management of dependencies. In contrast, with __, control is inverted; a framework or container (like Spring Boot) manages the creation and injection of dependencies. Your code
focuses on its core logic, while the container handles the wiring of components.
inversion of control (IOC)
____ ____ ____ - is responsible for managing the creation and wiring of objects (beans) in your application. It scans your codebase for classes annotated with annotations like @Component, @Service, @Repository, and others, and it creates instances of these classes as beans. It also manages the lifecycle of these
beans, handling tasks like initialization and destruction
spring IoC container
types of dependency injection
Constructor Injection: The most recommended and common form of DI in Spring Boot. Dependencies are
declared as constructor parameters, and the container automatically provides instances when creating objects
Setter Injection: Dependencies are provided via setter methods in the class
Field Injection: Dependencies are injected directly into class fields using annotations like @Autowired.
benefits of dependency injection
___ - Components are loosely coupled, allowing them to be developed, tested, and maintained independently
__
modularity
reusability
testing
____in Spring Boot means that the control over creating and managing objects (beans) and their dependencies is transferred from your application to the ____ ___ ___.
IoC
Spring IoC container
make a version of this code with dependency injection
class Car{
private Engine engine = new Engine();
public void start(){
engine.start();
}
}
class myApp{
public static void main(String[] args){
Car car = new Car();
car.start();
}
}
instead of having car reference the engine, inject engine into car
class Car{
private final Engine engine;
public Car(Engine engine){
this.engine=engine;
}
public void start(){
engine.start();
}
}
class myApp{
public static void main(string[] args)
{
Engine engine = new Engine();
Car car = new Car(engine);
car.start();
}
}
what does @Component do
tells spring boot that the class is a bean
what does @Autowired do
indicate where dependencies should be injected
signal the container to provide the required dependency
what is lombok good for
reduces the need for writing repetitive code
lombok operates at ___ ___
compile time
when the source code is compiled, not when the application is ran
____ code is code that you have to write over and over again for common tasks
Boilerplate
why lombok is important
reduces ___ code
enhances ___
saves ___
minimizes __
boilerplate
readability
time
errors
lombok
@Data
combines __________________
@Getter
@Setter
@ToString
@EqualsAndHashCode
@RequiredArgsConstructor
lombok logging annotations
@slf4j
@Log
lombok
@Builder annotation syntax
Person person = Person.builder()
.name(“Alice”)
.age(30)
.address(“123 main street”)
.build();
use @Builder in bean class
Thymeleaf is a powerful and versatile ____ ____ for web development.
it allows developers to create dynamic web pages by embedding dynamic content within HTML, XML, and other document types
templating engine
Thymeleaf’s primary goal is to simplify the process of generating ___ ____ ____, making it an essential tool for modern web application development.
dynamic web content
thymeleaf is designed to work in both ___ and ___ environments
web and standalone
thymeleaf has the capability to __________________
process a wide range of document type
thymeleaf
___ ____ - allows injecting logic into template files without disrupting their use as design prototypes. This approach enhances communication between design and development teams
bridging ____ and ___
___ ___ ____
natural templates
design and development
web standard compliance
thymeleaf use cases
(2)
web applications
design prototyping - dont have to worry about logic
templates that thymeleaf can process
(6)
HTML
CSS
JAVASCRIPT
RAW
XML
TEXT
The ____ attribute is used to set the text content of an HTML element in a Thymeleaf template. It allows you to
dynamically replace the text within an element with data from your application’s model or other expressions.
syntax
th:text
<p>Default Message</p>
The ___ attribute is used for iterating over collections
syntax
th:each
<ul>
<li></li>
</ul>
loops whatever tag it is attached to
th:if and th:unless syntax
<span th:if=”${employee.gender} == “M”” th:text=”male”/>
<span th:unless=”${employee..gender} == “M”” th:text=”female”/>
switch and case syntax
<td>
<span></span>
<span></span>
</td>
how to use images
<img></img>
___ __ ___ rely on system memory as opposed to disk space for
storage of data. Because memory access is faster than disk access, these databases are naturally faster
In-memory databases
___ _______is a high-performance, lightweight, and embeddable relational database management system (RDBMS)
written in Java
H2 Database
H2 database features
in memory and file-based modes
embedded database
ACID compliance (atomicity, consistency, isolation, durability)
Small footprint
compatibility
built in functions
web based console
H2 use cases
development and testing
embedding databases
prototyping and proof of concept
educational purposes
JDBC (Java Database Connectivity) is a Java-based API that allows Java applications to interact with ____ ____
simplifies ___
relational databases
database access
JDBC key features
siplifies JDBC code
exception handling
connection management
named parameters
batch processing
result mapping
CRUD meaning
create read update delete
path variables
let you __________
syntax
capture values directly from a url
@GetMapping(“/book/{bookID}”)
public Book getBookDetails(@PathVariable Long bookID){
}
update query
String query = “UPDATE tableName SET name1 = :name1, name2 = :name2 WHERE id = :id”
do a namedParameters.addValue for each variable
jdbc.update(query, namedParameters)