<?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 Görkem on Medium]]></title>
        <description><![CDATA[Stories by Görkem on Medium]]></description>
        <link>https://medium.com/@a-gorkemunuvar?source=rss-66892e20bc9e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ITV6d8rNjSzoGZBH4xq__w.jpeg</url>
            <title>Stories by Görkem on Medium</title>
            <link>https://medium.com/@a-gorkemunuvar?source=rss-66892e20bc9e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 16:26:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@a-gorkemunuvar/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[SOLID: Dependency Inversion Principle in Dart]]></title>
            <link>https://a-gorkemunuvar.medium.com/solid-dependency-inversion-principle-3d5de022bc04?source=rss-66892e20bc9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d5de022bc04</guid>
            <category><![CDATA[software-design]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[dependency-inversion]]></category>
            <category><![CDATA[solid]]></category>
            <category><![CDATA[oop]]></category>
            <dc:creator><![CDATA[Görkem]]></dc:creator>
            <pubDate>Fri, 18 Aug 2023 17:19:45 GMT</pubDate>
            <atom:updated>2023-08-18T17:25:43.251Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>- High-level modules should not depend on low-level modules. Both should depend on abstractions.</blockquote><blockquote>- Abstractions should not depend on details. Details (concrete implementations) should depend on abstractions.</blockquote><p>Briefly, adhering Dependency Inversion Principle (DIP) makes our code more flexible and adaptable to change.</p><p>Lets walk through and example violating DIP.</p><pre>class User {<br>  const User({required this.name, required this.age});<br><br>  final String name;<br>  final int age;<br>}<br><br>class HiveStorage {<br>  void save(dynamic item) {<br>    print(&#39;Saving to Hive Storage...&#39;);<br>  }<br>}<br><br>class UserRepository {<br>  final storage = HiveStorage();<br><br>  void addUser(User user) {<br>    storage.save(user);<br>  }<br>}<br><br>void main() {<br>  final user = User(name: &#39;John&#39;, age: 30);<br><br>  final userRepository = UserRepository();<br>  userRepository.addUser(user);<br>}</pre><p>Given example shows us <strong>UserRepository</strong> is dependent on <strong>HiveStorage</strong>. (Hive is simple and a fast nosql storage solution for Flutter)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*_9il4b_GWk28VstpEeglzw.png" /></figure><p>As we can see in the diagram, high level module <strong>UserRepository</strong> has a direct dependency to a low level model which is <strong>HiveStorage</strong>. Because it knows about implementation details such as what kind of action should be performed to save something to Hive.</p><p>Here we have a problem. If we would like to replace Hive with ObjectBox which is another local storage option, then we would have to make a change in <strong>UserRepository</strong> which is a high level module. However if <strong>UserRepository </strong>is<strong> </strong>a high level module and should not have to know about the storage api at all, why are we making these changes in <strong>UserRepository</strong>? That’s questionable.</p><p>On the other hand, same conflict would occur if we would like to add another type of storage instead of a replacement. How can we figure it out?</p><p>Let’s go back to the definition of DIP again.</p><blockquote>High-level modules should not depend on low-level modules. Both should depend on abstractions.</blockquote><p>Suggestion is clear, create an abstraction and make the modules dependent to it.</p><p>What if we create an <strong>IStorage</strong> interface in the middle of <strong>UserRepository</strong> and <strong>HiveStorage</strong>?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*kUuWAmfwxSF42mAsVacPDg.png" /></figure><p>In this case, <strong>UserRepository</strong> is only dependent on an abstraction which is the <strong>IStorage</strong> interface and therefore it does not have to know about what sort of storage API we are using, instead it only depends on the interface and using it’s functions. That’s why for <strong>UserRepository</strong>, it is not important when <strong>HiveStorage</strong> is changed with something else such as <strong>Objectbox</strong>.</p><p>And pay attention to the arrows, second arrow is not in the same direction as the first one, it is <strong>inverted</strong>.</p><p>Here is how our code would look like if we adhere DIP.</p><pre>class User {<br>  const User({required this.name, required this.age});<br><br>  final String name;<br>  final int age;<br>}<br><br>abstract interface class IStorage {<br>  void save(dynamic item);<br>}<br><br>class HiveStorage implements IStorage {<br>  @override<br>  void save(dynamic item) {<br>    print(&#39;Saving to Hive Storage...&#39;);<br>  }<br>}<br><br>class ObjectBoxStorage implements IStorage {<br>  @override<br>  void save(dynamic item) {<br>    print(&#39;Saving to ObjectBox Storage...&#39;);<br>  }<br>}<br><br>class UserRepository {<br>  UserRepository(this.storage);<br><br>  final IStorage storage;<br><br>  void addUser(User user) {<br>    storage.save(user);<br>  }<br>}<br><br>void main() {<br>  final user = User(name: &#39;John&#39;, age: 30);<br><br>  final userRepository = UserRepository(HiveStorage());<br>  userRepository.addUser(user);<br>}</pre><p>Using the code below, making a change from hive to objectbox would be only one line of change.</p><pre>final userRepository = UserRepository(ObjectBoxStorage());</pre><p>Here is how it looks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*XMLRHdKhe1YogOpZzP44ow.png" /></figure><p>Referefences:<br><a href="https://en.wikipedia.org/wiki/Dependency_inversion_principle">https://en.wikipedia.org/wiki/Dependency_inversion_principle</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d5de022bc04" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOLID: Interface Segregation Principle in Dart]]></title>
            <link>https://a-gorkemunuvar.medium.com/solid-interface-segregation-principle-in-dart-72f09a919543?source=rss-66892e20bc9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/72f09a919543</guid>
            <category><![CDATA[solid]]></category>
            <category><![CDATA[software-design]]></category>
            <category><![CDATA[interface-segregation]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[oop]]></category>
            <dc:creator><![CDATA[Görkem]]></dc:creator>
            <pubDate>Wed, 16 Aug 2023 17:09:11 GMT</pubDate>
            <atom:updated>2023-08-16T17:13:32.325Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>No code should be forced to depend on methods it does not use.</blockquote><p>Imagine a class implementing/extending another class and forced to implement all methods from the base class even if all the methods are not exactly relevant. How does it sound? According to Interface Segregation Principle (ISP), it does not sound good.</p><p>Besides not having a clean code base, violating ISP causes some other side effects such as fragile and tight coupled code base and reduced maintainability.</p><p>These side effects are particularly significant because they impact flexibility of a system.</p><p>Let’s go go ahead with a simple example <strong>violating ISP</strong>. Imagine that you are working on a transportation application and your requirements indicate that you should provide authentication and update profile settings feature for both passenger and staff users. However in your requirements there is a detail about the staff users.</p><blockquote><strong>- </strong>Sfaff users are registered through an admin panel.</blockquote><p>As we understand from the line above, our app should not provide register functionality for staff users.</p><p>With the given example use case, let’s have a look at the Dart example below:</p><pre>abstract interface class IUserProfile {<br>  void signIn();<br>  void signOut();<br>  void register();<br>  void updateSetting();<br>}<br><br>class PassengerProfile implements IUserProfile {<br>  @override<br>  void register() {<br>    print(&#39;Registered as passenger&#39;);<br>  }<br><br>  @override<br>  void signIn() {<br>    print(&#39;Signed in as passenger&#39;);<br>  }<br><br>  @override<br>  void signOut() {<br>    print(&#39;Signed out as passenger&#39;);<br>  }<br><br>  @override<br>  void updateSetting() {<br>    print(&#39;Updated profiel settings&#39;);<br>  }<br>}<br><br>class StaffProfile implements IUserProfile {<br>  @override<br>  void register() {<br>    // Registraion is not supported for staff users in the app.<br>    throw UnimplementedError();<br>  }<br><br>  @override<br>  void signIn() {<br>    print(&#39;Signed in as staff&#39;);<br>  }<br><br>  @override<br>  void signOut() {<br>    print(&#39;Signed out as staff&#39;);<br>  }<br><br>  @override<br>  void updateSetting() {<br>    print(&#39;Updated profile settings&#39;);<br>  }<br>}</pre><p>Everything looks good so far. We have <strong>IUserProfile</strong> interface, <strong>PassengerProfile</strong> and <strong>StaffProfile</strong> implementing the <strong>IUserProfile</strong>.</p><p>Hmm. What about our requirements? Why do we have a <strong>register</strong> function in <strong>StaffProfile</strong> class even if it does not have to be there? Assume another developer is responsible for fixing a bug in this module and seeing the <strong>register</strong> function inside the <strong>StaffProfile</strong>. What would he/she think? Is not it just confusing? It is confusing!</p><p>Apart from that this code snippet can create many questions in mind without answers, violating ISP can cause bigger problems.</p><p>Let’s try to achieve a better structure and adhere ISP.</p><pre>abstract interface class IUserProfile {<br>  void signIn();<br>  void signOut();<br>  void updateSetting();<br>}<br><br>abstract interface class IPassengerProfile implements IUserProfile {<br>  void register();<br>}<br><br>abstract interface class IStaffProfile implements IUserProfile {}<br><br>class PassengerProfile implements IPassangerProfile {<br>  @override<br>  void register() {<br>    print(&#39;Registered as passenger&#39;);<br>  }<br><br>  @override<br>  void signIn() {<br>    print(&#39;Signed in as passenger&#39;);<br>  }<br><br>  @override<br>  void signOut() {<br>    print(&#39;Signed out as passenger&#39;);<br>  }<br><br>  @override<br>  void updateSetting() {<br>    print(&#39;Updated profile settings&#39;);<br>  }<br>}<br><br>class StaffProfile implements IStaffProfile {<br>  @override<br>  void signIn() {<br>    print(&#39;Signed in as staff&#39;);<br>  }<br><br>  @override<br>  void signOut() {<br>    print(&#39;Signed out as staff&#39;);<br>  }<br><br>  @override<br>  void updateSetting() {<br>    print(&#39;Updated profiel settings&#39;);<br>  }<br>}</pre><p>Although many different approaches can be utilized, I’ve chosen a really simple one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/0*-jiYfAvT5dKFmmIb" /></figure><p>ISP stands for segregating fat interfaces into smaller meaningful interfaces. We already had <strong>IUserProfile</strong>, and with the new example just created two new interfaces <strong>IPassengerProfile</strong> and <strong>IStaffProfile</strong>.</p><p>As you can see <strong>PassengerProfile</strong> and <strong>StaffProfile</strong> are not forced to implement any irrelevant functions.</p><p>Reference:<br><a href="https://en.wikipedia.org/wiki/Interface_segregation_principle">https://en.wikipedia.org/wiki/Interface_segregation_principle</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72f09a919543" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOLID: Liskov Substitution Principle in Dart]]></title>
            <link>https://a-gorkemunuvar.medium.com/solid-liskov-substitution-principle-in-dart-7c9b1eafe72?source=rss-66892e20bc9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c9b1eafe72</guid>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[solid]]></category>
            <category><![CDATA[liskov-substitution]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[oop]]></category>
            <dc:creator><![CDATA[Görkem]]></dc:creator>
            <pubDate>Sun, 13 Aug 2023 15:03:13 GMT</pubDate>
            <atom:updated>2023-08-13T15:03:13.610Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“Derived classes must be usable through the base class interface, without the need for user to know the difference.”</blockquote><p>Some of the content and diagrams in this article have been quoted from the Uncle Bob’s speech in the link below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FzHiWqnTWsn4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DzHiWqnTWsn4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FzHiWqnTWsn4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/87931077215ded88b492eb21ec4ce9a5/href">https://medium.com/media/87931077215ded88b492eb21ec4ce9a5/href</a></iframe><p>I highly recommend you to watch the whole video for better understanding.</p><p>We will go through with Uncle Bob’s examples first, followed by a straightforward Dart example that has been adapted.</p><p>What does actually Liskov Substitution Principle (LSP) means using the <strong>derived class</strong> and the <strong>base class </strong>without knowing the difference?</p><p>Let’s have a look at the diagram below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zpbfCq95wV-S4tv8XoEtYQ.png" /></figure><blockquote><strong><em>Base Class:</em></strong><em> Abstract Server</em></blockquote><blockquote><strong><em>Derived Class:</em></strong><em> Concrete Server</em></blockquote><p>In the example, <strong>Client</strong> is dependent on <strong>AbstractServer</strong> and <strong>ConcreteServer</strong> inherits the <strong>AbstractServer</strong>. According to LSP if an instance of <strong>Client</strong> class is using any action on <strong>AbstractServer</strong>, when <strong>ConcreteServer</strong> is replaced with that, it should be still usable.</p><p>Concisely, base class and derived class <strong>must be substitutable</strong>.</p><p>Let’s go ahead with a simple use case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cBlEnc5QCQMiM8SSadHxtw.png" /></figure><p>We can basically say a <strong>square is a rectangle</strong>, right? Assuming that means we can derive a <strong>Square</strong> class from <strong>Rectangle</strong>. However square does not have different hight and width, that’s why whenever width or height is set, both width and height must be set.</p><p>Even though it looks correct, we better ask some questions to grasp if our design is well structured.</p><p>Let’s ask some questions to clarify:</p><blockquote>How many fields does a rectangle have?</blockquote><blockquote>Two. Width and Height</blockquote><blockquote>How many fields does a square have?</blockquote><blockquote>One. Width (widht = height)</blockquote><blockquote>How many fields square inherits from rectangle?</blockquote><blockquote>One.</blockquote><p>Then something is wrong because it means we are going to waste memory. You might think memory is cheap and would like to ignore it for now.</p><p>Imagine a user of <strong>Rectangle</strong> calling <strong>SetHeight</strong> function. Does the user expect that width will not change when height is set? Yes.</p><p>Then here we have a problem.</p><p>This is a violation of the LSP because Square is not substitutable for rectangle. Even though it seems to fit the definition of “<strong>is a</strong>”, it does fit the substitution rule.</p><p>Whenever we violate the substitution rule, we will eventually have an if statement that checks the type of the object to prevent us from crashing our system. Basically it means that we create another dependency using those if statements which is also violating the Open Closed Principle.</p><p>Here we have a Dart example <strong>violating</strong> the LSP.</p><pre>class Rectangle {<br>  Rectangle(this.width, this.height);<br><br>  int width;<br>  int height;<br><br>  void setWidth(int width) =&gt; this.width = width;<br><br>  void setHeight(int height) =&gt; this.height = height;<br><br>  int calculateArea() =&gt; width * height;<br>}<br><br>class Square extends Rectangle {<br>  Square(int side) : super(side, side);<br><br>  @override<br>  void setWidth(int width) {<br>    super.setWidth(width);<br>    super.setHeight(width);<br>  }<br><br>  @override<br>  void setHeight(int height) {<br>    super.setWidth(height);<br>    super.setHeight(height);<br>  }<br>}<br><br>void increaseWidth(Rectangle rectangle) {<br>  rectangle.setWidth(rectangle.width + 1);<br>}<br><br>void main() {<br>  final rectangle = Rectangle(10, 20);<br>  final square = Square(10);<br><br>  print(rectangle.calculateArea());<br>  print(square.calculateArea());<br><br>  increaseWidth(rectangle);<br>  increaseWidth(square);<br><br>  print(rectangle.calculateArea());<br>  print(square.calculateArea());<br>}</pre><p>In the <strong>main</strong> function body <strong>rectangle</strong> and <strong>square</strong> instances are created and their area is displayed using the <strong>calculateArea</strong> function. And Here is what it prints out.</p><blockquote>200 // 10 * 20 rectangle area</blockquote><blockquote>100 // 10 * 10 square area</blockquote><p>Other than that we have an <strong>increateWidth</strong> functions which takes a <strong>Rectangle</strong> object (can be rectangle and square) as a parameter.</p><p>Once increateWidth <strong>function</strong> is called for both rectangle and square, we calculate their area again and print out the results.</p><blockquote>220 // 11 * 10 rectangle area</blockquote><blockquote>121 // 11 * 11 square area</blockquote><p>Wait a minute. Even if square area is calculated correctly, would we really expect the height is increased after width is increased? As you have seen, we just complicated the situation. Therefore violating the LSP can be dangerous.</p><p>In the example above for <strong>increaseWidth</strong> function, derived class (Square) and base class (Rectangle) is <strong>not substitutable</strong>.</p><p>Let’s take a look at this example:</p><pre>abstract interface class Shape {<br>  void calculateArea();<br>}<br><br>class Rectangle extends Shape {<br>  Rectangle(this.width, this.height);<br><br>  int width;<br>  int height;<br><br>  void setWidth(int width) =&gt; this.width = width;<br><br>  void setHeight(int height) =&gt; this.height = height;<br><br>  @override<br>  void calculateArea() =&gt; width * height;<br>}<br><br>class Square extends Shape {<br>  Square(this.side);<br><br>  int side;<br><br>  void setSide(int side) =&gt; this.side = side;<br><br>  @override<br>  void calculateArea() =&gt; side * side;<br>}<br><br>...</pre><p>In this approach, we provided a <strong>Shape </strong>class to be derived by <strong>Rectangle</strong> and <strong>Square</strong>. And using the new version of the classes, we can substitute rectangle and square where they can be used by a client.</p><p>As a conclusion considering the LSP during implementation is going to prevent us to complicate the class relations and usage.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c9b1eafe72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOLID: Open-Closed Principle in Dart]]></title>
            <link>https://a-gorkemunuvar.medium.com/solid-open-closed-principle-in-dart-8c5ecf4449f3?source=rss-66892e20bc9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c5ecf4449f3</guid>
            <category><![CDATA[solid]]></category>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[open-closed-principle]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Görkem]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 18:34:27 GMT</pubDate>
            <atom:updated>2023-08-02T19:22:20.160Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article Open-Closed Principle is simply explained with the given Dart examples. Let’s go ahead.</p><p>Some of the content and diagrams in this article have been quoted from the Uncle Bob’s speech in the link below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FzHiWqnTWsn4%3Fstart%3D1710%26feature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DzHiWqnTWsn4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FzHiWqnTWsn4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b76194e43f7d3e1c467cdcb712fb7e1/href">https://medium.com/media/4b76194e43f7d3e1c467cdcb712fb7e1/href</a></iframe><p>I highly recommend you to watch the whole video for better understanding.</p><h3>Understanding the Open-Closed Principle (OCP)</h3><p>The Open-Closed Principle is the ‘O’ in the SOLID acronym. This principle states that software entities, such as classes, modules, or functions, should be open for extension but closed for modification. In simpler terms, you should be able to add new functionality without altering existing code.</p><p>The idea was introduced by Bertrand Meyer and here is what exactly he said:</p><blockquote>Modules should be open for extension, but closed for modification.</blockquote><p>Let’s have a look at a Dart example <strong>violating</strong> the OCP and try to understand what is wrong with it.</p><pre>class CashPayment {<br>  void pay() {<br>    print(&#39;Pay with cash&#39;);<br>  }<br>}<br><br>class CreditCardPayment {<br>  void pay() {<br>    print(&#39;Pay with credit card&#39;);<br>  }<br>}<br><br>class PaymentService {<br>  void pay(dynamic paymentMethod) {<br>    if (paymentMethod is CashPayment) {<br>      paymentMethod.pay();<br>    } else if (paymentMethod is CreditCardPayment) {<br>      paymentMethod.pay();<br>    } else {<br>      throw Exception(&#39;Unknown payment method&#39;);<br>    }<br>  }<br>}<br><br>void main() {<br>  final paymentService = PaymentService();<br>  paymentService.pay(CashPayment());<br>}</pre><p>In the example above, imagine that you would like to add a new feature such as PayPal Payment. Which changes would you make for it? Would you <strong>modify your code</strong> to add this new feature, and how?</p><p>In order to add PayPal payment, we could simply create a <strong>PayPalPayment</strong> class just like the <strong>CashPayment</strong> or <strong>CreditCartPayment</strong> classes. But it is not the end. As you can see the <strong>PaymentService</strong> is invoked to perform a payment which means that we have to <strong>modify the if-else </strong>statement and add a new condition to handle the <strong>PayPayPayment</strong>.</p><p>So it is not that difficult, right? It it easy to change <strong>BUT</strong> we are considering such a simple example. Imagine that we have a large-scale code base and many other modules use the <strong>PaymentService</strong> as a dependency with if-else and switch statements inside. Then, for each new feature going to be added, we would have to modify those statements to add the new payment method. In such a case our code base would be <strong>fragile</strong>. It would be so easy to break our code while making changes.</p><p>As we can see, the example above is <strong>violating</strong> the OCP since we have to modify the existing code to extend it.</p><p>Now, let’s check this version:</p><pre>abstract class IPaymentMethod {<br>  void pay();<br>}<br><br>class CashPayment implements IPaymentMethod {<br>  @override<br>  void pay() {<br>    print(&#39;Pay with cash&#39;);<br>  }<br>}<br><br>class CreditCardPayment implements IPaymentMethod {<br>  @override<br>  void pay() {<br>    print(&#39;Pay with credit card&#39;);<br>  }<br>}<br><br>class PayPalPayment implements IPaymentMethod {<br>  @override<br>  void pay() {<br>    print(&#39;Pay with PayPal&#39;);<br>  }<br>}<br><br>class PaymentService {<br>  void pay(IPaymentMethod paymentMethod) {<br>    paymentMethod.pay();<br>  }<br>}<br><br>void main() {<br>  final paymentService = PaymentService();<br>  paymentService.pay(PayPalPayment());<br>}</pre><p>In the new example, the OCP is properly followed. We introduced an interface <strong>IPaymentMethod</strong> that defines the <strong>pay()</strong> method. Each payment method implements this interface, ensuring a consistent way to perform the <strong>pay</strong> method.</p><p>The <strong>PaymentService</strong> class now accepts any object that implements the <strong>IPaymentMethod</strong> interface. This makes the software <strong>open for extensions</strong>, as new payment methods can be added <strong>without modifying</strong> existing code. The <strong>PaymentService</strong> class remains closed for modification, adhering to the OCP.</p><p>As a conclusion, it is possible to extend the payment methods only by creating a new class inheriting the <strong>IPaymentMethod</strong> and by playing the main method a little bit. <strong>PaymentService</strong> does not even has to know about the specific payment methods.</p><p>Using Open-Closed Principle in this way would help us maintain our codebase in an easy way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c5ecf4449f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOLID: Single Responsibility Principle in Dart]]></title>
            <link>https://a-gorkemunuvar.medium.com/solid-single-responsibility-principle-in-dart-f37c9a6bf004?source=rss-66892e20bc9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f37c9a6bf004</guid>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[solid]]></category>
            <category><![CDATA[single-responsibility]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <dc:creator><![CDATA[Görkem]]></dc:creator>
            <pubDate>Tue, 01 Aug 2023 15:55:44 GMT</pubDate>
            <atom:updated>2023-08-10T10:36:06.770Z</atom:updated>
            <content:encoded><![CDATA[<p>When it comes to creating maintainable, clean and sustainable software, some principles and standards such as SOLID are the game changers. In this article we will briefly walk through the Single Responsibility Principle.</p><p>Some of the content and diagrams in this article have been quoted from the Uncle Bob’s speech in the link below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FzHiWqnTWsn4%3Fstart%3D1712%26feature%3Doembed%26start%3D1712&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DzHiWqnTWsn4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FzHiWqnTWsn4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7335d61215f4d58808f13e1a882b2513/href">https://medium.com/media/7335d61215f4d58808f13e1a882b2513/href</a></iframe><p>I highly recommend you to watch the whole video for better understanding.</p><p>Let’s start with describing the main rule of SRP.</p><blockquote>A class should have one, and only one, reason to change.</blockquote><p>It means exactly that we should not be changing our class for different kind of reasons. Let’s have a look at the Uncle Bob’s example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*_S7w1SJNzDoOD8qMeOBO2w.png" /></figure><p>In the diagram above, <strong>Payroll</strong> module is dependent on the <strong>Employee</strong> class and <strong>Employee</strong> class has 3 different functions inside.</p><p>According to the description of SRP, let’s ask a question and try to understand if the <strong>Employee</strong> class violates the SRP.</p><blockquote>Does the Employe class has more than one reason to change?</blockquote><blockquote>- Yes. It has three or more different reasons to change.</blockquote><p>Calculation of payment, reporting and writing employee (database related) are totally different reasons to change the <strong>Employee</strong> class. That’s why it <strong>violates</strong> the <strong>Single Responsibility Principle</strong> and has to be separated into smaller parts.</p><p>Let’s go with a simple Dart example. In the example we’ll see a bad and good example.</p><p>For the sake of simplicity, let’s assume a simple example. In the example we will go ahead with a use case which a user has to perform authentication in the app.</p><p>Here is a <strong>BAD</strong> example which violates the Single Responsibility Principle.</p><pre>class User {<br>  const User({<br>    this.id,<br>    required this.name,<br>  });<br><br>  final String? id;<br>  final String name;<br>}<br><br>class AuthenticationRepository {<br>  Future&lt;User&gt; signUp(String email, String password) async {<br>    //Sign up the user.<br>    //...<br><br>    return User(id: &#39;userId1&#39;, name: &#39;Signed Up User&#39;);<br>  }<br><br>  Future&lt;User&gt; signIn(String email, String password) async {<br>    //Sign in the user.<br>    //...<br><br>    return User(id: &#39;userId2&#39;, name: &#39;Signed In User&#39;);<br>  }<br><br>  Future&lt;User&gt; signOut(User user) async {<br>    //Sign out the user.<br>    //...<br><br>    return User(id: null, name: &#39;&#39;);<br>  }<br><br>  Future&lt;void&gt; log(String? message, {bool reportCrashlytics = false}) async {<br>    if (reportCrashlytics) {<br>      //Report crashlytics.<br>    }<br><br>    print(message);<br>  }<br>}<br><br>void main() async {<br>  final authRepository = AuthenticationRepository();<br><br>  const email = &#39;user@email.com&#39;;<br>  const password = &#39;*******&#39;;<br><br>  final user = await authRepository.signIn(email, password);<br>  await authRepository.log(user.name);<br>}</pre><p>We can easily understand if it applies SRP. In order to understand it, just ask this question yourself.</p><blockquote>For what reasons would I make a change in <strong>AuthenticationRepository</strong>?</blockquote><p>As we can see in the code above, there might be two reasons to change it. We would make changes in such cases:</p><ul><li>If we would like to change authentication behaviour.</li><li>If we would like to change logging behaviour.</li></ul><p>Just remember that:</p><blockquote>A class should have one, and only one, reason to change.</blockquote><p>What if we would separate the logging functionality into another class. Let’s create a <strong>Logger</strong> class and put the <strong>log</strong> method inside it.</p><p>Here is a <strong>GOOD</strong> example which follows the Single Responsibility Principle.</p><pre>class User {<br>  const User({<br>    this.id,<br>    required this.name,<br>  });<br><br>  final String? id;<br>  final String name;<br>}<br><br>class AuthenticationRepository {<br>  Future&lt;User&gt; signUp(String email, String password) async {<br>    //Sign up the user.<br>    //...<br><br>    return User(id: &#39;userId1&#39;, name: &#39;Signed Up User&#39;);<br>  }<br><br>  Future&lt;User&gt; signIn(String email, String password) async {<br>    //Sign in the user.<br>    //...<br><br>    return User(id: &#39;userId2&#39;, name: &#39;Signed In User&#39;);<br>  }<br><br>  Future&lt;User&gt; signOut(User user) async {<br>    //Sign out the user.<br>    //...<br><br>    return User(id: null, name: &#39;&#39;);<br>  }<br>}<br><br>class Logger {<br>  Future&lt;void&gt; log(String? message, {bool reportCrashlytics = false}) async {<br>    if (reportCrashlytics) {<br>      //Report crashlytics.<br>    }<br><br>    print(message);<br>  }<br>}<br><br>void main() async {<br>  final logger = Logger();<br>  final authRepository = AuthenticationRepository();<br><br>  const email = &#39;user@email.com&#39;;<br>  const password = &#39;*******&#39;;<br><br>  final user = await authRepository.signIn(email, password);<br>  await logger.log(user.name);<br>}</pre><p>In the code above <strong>AuthenticationRepository</strong> and <strong>Logger</strong> classes have their only one reason to be changed.</p><p>As a conclusion let’s summarize the SRP with Uncle Bob’s words.</p><blockquote>- Don’t put functions that change for different reasons in the same class.</blockquote><blockquote>- Don’t mix concerns in classes.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f37c9a6bf004" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter: How to Highlight a Substring in Text Widget]]></title>
            <link>https://a-gorkemunuvar.medium.com/flutter-how-to-highlight-a-substring-in-text-widget-c86d3578dfb1?source=rss-66892e20bc9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c86d3578dfb1</guid>
            <dc:creator><![CDATA[Görkem]]></dc:creator>
            <pubDate>Sun, 28 May 2023 20:48:13 GMT</pubDate>
            <atom:updated>2023-05-28T20:48:13.156Z</atom:updated>
            <content:encoded><![CDATA[<p>As front-end developers, there are times we would like to render a text content with a highlighted sub string. Especially in some cases such as searching, we want our app to show a list of the search results are emphasises the target string to achieve a better user experience for our apps.</p><p>So, coming back to our point, in Fluter it is easy to achieve that by creating an extension on Text widget.</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>extension BoldSubString on Text {<br>  Text boldSubString(String target) {<br>    final textSpans = List.empty(growable: true);<br>    final escapedTarget = RegExp.escape(target);<br>    final pattern = RegExp(escapedTarget, caseSensitive: false);<br>    final matches = pattern.allMatches(data!);<br><br>    int currentIndex = 0;<br>    for (final match in matches) {<br>      final beforeMatch = data!.substring(currentIndex, match.start);<br>      if (beforeMatch.isNotEmpty) {<br>        textSpans.add(TextSpan(text: beforeMatch));<br>      }<br><br>      final matchedText = data!.substring(match.start, match.end);<br>      textSpans.add(<br>        TextSpan(<br>          text: matchedText,<br>          style: const TextStyle(fontWeight: FontWeight.bold),<br>        ),<br>      );<br><br>      currentIndex = match.end;<br>    }<br><br>    if (currentIndex &lt; data!.length) {<br>      final remainingText = data!.substring(currentIndex);<br>      textSpans.add(TextSpan(text: remainingText));<br>    }<br><br>    return Text.rich(<br>      TextSpan(children: &lt;TextSpan&gt;[...textSpans]),<br>    );<br>  }<br>}</pre><p>The extension above provides a function <strong>boldSubString </strong>which takes the <strong>target</strong> parameter and returns a <strong>Text</strong> including only the <strong>target</strong> string is bold.</p><p>Usage of the extension is pretty straight forward by calling the <strong>boldSubString</strong> function.</p><pre>Text(&#39;Here is the bold string.&#39;).boldSubString(&#39;the bold&#39;)</pre><p>The line above is going to return a <strong>Text</strong> and only the “<strong>the bold</strong>” is going to be rendered with a bold text style.</p><p>For sure, you can customize the text style as you wish.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c86d3578dfb1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Briefly Explanied — How Flutter framework optimizes widget rendering?]]></title>
            <link>https://a-gorkemunuvar.medium.com/briefly-explanied-how-flutter-framework-optimizes-widget-rendering-2d90f8c2eddb?source=rss-66892e20bc9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d90f8c2eddb</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Görkem]]></dc:creator>
            <pubDate>Sun, 13 Mar 2022 15:21:21 GMT</pubDate>
            <atom:updated>2022-03-13T15:23:30.873Z</atom:updated>
            <content:encoded><![CDATA[<h3>Briefly Explanied — <a href="https://stackoverflow.com/questions/71189689/how-flutter-framework-optimizes-the-widget-rendering-if-build-method-can-be-call">How Flutter framework optimizes widget rendering</a>?</h3><p>I had a simple question in my mind for a long time about widget rendering in Flutter. My question was simply like below:</p><p>In Flutter docs it is explained build method can be called many times by framework and it is recomended that we should only return widgets through the build method. But even we return only widgets, isn&#39;t it causing some performance issues? If build method is called 20 times in a second, does not it mean widgets will be rendered 20 times and should not it be slow? If Flutter framework optimizes rendering widgets, how?</p><p><strong>Answer</strong></p><p><strong>Widget Tree</strong> is hierarchy of widgets and includes all the widgets created. But since widgets are immutable and changed in the tree over time, there should be another tree called <strong>Element Tree</strong> which keeps the states and optimizes widget rendering.</p><p><strong>Element Tree</strong> is the tree which Flutter uses to render widgets on the screen and is not changed a lot over time same as <strong>Widget Tree</strong> because whenever a widget is changed in the <strong>Widget Tree</strong>, if the new widget has the same type as before, element tree keeps the element for the corresponding widget. For example if you only change a Text widget&#39;s text in the widget tree, <strong>Widget Tree</strong> is going to be changed but <strong>Element Tree</strong> is going to stay same because Text widget still has the same runtimeType as before.</p><p>So that render optimization is mostly about reusability. Flutter framework is trying to reuse the objects as much as it can. Even the <strong>Widget Tree</strong> is changed a lot over time, <strong>Element Tree</strong> is not changed a lot same as the <strong>Widget Tree</strong> and use the same element object if the widget type is not changed.</p><p>I hope this explanation answers you question :)</p><p>References:</p><ul><li><a href="https://www.youtube.com/watch?v=AqCMFXEmf3w">https://www.youtube.com/watch?v=AqCMFXEmf3w</a></li><li><a href="https://www.youtube.com/watch?v=996ZgFRENMs&amp;feature=youtu.be">https://www.youtube.com/watch?v=996ZgFRENMs&amp;feature=youtu.be</a></li><li><a href="https://stackoverflow.com/questions/71189689/how-flutter-framework-optimizes-the-widget-rendering-if-build-method-can-be-call">https://stackoverflow.com/questions/71189689/how-flutter-framework-optimizes-the-widget-rendering-if-build-method-can-be-call</a></li><li>Flutter Docs</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d90f8c2eddb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Robets Edge Detection and Applyig In Matlab]]></title>
            <link>https://a-gorkemunuvar.medium.com/robets-edge-detection-and-applyig-in-matlab-479981144a12?source=rss-66892e20bc9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/479981144a12</guid>
            <category><![CDATA[edge-detection]]></category>
            <category><![CDATA[roberts-operator]]></category>
            <category><![CDATA[matlab]]></category>
            <category><![CDATA[image-processing]]></category>
            <dc:creator><![CDATA[Görkem]]></dc:creator>
            <pubDate>Sun, 14 Feb 2021 12:35:27 GMT</pubDate>
            <atom:updated>2021-02-14T12:58:43.329Z</atom:updated>
            <content:encoded><![CDATA[<h3>Roberts Cross Edge Detection and Implementing in Matlab</h3><p>If you are reading this article I think it’s quite possible you’ve heard something about edge detection and Roberts Cross Operator. But if you are looking for a brief explanation about what is the math behind Roberts Operator and how to use it in Matlab, you are at the right place.</p><p>Edge detection is a process in order to find some regions where the image has boundaries. It measures the rate of change in brightness in an image. What we are doing here with edge detection algorithms is the process for find the amount of the difference between pixels in the matrix. Here we have a gray-level matrix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*1GNPsO7N4eWtm5kfsI4_OA.png" /></figure><p>As you can see some neighborhood pixels have strong signs of change in the matrix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*PF5wVAUzjzI4aF3HHgyaqg.png" /></figure><p>Using Roberts Operator we are going to be able to highlight changes in intensity.</p><h3>How It Works</h3><p>Roberts Cross Edge Detection is actually a <a href="https://en.wikipedia.org/wiki/Convolution">convolution</a>. Therefore in order to perform Roberts operator we are gonna convolve the original image with the kernels below firstly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*XkJStqoyMFD60bgeNcjSNg.png" /></figure><p>After we perform convolution gradient magnitude can be obtained. The gradient magnitude is given by:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/169/1*UvR3Cva1h1hjBg091HCk3A.png" /></figure><p>It was a really brief explanation. If you want to it out in more details you can learn from <a href="https://en.wikipedia.org/wiki/Roberts_cross">wikipeadia</a>.</p><h3>How to Detect Edges with Roberts Operator in Matlab</h3><p>Event though i didn’t use a built in function to perform Roberts Operator, usage is really simple.</p><pre>im = imread(&#39;image.jpg&#39;);</pre><pre>im_d = im2double(im);<br>im = rgb2gray(im_d);</pre><pre>hx = [+1 0; 0 -1];<br>hy = [0 +1; -1 0];</pre><pre>Gx = imfilter(im, hx);<br>imshow(Gy); figure;</pre><pre>Gy = imfilter(im, hy);<br>imshow(Gx); figure;</pre><pre>Gm = sqrt(Gx.^2 + Gy.^2);<br>imshow(Gm);</pre><p>Here is the original image;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*oVVT1_gsRrFj7QDKKXrQnA.png" /></figure><p>When we perform hx and hy masks over the image we get Gx and Gy like below;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*4rHMeIaim_EYucstcscEsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*bn8RwCnjwf7GQkYbITvKXw.png" /></figure><p>After gradient magnitude is performed we get the result image which we have all the edges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*vr_ysNLXnT0z0yL86Thwvw.png" /></figure><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=479981144a12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web Scraping in Python]]></title>
            <link>https://a-gorkemunuvar.medium.com/web-scraping-in-python-9f75dfb84dc1?source=rss-66892e20bc9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f75dfb84dc1</guid>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[html-parsing]]></category>
            <category><![CDATA[lxml]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Görkem]]></dc:creator>
            <pubDate>Sun, 18 Oct 2020 22:47:49 GMT</pubDate>
            <atom:updated>2021-01-31T02:51:36.497Z</atom:updated>
            <content:encoded><![CDATA[<p>In some cases we may want to get some data from websites to use in our apps or software we are working on. Let’s say you are following new ‘Upcoming Events’ on the <a href="https://www.python.org/">Python </a>website but you don’t want to go to the website every time to see whether there is a new upcoming event on the website. In order to handle this problem image that you are working on a python bot which sends an email to your mail address when a new upcoming event is published on the Python website. In this case we usually use APIs and send GET request to the websites and URLs. But what if they don’t have a public API that we can make GET request. This is where web scraping comes in.</p><p>Using web scraping techniques we can get the html source code of a web site. And if there is some valuable data in the source code like some texts or links, it is easy to parse the html source using a few line of code.</p><p>Let’s scrap and parse some certain data from the original Python website as I mentioned in the first paragraph.</p><p>First things first I am sharing the full code and then I will explain how lines work step by step.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/47e2b47e4e4e4eb8c3d3f0528b3390ba/href">https://medium.com/media/47e2b47e4e4e4eb8c3d3f0528b3390ba/href</a></iframe><p>In python there are different libraries for web scraping called ‘lxml’ and ‘BeautifulSoup’. I prefered to use lxml in my project. If you wonder about ‘<a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/#">BeautifulSoup</a>’, just check it out its documentation for more details.</p><pre>def get_data(url, title_selector)</pre><p>In the function definition we are passing two parameters.</p><p><strong>url</strong>: This is the website URL we want to scrap.</p><p><strong>title_selector</strong>: We use a css selector to select some specific tags.</p><pre>response = requests.get(url)</pre><p>We make a GET request to the website and get a response object.</p><pre>if status_code == 200</pre><p>In this line we check if the request has succeeded.</p><pre>content = str(response.content, ‘utf-8’)</pre><p>Content is the html source. We’ll parse this content.</p><blockquote>Note: Some of websites are not using utf-8 or unicode encoding. In this case we may have some strange characters in our result. That’s why we are passing a parameter called ‘utf-8’.</blockquote><pre>tree = html.fromstring(content)</pre><p><em>html.fromstring</em> function parses the html, returns a single element/document.</p><pre>titles = tree.cssselect(title_selector)</pre><p>Using a css selector we are parsing the tree and getting the upcoming event titles. After you see the output, I’ll make this parameter clearer.</p><pre>for title in titles:<br>   print(title.text_content())</pre><p>Here we are iterating all the upcoming event titles using a for loop. <em>text_content () </em>function gives us the text inside a tag. We would might get an attribiute(like ‘href’) using <em>attrib[“href”] function. For more information you can check it out from </em><a href="https://lxml.de/2.2/lxmlhtml.html">here</a><em>.</em></p><p>Now, it’s time to invoke our method.</p><pre>get_data(<br>         &#39;https://www.python.org&#39;, <br>         &#39;div.event-widget &gt; div.shrubbery &gt; ul.menu &gt; li &gt; a&#39;<br>)</pre><p>Output will be like;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*va4UXbY2PyVvLMKT8g8VXw.png" /></figure><p>We got the result correctly.</p><p>Now let’s make css selectors clearer. Firstly go to the original <a href="http://python.org/">Python </a>website. On the page when you scroll down a little you’ll see a part called ‘Upcoming Events’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*ElPlUYWrV9FhlPa6aISCqQ.png" /></figure><p>These were the titles for upcoming events in our output. So just right-click on the title and then click ‘Inspect’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*pwcWh2ox0GZG3bDhJyXCTA.png" /></figure><p>As you can see here we have some nested html elements. So in our selector we didn’t only use &lt;a&gt; tag to select. Because there can be a lot of different text in different &lt;a&gt; tags. Therefore we used more specific selector to select only ‘Upcoming Events’ part.</p><p>Let’s remeber the selector we passed in our function before. It was like given below;</p><pre>‘div.event-widget &gt; div.shrubbery &gt; ul.menu &gt; li &gt; a’</pre><p>In general css selectors are used by web developers and designers to style the elements. If you are confused about how css selectors work you can learn them from <a href="https://www.w3schools.com/cssref/css_selectors.asp">here </a>in more details.</p><blockquote>Note: Web scraping has a disadvantage. When the website owner rebuilds the website or changes its style, we won’t be able to use our selector like before. In this case we need to change our css selector. Even though web scraping has a disadvantage like that, it’s still a good option when we don’t have an API to get data from websites.</blockquote><p>I hope the article was useful for you, thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f75dfb84dc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>