Bringing Innovation to Life: Leading the Samsung The Frame TV for Barclays Promotion

I usually don’t write about physical products, as my enthusiasm lies in building software. However, I couldn’t help but be fascinated by a special promotional project I led last Christmas—the launch of Samsung’s The Frame 43” TV in partnership with Barclaycard. This wasn’t just any TV; it was a piece of art, both literally and figuratively.

At the heart of this promotion was the development of a custom web portal by my team and me that allowed Barclays customers to explore, order, and experience this exclusive product. So I should be excited about the technology I have used to create the web portal. But this time, I am rather excited about the idea of transforming a TV into an art piece.

The Project: A Unique Customer Incentive

Samsung introduced The Frame 43” TV, which looks like a picture frame displaying stunning artwork when not in use. Barclaycard partnered with Samsung to offer a Special Edition version of this TV exclusively to its customers. This exclusive offer for The Frame 43” Television, with the Special Edition Porcelain Blue bezel was designed by acclaimed designer duo Scholten & Baijiings. Our engineering team was responsible for developing the e-commerce platform for this promotion, handling the order process seamlessly.

Also, as the dedicated supplier for this promotion, our company’s warehouse was filled with these exclusive TVs, and we even set up a studio space to experience the product firsthand. I made several visits to the warehouse myself to get a closer look—and I have to admit, I was impressed!

This is how we designed the Portal for them

What Makes This TV Special?

The Samsung The Frame 43” Special Edition comes with a unique Porcelain Blue frame bezel designed by award-winning studio Scholten & Baijings. This limited edition bezel was only available to Barclaycard customers during the promotion.

Hang it Like a Real Frame

One of the standout features of The Frame is its seamless design. It mounts flush against the wall, just like a real piece of art, making it an elegant addition to any space.

Enhance Your Space with Art Mode

When not in use, The Frame displays digital artwork, transforming your living room into a personal gallery. With its high-resolution display and rich colors, the artwork looks as authentic as a real painting.

Minimalist Setup with Invisible Wires

One of my favorite aspects was the near-invisible optical cable that connects all devices. This eliminates clutter and makes the setup look clean and sophisticated.

Smart Sensors for a Smart Experience

The Motion Sensor detects when you enter the room and turns on the screen to display artwork. When you leave, it powers down to save energy. Meanwhile, the Brightness Sensor adjusts the display according to ambient light, ensuring that the artwork looks perfect at any time of the day.

From an engineering perspective, building a simple eCommerce platform for this campaign was not a very exciting challenge. But seeing the project come to life and watching customers receive their exclusive TVs was truly rewarding. This project reaffirmed my belief that technology, whether hardware or software, is at its best when it enhances our daily lives seamlessly. And sometimes, it’s okay to step out of your comfort zone and appreciate the beauty of a well-crafted physical product!

Managing a Huge System Built on Top of a Temporary Project: Challenges and Solutions

During my time at Avinity, I experienced firsthand how a small internal web application, initially built to solve a minor problem, evolved into a large and complex system. We used to call it the “Imagine Platform”, and honestly, it ended up beyond any imagination at one point in time. What started as a temporary project quickly became critical to business operations, requiring continuous development and management. This experience taught me valuable lessons about handling the challenges that come with managing a system that was never meant to scale.

Challenges of Growing a Temporary Project into a Large System

Lack of Proper Architecture: Since the initial system was never meant to scale, it often lacks a robust architecture, making future development difficult.

Technical Debt: Quick fixes and workarounds accumulate, leading to inefficiencies and bugs that slow down development.

Performance Bottlenecks: As the system grows, performance issues arise due to poor initial design choices.

Security Risks: A system that started as a small project may not have been built with security in mind, leading to vulnerabilities.

Scalability Issues: The system may not be able to handle increased load or integrate well with newer technologies.

Steps I Took to Manage the System at Avinity

Gradual Refactoring(Most significant): Instead of rebuilding the system from scratch, I initiated incremental updates to modularize components and introduce microservices where applicable.

Performance Optimization(Most significant): By analyzing system performance and identifying bottlenecks, I was able to implement targeted improvements, such as database indexing and caching strategies.

Automating Processes: To improve efficiency, I introduced automation tools for testing, deployment, and monitoring, reducing manual effort and increasing system stability.

Implementing Documentation: Another step I took was to create some documentation(the idea was to create some detailed documentation, but it never happened for an internal project), which helped developers understand the system structure and avoid redundant work.

Introducing Code Reviews: To improve code quality and reduce technical debt, I enforced a strict code review process that ensured best practices were followed. Modified some poorly written codes and eliminated a lot of not used modules.

Budget Constraints and How to Overcome Them

For small to medium-sized businesses, budget limitations are a significant challenge when managing and upgrading such systems. Investing in a complete overhaul may not be feasible, so companies must find ways to improve efficiency without excessive spending.

Prioritize Critical Updates: Instead of rewriting the entire system, focus on fixing the most pressing issues, such as security vulnerabilities and performance bottlenecks.

Use Open-Source Solutions: Many open-source frameworks, tools, and libraries can help modernize the system without the high costs of proprietary software.

Incremental Refactoring: Instead of a full system rebuild, update parts of the system gradually. Start by modularizing key components and introducing microservices where possible.

Leverage Cloud Services: Migrating parts of the system to cloud-based solutions can improve scalability and reduce infrastructure costs.

Seek External Funding or Partnerships: In some cases, government grants, technology partnerships, or investors might help fund critical technology upgrades

    Best Practices for Managing Large, Evolved Systems

    Managing a system that started as a temporary project taught me valuable lessons. It is essential to plan for the future. Even small projects can grow, so design with scalability in mind. It is also important to avoid technical debt. Cutting corners may save time initially, but it will cost you in the long run. Clear documentation is essential for maintainability and onboarding. Finally, the system should be regularly reviewed and improved to prevent it from becoming unmanageable.

    My experience at Avinity taught me that while budget constraints can make upgrades difficult, strategic planning and incremental improvements can help businesses modernize their systems without excessive costs. By focusing on critical updates, leveraging open-source solutions, and implementing best practices, businesses can ensure their systems remain efficient, scalable, and secure for the future. If you’re facing a similar situation, remember that it’s never too late to make improvements. With careful planning and execution, you can turn a chaotic system into a well-oiled machine that drives your business forward.

    Pre- and Post-Release Checklist for an ASP.NET Application with IIS and SQL

    Releasing an ASP.NET application requires careful planning to ensure a smooth deployment without disruptions. Below is a checklist that I use to cover essential pre- and post-release checks, focusing on database changes, application performance, and stability.

    Pre-Release Checklist

    TaskCheckbox
    Prepare the Code and Database Changes
    Peer-review all code changes. Make sure all code changes are reviewed and approved through pull requests.
    Run automated tests (unit, integration, and functional tests).
    Ensure proper logging and error-handling mechanisms are in place.
    Compile the code in Release Mode and make sure it does not throw any errors.
    Make a list of the files that need to be updated in live. Views/ASPX/ASCX/CSS/JS
    Make a list of any hard-coded value that needs to be changed in any file.
    Gather a list of newly added or updated third-party libraries, NuGet packages, or other resource files, such as images.
    Verify all SQL table schema changes (new tables, column modifications, constraints, etc.) and prepare the script.
    Use ALTER TABLE instead of DROP TABLE to prevent data loss.
    Review and test stored procedures, triggers, and views. Make the script ready.
    Verify new indexes are optimized and do not impact write operations.
    Make a script if you need to add any new data to any table. Or update any existing data in any table.
    Ensure that the SQL script does not have any hardcoded value that requires changing the live environment.
    Make a list of what changes in in web.config or appsettings.json.
    Make a list of any new application settings that are required in live(e.g., API keys).
    Make a list of any dependent systems that need to be updated. Review and list any scheduled jobs and background services that need to change with this release.
    Make a list of any site setup changes required in IIS for this release.
    Database Backup
    Take a full backup of the production database just before the start of the release process.
    Prepare a rollback plan in case of deployment failure.
    Deployment Package Preparation
    Generate and package build the files (e.g., DLLs, CSS, JS files). Make sure the ddl is made in release mode. Minify css/js files.
    Organize and test the SQL scripts with a test database.
    Testing
    Run all unit tests.
    Perform integration testing with the database and external services.
    Conduct performance testing.
    Perform regression testing to ensure existing functionality works.
    Documentation
    Document release notes with changes, new features, and known issues.
    Create a step-by-step deployment guide.
    Communication
    Notify stakeholders about the release schedule and potential downtime.
    Brief the development, QA, and operations teams on the release process.

    Follow the step-by-step deployment guide to make the release. For a major release, it is recommended to schedule downtime and include a maintenance page for the user.

    Once the release is done, this is the post-release checklist.

    Post-Release Checklist

    TaskCompleted
    Verify that the application is running correctly in the production environment.
    Perform tests on critical functionalities.
    Check logs for unexpected errors or warnings.
    Validate integrations with external systems (APIs, third-party services, etc.).
    Monitor database performance and query execution times.
    Perform real-user testing to ensure functionalities work as expected.
    Validate security settings post-release.
    Gather user feedback and address any reported issues promptly.
    Be prepared to roll back changes if critical issues arise.
    Communicate fixes and updates to stakeholders as necessary.

    This checklist ensures a structured and thorough approach to deploying your ASP.NET application and minimizing risks to ensure a smooth production environment. Let me know if I have missed anything!

    Searching for a Specific Text String in SQL Server Objects

    When managing a SQL Server database, you may need to find occurrences of a specific text string within database objects, such as table names, stored procedures, functions, or views. This can be useful for debugging, auditing, or refactoring existing code.

    The following stored procedure, sp_search_code, allows you to search for a specific text string across different database objects, including table names, stored procedures, functions, and views

    CREATE PROC [dbo].[sp_search_code] (
    	@SearchStr VARCHAR(100)
    	,@RowsReturned INT = NULL OUT
    	)
    AS
    BEGIN
    	SET NOCOUNT ON
    
    	SELECT DISTINCT USER_NAME(o.uid) + '.' 
        + OBJECT_NAME(c.id) AS 'Object name'
    		,CASE 
    			WHEN OBJECTPROPERTY(c.id, 'IsReplProc') = 1
    				THEN 'Replication stored procedure'
    			WHEN OBJECTPROPERTY(c.id, 'IsExtendedProc') = 1
    				THEN 'Extended stored procedure'
    			WHEN OBJECTPROPERTY(c.id, 'IsProcedure') = 1
    				THEN 'Stored Procedure'
    			WHEN OBJECTPROPERTY(c.id, 'IsTrigger') = 1
    				THEN 'Trigger'
    			WHEN OBJECTPROPERTY(c.id, 'IsTableFunction') = 1
    				THEN 'Table-valued function'
    			WHEN OBJECTPROPERTY(c.id, 'IsScalarFunction') = 1
    				THEN 'Scalar-valued function'
    			WHEN OBJECTPROPERTY(c.id, 'IsInlineFunction') = 1
    				THEN 'Inline function'
    			END AS 'Object type'
    		,'EXEC sp_helptext ''' + USER_NAME(o.uid) + '.' 
              + OBJECT_NAME(c.id) + '''' 
             AS 'Run this command to see the object text'
    	FROM syscomments c
    	INNER JOIN sysobjects o ON c.id = o.id
    	WHERE c.TEXT LIKE '%' + @SearchStr + '%'
    		AND encrypted = 0
    		AND (
    			OBJECTPROPERTY(c.id, 'IsReplProc') = 1
    			OR OBJECTPROPERTY(c.id, 'IsExtendedProc') = 1
    			OR OBJECTPROPERTY(c.id, 'IsProcedure') = 1
    			OR OBJECTPROPERTY(c.id, 'IsTrigger') = 1
    			OR OBJECTPROPERTY(c.id, 'IsTableFunction') = 1
    			OR OBJECTPROPERTY(c.id, 'IsScalarFunction') = 1
    			OR OBJECTPROPERTY(c.id, 'IsInlineFunction') = 1
    			)
    	ORDER BY 'Object type'
    		,'Object name'
    
    	SET @RowsReturned = @@ROWCOUNT
    END
    
    
    

    How to Use the Stored Procedure

    To execute this stored procedure and search for a specific text string, you can use the following SQL command:

    EXEC sp_search_code 'Customer';
    

    This command will return a list of tables, views, stored procedures, and functions containing the word Customer in their names or definitions.

    This stored procedure is a powerful tool for searching database objects based on a specific text string. Whether you need to find references to a particular table or locate a function containing certain logic, this procedure simplifies the process. You can further enhance it by adding search capabilities for triggers, indexes, or column names as needed.

    Deadlock in SQL server

    We have been struggling with many deadlocks in an old project that started getting busier during working hours. This project was initially built quickly to solve a small problem in stock operation. Over the last three years, a lot of code and processes have been added to the platform. As a result, we have a big platform with a very unstable base of code structure. This is one of the common issues where we see projects were developed without any longer-term plan.

    So, what is deadlocks?

    SQL Server deadlocks occur when two processes/queries attempt to access the same data, but each query has already locked the data that the other query needs. In simple terms, it is a lock that takes you to the dead end. While query optimization can improve the speed and efficiency of queries, it’s crucial to understand the root cause of deadlocks and how to prevent them. A deadlock happens when two or more tasks permanently block each other, with each task holding a lock on a resource that the other tasks are trying to acquire. 

    For example, Process-1 needs to modify data in the Product table, which also requires reading data from the ProductDetails table. So, Process-1 puts a lock in the Product table and requests data from the ProductDetails table. At the same time, Process-2 needs to modify data in the ProductDetails table, which also requires reading data from the Product table. So, Process-2 puts a lock in the ProductDetails table and requests data from the Product table.

    At this point neither process can finish because they are both waiting on locked resources. i.e. they are deadlocked. One of them must be killed to allow either of them to finish. SQL decides which is the “least expensive process to kill” and it becomes the Deadlock victim.

    Let’s not confuse deadlock with Blocking.

    Although it’s based on the same principles, blocking is much simpler than deadlock. Blocking happens when two or more processes need access to the same resource. In Microsoft SQL Server, only one process can use a resource at any given time. If the first process is already using (or locking) the resource, the second process is blocked from accessing it. SQL Server will then make the second process wait until the first process has completed its task.

    What was happening in our case

    We have many SQL jobs that frequently get product feeds from our supplier and update the product, product details table and a few other tables. During the process, the SQL job locks the Product table to make necessary updates and request details of the product from the ProductDetails table. This process takes a long time due to the large volume of data the SQL job processes. At the same time, if anyone in our team uses our internal web applications to update any product details that require updating the ProductDetails table and getting data from the product table, the web application becomes the victim of the deadlock. Also, the team always complains that the product update process takes a long to time complete even they do not get the deadlock.

    So what we have done to resolve the issue

    We have identified that our platform is a victim of both blocking and deadlock. So, we have taken the following steps to improve the issue.

    Create a separate temporary Product table to hold the products from all SQL jobs. This will free the main Product table for the web applications.

    Put multiple similar SQL jobs under one job but in steps. Set to run the following step once the current step is completed and succeeds. The last step is to update the main Product table from the temp Product table.

    In our case it is important to allow our web application to get the priority. So we set SET DEADLOCK_PRIORITY LOW for the query behind the SQL job. By default SQL set SET DEADLOCK_PRIORITY NORMAL for all queries so the web application query will have the priority and SQL Job will be the victim of the deadlock.

     Use ” WITH (NOLOCK)” for the select queries, which is equivalent to READ UNCOMMITTED

    Ensure enough Index and tune the transactional code to make sure the query runs faster.

      Deadlock code example

      To experience the deadlock, you can use the code below.

      Creating two tables and adding some sample data

      CREATE TABLE ##Product (
          ProductId INT IDENTITY,
          ProductName VARCHAR(16),
          ProductCode VARCHAR(16)
      )
      GO
      
      INSERT INTO ##Product (ProductName, ProductCode)
      VALUES ('iPhone', '123'), ('iPad', '124')
      GO
      
      CREATE TABLE ##Supplier(
          SupplierId INT IDENTITY,
          SupplierName VARCHAR(64),
          SupplierEmail VARCHAR(64)
      )
      GO
      
      INSERT INTO ##Supplier (SupplierName, SupplierEmail)
      VALUES ('Apple', '222-555-6666'), ('Samsung', '888-568-1234')
      GO
      

      Now, Open two separate query windows in SSMS. In one window, enter the code for session 1, and in the other, enter the code for session 2. Execute the steps in each session alternately, switching between the two query windows as needed. You’ll notice that each transaction holds a lock on a resource that the other transaction is also trying to access.

      -- Step 1 --  -- Run in Session 1 --
      BEGIN TRAN;                 
      
      UPDATE ##Product SET ProductName = 'Apple Watch'
      WHERE ProductId = 1
      
      -- Step 2 -- --  Run in Session 2 --
      BEGIN TRAN;
      
      UPDATE ##Supplier SET SupplierEmail = N't@t.com'
      WHERE SupplierId = 1
      
      -- Step 3 -- --  Run in Session 1 --
      UPDATE ##Supplier SET SupplierEmail = N's@s.com'
      WHERE SupplierId = 1
      
      -- Step 4 -- --  Run in Session 2 --
      UPDATE ##Product SET ProductCode = '234'
      WHERE ProductId = 1
      
      And You will get deadlock.
      
      Msg 1205, Level 13, State 45, Line 7
      Transaction (Process ID 70) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.