Software development

  • Kafka Consumer Swap: How to Migrate Without Missing a Beat

    Kafka Consumer Swap: How to Migrate Without Missing a Beat

    Apache Kafka is more than a message queue—it’s a distributed log built for fault tolerance and scale. Understanding how it works under the hood is essential for designing an effective migration strategy. Kafka is a publish/subscribe messaging system designed to handle generic data. Unlike traditional queue mechanisms, Kafka can be thought of as a distributed Continue reading

  • ASP.NET Core HybridCache library

    ASP.NET Core HybridCache library

    Almost all real-world applications need to implement a caching mechanism. Caching can drastically improve application performance, scalability, and user experience while optimizing resource use and reducing costs. .NET supports both in-memory and distributed cache implementation and is easily configured via middleware. Additionally, the application code interacts with the IDistributedCache interface and remains completely abstracted away Continue reading

  • Understanding Soft Delete Strategies in Application Design

    When designing an application, it is worthwhile to carefully consider your DELETE strategy. SQL provides us with the power to delete a record from existence. However, doing such a destructive operation might not be the right approach. It could cause us a lot of pain later on. Additionally, there is much value to be gained Continue reading

  • JavaScript testing with Mocha, Chai and Grunt

    Everyone agrees that TDD (test-driven development) is a good thing and yet very few people do it. why? I believe that one of the reason is pure laziness.  It is too much work to click “Run Test” every single time, however there is another more important reason and that is the “feedback loop”, which in Continue reading

  • Mavenize SqlJdbc Jar

    Download SQL Server jdbc driver from here. Open command prompt and cd into the directory until you see the sqljdbc4.jar file. Run the following command, which will mavenize and install the package in your local .m2 repository. mvn install:install-file -Dfile=sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar Now add the dependency in your pom file <dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>sqljdbc4</artifactId> Continue reading

  • Java–Pretty print xml string

    To print a formatted xml string in Java, first convert the raw string into a Document object, then use Transformer class to format the output like so: Now simply call this method to print the formatted xml string for e.g., Continue reading

  • Spring Mvc–Layout/Master pages

    To set up layout pages in Spring you could use SiteMesh. The way you set it up is as follows: Add the latest version of sitemesh to your pom file, during this writing it was v2.4.2 Create a new decorators.xml file within the WEB-INF folder, this file is used to describe where your layout page Continue reading

  • Spring MVC – CSS and JavaScript imports

    In this series we will go through setting up a basic web structure that deals with importing resources (css/javascript), we’ll slowly progress this app in subsequent blog posts by adding layout/master page support as well as reading values from config files.  I will primarily use xml configuration for these setups, you can also do it Continue reading

  • Resource Cleanup functional way

    For some applications there might be times when expensive resources must be cleaned up properly or there might be times where your clients are being irresponsible and forget to wrap your class in using statements resulting in memory leaks or open database connections.  These might be a good time to implement the following strategy by Continue reading

  • URL Through JavaScript

    JavaScript by default gives you full access to the browser’s url property through the global window.location object.  Let’s use this following url as an example: “http://www.demo.com/Sports/Running/Shoes?item=1&size=10&color=green” To get the full url use: To only get the origin use: With these two properties you can extract any values that you want using regular string functions, such Continue reading

  • Onion Architecture

    Recently I have been writing some applications using the Onion Architecture one of which is here: Github.  I guess I’ve been using this pattern for a long time, I just didn’t know the name for it until I read Jeffrey’s blog, which is a very good read.  One thing that you have to consider though Continue reading

  • Testable Object pattern

    UnitTests should be given the same level of respect and care that we put into writing production code, if it is not readable and maintainable then you might as well remove it.  I’ve always struggled with refactoring test code that contains mocked objects that I want to invoke some method on within my tests.  This Continue reading

  • Using Ninject with constructor parameters

    Before I even begin to write about this topic let me clarify one thing.  This is an example of the infamous Service Locator pattern or some call it an anti-pattern.  There are tons of articles on the internet, and I suggest you read some of them before you begin to implement the following sample code.  Continue reading

  • JavaScript: function expression vs. function statement

    In JavaScript, all of the variables and functions are subject to hoisting.  It simply means that the compiler will move both functions and variables to the top of its parent scope. Lets look at an example that depicts how hoisting affects function expression and function statements differently. Both foo1 and foo2 are called before they’re Continue reading

  • Input validation with jQuery

    The jQuery validation plugin provides ways to seamlessly enable client side input validation and allows you to dial the knob from basic – all the way up to fully customized validation rules. Here is an example of a basic form validation which contains the html that we’ll use throughout our examples. One very important thing Continue reading