10 more Rules that will help you write secure, scalable and adaptable programs
Tags: beginners, programming, systems, devjournal
Published: 2023-06-22 01:31:00

Bad programmers worry about the code. Good programmers worry about data structures and their relationships. - Linus Torvalds

10 more Rules that will help you write secure, scalable and adaptable programs:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/chw3xspmssu2womwnym0.png)

## 1. Don't select everything: 

Selecting everything in a query is prone to break things when the table structure changes and it transfers unneeded data. Don't use wildcards when selecting or inserting data.



## 2. Implement fault isolation or swimlanes in your designs:

It consists of eliminating synchronous calls between fault isolation domains, limiting asynchronous calls and handling synchronous call failure, and eliminating the sharing of services and data between swimlanes.



## 3. Never trust a single point of failure: 

Strive for active/active rather than active/passive solutions. Use load balancers to balance traffic across instances of a service. Use control services with active/passive instances for patterns that require singletons.


## 4. Avoid putting systems in series: 

Avoid adding components to your system that are connected in series. When necessary to do so add multiple versions of that component so that if one fails others are available to take its place.


## 5. Ensure you can wire on and off functions:

Develop shared libraries to allow automatic or on-demand enabling and disabling of services. Implement Wire On/Wire Off Frameworks. Work to develop shared libraries that can be reused to lower the cost of future implementation.


## 6. Strive for statelessness:

Choose stateless implementations whenever possible. If stateful implementations are warranted for business reasons,  always push back on the need for a state in any system. Use business metrics and multivariate (or A/B) testing to determine whether state in an application truly results in the expected user behavior and business value.



## 7. Maintain sessions in the browser when possible:

Using cookies to store session data is a common approach and has advantages in terms of ease of scale but also has some drawbacks. Note that unsecured cookies can easily be captured and used to log into people’s accounts.



## 8. Make use of a distributed cache for states:

Many web servers or languages offer simple server-based session management but are often fraught with the problem of user affiliation with specific servers. Implementing a distributed cache allows you to store session data in your system and continue to scale.


## 9. Communicate asynchronously as much as possible: 

Use asynchronous communication techniques to ensure that each service and tier is as independent as possible. This allows the system to scale much farther than if all components are closely coupled together.


## 10. Ensure your message bus can scale: 

Message busses can fail from demand like any other physical or logical system. They need to be scaled. Treat message busses like any other critical component of your system. Scale them ahead of demand.



The earlier 30 rules: [Link](https://dev.to/pragyanatvade/10-more-rules-that-will-help-you-write-secure-scalable-and-adaptable-applications-24hl)


Thanks for reading this.

If you have an idea and want to build your product around it, schedule a call with [me](https://calendly.com/pragyanatvade).

If you want to learn more about DevOps and Backend space, [follow me](https://dev.to/pragyanatvade).

If you want to connect, reach out to me on [Twitter](https://twitter.com/pragyanatvade) and [LinkedIn](https://www.linkedin.com/in/pragyanatvade/).