0% found this document useful (0 votes)
14 views38 pages

Lec 1

Uploaded by

rama--sabbagh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views38 pages

Lec 1

Uploaded by

rama--sabbagh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 38

Software

Framewor
ks and
Tools
• Understand the difference between
Frameworks and Tools
• Practice with some web and
database application development
Course frameworks
objectives • Practicing with machine learning
development framework
• Exposure to some tools for code
building and versioning
• Midterm Exam: 20%
• Final Exam: 40%
Course
• Project: 10%
Grading
• Quizzes/Periodic Exams/HomeWorks:
System 20%
• Lab : 10%
• Don’t be late to class
• Don’t raise hand to go out during the
class
• Must be active and take notes during
Students class – don’t be a guest!
• Write down your questions, think
Obligations about it, then ask when appropriate!
! • Must spend 3 hours minimum
weekly doing self-study ,homework ,
revision, practice … etc

4
Key Topics to be covered in the
course
• Brief theoretical background about Frameworks/Tools
• Webservices/Microservices and APIs theoretical background
• Spring Boot Framework in depth
• Different annotations
• Microservice development
• JSON based end points
• Pages rendering (Thymeleaf /Flutter .. )
• Machine Learning theoretical background
• Pytorch Framework in depth
• Model development
• Training and prediction
• APEX low-code development framework for web application
• Building simple data-driven dashboard
• Exposure to simple PL/SQL
Frameworks & Tools
What is Software Framework?
• A framework is a reusable structure that provides a base for the
application development process. With the help of a framework, you
can avoid writing everything from scratch. Frameworks provide a set
of code and libraries that help in speeding the development process.
• It provides structure, tools and templates that can be used and
even modified/extended to meet project requirements.
• Frameworks are based on programming languages. Few examples:
• Spring Boot (Java),
• Pytorch (Python),
• Angular(Type Script)
… and many more!
Software Dev Frameworks
Characteristics
• Reusability: A framework provides reusable components or modules
that developers can reuse across multiple projects, reducing
redundancy and saving development time.
• Example: Spring Boot provides reusable components such as Spring Data JPA for database operations,
Spring Security for authentication/authorization, and Spring Web for creating RESTful APIs.

• Inversion of Control (IoC): a framework manages the calls and


lifecycle of the components provided by developers.
• Example: In Spring Boot, the IoC Container (Spring Context) manages the lifecycle of objects (beans) and
their dependencies.

• Extensibility: Frameworks are designed to be extended by developers


to include custom features while adhering to predefined structures.
• Example: Spring Boot allows developers to extend its features by adding custom implementations or
modules while leveraging the existing framework.
Software Dev Frameworks
Characteristics(2)
• Pre-Defined Structure: Frameworks enforce a standard way to
organize and structure applications, promoting consistency
across projects.
• Example: Spring Boot enforces a predefined project structure
src/main/java
├── com.example.demo
├── controller
├── service or view
├── repository or model

• Abstraction: Frameworks abstract low-level functionality,


allowing developers to focus on high-level application logic rather
than complicated details.
• Example: Hibernate abstracts SQL queries, enabling developers to interact with databases
using object-oriented principles.
Software Dev Frameworks
Characteristics(2)
• Configurability : Frameworks offer configuration options to adapt to
different project requirements, often following "convention over
configuration" principles to minimize setup.
• Example: Spring Boot supports externalized configuration using properties files (application.properties
or application.yml) spring:
datasource:
url: jdbc:mysql://localhost:3306/dev_db

• Execution Focus: Manages runtime behaviors and interactions of


different components(objects) within the application
• Example: in Spring Boot, The execution environment ensures that these components are properly
instantiated, wired together, and managed during runtime.

• Ecosystem and Integration: refers to a framework's ability to work


seamlessly with a wide range of tools, libraries, and platforms, both
within its own ecosystem and with external systems.
• Example: in Spring Boot integration within Spring modules ( Spring JPA, security) and outside (e.g.
hibernate, Thymeleaf).
Is Maven a Software Dev
Framework?
Characteristic ✓/× Explanation
Maven does not provide reusable business logic or components for application
Reusability × development
Inversion of Control
(IoC) × Maven does not manage the lifecycle or flow of application components
Maven supports custom plugins and profiles, allowing it to be extended for specific
Extensibility ✓ project needs
Maven enforces a standard directory structure (e.g., src/main/java), ensuring
Predefined Structure ✓ consistency across projects.
Maven does not abstract business logic or provide prebuilt components for
Abstraction × application development
Maven allows extensive configuration through the pom.xml file, which can adapt to
Configurability ✓ various project requirements
Ecosystem and Maven integrates seamlessly with build tools, CI/CD pipelines, and dependency
Integration ✓ repositories like Maven Central

Execution Focus × Maven is focused on building and preparing applications, not their runtime behavior
Community and Maven has a large community and extensive documentation, ensuring robust support
Support ✓ and frequent updates
Inversion of Control (IoC)
• inversion of Control (IoC) is a programming principle where
the control of object creation, lifecycle management, and
dependency resolution is transferred from the developer
(manual control) to a framework.
• This principle is a cornerstone of frameworks like Spring and
promotes loose coupling between components.
Key concepts of IoC:
• Control is Inverted: traditionally, the developer writes code to instantiate
objects, manage dependencies, and invoke methods. In IoC, the framework
takes over this responsibility, and the developer provides instructions or
configurations about what to instantiate and how.
• Dependency Injection(DI): this is a common technique to implement IoC.
Dependencies (objects a class depends on) are "injected" into the class by the
framework instead of the class creating them itself.
Inversion of Control (IoC)
Key concepts of IoC (cont):
• Decoupling: IoC decouples the application’s components from each other,
making the codebase more flexible and easier to test.
• Lifecycle Management: The IoC container manages the lifecycle of
components, including their initialization, configuration, and destruction.

// No IoC // with IoC


public class UserService { public class UserService {
private UserRepository userRepository; private final UserRepository userRepository;
// Dependency injected by the framework
public UserService() { @Autowired
// You create the dependency public UserService(UserRepository userRepository) {
this.userRepository = new UserRepository(); this.userRepository = userRepository;
} }
} }
Why software frameworks are
important?
• Re-inventing the wheel: Without a framework, you need to write common
features (e.g., routing, authentication, database interaction) from scratch.
• Lack of standardization: Applications may lack a consistent structure or
conventions, making collaboration and maintenance challenging as different
developers might implement the same functionality in different ways, leading to
confusion.
• Security Risks: Without built-in tools or libraries, developers need to address
vulnerabilities (e.g., SQL injection, CSRF) manually, increasing the likelihood of
errors.
• Scalability: Scaling your application might require a significant rewrite.
• Performance optimization: Manually handling performance optimization (e.g.,
caching, load balancing) can be difficult without a framework's built-in tools.
• Testing Complexity: Writing and maintaining tests for a custom codebase can
be more complex and less efficient. Frameworks often include testing libraries to
ease several testing tasks (e.g. mocking).
Types of Frameworks
• Web Applications:
• Front-end: Angular, VueJS
• Back-end: Spring Boot, Django
• Mobile Applications
• Flutter
• React
• Desktop Applications
• JavaFX
• .Net
• Data Science
• Pytorch
• TensorFlow
Frameworks we are going to cover in
this course
• Spring Boot: is a backend Java-based framework that simplifies
the development of microservices and enterprise applications.
• Used by: Netflix, Amazon, Paypal, Google.
• Pytorch: is an open-source machine learning framework
primarily used for deep learning and artificial intelligence tasks
ranging from natural language processing to computer vision.
• Used by: Meta, Tesla, Microsoft,Uber, OpenAI
• APEX (if time permit): low code application development
framework for creating web applications that run on Oracle
databases
• Used by: HSBC, FedEX, Siemens
What are development Tools?
• Software Development Tools are programs, applications, or
utilities that assist developers in creating, debugging, maintaining, or
supporting software.
• They are primarily focused on aiding specific aspects of the
development process rather than providing a foundation or
architecture for the software itself, as frameworks do.
Key Features of Software Development Tools
1.Task-Specific: Tools are designed for specific tasks, such as coding,
testing, debugging, version control, or project management.
2.Utility-Oriented: They provide functionality to make development more
efficient but don't enforce patterns or control the flow of the application.
3.No Inversion of Control (IoC): Unlike frameworks, tools do not control
how your application is structured or executed.
Difference Between Tools and
Frameworks
Software Development
Software Development Tools
Frameworks
Focus on specific development
Provide a foundation and structure
Purpose tasks like building, testing, or
for building applications.
debugging.
Developers fully control how and Frameworks control certain parts of
Control
when to use the tool. the application's flow (e.g., IoC).
Solves specific problems (e.g., Aids in building complete
Task-Specific
automating builds or testing). applications (e.g., Spring Boot).
Tools can be integrated into
Frameworks often work within
Integration frameworks or used
ecosystems of tools and libraries.
independently.
Code No predefined patterns or Enforces design patterns like MVC
Architecture architecture. (e.g., Django, Angular).
Web Development
Webservices
• A web service is a standardized way for two applications or systems to communicate
with each other over the internet. It enables the exchange of data and functionality
between different systems, regardless of the programming languages or platforms they are
built on.
• A web service exposes functionality or data over the internet using standard protocols,
enabling communication between applications. In the context of modern software
development, RESTful web services are the most common form, widely used for APIs in
mobile, web, and enterprise applications.
• Characteristics:
• Support m2m interaction
• Interoperable: language independent
• Interact over a network : using XML/Json
• Terminologies to remember:
• Request
• Response
• Messages
• Server/provider
• Client /consumer
Types of Webservices
• SOAP (Simple Object Access Protocol) : SOAP is a protocol
for exchanging structured information in the implementation of
web services. It defines a strict set of rules for message
formatting, communication, and error handling, making it more
suitable for enterprise-grade, complex applications.
• Supported Operations details are given in WSDL(Web-service
Description Language) file for the webservice. This file provides
detailed information about:
• Operation Names: The specific actions the service can perform.
• Input and Output Messages: The structure and data types required for
each operation.
• Endpoint URL: The location where the service is hosted.
Types of Webservices

Client sends Request Server sends Response


<soapenv:Envelope <soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.o xmlns:soapenv="http://schemas.xmlsoap.org
rg/soap/envelope/" /soap/envelope/"
xmlns:ns="http://example.com/namespace" xmlns:ns="http://example.com/namespace">
> <soapenv:Header/> <soapenv:Body>
<soapenv:Header/> <ns:GetUserResponse>
<soapenv:Body> <ns:User>
<ns:GetUserRequest> <ns:Id>123</ns:Id>
<ns:userid>123</ns:userid> <ns:Name>John Doe</ns:Name>
</ns:GetUserRequest> </ns:User>
</soapenv:Body> </ns:GetUserResponse>
</soapenv:Envelope> </soapenv:Body>
</soapenv:Envelope>
Types of Webservices (2)
• REST (Representational State Transfer): REST is an architectural style
for designing networked applications. It leverages standard HTTP methods to
perform CRUD (Create, Read, Update, Delete) operations on resources.
• Uses HTTP Methods: -- Example: JSON
{
• GET: Retrieve a resource "id": 1,
• POST: Create a resource "name": "John Doe",
"email": "[email protected]"
• PUT: Update a resource }
• DELETE: Delete a resource
• Data Formats: REST supports multiple formats like JSON, XML, or even plain text.
• Common Use Cases of REST
• Web and Mobile Backends: Modern web and mobile apps rely on RESTful APIs for
communication.
• Microservices: REST is widely used for communication between microservices.
• Public APIs: Most public APIs (e.g., Google Maps, Twitter) use REST.
How Webservices are important for
Software Frameworks?
• Web services are crucial for software development frameworks
because they:
1.Enable interoperability between systems.
2.Facilitate modularity and scalability.
3.Support modern architectures like microservices.
4.Provide a communication layer for distributed systems.
5.Enable seamless integration with third-party and cloud services.
• Frameworks like Spring Boot and .NET heavily rely on web
services to create APIs that connect the backend logic to
frontend applications, mobile apps, or other services, making
web services a fundamental component of modern software
development.
Microservice Architecture
• Is a software design approach where an application is built as a
collection of small independent services, each focused on a
specific business capability.
• The services are loosely coupled, independently deployable, and
communicate with each other using lightweight protocols like
HTTP or messaging systems.
• Microservices often use web services (REST, SOAP) for
communication, making web services a key enabling technology
for microservices architecture.
API Endpoint
• An API endpoint (REST API) is a specific URI(URL/URN) where
an application or client can access resources or functionality
provided by an API.
• It serves as the interface through which an API interacts with
other software systems, enabling communication between clients
(e.g., frontend, mobile apps) and servers.
• Methods for REST API:
• GET: Retrieve details of a resource
• POST: Create a new resource
• PUT: Update existing resource
• DELETE: Delete a resource
References
Consult these references for more details:
• Microservices vs Web Services: Choosing the Right Architecture |
SPEC INDIA

• Web APIs, Web Services, & Microservices: Basics & Differences


Spring Boot
Framework
Spring Boot Description
• Spring Boot is a Java-based framework that simplifies the
development of web applications by providing pre-configured
templates and reducing the amount of boilerplate code needed.
• It is part of the larger Spring Framework ecosystem and is designed
to streamline the development of standalone, production-ready
applications.
Common Use Cases:
• Web Applications: Build dynamic websites and REST APIs.
• Microservices: Develop lightweight, independent services that
communicate over HTTP.
• Enterprise Applications: Quickly set up enterprise-level Java
applications with extensive Spring ecosystem integration.
• Batch Processing: Handle scheduled jobs and large-scale processing
tasks.
Spring Boot Project Structure
project-root/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── example/
│ │ │ └── project/
│ │ │ ├── controller/ (Classes to handle HTTP Request)
│ │ │ ├── service/ (Business Logic Classes)
│ │ │ ├── repository/(Interaction with Database)
│ │ │ ├── model/ (Holds entities to map Tables in DB)
│ │ │ ├── config/ (Hard coded behavioral configuration)
│ │ │ └── ProjectApplication.java (The Entry Point)
│ │ ├── resources/
│ │ │ ├── static/ (CSS,Java scripts, Images of web pages)
│ │ │ ├── templates/ ( HTML templates for server-side rendering)
│ │ │ ├── application.properties (optional: server configuration file)
│ │ │ └── application.yml (optional: configuration file)
│ ├── test/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── example/
│ │ │ └── project/
│ │ │ └── ProjectApplicationTests.java
│ │ └── resources/
├── pom.xml
└── README.md
Entry Point
• Every Spring Boot application has a main class annotated with
@SpringBootApplication, which serves as the entry point to
execute the application.

@SpringBootApplication
public class MicroserviceApplication {
public static void main(String[] args) {
SpringApplication.run(MicroserviceApplication.class, args);
}
}
Controller
• A controller in Spring Boot application is a key component of the
Model-View-Controller (MVC) architectural pattern. It is
responsible for handling HTTP requests, processing them
(often with the help of a service layer), and returning an
appropriate response to the client.
• Controllers are typically used to expose RESTful endpoints in a
Spring Boot application.
• A controller must be annotated with @RestController
@RestController
public class MyController {

}
Annotations within Controller-
@GetMapping
• The @GetMapping annotation is used to handle HTTP GET
requests. It is commonly used to retrieve data or resources from
a server. This is a key part of building RESTful APIs.
@RestController
public class MyController {

@GetMapping("/hello") // (URL: localhost:8080/hello)


public String hello() {
return "Hello!";
}
}
Annotations within Controller-
@PostMapping
• The @PostMapping annotation is used to handle HTTP POST requests.
It's commonly used in REST APIs for creating new resources or
processing data sent in the body of the request.
• The new entry body contains the data to be stored. It could be a JSON
message hence @RequestBody annotation is used to map this
message.
@RestController
public class MyController {

@PostMapping("/users")
public User createUser(@RequestBody User user) {
return userService.save(user);
}
}

• You can use Talend API or Postman to post new resource


Annotations within Controller-
@DeleteMapping
• The @DeleteMapping annotation in Spring Boot is used to map
HTTP DELETE requests to specific handler methods in a Spring
controller. It's commonly used in REST APIs to delete resources.

@RestController
public class MyController {

@DeleteMapping(path = "/beans/{id}")
public void deleteBean(@PathVariable int id) {

}
}
• Notice the usage of @PathVariable to extract values from the
URL in a request.
Annotations within Controller-
@PathVariable
• The @PathVariable annotation is used to bind the placeholder in
the URL path to a method parameter in your controller.

@RestController
public class MyController {

@GetMapping("/{id}")
public String getUserByCustomId(@PathVariable("id") Long
userIdentifier) {
return "User ID: " + userIdentifier;
}
}
Annotations within Controller-
@Autowired
• The @Autowired annotation is used for dependency injection. It
enables Spring to automatically inject the required bean (object)
into a component, such as a controller, service, or repository.
• Three types of injection:
• Field Injection
• Constructor Injection
• Setter Injection
Exercise

• Develop a microservice that displays hello world message on the


browser
• Customize the microservice to display a custom greeting
message ( e.g. Hello <your Name> ).
• Develop a microservice to return the square root of a number
given by the user.
• Develop a simple microservice to generate a JSON message that
displays a number of students details ( Student_id,
Student_Name, GPA)

You might also like