Reducing Code Duplication in Swift using fundamentals of programming

Duplication, as the name suggests, is something that exists more than once. The same goes for code duplication. It's code that exists many times in the same codebase. An increase in the codebase, a subsequent rise in code duplication - is this what's happening with you? If yes, then: Have you ever thought about why this happens? The code duplication subsequently increases with time as many developers work simultaneously on similar functionalities in the codebase. Is it a good programming practice? No, because coding works on a fundamental principle called DRY, i.e., Don't Repeat Yourself! We must follow the

Rails 7 adds in_order_of for ActiveRecord::QueryMethods and Enumerable

Quite often in our Rails application, we need to retrieve records sorted in a specific order. For example, in an e-commerce application, we want to retrieve the customer orders in the order of "Completed, Cancelled, In Transit, Pending" statuses. The way to do it is to write an explicit SQL query. Starting Rails 7, this can be achieved simply with the help of the in_order_of method for ActiveRecord::QueryMethods and Enumerable. This article explains how we can use the in_order_of method to sort data in Rails 7. 1. ActiveRecord::QueryMethods#in_order_ofConsider we have a

Embedding of Scenario Outline with Data Table in Cucumber

Let's look at how to reduce the complexity of the automation script by combining the cucumber Data table and the scenario outline.

Ruby 3 adds Scheduler Interface for Fibers

Ruby adds Fiber SchedulerInterface to support non-blocking fiber. Splitting long operations into fiber hooks and Scheduler will manage it for us.

Rails 7.1 introduces destroy_association_async_batch_size

Rails 7.1 now allows you to tweak the destroy_async behavior by allowing you to destroy the dependent associations in multiple batches.

How to build a robust chat app using Azure Communications Service?

Let's look into the functions provided by Azure Communication Services used to build a robust chat app and no need to rely on APIs

Rails 7.1 adds authenticate_by when using has_secure_password

Rails 7.1 introduces a method authenticate_by, used with has_secure_password to prevent timing-based enumeration attacks.

Creating Zoom-Out-Slide-In Parallax Effect with Framer Motion

Check out how easy it is to create a stunning Parallax effect using the framer-motion library

Stimulus.js adds inbuilt support for stopping event propagation and preventing default action

It's very common in Stimulus.js to call the .preventDefault() or .stopPropagation() methods on an Event object immediately after a controller's action has been fired: import { Controller } from "@hotwired/stimulus"; export default class extends Controller { open(event) { event.preventDefault(); /* ... action logic ... */ } close(event) { event.stopPropagation(); /* ... action logic ... */ } } But it starts to feel repetitive after a while; which is why a PR introduced by yours truly to the hotwired/stimulus repo makes it so that you can do those things while defining the action descriptors themselves: <div data-controller="modal"> <a data-action="modal#open:prevent">Open</a&

Turbo - The heart of Hotwire

Turbo provides the most basic building blocks for building Hotwire application. In this article, let's learn more about its features.