<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sudhakaran Packianathan on Medium]]></title>
        <description><![CDATA[Stories by Sudhakaran Packianathan on Medium]]></description>
        <link>https://medium.com/@lksudha?source=rss-8926fba64384------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8Op9n7J2smpPIKbe7va0aw.jpeg</url>
            <title>Stories by Sudhakaran Packianathan on Medium</title>
            <link>https://medium.com/@lksudha?source=rss-8926fba64384------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 03:51:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lksudha/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Spaghetti PHP to CodeIgniter 4: An AI-Assisted Migration Journey]]></title>
            <link>https://medium.com/@lksudha/from-spaghetti-php-to-codeigniter-4-an-ai-assisted-migration-journey-293e5894dfa8?source=rss-8926fba64384------2</link>
            <guid isPermaLink="false">https://medium.com/p/293e5894dfa8</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[chatgpt4]]></category>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[ai-development]]></category>
            <dc:creator><![CDATA[Sudhakaran Packianathan]]></dc:creator>
            <pubDate>Sat, 03 May 2025 13:59:37 GMT</pubDate>
            <atom:updated>2025-05-03T14:12:23.304Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0JrCeCrmeYCgs1MAG-LJMg.png" /><figcaption>Modernizing legacy PHP with CodeIgniter 4 guided by ChatGPT.</figcaption></figure><h3>Introduction</h3><p>I wanted to explore how LLMs are effective for understanding and refactoring legacy apps. One of my earlier projects involved a stack of legacy PHP and MySQL applications: several airport transfer booking engines and a back-office dispatch/admin app used by the call center and management. We were initially hosted on a leading hosting provider and then after covid moved to AWS lightsail for cost optimization. The original apps were developed in php 5.3 and mysql 5.7. For the AWS migration, we performed a quick refactoring to php 7.2 and mysql 7. Since there was significant code duplication, we developed a common library to share code across our booking engines and the back-office app.</p><h3><strong>The starting Point</strong></h3><p>At that time, due to resource constraints, we didn’t consider rewriting the app using an MVC-based PHP framework. I started using ChatGPT to understand some of the code, and I was surprised <strong>with the explanations</strong> provided by ChatGPT and other LLMs. Some of the explanations were even clearer than my own understanding of the code.</p><p>My initial plan was to use ChatGPT to refactor and the code and I was using ChatGPT to understand the home page of the back-office app to get ideas for refactoring. ChatGPT suggested using an MVC framework and recommended CodeIgniter over Laravel. The reasoning was that CodeIgniter was <strong>lighter weight</strong> than Laravel and potentially better for quick <strong>prototyping</strong>. ChatGPT even gave me quick code to rewrite the home page of the back office app. The existing home page was one of the most complex parts, using numerous iframes and resembling spaghetti code. ChatGPT recommended an AJAX-based approach for the home page, which I was able to quickly implement and get running. Using ChatGPT, I quickly migrated the menu, navigation, and some key admin reports to CodeIgniter. The migration occurred over three weeks, with each report taking roughly 2 to 3 hours per day for generating code with ChatGPT, refining it, and testing. I am documenting the lesson leaned in the following sections.</p><h3>Migration Process</h3><p>Initially I did not start with well defined prompts. I copied the existing legacy php code and asked ChatGPT for migration approach. The model I used was GPT-4o, and it provided a step-by-step approach, generating the controller code, model, view, and finally the routes. I then copied the generated code into Visual Studio Code, tested it, and used ChatGPT again to help debug any issues. Remarkably, during this process, I barely wrote any code manually; I primarily used ChatGPT to generate code and Copilot to assist with fixes <strong>and</strong> debugging during the migration.</p><h3>Challenges Faced</h3><p>Effectively using ChatGPT for this migration involved a learning curve, particularly around managing conversation context and writing precise prompts. To improve, I leveraged ChatGPT itself, asking it to critique my interaction process after completing the migration for each component. The following sections detail the feedback and suggestions it provided, highlighting common pitfalls and better techniques.</p><h4>Context</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QF9DAChGehR52_2CMStq2g.png" /><figcaption>ChatGPT provided context improvements suggestions</figcaption></figure><h4>Prompting</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qT40E5owJcJmoej9HIE2ZA.png" /><figcaption>ChatGPT provided prompt improvements</figcaption></figure><h4>Missed out features</h4><p>Given the original code, I initially assumed ChatGPT <strong>would</strong> migrate _everything_ to the new CodeIgniter style. However, some features or nuances <strong>were missed</strong> during the automated migration. It’s crucial to thoroughly review and test the generated code to ensure the migration is complete and accurate.</p><h3>Key Lessons Learned from AI-Assisted Migration</h3><p>Migrating legacy code with AI tools like ChatGPT and Copilot was an enlightening experience. Here are the key takeaways:</p><ol><li><strong>AI as a Tool, Not a Replacement (The “Overconfident Intern”):</strong> <br> — The analogy holds true: treat AI like an enthusiastic but inexperienced helper. It excels at generating boilerplate, translating patterns, and suggesting approaches (like recommending CodeIgniter and AJAX).<br> — <strong>Actionable Insight:</strong> _Always_ provide explicit, clear instructions. Don’t assume it understands implicit business logic or project nuances. Be prepared to guide, review, and correct its output meticulously.</li><li><strong>Mastering Context is Crucial:</strong> <br> — LLMs are stateless. You must constantly reinforce the context.<br> — <strong>Actionable Insight:</strong><br> — Use checkpoints: Summarize progress before switching tasks (“Okay, report X is done, now let’s work on Y. Remember we need these filters…”).<br> — Provide relevant files/structure upfront. Attaching files with brief notes on their purpose significantly improves results.<br> — Repeat key context in new sessions or threads.</li><li><strong>Iterative Refinement and Feedback Loops are Key:</strong> <br> — Don’t accept the first output blindly. Iterate with the AI. Ask _why_ it chose a specific approach (“Why use this CI4 feature instead of that one?”).<br> — <strong>Actionable Insight:</strong> Use the AI to critique _itself_ and _your process_. Regularly ask: “Based on our interaction for migrating this module, what mistakes did I make in my prompts? How can I provide better context next time?”. The suggestions often improve significantly over time. This feedback loop was invaluable.</li><li><strong>AI Won’t Catch Everything (Human Oversight is Non-Negotiable):</strong> <br> — ChatGPT might miss subtle requirements or edge cases present in the original code. It doesn’t fully grasp the _intent_ behind legacy logic.<br> — <strong>Actionable Insight:</strong> Rigorous manual code review and thorough testing are essential. You are still the domain expert responsible for ensuring the migrated code is functionally correct, secure, and maintainable. Assume features _will_ be missed initially.</li><li><strong>Synergy Between Different AI Tools:</strong> <br> — ChatGPT (GPT-4o) was excellent for high-level structure, explanations, and generating initial code blocks.<br> — GitHub Copilot excelled at inline suggestions, fixing minor syntax errors, and completing repetitive code patterns during the debugging and refinement phase in the IDE.<br> — <strong>Actionable Insight:</strong> Experiment to find the strengths of each tool for different parts of the workflow. Using them in combination (e.g., ChatGPT for structure, Copilot for implementation details) can be very effective, but requires understanding where each shines.</li></ol><h3>Putting Lessons into Practice: Example Templates</h3><p>These are some templates which ChaptGPT provided when I asked for suggestions to improve the process I followed:</p><p><a href="https://gist.github.com/lksudha/d01c15457ed4c1ae0eabaa0a51e29b4d">ci migration prompt.md</a></p><p><a href="https://gist.github.com/lksudha/be5b25dcc849504ba35730ba73367188">context prompt.md</a></p><h3>Conclusion</h3><p>I did this exercise to learn AI assisted programming workflow and improve my working approach with AI tools. I will be writing some more on this topic as I migrate father pages. I have felt as I get better, ChatGPT gets better in suggesting and improving us. Happy AI assisted Coding.</p><h4>Note</h4><ol><li>Gemini 2.5 was used to review and fine tune the post</li><li>The Splash image was generated from ChatGPT</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=293e5894dfa8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[On Object Oriented Programming]]></title>
            <link>https://medium.com/@lksudha/on-object-oriented-programming-aa3abf2ef336?source=rss-8926fba64384------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa3abf2ef336</guid>
            <category><![CDATA[object-oriented-design]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Sudhakaran Packianathan]]></dc:creator>
            <pubDate>Thu, 14 Feb 2019 10:26:18 GMT</pubDate>
            <atom:updated>2019-02-14T10:26:18.000Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*Nyv3N7_pFZ3puuT98MV-rg.png" /></figure><p>Object Oriented Programming has been one of mainstream programming paradigm’s since late 90’s. Almost all the applications developed in any enterprise today are object oriented.</p><p>But even though object oriented is used widely, very few people understand and develop effective object oriented applications. The true effectiveness and benefits provided by object oriented techniques are not fully reaped in companies.</p><p>It takes certain amount of experience and introspection to truly appreciate the concepts of Object Oriented paradigm.</p><p>One of the core concepts in Object Oriented programming and computing in general is — Abstraction. The ability to design elegant abstractions if the hallmark of a good designer and architect.</p><p>Even though theoretically we read in books — the four key tenets in object oriented programming are: Abstraction, Encapsulation, Polymorphism and Inheritance Do we truly relate and measure how these concepts are used in the applications we develop using object oriented techniques.</p><p>Now coming to the key question — how do we become better using Object Oriented techniques? It is a very important question and I remember getting a good advise on how one becomes a good programmer from one of the earlier CTO’s:</p><p><strong><em>“To become a good programmer you have read good programming techniques and good work done by others. Then you have to review the programs you have written. Then next time you program see how you can program better based on the new concepts you learnt”</em></strong></p><p>The road to become a good Object Oriented Designer or Programmer can be achieved following the above advise:</p><p>In Short:</p><ol><li>Read good books and articles by top Object Oriented experts</li></ol><p>2. Relate the Concepts learned to you work product</p><p>3. Use the new concepts next time you develop something using you judgement and reach for help from other when in doubt</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa3abf2ef336" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>