Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Discover millions of ebooks, audiobooks, and so much more with a free trial

From $11.99/month after trial. Cancel anytime.

Hands-On Microservices with JavaScript: Build scalable web applications with JavaScript, Node.js, and Docker
Hands-On Microservices with JavaScript: Build scalable web applications with JavaScript, Node.js, and Docker
Hands-On Microservices with JavaScript: Build scalable web applications with JavaScript, Node.js, and Docker
Ebook840 pages5 hours

Hands-On Microservices with JavaScript: Build scalable web applications with JavaScript, Node.js, and Docker

Rating: 0 out of 5 stars

()

Read preview
LanguageEnglish
Release dateDec 20, 2024
ISBN9781788625265
Hands-On Microservices with JavaScript: Build scalable web applications with JavaScript, Node.js, and Docker

Related to Hands-On Microservices with JavaScript

Related ebooks

Programming For You

View More

Reviews for Hands-On Microservices with JavaScript

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

    Hands-On Microservices with JavaScript - Tural Suleymani

    Cover.png

    Hands-On Microservices with JavaScript

    Copyright © 2024 Packt Publishing

    All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

    Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

    The author acknowledges the use of cutting-edge AI, such as ChatGPT, with the sole aim of enhancing the language and clarity within the book, thereby ensuring a smooth reading experience for readers. It’s important to note that the content itself has been crafted by the author and edited by a professional publishing team.

    Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

    Group Product Manager: Kaustubh Manglurkar

    Publishing Product Manager: Bhavya Rao

    Book Project Manager: Sonam Pandey

    Senior Editor: Ayushi Bulani

    Technical Editor: K Bimala Singha

    Copy Editor: Safis Editing

    Indexer: Manju Arasan

    Production Designer: Prashant Ghare

    First published: December 2024

    Production reference: 1221124

    Published by Packt Publishing Ltd.

    Grosvenor House

    11 St Paul’s Square

    Birmingham

    B3 1RB, UK

    ISBN 978-1-78862-540-1

    www.packtpub.com

    To Elvira, my steadfast companion, whose unwavering love and support has been the bedrock of my life and work. To Turgut and Farah, my beloved children, whose existence fills my world with immeasurable joy and purpose.

    Every challenge I’ve faced has been a crucible, forging the strength and resilience necessary for this journey. I am eternally grateful for the trials that have shaped me, and for the love that has carried me through.

    – Tural Suleymani

    Contributors

    About the author

    Tural Suleymani is a seasoned software development expert with over a decade of industry experience. Renowned as Azerbaijan’s first Microsoft MVP in .NET and a three-time C# Corner MVP, he has established himself as a leading authority in his field. With a passion for sharing knowledge, Tural has dedicated ten years to mentoring developers through comprehensive programming languages and technology tools instruction. A self-taught pioneer, he empowers a global audience through his TuralSuleymaniTech YouTube channel, where he delivers in-depth tutorials and insights on C#, Apache Kafka, SQL, JavaScript, Domain-Driven Design, software architecture, microservices, and more. His deep technical knowledge and practical insights have empowered countless developers through his work as a mentor, educator, and public speaker. He also holds prestigious certifications including MCP, MCSA, and MSCD from Microsoft. Tural is also a Udemy instructor, further expanding his educational reach. Currently, Tural holds the position of Chief Software Architect at VOE Consulting, where he continues to innovate and lead in the software development industry.

    About the reviewer(s)

    Rasul Huseynov is a senior software developer and consultant with over seven years of experience in delivering high-quality software solutions. He graduated with high honors in computer engineering and brings deep expertise in Object-Oriented Analysis and Design (OOAD), Extreme Programming, and Distributed Systems. Holding certifications such as MCP, MCSA, and MCSD, Rasul has a solid foundation in Microsoft technologies and has successfully delivered numerous web projects. His experience extends to ensuring that software solutions are robust, maintainable, and efficient while adhering to industry best practices.

    Adewole Caleb is a skilled backend engineer with a solid foundation in JavaScript, Golang, and TypeScript. Over his five years of professional experience, he has built a reputation for his curiosity, problem-solving abilities, and dedication to continuous learning. Having recently graduated, Caleb is now exploring a career transition into distributed and system engineering. Beyond his professional work, Caleb is deeply passionate about music. He finds joy in playing the guitar, singing, and participating in other activities that allow him to express his creativity. Caleb volunteers as a boot camp tutor, where he shares his knowledge and experience to inspire budding developers.

    Joel Edmond Nguemeta is a full-stack developer and mentor with expertise in web application development and system design. He has worked as a mentor and evaluator at OpenClassrooms, providing personalized support to numerous students and contributing to their professional growth. As a mobile developer at Tamangwa Shipping, he designed several custom systems tailored to the company’s specific needs. Joel also has solid experience in creating and implementing microservices architectures, ensuring scalability and performance. He regularly shares his knowledge and technical advice on his YouTube channel, which is dedicated to the developer community.

    Jean Clayton Seraphin is an accomplished full-stack developer with over five years of experience in the industry. He has honed his skills in building robust APIs using Python and Django, as well as crafting engaging frontend applications with ReactJS. Beyond his expertise in web development, Jean Clayton Seraphin boasts an advanced understanding of servers and cloud services, particularly in the realm of AWS. He is well-versed in Linux administration and proficient in utilizing infrastructure-as-code tools such as Docker, CircleCI, and Nginx to streamline deployment and ensure the scalability and reliability of his projects.

    Table of Contents

    Preface

    Part 1: Fundamentals of Microservices Architecture

    1

    Introduction to Microservices

    Introducing microservices

    Moving toward microservices

    Understanding a big ball of mud

    Understanding the software development process

    Exploring the monolith approach

    What is service-oriented architecture?

    The differences between SOA and microservices

    Advantages of microservices

    Disadvantages of microservices

    Summary

    2

    Diving into Microservices Internals

    Solidifying the communication

    Microservice communication techniques

    Introduction to APIs

    What exactly is REST?

    HTTP-based REST implementation

    HTTP response status codes

    Introduction to GraphQL

    Remote Procedure Call

    Synchronous microservice communication

    Asynchronous microservice communication

    Essential communication patterns

    Message brokers

    Summary

    3

    What Do You Need Before Getting Started?

    Technical requirements

    JavaScript essentials

    JavaScript engine

    JavaScript runtime

    Callback-based asynchronous JavaScript

    The way to promises

    Promise API

    Async/await in JavaScript

    Microtask queue

    Node.js essentials

    Summary

    4

    Stack Development Technologies

    Technical requirements

    Node.js and its installation

    Installing Node.js for Windows

    Installing Node.js for macOS and Linux

    Node.js frameworks

    Express.js

    NestJS

    Choosing between Express.js and Node.js

    Choosing the right IDE

    Understanding and installing Docker

    Understanding and installing Apache Kafka

    Understanding and installing Git

    Installing Postman

    Installing MongoDB

    Summary

    Part 2: Building and Managing Microservices

    5

    Basic CRUD Microservices

    Technical requirements

    Understanding business requirements

    Tools to develop a basic microservice

    Preparing our first project

    Understanding the concept of packages

    Understanding the package.json file

    Understanding index.js files

    Installing the required packages

    Defining the internal architecture of our microservice

    MVC architectural pattern

    Integrating MVC into our Node.js project

    Hands-on account microservice development

    Implementing our data-access functionalities

    Implementing the M in MVC

    Storing configuration

    Implementing the business layer

    Implementing the controller

    Simple data validation for your API

    Implementing routing

    Constructing our web application

    Combining all the elements

    Running and testing our first microservice

    Creating a new account

    Getting an account by ID

    Updating an account by ID

    Gettings all accounts

    Deleting account by ID

    Summary

    6

    Synchronous Microservices

    Technical requirements

    Understanding the requirements for the transaction microservice

    Tools to develop the transaction microservice

    NestJS

    Docker

    Prisma ORM

    Hands-on transaction microservice development

    Dockerizing your PostgreSQL instance

    Modeling the data

    Seeding test data

    Implementing the transaction service

    Configuring Swagger

    Working on transaction implementation

    Establishing synchronous communication with the account microservice

    Summary

    7

    Asynchronous Microservices

    Technical requirements

    Understanding the requirements

    Exploring asynchronous communication

    Implementing an asynchronous transaction microservice

    Getting started with Kafka for NestJS

    Cluster and brokers in Kafka

    Topic and partition concepts in Apache Kafka

    Configuring Apache Kafka

    Adding an asynchronous nature to a transaction microservice

    Adapting an account service to new requirements

    Testing our microservices together

    Summary

    8

    Real-Time Data Streaming Using Microservices

    Technical requirements

    What is real-time streaming?

    Why real-time data is essential

    Understanding use cases

    Relationship between real-time streaming and microservices

    Microservices we will develop

    Getting started with an earthquake streaming API

    Implementing the earthquake stream consumer

    Summary

    Part 3: Securing, Testing, and Deploying Microservices

    9

    Securing Microservices

    Technical requirements

    Security, authentication, and authorization in microservices

    Understanding security

    Exploring authentication

    Defining authorization

    Best practices for authorization

    Difference between authentication and authorization

    Getting started with JWTs

    Implementing an Authentication microservice

    Integrating token-based authentication for the account microservice

    Summary

    10

    Monitoring Microservices

    Technical requirements

    Importance of observability

    Introduction to logging

    Logging levels and node libraries

    Log formats

    Best practices for logging

    Implementing logging in your microservices

    Centralized logging with Elasticsearch, Logstash, and Kibana (ELK) stack

    A brief introduction to Logstash

    A brief introduction to Elasticsearch

    A brief introduction to Kibana

    Summary

    11

    Microservices Architecture

    Technical requirements

    Getting started with an API gateway

    How an API Gateway works

    Single versus multiple API gateways

    Implementing microservices using an API gateway

    CQRS and event sourcing

    Understanding CQRS

    Event sourcing

    Event store

    Implementing CQRS and event sourcing

    Commands and handlers

    Implementing an aggregate root

    Implementing projection

    Implementing API functionalities

    Testing an application

    Service Registry and discovery in microservices

    Understanding Service Registry and discovery

    Approaches for implementing Service Registry and Discovery

    Implementing Service Registry

    Summary

    12

    Testing Microservices

    Technical requirements

    Understanding testing in a microservice architecture

    Understanding unit tests

    Introducing unit testing packages

    What should we test in unit testing?

    Implementing unit tests for the account microservice

    Writing unit tests for the transaction microservice

    Comparing mocks, stubs, and spies in unit tests

    Mocks

    Stubs

    Spies

    Understanding and implementing integration tests

    Summary

    13

    A CI/CD Pipeline for Your Microservices

    The essentials of CI/CD processes

    Understanding CI

    Understanding CD

    Integrating CI/CD into microservices

    Working with Azure Cloud

    Working with GitHub Actions

    Understanding Secrets

    Building a pipeline

    Summary

    Index

    Other Books You May Enjoy

    Preface

    Hello there! Welcome to Hands-On Microservices with JavaScript, a journey through the fascinating intersection of one of the most popular programming languages and the ever-evolving world of microservices architecture. JavaScript, with its versatility and ubiquity, combined with the modular, scalable power of microservices, forms the perfect duo for modern software development. This book is designed to bridge these two worlds, offering a comprehensive guide to building, managing, and scaling microservices with JavaScript.

    The rise of microservices has revolutionized the way we think about software architecture. Gone are the days when monolithic applications dominated the landscape, offering simplicity but at the cost of scalability and flexibility. Microservices, with their promise of independent, self-contained units, have brought about a new era of development: agile, resilient, and highly scalable. However, with great power comes great responsibility, and the challenges of adopting a microservices architecture should not be underestimated.

    In this book, we’ll take you step by step through the process of understanding and implementing microservices using JavaScript. Each chapter is crafted to not only introduce you to the theoretical concepts but also to provide hands-on guidance that you can apply in real-world scenarios.

    We will start with an introduction to microservices, exploring their core principles, benefits, and challenges. From there, we will delve into the internals of microservices, focusing on communication techniques and patterns that are essential for building robust systems. We’ll also cover the foundational knowledge you need in JavaScript and Node.js before diving into more advanced topics, such as real-time data streaming, securing your microservices, and deploying them to production.

    This book is not just about writing code; it’s also about understanding the architectural patterns and best practices that will allow you to build scalable, maintainable, and efficient microservices. Whether you’re an experienced developer looking to expand your skill set or a newcomer eager to explore the world of microservices, this book is designed to be your guide.

    Thank you for embarking on this journey with me. I hope this book will not only enhance your technical skills but also inspire you to push the boundaries of what you can achieve with microservices and JavaScript.

    Let’s dive in!

    Who this book is for

    This book is designed for software developers, architects, and IT professionals who are eager to dive into the world of microservices using JavaScript. Whether you’re new to microservices or looking to enhance your existing knowledge, this book provides practical insights and hands-on experience to help you build, manage, and scale microservices in a real-world context.

    You are likely to benefit from this book if you belong to one of the following groups:

    JavaScript developers: If you’re a JavaScript developer interested in expanding your skill set into the microservices architecture, this book will guide you through the process. You’ll learn how to apply your existing JavaScript knowledge to build scalable and resilient microservices, gaining insights into best practices, common challenges, and effective solutions.

    Software architects: For architects looking to design and implement microservices architectures, this book offers a comprehensive exploration of patterns, tools, and strategies. You’ll learn how to make informed decisions on structuring and deploying microservices, ensuring that your systems are both flexible and robust.

    DevOps and IT professionals: If you’re involved in the deployment, monitoring, and maintenance of microservices, this book will equip you with the knowledge to manage these systems effectively. You’ll gain a deep understanding of CI/CD pipelines, containerization, orchestration, and monitoring techniques that are critical for running microservices in production environments.

    This book will provide you with the practical knowledge and tools you need to successfully navigate the complexities of microservices architecture with JavaScript, positioning you for success in today’s fast-paced development landscape.

    What this book covers

    Chapter 1

    , Introduction to Microservices, provides an introduction to microservices architecture, exploring its core principles and defining microservices as small, independent units focused on specific functionalities. This chapter also contrasts microservices with traditional monolithic architecture, highlighting the pros and cons of each approach and setting the stage for the rest of the book.

    Chapter 2

    , Diving into Microservices Internals, delves deeper into the internal workings of microservices. It covers microservice communication techniques, including REST, GraphQL, and Remote Procedure Call (RPC), and explains both synchronous and asynchronous communication methodologies. The chapter also explores popular communication patterns such as API gateways and message queues, providing a theoretical foundation that is essential for practical implementation.

    Chapter 3

    , What Do You Need Before Getting Started?, focuses on the essential concepts of JavaScript and Node.js that you need to understand before building microservices. This chapter covers JavaScript engine internals, asynchronous programming, the Node.js runtime environment, and the crucial role of threading and runtime management in building effective microservices.

    Chapter 4

    , Stack Development Technologies, introduces the essential tools and technologies required to develop and manage microservices with JavaScript. This includes a deep dive into Node.js and various frameworks, choosing the right IDE, and the installation and use of Docker and Git. The chapter also covers Postman, a key tool for testing APIs and interacting with microservices during development.

    Chapter 5

    , Basic CRUD Microservices, takes a practical approach by guiding you through the development of your first microservice using Express.js. This chapter covers the tools required, the internal architecture of microservices, and the step-by-step process of creating and testing a basic CRUD (Create, Read/Retrieve, Update, Delete) microservice, preparing you for more complex implementations.

    Chapter 6

    , Synchronous Microservices, explores the creation and orchestration of synchronous communication between microservices. This chapter focuses on building a second microservice using NestJS and establishing communication between services.

    Chapter 7

    , Asynchronous Microservices, delves into the world of asynchronous communication, a crucial aspect of building scalable systems. The chapter covers the implementation of Apache Kafka for asynchronous messaging, setting up the infrastructure for Kafka with NestJS, and building an asynchronous transaction service. It also breaks down Kafka’s core concepts and explains how to incorporate asynchronous communication into your microservices architecture.

    Chapter 8

    , Real-Time Data Streaming Using Microservices, explores the power of real-time data streaming within a microservices ecosystem. This chapter covers the concept of streaming, its benefits, and how to implement stream processing microservices using Node.js. It also demonstrates how to integrate these services with Apache Kafka to build a real-time data pipeline.

    Chapter 9

    , Securing Microservices, focuses on the fundamental aspects of securing microservices by implementing robust authentication mechanisms. It covers the use of JSON Web Tokens (JWT) for stateless authentication, discusses centralized and decentralized approaches to security, and demonstrates how to build a dedicated authentication microservice. Additionally, best practices for ensuring your microservices' confidentiality, integrity, and availability are provided, offering a solid foundation for secure microservice architectures.

    Chapter 10

    , Monitoring Microservices, focuses on equipping your microservices with robust observability and monitoring practices. This chapter covers the importance of logging and monitoring in microservice architectures, ensuring that you can effectively track the health and performance of your system. It introduces essential observability concepts such as logs, metrics, and traces and explores centralized logging with the ELK Stack (Elasticsearch, Logstash, and Kibana). By the end of this chapter, you’ll have a strong foundation for implementing logging and monitoring strategies to keep your microservices resilient and responsive.

    Chapter 11

    , Microservices Architecture, provides a deep dive into advanced architectural patterns for microservices. This chapter explores the API gateway, event-sourcing, and Command Query Responsibility Segregation (CQRS) patterns to separate reads and writes.

    Chapter 12

    , Testing Microservices, emphasizes the importance of testing in maintaining microservices’ stability and reliability. This chapter covers essential testing strategies, including unit tests and integration tests, ensuring that your microservices can withstand any demand and work seamlessly together.

    Chapter 13

    , A CI/CD Pipeline for Your Microservices, unveils the process of automating microservices development through Continuous Integration (CI) and Continuous Delivery (CD). This chapter covers the essentials of CI/CD processes, working with GitHub Actions, building a robust pipeline that streamlines the transition from development to production and deploying your application to Azure Cloud.

    To get the most out of this book

    To fully benefit from this book, you should have a foundational understanding of JavaScript and basic programming concepts. Familiarity with Node.js, including its runtime environment and asynchronous programming model, will be advantageous as you dive into microservices development. Additionally, a basic knowledge of web development and RESTful APIs will help you grasp the communication techniques and patterns discussed in the book. While not mandatory, experience with Docker, Git, and CI/CD processes will enhance your ability to follow along with the practical examples and deployment strategies covered in the later chapters.

    While the aforementioned versions are specific to Windows, Node.js, Docker Desktop, Visual Studio Code, and Postman also work seamlessly on macOS and Linux. Users of these operating systems should download their appropriate versions from the official websites. The core functionality remains consistent across all operating systems, ensuring a similar experience regardless of your platform.

    Important note

    If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

    For your convenience, you can download the source code to follow along with the book. However, most chapters also provide detailed instructions to guide you in writing everything from scratch, ensuring that you understand each step of the process.

    Download the example code files

    You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Hands-on-Microservices-with-JavaScript

    . If there’s an update to the code, it will be updated in the GitHub repository.

    We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/

    . Check them out!

    Conventions used

    There are a number of text conventions used throughout this book.

    Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: To track changes, we are going to add createdAt and updatedAt fields.

    A block of code is set as follows:

    {

        name:AccName1,

        number:Ac12345,

        type:root,

        status:new

    }

    Any command-line input or output is written as follows:

    $ cd transactionservice

    Bold: Indicates a new term, an important word, or words that you see on screen. For instance, words in menus or dialog boxes appear in bold. Here is an example: Go to the Terminal menu, select New Terminal.

    Tips or important notes

    Appear like this.

    Get in touch

    Feedback from our readers is always welcome.

    General feedback: If you have questions about any aspect of this book, email us at customercare@packtpub.com

    and mention the book title in the subject of your message.

    Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata

    and fill in the form.

    Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packtpub.com

    with a link to the material.

    If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com

    .

    Share Your Thoughts

    Once you’ve read Hands-On Microservices with JavaScript, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page

    for this book and share your feedback.

    Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.

    Download a free PDF copy of this book

    Thanks for purchasing this book!

    Do you like to read on the go but are unable to carry your print books everywhere?

    Is your eBook purchase not compatible with the device of your choice?

    Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.

    Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.

    The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily

    Follow these simple steps to get the benefits:

    Scan the QR code or visit the link below

    https://packt.link/free-ebook/978-1-78862-540-1

    Submit your proof of purchase

    That’s it! We’ll send your free PDF and other benefits to your email directly

    Part 1:Fundamentals of Microservices Architecture

    In this part, we will gain a comprehensive understanding of the foundational principles and internal workings of microservices architecture. We will explore what microservices are, how they compare to traditional monolithic architectures, and the various communication techniques and patterns that make microservices a robust and scalable solution. Additionally, we’ll learn the essential JavaScript and Node.js concepts that are necessary to develop microservices.

    This part contains the following chapters:

    Chapter 1

    , Introduction to Microservices

    Chapter 2

    , Diving into Microservices Internals

    Chapter 3

    , What Do You Need Before Getting Started?

    Chapter 4

    , Stack Development Technologies

    1

    Introduction to Microservices

    As human beings, we all go through various stages of development. With each stage we reach, even if it seems like the best at the time, we later realize we still have a long way to go. Each period has its problems, and depending on their size and nature, they require different solutions.

    We humans tend to simplify things. That is why we build our lives around problems and their corresponding solutions. Finding solutions to problems has been our main goal throughout history, perhaps due to our instinct to survive.

    If we consider each piece of software as an individual, they also have problems to solve. Depending on the size and shape of the problems, software has a different structure, which we call architecture. The size and nature of the problems directly affect the architecture of the software. One of these architectural approaches we use is called microservices.

    Microservices are important when it comes to building scalable distributed applications that respond to modern-day concerns. It is also a de facto requirement for most huge companies when they interview you as a developer. The vast majority of technologies we use nowadays try to support microservice development out of the box. So, being a software engineer without microservice knowledge doesn’t make you an ideal candidate in the modern IT world.

    Starting from this chapter, we’re going to dive into the world of microservices. We will build strong theoretical knowledge before moving on to practical sections.

    First, we will go back and try to understand what type of popular approaches were there before microservices. Microservices are important, but understanding the need to apply them is foremost.

    In this chapter, we’re going to cover the following topics:

    Introducing microservices

    Exploring the monolith approach

    What is service-oriented architecture?

    The differences between SOA and microservices

    Advantages of microservices

    Disadvantages of microservices

    Introducing microservices

    A microservice architecture decomposes an application into loosely coupled, independently deployable services that own their data and communicate through lightweight protocols. It breaks down large applications into smaller, self-contained business capabilities, enabling faster development, easier scaling, and better fault tolerance. Microservices enable continuous delivery and agile development by allowing teams to independently build, test, and deploy features. You can imagine an application as an orchestra, where each microservice is a musician playing their part, but in perfect harmony with the others, to create a beautiful symphony.

    What we’ve just mentioned sounds like a silver bullet but as you know, nothing is free and there is no one-size-fits-all solution to the problems we face. The same applies to microservices.

    We, as software developers, love to learn new trends and try to apply them to our practice. But after delving into the details, we understand that every trend is just an encapsulation of old knowledge. Before applying any architecture to software, it is always better to engage in careful planning, discussion, collaboration, and analysis.

    Moving toward microservices

    Creating software is more than just learning a programming language and applying syntactical elements of it to code, to build things. It’s like wielding a hammer and nails; having them in your arsenal doesn’t make you a skilled builder. Similarly, having all the tools doesn’t make you a good software developer.

    As you embark on creating a basic hello world type application, it remains just that – basic. However, it is important to understand that such simple applications don’t warrant payment. If you want your application to have value, it must address tangible real-world challenges – in short, it should hold business value. Adding more business value also brings complexity. In most cases, more business means more complexity. After some time, you’ll realize that instead of dealing with a business, you’re starting to deal with the complexity that your business brought to your application.

    In navigating complexity, we aim to break it down into smaller, maintainable, extensible, and reusable components. Only by doing so can we effectively handle the complexity and future changes. In programming, the only true constant is the need to embrace changes, a principle that remains as-is, not just during the process of creating the application, but until the end.

    This constant change forces us to not only master the selected programming language but also to have an understanding of the business domain. Naturally, this leads to us adopting a design-oriented mindset. Without having good knowledge of business, it is almost impossible to develop valuable software.

    Although the simple applications we write to learn a language may seem useless, when we connect the dots, we get closer to the truth. Isn’t our whole life spent in search of truth? Soon, you’ll realize that the software that meets the customer’s business requirements is the software that matters, and that reflects the truth.

    If you start your development process without carefully analyzing and designing, you’re going to pay a higher price throughout the development itself. The earlier you start with design and analysis, the less likely you are to run into a bigger problem at a later stage. We call our first not properly analyzed and designed application a big ball of mud that uses spaghetti-driven development:

    In software design, the phrase a big ball of mud is used to draw attention to an anti-pattern or a design approach that produces undesirable results. Let’s understand this phrase in more depth.

    Understanding a big ball of mud

    The main issue with a big ball of mud is the lack of structure and organization. The absence of modularity and distinct issue separation in the code base leads to a complex network of interconnected files and functions. Imagine a house that is just a disorganized jumble of rooms and materials with no walls or other distinguishing features. Because everything in it is connected, changes that are made in one part could have a disastrous effect on other parts. It’s like pulling on a loose thread in a badly tailored sweater – you run the risk of the entire garment coming apart. Similarly code fragments are dispersed throughout the code base, which causes inefficiencies when performing maintenance.

    Due to the absence of structure and documentation, maintaining the code base and adding new features is challenging for developers. Imagine attempting to navigate a house devoid of layout or labels; it’s nearly impossible.

    Because of their close coupling, changes in one area can unintentionally disturb seemingly unrelated components. Because of its fragility, the software is prone to mistakes and regressions. Imagine a house built with weak, interconnected supports so that even a small outside force could result in serious harm.

    A big ball of mud may seem like the right choice at first in small, simple projects,

    Enjoying the preview?
    Page 1 of 1