<?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 Rahul Patil on Medium]]></title>
        <description><![CDATA[Stories by Rahul Patil on Medium]]></description>
        <link>https://medium.com/@rahulpatil2387?source=rss-58a6126360cd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*T7d77GmQVhTULI2mzdxvFQ.png</url>
            <title>Stories by Rahul Patil on Medium</title>
            <link>https://medium.com/@rahulpatil2387?source=rss-58a6126360cd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 21:27:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rahulpatil2387/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[Design Patterns in Ruby — Simplified with Real-World Scenarios (By Russ Olsen)]]></title>
            <link>https://medium.com/@rahulpatil2387/design-patterns-in-ruby-simplified-with-real-world-scenarios-by-russ-olsen-a4d57cc383b8?source=rss-58a6126360cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4d57cc383b8</guid>
            <dc:creator><![CDATA[Rahul Patil]]></dc:creator>
            <pubDate>Fri, 18 Apr 2025 07:08:52 GMT</pubDate>
            <atom:updated>2025-04-18T07:08:52.931Z</atom:updated>
            <content:encoded><![CDATA[<h3>Design Patterns in Ruby — Simplified with Real-World Scenarios (By Russ Olsen)</h3><h3><strong>🔰 Introduction</strong></h3><p><strong>Design patterns</strong> are time-tested solutions to common problems in software design. This book simplifies classic patterns using Ruby’s expressive features like blocks, mixins, metaprogramming, and open classes. The goal is not just to learn patterns, but to understand how to apply them elegantly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ykBwrFL5B5ktIBenheYQw.png" /></figure><h3>🏗️ <strong>Creational Patterns — Object Creation Made Flexible</strong></h3><p>🔹 <strong>Singleton Pattern</strong></p><p><strong>Purpose:</strong> Ensure only <strong>one instance</strong> of a class exists.</p><p><strong>Real-World Scenario</strong>: App configuration — we only need one configuration manager across the entire application.</p><p><strong>Ruby Code:</strong></p><p>```ruby<br>require ‘singleton’</p><p>class AppConfig<br> include Singleton<br> attr_accessor :settings<br>end</p><p>AppConfig.instance.settings = { theme: ‘dark’, locale: ‘en’ }<br>```</p><p><strong>How it helps</strong>: You always access `AppConfig.instance` without worrying about duplicate instances or shared state.</p><p>🔹 <strong>Factory Method</strong></p><p><strong>Purpose:</strong> Delegates object creation to subclasses or decision logic.</p><p><strong>Use Case</strong>: You have different types of notifications (email, SMS, push). Let the factory decide which to instantiate.</p><p><strong>Code Example:</strong></p><p>```ruby<br>class NotificationFactory<br> def self.build(type)<br> case type<br> when :email then EmailNotification.new<br> when :sms then SMSNotification.new<br> when :push then PushNotification.new<br> else raise ‘Unknown type’<br> end<br> end<br>end</p><p>notif = NotificationFactory.build(:email)<br>notif.send(“Hello”)<br>```</p><p><strong>How it helps</strong>: Decouples creation logic and centralizes it, making the code easier to scale and test.</p><p>— -</p><h3>🧱<strong> Structural Patterns — Organizing Code for Flexibility</strong></h3><p>🔹 <strong>Adapter Pattern</strong></p><p><strong>Purpose</strong>: Allows incompatible interfaces to work together.</p><p><strong>Real-World Use Case</strong>: You’re integrating a third-party payment gateway, but its method names don’t match your system.</p><p><strong>Code:</strong></p><p>```ruby<br>class LegacyPayment<br> def execute_payment(amount)<br> puts “Paid #{amount} via legacy gateway”<br> end<br>end</p><p>class PaymentAdapter<br> def initialize(service)<br> <a href="http://twitter.com/service">@service</a> = service<br> end</p><p>def pay(amount)<br> <a href="http://twitter.com/service">@service</a>.execute_payment(amount)<br> end<br>end</p><p>payment = PaymentAdapter.new(LegacyPayment.new)<br>payment.pay(100)<br>```</p><p><strong>How it helps</strong>: Adapts the legacy system to your modern interface, avoiding rewriting or deep refactoring.</p><p>🔹<strong> Decorator Pattern</strong></p><p><strong>Purpose</strong>: Dynamically adds behavior to objects.</p><p><strong>Use Case</strong>: You want to log or monitor service usage <strong>without changing the original class</strong>.</p><p><strong>Code:</strong></p><p>```ruby<br>class BasicNotifier<br> def send(message)<br> puts “Sending: #{message}”<br> end<br>end</p><p>class LoggingNotifier<br> def initialize(notifier)<br> <a href="http://twitter.com/notifier">@notifier</a> = notifier<br> end</p><p>def send(message)<br> puts “[LOG] Sending message”<br> <a href="http://twitter.com/notifier">@notifier</a>.send(message)<br> end<br>end</p><p>notifier = LoggingNotifier.new(BasicNotifier.new)<br>notifier.send(“Hello World”)<br>```</p><p><strong>How it helps</strong>: Allows layering of responsibilities (like logging, caching, authentication) without altering core logic.</p><p>— -</p><h3><strong>🔁 Behavioral Patterns — Managing Communication &amp; Flow</strong></h3><p>🔹 <strong>Observer Pattern</strong></p><p><strong>Purpose</strong>: One object notifies others when its state changes.</p><p><strong>Real Use Case</strong>: A blog CMS that notifies subscribers when a new article is published.</p><p><strong>Code:</strong></p><p>```ruby<br>require ‘observer’</p><p>class Blog<br> include Observable</p><p>def publish(title)<br> puts “Publishing: #{title}”<br> changed<br> notify_observers(title)<br> end<br>end</p><p>class Subscriber<br> def update(title)<br> puts “New article notification: #{title}”<br> end<br>end</p><p>blog = Blog.new<br>blog.add_observer(Subscriber.new)<br>blog.publish(“Design Patterns in Ruby”)<br>```</p><p><strong>How it helps</strong>: Decouples publisher and subscriber logic, enhancing flexibility and reusability.</p><p>🔹 <strong>Strategy Pattern</strong></p><p><strong>Purpose</strong>: Encapsulates interchangeable algorithms/behaviors.</p><p><strong>Use Case</strong>: Different sorting strategies in an e-commerce site (e.g., price, rating, popularity).</p><p><strong>Code:</strong></p><p>```ruby<br>class Sorter<br> attr_writer :strategy</p><p>def sort(items)<br> <a href="http://twitter.com/strategy">@strategy</a>.sort(items)<br> end<br>end</p><p>class PriceSort<br> def self.sort(items)<br> items.sort_by { |item| item[:price] }<br> end<br>end</p><p>class RatingSort<br> def self.sort(items)<br> items.sort_by { |item| -item[:rating] }<br> end<br>end</p><p>items = [{ price: 100, rating: 4.5 }, { price: 50, rating: 4.8 }]<br>sorter = Sorter.new<br>sorter.strategy = PriceSort<br>p sorter.sort(items)<br>```</p><p><strong>How it helps</strong>: Promotes clean separation of algorithms and makes your system extensible.</p><p>— -</p><h3><strong>🧙 Metaprogramming and Patterns</strong></h3><p><strong>Metaprogramming</strong> allows you to build powerful, reusable solutions like:</p><p>- Singleton creation logic<br>- Decorators using method wrappers<br>- DSLs (domain-specific languages)</p><p><strong>Example:</strong> Create dynamic methods:</p><p>```ruby<br>class Report<br> [:pdf, :csv, :html].each do |format|<br> define_method(“generate_#{format}”) do<br> puts “Generating #{format} report…”<br> end<br> end<br>end</p><p>r = Report.new<br>r.generate_pdf<br>```</p><p><strong>Why it matters</strong>: Reduces repetition, increases flexibility.</p><p>— -</p><h3>✅ Best Practices</h3><p>- Patterns should <strong>simplify</strong> your code, not complicate it.<br>- Avoid “pattern obsession.” Use only when it solves a real problem.<br>- Ruby’s features often make classic patterns **easier and shorter** to implement.<br>- Mix and match patterns to suit your project’s needs.</p><p>— -</p><h3>🎯 Final Thoughts</h3><p>Design patterns are not rigid templates. They are tools in your toolbox to write better Ruby code.</p><p>- Think in terms of <strong>problems and solutions</strong>.<br>- Start with clean code, then apply patterns if necessary.<br>- Let Ruby’s expressive syntax do the heavy lifting.</p><p>Want to go deeper? Re-implement these patterns using your own project. That’s how you make them stick.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4d57cc383b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Difference between AngularJS, Angular 2 and Angular 4.]]></title>
            <link>https://medium.com/@rahulpatil2387/difference-between-angularjs-angular-2-and-angular-4-4cf95d0ba374?source=rss-58a6126360cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cf95d0ba374</guid>
            <category><![CDATA[angular-4]]></category>
            <category><![CDATA[angularjs]]></category>
            <dc:creator><![CDATA[Rahul Patil]]></dc:creator>
            <pubDate>Fri, 02 Mar 2018 22:51:10 GMT</pubDate>
            <atom:updated>2018-03-02T22:51:10.739Z</atom:updated>
            <content:encoded><![CDATA[<p>Google has released following versions of Angular,</p><ul><li>AngularJS 2010</li><li>Angular 2 2016</li><li>Angular 4 2017</li></ul><p>Let us discuss the differences between them,</p><h4>AngularJS vs Angular 2</h4><ul><li>Angular 2 is not simple upgrade from Angular 1</li><li>Angular 2 is completely rewritten from the ground up.</li><li>Angular 2 is 5 times faster compared to AngularJS.</li><li>AngularJS was not built for mobile devices, where Angular 2on the other hand is designed from the ground up with mobile support in mind.</li><li>With Angular 2 we have more language choices (JavaScript, TypeScript, Dart, PureScript, Elm, etc)</li></ul><h4>Angular 2 vs Angular 4</h4><ul><li>Changing from Angular 2 to Angular 4 and even future versions of Angular won’t be like changing from Angular 1.</li><li>Angular 4 is backwards compatible with Angular 2 for most applications.</li></ul><h4>What has changed and what is new in Angular 4</h4><ul><li>Some under the hood changes to reduce the size of the compiler generated code.</li><li>TypeScript 2.1 and 2.2 compatibility.</li><li>Animation features are pulled out of @angular/core and are moved into their own package.</li><li>New if/else style syntax with *ngif structural directive.</li></ul><h4>What about Angular 3</h4><p>LIBRARYVERSION</p><ul><li>@angular/core v2.3.0</li><li>@angular/compiler v2.3.0</li><li>@angular/compiler-cli v2.3.0</li><li>@angular/http v2.3.0</li><li>@angular/router v3.3.0</li></ul><p>Due to a misalignment of the router package’s version, the team decided to go straight for Angular 4.</p><h3><strong>Naming Guidelines</strong></h3><ul><li>Use AngularJS to describe versions 1.x or earlier.</li><li>Use Angular for versions 2.0.0 and later.</li><li>Use the version numbers Angular 4.0, Angular 2.4 when you need to talk about specific release.</li></ul><p><strong><em>Thanks for reading!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cf95d0ba374" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>