Understanding Software Engineering Vol 3: Programming Basic Software Functionalities.
()
About this ebook
Read more from Gabriel Clemente
Understanding Software Engineering Vol 1: Where does the software run and how? The hardware. Rating: 0 out of 5 stars0 ratingsUnderstanding Software Engineering Vol 2: Programming principles and concepts to build any software. Rating: 5 out of 5 stars5/5
Related to Understanding Software Engineering Vol 3
Related ebooks
PostgreSQL Server Programming Rating: 0 out of 5 stars0 ratingsCoding In C Decoded: Decoded, #1 Rating: 0 out of 5 stars0 ratingsProjects with IOTA Rating: 0 out of 5 stars0 ratingsPython APIs: From Concept to Implementation Rating: 5 out of 5 stars5/5Golang for Jobseekers: Unleash the power of Go programming for career advancement (English Edition) Rating: 0 out of 5 stars0 ratingsGo Programming Cookbook Rating: 0 out of 5 stars0 ratingsIntroduction to Google's Go Programming Language: GoLang Rating: 0 out of 5 stars0 ratingsMastering C: A Comprehensive Guide to Proficiency in The C Programming Language Rating: 0 out of 5 stars0 ratingsMastering Go Programming: From Basics to Expert Proficiency Rating: 0 out of 5 stars0 ratingsC++ Networking 101 Rating: 0 out of 5 stars0 ratingsPractical C++ Backend Programming Rating: 0 out of 5 stars0 ratingsLearning SQLite for iOS: Extend SQLite with mobile development skills to build great apps for iOS devices Rating: 0 out of 5 stars0 ratingsProgramming Backend with Go Rating: 0 out of 5 stars0 ratingsNoSQL Essentials: Navigating the World of Non-Relational Databases Rating: 0 out of 5 stars0 ratingsPython Apps on Visual Studio Code: Develop apps and utilize the true potential of Visual Studio Code (English Edition) Rating: 0 out of 5 stars0 ratingsComputer Networking Bootcamp: Routing, Switching And Troubleshooting Rating: 0 out of 5 stars0 ratingsJavaScript for Beginners Rating: 5 out of 5 stars5/5Raspberry Pi User Guide Rating: 4 out of 5 stars4/5Modern Web Development with Go Rating: 0 out of 5 stars0 ratingsAlgorithms: Computer Science Unveiled Rating: 0 out of 5 stars0 ratingsMulticore DSP: From Algorithms to Real-time Implementation on the TMS320C66x SoC Rating: 0 out of 5 stars0 ratingsUltimate PowerShell Automation for System Administration Rating: 0 out of 5 stars0 ratingsMastering JAVA Programming for Beginners Rating: 0 out of 5 stars0 ratingsAndroid Studio Hedgehog Essentials - Kotlin Edition: Developing Android Apps Using Android Studio 2023.1.1 and Kotlin Rating: 0 out of 5 stars0 ratingsWriting Compilers and Interpreters: A Software Engineering Approach Rating: 3 out of 5 stars3/5Instant Handlebars.js Rating: 0 out of 5 stars0 ratingsThe Art of Code: Exploring the World of Programming Languages Rating: 0 out of 5 stars0 ratingsSoftware Architecture Complete Self-Assessment Guide Rating: 0 out of 5 stars0 ratings
Computers For You
Creating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5Mastering ChatGPT: 21 Prompts Templates for Effortless Writing Rating: 4 out of 5 stars4/5The ChatGPT Millionaire Handbook: Make Money Online With the Power of AI Technology Rating: 4 out of 5 stars4/5Procreate for Beginners: Introduction to Procreate for Drawing and Illustrating on the iPad Rating: 5 out of 5 stars5/5Elon Musk Rating: 4 out of 5 stars4/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Data Analytics for Beginners: Introduction to Data Analytics Rating: 4 out of 5 stars4/5Technical Writing For Dummies Rating: 0 out of 5 stars0 ratingsUX/UI Design Playbook Rating: 4 out of 5 stars4/5The Self-Taught Computer Scientist: The Beginner's Guide to Data Structures & Algorithms Rating: 0 out of 5 stars0 ratingsStorytelling with Data: Let's Practice! Rating: 4 out of 5 stars4/5CompTIA Security+ Get Certified Get Ahead: SY0-701 Study Guide Rating: 5 out of 5 stars5/5The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution Rating: 4 out of 5 stars4/5Deep Search: How to Explore the Internet More Effectively Rating: 5 out of 5 stars5/5Microsoft Azure For Dummies Rating: 0 out of 5 stars0 ratingsBecoming a Data Head: How to Think, Speak, and Understand Data Science, Statistics, and Machine Learning Rating: 5 out of 5 stars5/5Learning the Chess Openings Rating: 5 out of 5 stars5/5Computer Science I Essentials Rating: 5 out of 5 stars5/5Fundamentals of Programming: Using Python Rating: 5 out of 5 stars5/5The Musician's Ai Handbook: Enhance And Promote Your Music With Artificial Intelligence Rating: 5 out of 5 stars5/5A Quickstart Guide To Becoming A ChatGPT Millionaire: The ChatGPT Book For Beginners (Lazy Money Series®) Rating: 4 out of 5 stars4/5Get Into UX: A foolproof guide to getting your first user experience job Rating: 4 out of 5 stars4/5CompTIA IT Fundamentals (ITF+) Study Guide: Exam FC0-U61 Rating: 0 out of 5 stars0 ratings
Reviews for Understanding Software Engineering Vol 3
0 ratings0 reviews
Book preview
Understanding Software Engineering Vol 3 - Gabriel Clemente
Gabriel Clemente
Understanding Software Engineering Vol 3
Programming Basic Software Functionalities.
Copyright © 2024 by Gabriel Clemente
All rights reserved. No part of this publication may be reproduced, stored or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise without written permission from the publisher. It is illegal to copy this book, post it to a website, or distribute it by any other means without permission.
First edition
ISBN: 978-1-326-91144-7
This book was professionally typeset on Reedsy
Find out more at reedsy.com
Publisher LogoContents
1. Understanding Server Setup and Configuration
2. Understanding Authentication and Authorization
3. Understanding Middleware
4. Understanding Database Connection and Management
5. Understanding REST APIs and Communication
6. Understanding Frontend Integration
7. Understanding Form Validation
8. Understanding File Handling and Storage
9. Understanding Error Handling and Logging
10. Understanding Testing and Quality Assurance
11. Understanding Security Practices
12. Understanding Concurrency and Asynchronous Processing
13. Understanding Deployment and CI/CD
14. Understanding Monitoring and Analytics
15. Understanding State Management
16. Understanding Scalability
17. Understanding Performance Optimization
18. Understanding Localization and Internationalization
19. Understanding Dependency Management
20. Understanding Job Scheduling and Background Processing
21. Conclusion
About the Author
1
Understanding Server Setup and Configuration
Creating a Server
Creating a server is the foundation of any application, whether you’re building a simple backend API or a full-fledged web application. We’ll focus on setting up servers in both TypeScript (Node.js with Express) and C. While TypeScript is commonly used for server-side JavaScript, C provides more control over low-level server operations.
Setting Up a Server in TypeScript (Node.js with Express)
Before we start, let’s get everything ready:
1.Create a Project Folder: Open your terminal and create a folder for the server by running:
mkdir my-server
cd my-server
2.Initialize the Project: Now, initialize a new Node.js project. This will generate a package.json file that tracks your project dependencies.
npm init -y
3.Install Dependencies: We will install Express.js (a web framework for Node.js) and Nodemon (a tool that restarts the server when file changes are detected).
npm install express
npm install -D nodemon
4.Set Up package.json: Open your package.json file and add the following start script, which will use Nodemon to automatically restart the server during development:
{
scripts
: {
start
: nodemon index.js
}
}
5.Create index.js: Let’s create an index.js file where the server code will live:
const express = require('express'); //This line imports the express
//library into your file.
const app = express(); //express() is a function imported
//from the express module.
//When you write express(), you're
//invoking (or calling) the
//express() function.
//The result of this function call
//is assigned to the variable app.
//In this case the express()
//function creates a basic express
//server which is assigned
//commonly to a variable called
//app.
const port = process.env.PORT || 4000; //This variable just holds the
//number of the port in which
//we want our server to run.
//We first try to get the
//variable from our environment
//variables then if that fails
//we use the 'or' operator to
//assign a default fallback
//number.
app.get('/', (req, res) => { //This line calls the built in get
res.send('Hello World!'); //method in the express server, this
}); // method gets 2 parameters, the
//is a string to indicate the name
//of the route in which the endpoint
//will be available, the second
//parameter is an anonymous arrow
//function that has 2 parameters as
//well, one is the request, with the
//data sent to the endpoint and the
//other one is the response, the
//data the endpoint returns. In this
//case this endpoint only returns a
//string with the build in method
//.send in the response object.
app.listen(port, () => {
// The app.listen() function tells your server to start listening
// for incoming requests. The 'port' variable is used here to
// define on which port the server should listen.
// The second argument is a callback function that will run once
// the server successfully starts.
console.log(`Server is running on port ${port}`);
// This line logs a message to the console indicating that the
// server has started successfully and specifies which port it's
//running on.
// The backticks and ${port} allow us to include the actual port
// number dynamically in the string using template literals.
});
6.Start the Server: Finally, start your server by running:
npm start
7.You should see output like:
Server is running on port 4000
Now you have a basic Node.js server up and running! This server listens on port 4000 and responds with Hello World!
whenever someone makes a request to the / route.
Setting Up a Server in C
In C, setting up a server is more manual and requires lower-level networking libraries like POSIX or Winsock (depending on your platform). For simplicity, we’ll use a basic POSIX socket example that can run on Linux/macOS.
1.Create a C Project: First, create a new C project folder.
mkdir c-server
cd c-server
2.Write the Server Code: Now, create a file named server.c and paste the following code that implements a basic server using sockets:
#include
#include
//exit
#include
//like strcpy
#include
//managing sockets
#include
#include
#define PORT 8080 // Defining the port number where the
//server will listen
int main() {
int server_fd, new_socket;
struct sockaddr_in address; // Structure to hold server's address
//information
int addrlen = sizeof(address);
char buffer[1024] = {0}; // Buffer to store incoming messages
char *hello = Hello from C server
; // Response message to send
//back to the client
// Create socket file descriptor
if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) == 0) {
// AF_INET: IPv4, SOCK_STREAM: TCP, 0: Default protocol
perror(socket failed
); // Print error message if socket
//creation fails
exit(EXIT_FAILURE); // Exit the program with failure
//status
}
// Define address family, IP address, and port number for the
//server
address.sin_family = AF_INET; // IPv4
address.sin_addr.s_addr = INADDR_ANY; // Accept
//connections from
//any IP
address.sin_port = htons(PORT); // Convert the port
//number to network
//byte order
// Bind the socket to the network address and port
if (bind(server_fd, (struct sockaddr *)&address, sizeof(address)) < 0) {
perror(bind failed
); // Print error if binding fails
exit(EXIT_FAILURE); // Exit if bind fails
}
//