Testing - Finding Errors Early

Errors in software systems are inevitable. They can be caused by a variety of factors, including human error, hardware failure, or software bugs. Testing a software helps in finding errors early, It is important to find errors as early as possible to avoid any sort of issues in production. Let’s explore some checkpoints in which errors can be found early. Build Time Compiler performs a syntax check on the code and reports any errors. It includes type checking to ensure that the types of variables are used correctly. The limitations depends on the language and compiler, on how much it can check. Unit Testing Unit tests are written to test individual units of code. It helps in finding errors in the code logic. Unit tests works like a double entry book keeping system. Integration Testing Integration tests helps to check if different systems are interacting correctly, and if the data is being passed correctly. It is very helpful to find errors in systems which are dynamically typed and the cases of interactions needs to be valid. Load Testing Load tests help us to find errors in the system when it is under heavy load. We verify if the system is able to handle the incoming requests and if it is able to respond within the expected time. It also helps identify the limits of the system. End-to-End Testing End-to-End tests are mostly used to test the entire system from start to finish in a user-like environment. It helps find errors in a user point of view, while using the system. typically for e2e systems, we deploy the whole system and have another software interact with it like a user. It’s a good practice to have a combination of these tests to find errors early in the development process. It becomes crucial to run more tests as the system grows and becomes more complex. ...

Bash - Overview

Bash Scripting is a handy and powerful tool for automating tasks on a Unix-like operating system. It is a command language interpreter that executes commands read from the standard input or from a file. Bash also incorporates useful features from the Korn and C shells (ksh and csh). Variables Variables in Bash are used to store data. They can be used to store strings, numbers, and other types of data. Variables are defined using the = operator. ...

API Patterns

API is a common concept among software systems. Different software systems require to communicate with eachother to invoke some functionality or to exchange data. Since it’s a frequent requirement, it’s important to have a set of standards. There are different patterns and best practices that can be used to design and implement APIs. RESTful API REST APIs are designed around resources, which are any kind of object, data, or service that can be accessed by the client. They are mainly used for CRUD operations (Create, Read, Update, Delete) on resources. They use standard HTTP methods (GET: Read, POST: Create, PUT: Update, DELETE: Delete) and status codes to perform these operations on the resources. REST APIs are stateless, meaning that calls can be made independently of one another, and each call contains all of the data necessary to complete itself successfully. GraphQL GQL is a query language for APIs and a runtime for executing those queries by using a type system you define for your data. Graphql APIs are designed with a schema that defines the types and fields that can be queried. The Client can request only the data it needs, and the server will return only the requested data. The shape of response follows the shape of the request. gRPC It is designed for low latency and high throughput communication between microservices. gRPC is particularly suitable for microservices and between systems written in multiple programming languages due to its support for multiple programming languages. It based on HTTP/2, which is a binary protocol that is more efficient than HTTP/1.1. It uses Protocol Buffers as the Interface Definition Language (IDL) for describing both the service interface and the structure of the payload messages. Webhooks Webhooks are user-defined HTTP callbacks, which are triggered by specific events. When an event occurs, the source site makes an HTTP request to the URL configured for the webhook. They are useful for integrating different systems or for events in asynchronous communication. WebSocket WebSocket provides two-way (full duplex) communication channels over a single TCP connection. It enables interaction between a client and server in a real-time manner. It is particularly useful for applications that require real-time updates, such as chat applications, online gaming, and financial trading platforms. Each of these standards are useful and are best practices for their specific use cases. It’s important to choose the right pattern based on the requirements of the system. ...

Razor Pages - Overview

Razor pages provides a way to build web applications using a page-focused approach. Under the hood, it uses the same routing and middleware as MVC, and it provides directory-based conventions for views. Pages can have a viewmodel where we can define page data and actions. Pages: Pages are the main part of a Razor Pages application. Pages are created in the Pages directory and are named with the .cshtml extension. Each page can have a corresponding .cshtml.cs file which contains the page model. Page Model: The page model is responsible for handling requests and rendering the page. It is a class that contains the data and actions for the page. The page model is defined in a .cshtml.cs file and is associated with a .cshtml file. Getting Started Create a new project using the dotnet command-line interface. ...

Dotnet MVC - Overview

C# asp.net MVC is a web application framework that provides a model-view-controller architecture. The MVC pattern separates the application into three main components: the model, the view, and the controller. This separation of concerns makes it easier to manage and maintain the application. This structure also makes it easier to test and debug the application. Model: The model represents the data and core business logic related to data of the application. It is responsible for managing the data and the rules for accessing and updating the data. The model is independent of the user interface and can be reused across different views. View: The view is responsible for presenting the data to the user, think of HTML Templates. It is the UI of the application and is responsible for rendering the data to the user. The view is independent of the model and the controller and can be reused across different models and controllers. Controller: The controller is primarily responsible for handling user input and requests. It processes the input, interacts with the model, and selects the view to be rendered. The controller is responsible for the flow of the application and is the glue between the model and the view. Underneath, it uses kestrel server to host the application and uses asp.net core for web development. ...

Scala - Testing

Scala supports testing using the JUnit and ScalaTest frameworks. These frameworks provide a way to write and run tests for your Scala code. JUnit is a popular choice for unit testing in Scala due to its simplicity and extensibility. Writing Tests JUnit provides a set of annotations that can be used to write tests. The @Test annotation is used to mark a method as a test method. The @Before and @After annotations are used to mark methods that should be run before and after each test method, respectively. ...

Rust - Testing

Rust has built-in support for testing with the cargo and assert. We can write tests in Rust using the #[test] attribute and the assert! macro. The cargo command-line interface can be used to run the tests. The tests can be written in the same file as the code being tested, or in a separate file. Writing Tests Suppose we have a function add in main.rs which adds two numbers. // main.rs pub fn add(a: i32, b: i32) -> i32 { a + b } We can write a test for this function in the same file. ...

Python - Testing

Python unittest library is a built-in library that provides a way to write and run tests for your Python code. It is a part of the Python standard library and is widely used for writing unit tests in Python. pytest is another popular choice for testing in Python due to its simplicity and extensibility. Writing Tests unittest provides a set of classes and methods that can be used to write tests. The unittest.TestCase class is used to define test cases, and the assert methods are used to verify the expected behavior of the code under test. ...

Kotlin - Testing

Writing tests in Kotlin can be done using the JUnit and KotlinTest frameworks. These frameworks provide a way to write and run tests for your Kotlin code. JUnit is a popular choice for unit testing in Kotlin due to its simplicity and extensibility. Writing Tests JUnit provides a set of annotations that can be used to write tests. The @Test annotation is used to mark a method as a test method. The @Before and @After annotations are used to mark methods that should be run before and after each test method, respectively. ...

C# - Testing

C#, NUnit has a lot of features that makes it a good choice for testing. It provides features for writing and running tests, and also for creating test fixtures and test suites. NUnit is a popular choice for unit testing in C# due to its simplicity and extensibility. Writing Tests NUnit provides a set of attributes that can be used to write tests. The Test attribute is used to mark a method as a test method. The TestCase attribute is used to provide test data for parameterized tests. The SetUp and TearDown attributes are used to mark methods that should be run before and after each test method, respectively. ...