Explore 1.5M+ audiobooks & ebooks free for days

Only $12.99 CAD/month after trial. Cancel anytime.

Understanding Software Engineering Vol 3: Programming Basic Software Functionalities.
Understanding Software Engineering Vol 3: Programming Basic Software Functionalities.
Understanding Software Engineering Vol 3: Programming Basic Software Functionalities.
Ebook331 pages2 hours

Understanding Software Engineering Vol 3: Programming Basic Software Functionalities.

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Following with this series this book explains how to build basic functionality common to most software and products, trying to simplify the concepts to display them as clear as possible for the readers, this book shouldn't be used to get specialized, but to get good foundation, you'll find concepts related to Site Reliability Engineering or DevOps, but if you want to become a DevOps Engineer you should go way deeper, though after reading this book I'll hope you'll be able to understand most tutorials, guides, or books related to DevOps.
LanguageEnglish
PublisherLulu.com
Release dateOct 9, 2024
ISBN9781326911447
Understanding Software Engineering Vol 3: Programming Basic Software Functionalities.

Read more from Gabriel Clemente

Related to Understanding Software Engineering Vol 3

Related ebooks

Computers For You

View More

Reviews for Understanding Software Engineering Vol 3

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    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 Logo

    Contents

    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               // Standard I/O functions like printf

     

    #include             // Standard library functions like

                                    //exit

     

    #include             // Functions to manipulate C strings

                                    //like strcpy

     

    #include         // Socket functions for creating and     

                                    //managing sockets

     

    #include         // Structures for internet addresses

     

    #include             // Close function to close the socket

     

    #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

        }

     

       

        //

    Enjoying the preview?
    Page 1 of 1