Share E-Book

Full-Stack Tao Practical lessons on software design with React.js and Node.js (Alexander Kondov) (z-library.sk, 1lib.sk, z-lib.sk)

Author

Rating 3.5 AI initial rating

Log in to rate

Software
Language English

Master Software Design & Architecture This is a book about writing good code with examples written in JavaScript. Software development is about more than shipping features - it's about building code that stands the test of time and remains adaptable to changing requirements. This book teaches principles of maintainable software design, demonstrating how key patterns apply across REST APIs, front-end state, lambda functions, or even tiny scripts. You’ll see domain logic, data access, and transport layers in action, and learn to manage clarity and flexibility. Through practical examples like splitting monolithic handlers or extracting front-end logic, you'll learn to handle complexity with confidence. We cover duplication, reusability, and more, showing why some repetition may beat overkill abstractions. By the end, you’ll refine your taste in code, knowing how to create maintainable software in any environment.

Format PDF
Size 2.3 MB
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
(This page has no text content)
Page 2
Full-Stack Tao Practical lessons on software design with React.js and Node.js Copyright 2025 © Alexander Kondov All rights reserved
Page 3
To my wife. Thank you for giving me the courage to build for the last ten years.
Page 4
Foreword I started writing books as a way to pass on the practical knowledge I've gathered in the industry. I wanted to make sure that all these hours fighting obscure problems are not wasted, and that the little wisdom I have acquired can help someone who is just starting out. This book is precisely that - everything I've learned about software development after a decade in the industry. These are all the ideas and little details I wished someone had told me ten years ago. I think I'm publishing it at an important moment as AI is revolutionizing how we build and maintain software. AI won't replace you, not yet. But it will change how we work as time passes. Much like how we moved from low-level languages to high-level ones, it seems that the level of abstraction in our industry is once again increasing. The ratio between code read and code written will become even higher as we slowly turn into editors rather than writers. It's even more important to have a taste for well-written code and understand the patterns that we've come to as an industry. Software design can be tough to pin down, though. Just when you think you've found a perfect set of rules to follow you end up in another situation that doesn't quite fit the mold. Best practices taken out of context can only take you so far. In the next chapters, we will see how small decisions accumulate into architecture, how some patterns keep repeating in the frameworks and libraries we use, and how software design is applicable everywhere - from the "one-off" scripts we write to solve a problem to the codebases we need to maintain in an enterprise environment. I won't teach you a grand theory of software design and I'm not asking you to remember dogmatic rules. I will show you some guiding questions and walk you through real-world examples so you can develop an intuition about good code. All I'm asking is that you keep an open mind. Some of the chapters you will agree with and they will reinforce the opinions you already have. This is great because it means we're all on the same path and we've discovered the same ideas independently. Other chapters you might disagree with. That's even better - pay attention to them because you will see a different point of view that will expand how you think. Design is something we wrestle with daily and here you won't find the final word on how you should build software, but a conversation about why you might choose one way over the other.
Page 5
Section 1: Breaking Ground
Page 6
A Story I wanted to start this book with a story. It's the story of a team that was put together with the task of building a greenfield project, a new product without a single line of code written for it. A clean slate. They get together, plan it out, split the work between the team members and in half a year they have a working software. Maybe they had to crunch at the end and cut some corners, but they got it done. They have a product that's solving a problem and making revenue. And here's where the easy part ends. Once this product is out into the world it becomes subject to forces the engineering team has no control over. Market conditions change, competitors come out with features you need to replicate, leadership teams change and they shift the direction of the product. Suddenly, it turns out that the initial structure the team put in place is no longer good enough to support the changes they need to implement. They need to add new modules to it, but it only gets more bloated because it's not split in a way that makes this easy. They need to change the color scheme of the web application but it wasn't built with the idea of themes in mind so every style change has to be done manually. They need to display additional data on the screen but the current API can't serve it so they need to make additional requests, slowing down the rendering of the page. The team finds themselves in a rough spot. And they're not to blame. No one could foresee that the company would shift in this direction. They do the best they can but the codebase just wasn't built with change in mind. It had a perfect structure for what it was supposed to be doing, not what the company wanted it to do now. The tech debt backlog keeps growing and changes take longer and longer. As time passes the initial team slowly changes and people move on to other greenfield projects until there are no remaining engineers from the initial team. The developers left maintaining the product have all joined when it was already completed and they don't have the historical context about why things are the way they are. Documentation is non- existent because people had no time (or reason) to document decisions up until now. One more year down the line changing the color of a button and deploying it takes multiple days. Business people are frustrated, engineers are exhausted from working with the codebase they now consider legacy, and it's only a matter of time before someone asks for a rewrite. When some unfortunate VP or executive agrees to the rewrite the engineers roll their sleeves up, start a new repository, and get to work. They create the module structure
Page 7
they've long needed, add theme support from the start, and implement the API capabilities they've been missing. And it's all going according to plan until the company decides to make another change and it turns out that the structure they had in place is now no good. Then the story slowly starts to repeat again. What I want to tell you with this story is that software maintainability is important. I could've just opened with this but facts are not accepted as well as emotion. This story is a pattern that I've lived through multiple times over and I'm sure many of the people reading this book have as well. I've been on the side of the founding team, I've been the person to inherit the messy codebase, and I've even been the one greenlighting a rewrite. Even now I occasionally join a new team or consult a company that is caught somewhere in this endless cycle. What I want to tell them is that yet another rewrite won't save them unless they change the way they're writing software. I hope this book is a step in this direction.
Page 8
Good Code Doesn't Take More Time One of the common misconceptions is that software can't be designed properly unless the engineers are given additional time to put the codebase in a better condition. I've seen messes both in startups pressed for time and in corporations where the teams can have full sprints devoted to refactoring. The decisive factors in both cases are care and knowledge. Do the engineers care enough about the product to put effort into its codebase? Do they have the knowledge about which patterns and principles they can apply to improve its maintainability? You need both answers to be "yes" in order to have a well-structured codebase. If the team cares but they lack the experience you will end up with something under or over-engineered for its purpose. If the team is knowledgeable but doesn't care, then they just won't put in the effort - your codebase's software design will be up to chance. The truth is that you will never find a place where time isn't a factor. There will never be a job where you're not pressed by the business to deliver faster. There might be periods in any company where you get more time to flesh out your work depending on what department you're working for, but we don't build software in isolation and the real world works with deadlines and budgets. So that dreaded question "When is this going to be ready" will come sooner or later. It's not even always about money. Even well-funded tech companies get pressured by investors to go to market quickly. So even though you have the runway to build something "the right way" the company needs to validate its idea quickly, so you will get asked "When is this going to be ready" a lot. I don't mean to discourage you from our profession. I just want to tell you that this is bound to happen everywhere and it's even more important to be able to deliver well- structured code in these situations. It's easy to succumb to cynicism and tell yourself that quality doesn't matter when you get pushed to deliver quickly. But this is precisely when quality matters the most. If you leave behind all principles and ideas and sling code just for the sake of being left alone, every next feature you implement will take more and more time. And you will blame the business for it. Only if you had more time. Only if they understood how important refactoring is. But at the end of the day working with this code is our responsibility, and after a decade in the industry, I decided to take ownership of it and make the best with what I have available rather than hate my job or switch companies with the hopes that I'll find a utopia somewhere. At the end of the day I'm spending most of my time, knee deep in that codebase and I want this time to be enjoyable. I won't tell you that it's possible to get both quality and speed.
Page 9
I won't tell you the mantra that clean is fast and that by writing clean code you will be able to work faster. I don't believe in miracle practices. What I'll try to describe in this book is a common sense approach to building applications that focuses on maintainability. It's not the purist approach that you will read about in the books. It's not a specific pattern applied to the letter. It's an amalgamation of many ideas and practices I've seen throughout the years. But it's the only approach we have when we want to keep our sanity in a realistic work environment. You can read about fascinating architectures that produce beautiful code that's just a pleasure to look at. But this same code is also a nightmare to maintain. I've always been driven by the idea of building products. My love for creating things came before the love of programming and for many years I saw code just as a means to an end. But then I fell in love with the craft and I started respecting mastery more than the end result. After building plenty of unmaintainable spaghetti codebases that I wouldn't touch with a stick, I understood that real craftsmanship is not just in building something but being able to maintain this pile of code for a long time. I've gotten into some heated arguments throughout the years because of my stance on this topic. One engineer refuted my statement with very simple logic. Writing good code takes more time. If you're pressed for time but you want quality you'll have to do overtime, he said. It's hard to argue with that, but let me give it a shot. What does good code mean? You can ascribe many qualities to it - testability, structure, modularity, naming, etc. But I kept asking myself why these aspects of the code in particular. I've come to realize that these are all metrics that help us understand and change the code in question over a long period of time. In other words, these are metrics that contribute to a codebase's maintainability. Let's look at an overly exaggerated example of code I'd consider badly written: function total(p, d) { return p * (1 - d / 100); } This code may make perfect sense when you're writing it but if you stumble across it and have to modify it it will leave you confused. Now imagine if the only change we made to this implementation was thinking of better names for the function and the variables. function calculateTotalPrice(price, discountPercentage) { const discountAmount = price * (discountPercentage / 100);
Page 10
const totalPrice = price - discountAmount; return totalPrice; } It's essentially the same function, but we make it clear that it's used to calculate a price, and the variable name discountPercentage makes it clear that the value passed is a percentage and not just an arbitrary discount number. We add important context using the variable name that could be omitted otherwise. Now, would this code realistically take longer to write? The time it would take you to think of a better variable name (or ask an LLM for help) and structure it better is insignificant, the additional seconds of typing the longer variable names also would have no effect on the time it takes you to deliver your feature. While this is an overly simplified example, even in real-world scenarios where you need to ponder data structures and larger blocks of code, the difference of doing these small steps that improve the readability of your code will have much less of an impact. To write "clean" code what we need isn't infinite time but knowledge and intuition to recognize the aspects that would impact our software's maintainability. We all have limited time but simple things like spending a couple of moments to think of the best name for your variables, functions, and objects will have a better impact on your codebase than thinking of the perfect data structure.
Page 11
Maintainability I thought about how I wanted to write this for a long time. The previous two books I published were collections of best practices aimed at people who needed medicine for a specific problem in their codebases. Naturally, I started this one similarly, exploring advanced concepts from various ends of the web development field - UIs, APIs, message queues, and whatnot. But this still doesn't give people the complete picture. It doesn't give guidance about maintaining quality when you have to make a gnarly change to your freshly written application because of a business pivot. I imagined it as a journey through a very complex web application, building it from scratch, showing how it evolves, and, most importantly, how it changes with time. But to show the reality of building software, we'd have to focus on a domain that will make the book way too specific for its lessons to be applied widely. One lesson I learned the hard way is that building new features is only a subset of the software engineer's work. The vast majority of your time you will be extending and maintaining existing products and systems as they evolve through time. And that’s where the true quality of an engineer is shown. I’m not saying this to sell you boring work. Yes, maintenance doesn’t sound as exciting as building something from scratch. But trust me, everyone can build. You’ll scratch and claw, and hack together solutions you find online, but you will manage to put together a product that will cover the requirements you have. You will prompt the LLM until it gives you working code and you will find a combination of function calls that output the correct result. But the moment you have to change something, though, that house of cards will come tumbling down if it’s not built on solid foundations. The only constant in our field is change. Yet, we're still ill-equipped to deal with it. Software is never set in stone and that's the source of all our problems. While new technologies make us more productive, we need to come up with principles with which to use them to avoid uncomfortable conversations that end with a request to rewrite the codebase. I won’t teach you how to refactor that inherited legacy application that came to mind when you were reading the paragraphs above. Even though we will touch on that topic, this is not a refactoring book. I will teach you how to build better software so no one will have to rewrite your work.
Page 12
Everything Matters To make this book as understandable as possible, I’ve picked JavaScript, React, and Express - all technologies that are widely used by engineers at the time of this writing. Some of the examples use currently popular libraries, but the principles and ideas we will cover are applicable in all languages and environments. The environment you use doesn't matter as long as it's able to solve the technical challenges you have. The high-level concepts that we will discuss transcend beyond technology and time. They were established before the tech stack I will use in this book existed and they will still exist when it's no longer the most popular way to build web applications. So if you've found this book in the distant future and you're reading this wondering if it's still relevant - I'm sure you'll find some wisdom to take home from it. High-level design patterns provide a structural blueprint for your software, helping to ensure that it is architecturally sound and scalable. On the other hand, attention to granular code-level decisions ensures that the individual components of the software are well-implemented and efficient, and that balance is essential. Design patterns make the overall structure of your code easier to understand and maintain, but the little details in the code improve the readability and maintainability of your functions and classes. The high-level patterns create our strategy, but the tactics applied in the code-level decisions are just as important for successful software. Some problems are only addressable in the details. When performance is high on the priority list, you will be sweating the details. When you need to be careful with your memory usage, you will be pondering your data structures. They go hand in hand, and if one suffers it will affect the other as well. Tight coupling between the modules of an application means they can't operate independently and they're ruining the integrity of the patterns you apply. But this is felt at the code level in the form of cascading changes. You modify one module, and you have to do the same with the others it's coupled with. On the other hand, a hard-to-read codebase makes recognizing patterns and opportunities for abstraction harder. Poor function organization and bad naming can undermine the architecture we're trying to establish. You may be using perfectly designed data structures, but if your database logic is mixed with your domain logic you will have a hard time maintaining the codebase over a long period of time. Maintainability depends on harmony between these levels. Well-structured high-level patterns make code easier to understand and modify, but only if supported by clean,
Page 13
consistent low-level implementation. Poor practices at either level create technical debt that compounds over time.
Page 14
Why We Don't Learn Software Design Computer science graduates rarely concern themselves with writing beautiful code because the scientific nature of our work is mostly occupied with the "how". When building the foundations of our programming knowledge, its collaborative aspect is rarely in our focus. The same is true even in bootcamps that pride themselves in preparing developers for the actual job and skipping the academic side of things. But what I've seen in most bootcamps is an environment that only rewards the final product of the person's work, without stressing the importance of well-written code. This means that people learn that the ends justify the means and that there's nothing more important than getting something to work. However, once you leave the academic environment and have to work with other people on actual real-world products, code quality becomes more important than anything else. Suddenly you have to learn to structure your code well, your colleagues ask you to rewrite parts of your pull requests because they're not "clean" enough. A big part of what it means to be an engineer is learning to write code that can be understood by others, but we spend almost no time on that as if it's a skill that everyone is born with. This is not surprising in an academic environment. We don't think about the maintainability of algorithms because we're not concerned with change. No one will have to maintain your quicksort implementation, and you might get bonus points if you manage to implement it more concisely, even if this means that its readability is awful. We're not concerned with the "habitability" of the software we write in an academic environment because no one will have to "live" in it. No one will have to make daily changes to the snippets that you're producing. If there's one thing I believe with all my heart it's that maintainability and expressing yourself clearly is far more important than being able to write a sorting algorithm with the smallest possible time complexity. Don't get me wrong, it was important in the past. When computer performance was the thing we were most concerned with it was important to produce engineers who could make the most out of the machines we had available. But now computing power is cheap, it's engineering time that's expensive. It's better for us to spend it building products, not trying to untangle the mess in the underlying codebase. Chances are that well-written code will even be easier to optimize. Most programming books concern themselves with correctness. Mine is concerned with maintainability. I think there's plenty of excellent content you can find on the former but this is my attempt to make the latter more approachable. By incorporating the principles of good software design we ensure that our code can be understood by experienced people, and more junior colleagues can continue to build well-structured products by
Page 15
following the existing patterns. As the saying goes - teach a man to use the strategy design pattern, he will do software design once; teach him to replace conditional statements with polymorphism, he will do software design for life. Software correctness is trivial compared to software maintainability. The days of writing out algorithms alone are realistically over and knowledge of distributed systems, architecture, and software design becomes even more important in the age of LLMs.
Page 16
Why We Need Principles If you go on a walk through one of these old European cities with rich history you will likely see buildings that are hundreds of years old. The kind with the ornaments and pillars on their facades. Some are in better condition than others but they still stand. People live in them, work in them, take photos with them in the background. They continue to serve their purpose. I wanted to build software like these buildings. Products that people can use for a long time. Products that serve their purpose. It's too much to ask the same from software, though. We've had millennia to master construction work and figure out our habits to decide the best way to build these structures. Compared to that software is still in its infancy. If you're not convinced, I've got an experiment for you. Write a post on a social media website with the programming principle you believe the most in. It won't take more than a day to get some pretty convincing comments that this is not only false but it's also one of the biggest mistakes you could make. We're still figuring this out. At the same time, we can't approach every project thinking about it from the ground up. The three little piggies made a couple of mistakes before they figured out that bricks are more resilient to wolves than other materials and I doubt they'd make the same mistake again. I think we're at the point in our industry where we need to start focusing on successful development practices. But every software project is both unique and the same, and finding the principles that can be applied to all unique cases is difficult. Every domain has its specifics, unique traits that are not found in other businesses, that will dictate the architecture of the software and the technical decisions. But at the same time every digital product has the same problems on an abstract level - network communication, working with data and describing the business logic that it needs to execute. Some say that it's impossible to make general rules that can be applied for every software product. I think it's not only possible but that we're already doing it daily and it's only a matter of describing the successful patterns in a way that will make them easier to communicate and pass on to others. After all, why are so many other fields able to create such fundamental principles but not us? Why is it possible for complex games like chess to come up with fundamental ideas to follow when you're playing, but we can't settle on a few rules to abide by when we're building digital products?
Page 17
If we don't focus on these ideas we'd be thinking about every situation from scratch, wasting time, making errors, and ending up with similar solutions again and again. Why should we do that when we could focus on building our intuition instead? It's doubtful that we'd spend our entire careers working with the same language, in the same environment. When paradigms shift we need fundamental knowledge that we can lean on.
Page 18
Principles Instead of Dogma For many years the codebases I built ended up with a specific design out of pure chance. I felt like implementing something in a specific way, I was in a rush, I had a free Friday afternoon to refactor something - there was no grand idea behind my decisions, just moods and tastes that change with time. Then when I discovered the power of principles I overcompensated. I made specific rules that I followed regardless of my previous working habits. I implemented each component with a custom hook, I made factories and strategies for each module in my REST API, and I obsessed over file organization. Everything had to fit into a principle, everything had to be a pattern. What was the point of studying them if I can't apply them every time I'm writing code? To my surprise, the codebases weren't better off because of this. They were better structured, yes, but we don't organize our applications because of beauty. A beautiful design is a nice side effect, but the point of software design is productivity. We want a codebase that we can work on at a good pace, maintain without exponential development costs, and feel relatively happy while doing so. But from one extreme, I jumped into another and from not thinking about design I started thinking predominantly about it. I turned principles into dogma. When I had a new feature to develop I wasn't bothered by the technical complexity, but about how I'd fit it into this rigid structure that I had created. I experienced true horror when I had to do something in an unplanned or sketchy way because my architecture couldn't support it. My projects looked incredibly well but they weren't set in stone, they weren't a Renaissance building that you can marvel at. They're a living, breathing codebase that you have to work on day after day, and rigidity is not a quality you want. Any application that doesn't have to change can be refactored to a perfect condition. But aiming for perfection is the wrong goal in a world that's changing all the time. I think this overcompensation in over-engineering is normal for any engineer so if you recognize yourself in the words above, don't be bothered. True virtue is always found in the balance. Extremes come easy. But knowing the principles and applying them with context, that's the true craftsmanship that we need to build better software.
Page 19
Do Not Follow Paradigms Blindly When you're getting your driver's license you don't get a license for a specific model of car. You get a license for a category of cars that you can safely drive. You learn principles - the markings on the road, the signs, the rules. Then you can pick whatever car you want. Of course, you'll probably drive better if you're behind the wheel of a car that you know well. You know how far you need to press the pedal, you know that the trunk doesn't close sometimes and you need to lift it up to make sure. If you get behind the wheel of a new car it will take you some time to get acquainted with it. But you will be able to drive it nonetheless. The rules of the road haven't changed even if the vehicle is not behaving exactly as you would expect. I look at programming languages and frameworks the same way. You're not a JavaScript developer or a Go developer. You're a software developer and you need principles that you can use regardless of what environment you're working in. There's nothing wrong with having a favorite language, library, or framework, but it's important not to become blind to other practices. In the context of web development, I've found that using simple objects and functions is a better way for me to model thoughts and requirements than to try and apply OOP to every problem. This, however, doesn't mean that object-oriented programming should be avoided. If I become hellbent on using functional programming patterns I might miss situations in which applying object- oriented principles would actually lead to better-designed code. When we overly rely on one approach, we risk missing valuable insights from others. Think of each programming paradigm, from OOP to functional programming as a lens through which a problem can be viewed. Each has strengths and trade-offs that can shift in value depending on the context. I've found that functional programming is very useful when it comes to data processing. Since we're not relying on shared state there's less context to keep in your head and the code becomes easier to read from top to bottom - it's just operations over the data. OOP is very useful when we want to encapsulate behavior in a way that mirrors real-world relationships. If the problem we're solving can be described as a hierarchy of objects then this would be a perfect solution. Everything that can be written with one approach can be written with the other. Maintaining, refactoring, and adapting code that's shoehorned into a specific paradigm becomes much harder. If you've learned that descriptive code is preferable to imperative code you might resort to extreme practices like using recursion for loops because that's the way to do it in a functional context.
Page 20
A person stumbling on such code a few months later will undoubtedly left stunned about the use of recursion for something so trivial. This may sound like too extreme of an example to be taken seriously, but it's a real story that I've lived through. I was the unlucky engineer to find the recursive loop and it took me a few hours to get in touch with the person who wrote it (thankfully he was still working at the same company) only to find out that there was no reason behind it. Similarly, imagine that you have more complex data manipulations to implement, and in order to adhere to the rest of the codebase you end up doing it with a bunch of Processor , Manager , and Parser classes that you have to inject into one another. This approach would add a lot of unnecessary complexity to an operation that can easily be described by letting the data flow through a set of pure functions, making each operation encapsulated and clear. By following the OOP principles blindly we introduce models and responsibilities into the logic that can be much simpler when implemented as a consecutive set of operations over data. We remove the logic of creating class instances and thinking about the state that they keep inside. By being flexible in our decisions we make our code more maintainable. But isn't switching between object-oriented and functional ways of writing code tiring? Yes if you have to do it frequently, it definitely adds more cognitive load. But in reality, you will have one dominant way of describing logic in your application with occasional small pockets of code where this changes. And by making our code modular (more about this in another chapter) we make sure that these decisions don't leak to the rest of our code.
The above is a preview of the first 20 pages. Register to read the complete e-book.

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
← Back to List