<?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 Auliyamichellea on Medium]]></title>
        <description><![CDATA[Stories by Auliyamichellea on Medium]]></description>
        <link>https://medium.com/@auliyamichellea?source=rss-113c7d7ac8ea------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*tthOhFBthoL2B68F.jpg</url>
            <title>Stories by Auliyamichellea on Medium</title>
            <link>https://medium.com/@auliyamichellea?source=rss-113c7d7ac8ea------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 11:05:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@auliyamichellea/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[The 4 Pillars of OOP Explained Simply (with Swift Examples)]]></title>
            <link>https://auliyamichellea.medium.com/the-4-pillars-of-oop-explained-simply-with-swift-examples-9857d7460438?source=rss-113c7d7ac8ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/9857d7460438</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[object-oriented]]></category>
            <dc:creator><![CDATA[Auliyamichellea]]></dc:creator>
            <pubDate>Wed, 13 Aug 2025 07:29:57 GMT</pubDate>
            <atom:updated>2025-08-13T07:29:57.070Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e7j1wqqIVFzSa4B7" /><figcaption>Photo by <a href="https://unsplash.com/@mertkahveci?utm_source=medium&amp;utm_medium=referral">Mert Kahveci</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you’ve ever built an iOS app with Swift — especially using UIKit — you’ve probably already used Object-Oriented Programming (OOP), even if you didn’t realize it.</p><p>I covered the basics of OOP in a previous article (feel free to check it out if you haven’t yet!).</p><p>OOP has four key pillars: E<strong>ncapsulation, Inheritance, Polymorphism</strong>, and A<strong>bstraction</strong>. Learning these helped me understand OOP on a deeper level and write cleaner, more maintainable code. These principles guide me toward more reusable, scalable architecture, especially in larger projects.</p><p>In this article, I’ll explain each pillar using simple analogies and code examples. This is part of my personal series on OOP, written to strengthen my own understanding and hopefully help others along the way, too.</p><h3>Encapsulation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CB5STgzPRamgFjz3" /><figcaption>Photo by <a href="https://unsplash.com/@lucasgwendt?utm_source=medium&amp;utm_medium=referral">Lucas George Wendt</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Encapsulation is about wrapping related data and functions together (using classes, structs, or enums), and hiding the internal data from outside access.</strong></p><h4>Let’s Imagine ✨</h4><p>Imagine a person’s heart as a class. The heart has feelings — this is the internal data or property — and the feelings are private, meaning they can’t be accessed or changed directly by other people (or other classes).</p><p>To understand how someone feels, we might call a method like tellStory(). To change their mood or feelings, we could use another method, like takeAWalk().</p><p>These methods — tellStory() and takeAWalk() — along with the private feelings property, are all bundled inside the Heart class.</p><p>Since the internal data (feelings) is hidden and only accessible through specific methods, this is an example of encapsulation. If the feelings property is not hidden (e.g., it&#39;s marked as public), and other objects can directly access or modify it without using the methods, then it’s not true encapsulation.</p><h4>Benefits of Encapsulation</h4><ul><li><strong>Protects data for security and integrity<br></strong>By making properties private and only accessible through controlled methods, you prevent unintended changes or misuse of internal data. This protects your data from being corrupted or accessed inappropriately.</li><li><strong>Easier maintenance and debugging<br></strong>Since external code can’t directly access internal data, bugs are easier to trace and fix. There’s a clear separation between what data is stored and how it can be accessed or changed , which reduces the chances of accidental misuse.</li><li><strong>Flexibility<br></strong>Encapsulation allows programmers to change the internal workings of a class (like how data is stored or calculated) without affecting other parts of your code , as long as the public interface (methods) remains consistent.</li></ul><h4>Code Example</h4><pre>class Post {<br>  private var likeNumber: Int<br><br>  init(like: Int) {<br>    self.likeNumber = like<br>  }  <br><br>  func like() {<br>    likeNumber += 1<br>  }<br><br>  func getLikeNumber() -&gt; Int {<br>    return likeNumber<br>  }<br><br>}<br><br>// Usage:<br>let post = Post(like: 0)<br>post.like()<br>print(post.getLikeNumber()) // Output: 1</pre><p>This is a simple example of encapsulation<strong> </strong>in a social media context like Instagram (note: not real Instagram code). It shields the internal likeNumber from direct access by external code, and it hides the internal logic of how a “like” is processed. External components can interact with the post using clearly defined methods ( like() and getLikeNumber()), which makes the system <strong>more secure, modular, and predictable</strong>.</p><h3>Abstraction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9vF6snFcZWAdOnYH" /><figcaption>Photo by <a href="https://unsplash.com/@himiwaybikes?utm_source=medium&amp;utm_medium=referral">Himiway Bikes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Abstraction is about hiding the implementation details</strong> and exposing only the necessary parts of an object or system. It allows you to use code without needing to understand how it works inside, you just interact with a clean, simplified interface. Abstraction also means <strong>depending on the interface, not the implementation.</strong></p><p>Abstraction <strong>improves code readability</strong> by hiding complex internal logic and showing only what’s essential. It also <strong>makes code</strong> <strong>easier to maintain, modify, and reuse</strong>, since developers can work with high-level structures without worrying about the underlying details.</p><h4>Let’s Imagine ✨</h4><p>Imagine a hybrid electric bike like Himiway, which can move using either pedals or a motor. Inside the bike, there’s a movement system that tells it to “go forward”, but it doesn’t need to know <em>how</em> that happens. Whether the motion comes from pedaling or a motor is hidden behind the scenes, the important thing is that the bike moves.</p><p>Both the pedal system and the motor system follow the same rule: they know how to move forward, just in different ways. This is what abstraction is all about — hiding complex implementation details and exposing only what’s necessary (like a moveForward() method). The bike system doesn’t know the implementation or how it moveForward(). The bike only <em>depends on the interface</em> (moveForward()), without needing to know how the pedal or motor system works internally.</p><h4>Code Example</h4><pre>protocol Movement {<br>   func moveForward()<br>}<br><br>class PedalSystem: Movement {<br>   func moveForward() {<br>    print(&quot;Pedaling forward!&quot;)<br>    }<br>}<br><br>class MotorSystem: Movement {<br>  func moveForward() {<br>    print(&quot;Brooom forward with motor!&quot;)<br>  }<br>}<br><br>class HimiwayBike {<br>  var movement: Movement<br><br>  init(movement: Movement) {<br>    self.movement = movement<br>}<br><br>  func startMoving() {<br>    movement.moveForward()<br>  }<br>}<br><br>// Usage:<br>let bike = HimiwayBike(movement: MotorSystem())<br>bike.startMoving() // Output: Brooom forward with motor!</pre><p>Swift doesn’t support abstract classes directly. But we can simulate them using protocols and a basic class. Protocol is the most common way to achieve abstraction.</p><h4>Way to achieve abstraction in Swift</h4><p><strong>1. Protocol</strong></p><pre>protocol Animal {<br>  func sound()<br>}<br><br>class Cat: Animal {<br>  func sound() {<br>    print(&quot;Meow&quot;)<br>  }<br>}<br><br>class Dog: Animal {<br>  func sound() {<br>    print(&quot;Woof&quot;)<br>  }<br>}<br><br>func makeSound(animal: Animal) {<br>  animal.sound()<br>}<br><br>// Usage:<br>let cat = Cat()<br>let dog = Dog()<br>makeSound(animal: cat)  // Output: Meow<br>makeSound(animal: dog)  // Output: Woof</pre><p>This example demonstrates abstraction because:</p><ul><li>The makeSound function doesn&#39;t know the exact type of animal it&#39;s working with.</li><li>It doesn’t care how sound() is implemented — it simply calls the method defined by the protocol.</li><li>It relies on the protocol (Animal) rather than a specific implementation.</li></ul><p>We shouldn’t write the functionmakeSound(animal: Cat)because it is not abstract; it still depends on a concrete type (Cat). We must write makeSound(animal:Animal) which means it depends on a general behavior, not a specific class.</p><p><strong>2. Class</strong></p><pre>class Animal {<br>  func sound() {<br>     fatalError(&quot;Subclasses need to implement the `sound()` method.&quot;)<br>   }<br>}<br><br>class Cat: Animal {<br>    override func sound() {<br>        print(&quot;miauw&quot;)<br>    }<br>}<br><br>class Dog: Animal {<br>    override func sound() {<br>        print(&quot;woof&quot;)<br>    }<br>}<br><br>// Usage:<br>let kitty = Cat()<br>kitty.sound() // Output: Meow<br><br>let bobby = Dog()<br>bobby.sound() // Output: Woof</pre><p>fatalError()is used to simulate an abstract method; it forces subclasses to override sound(). This mimics how abstract classes work in other languages by ensuring the subclass provides its implementation.</p><h3>Inheritance</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LyLq9g16LjqWmGml" /><figcaption>Photo by <a href="https://unsplash.com/@jessicarockowitz?utm_source=medium&amp;utm_medium=referral">Jessica Rockowitz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Inheritance is like a family relationship, </strong>there’s a parent class and child classes. The <strong>child classes inherit behaviors and properties from the parent</strong>, meaning they can do what the parent can do, and even extend or customize those behaviors.</p><p>In real-world Swift development, you see this often in UIKit. When you create a custom view controller, programmers usually subclass from UIViewController. By doing so, your custom controller automatically gets access to powerful methods like viewDidLoad() and viewDidAppear(). Inheritance lets you reuse existing logic while still allowing flexibility.</p><h4>Code Example</h4><pre>class Bear {<br>  var mass: Int<br>  var speed: String<br>  var food: String<br>  var height: Int<br><br>  init(mass: Int, speed: String, food: String, height: Int) {<br>    self.mass = mass<br>    self.speed = speed<br>    self.food = food<br>    self.height = height<br>  }<br><br>  func eat() {<br>    print(&quot;The bear eats&quot;)<br>  }<br>}<br><br>class PolarBear: Bear {<br>  var friends: Int<br><br>  init(mass: Int, speed: String, food: String, height: Int, friends: Int) {<br>    self.friends = friends<br>    super.init(mass: mass, speed: speed, food: food, height: height)<br>  }<br>}<br><br>class GrizzlyBear: Bear {<br>  func dance() {<br>    print(&quot;Grizzly bear dances&quot;)<br>  }<br>}<br><br>class Panda: Bear {<br>  func kungfu() {<br>    print(&quot;Panda does kungfu&quot;)<br>  }<br>}</pre><p>The base class called Bear has properties like mass, speed, and a method eat(). Then, different types of bears like the Panda, Grizzly Bear, and Polar Bear inherit from the Bear. They get all the common bear traits automatically, but can also add their unique methods like kungfu() or dance().</p><h3>Polymorphism</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zBINXx_hsChhz0FR" /><figcaption>Photo by <a href="https://unsplash.com/@amseaman?utm_source=medium&amp;utm_medium=referral">Andrew Seaman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Polymorphism</strong> means “many forms”. This means <strong>an object can have many different forms of implementation or methods</strong>.</p><h4>Polymorphism Types</h4><ol><li><strong>Compile-time polymorphism<br></strong>Also known as <strong>method overloading</strong>, it <strong>allows multiple functions with the same name but different parameter types or counts</strong>. Compile-time polymorphism <strong>happens when compilation.</strong></li></ol><pre>class Suneo {<br>  func show() {<br>    print(&quot;Suneo starts to show off&quot;)<br>  }  <br><br>  func show(_ name: String) {<br>    print(&quot;Suneo shows off his \\(name)&quot;)<br>  }<br><br>  func show(itemCount: Int) {<br>    print(&quot;Suneo shows off \\(itemCount) items&quot;)<br>  }<br>}<br><br>// Usage:<br>let suneo = Suneo()<br>suneo.show() // Output: Suneo starts to show off<br>suneo.show(&quot;drone&quot;) // Output: Suneo shows off his drone<br>suneo.show(itemCount: 3) // Output: Suneo shows off 2 items</pre><p><strong>2. Runtime Polymorphism <br></strong>Also known as <strong>method overriding</strong>, Runtime polymorphism occurs when a <strong>subclass overrides</strong> <strong>a method that is already defined in its superclass</strong>. This means the subclass provides its specific implementation of the method, replacing or extending the behavior inherited from the parent. Runtime polymorphism happens <strong>during program execution</strong></p><pre>class Bear {<br>  var mass: Int<br>  var speed: String<br>  var food: String<br>  var height: Int<br><br>  init(mass: Int, speed: String, food: String, height: Int) {<br>    self.mass = mass<br>    self.speed = speed<br>    self.food = food<br>    self.height = height<br>  }<br><br>  func eat() {<br>    print(&quot;The bear eats&quot;)<br>  }<br>}<br><br>class Panda: Bear {<br><br>  override func eat(){<br>     print(”Panda eats bamboo”)<br>  }<br><br>  func kungfu() {<br>  print(&quot;Panda does kungfu&quot;)<br>  }<br>}</pre><h3>Conclusion</h3><p>Understanding encapsulation, abstraction, inheritance, and polymorphism helps us write better, cleaner, and more flexible code.</p><ul><li><strong>Encapsulation</strong> means<strong> bundling data and related functions</strong> together (using classes, structs, or enums) while <strong>hiding internal details</strong> from the outside.</li><li><strong>Abstraction</strong> improves code readability by <strong>hiding complex logic</strong> and exposing only what’s essential through simplified interfaces.</li><li><strong>Inheritance</strong> is like a <strong>family structure</strong>; child classes inherit properties and behaviors from a parent class, and can extend or modify them.</li><li><strong>Polymorphism</strong> means <strong>objects can take on many forms</strong> ; the same method can behave differently depending on the object calling it.</li></ul><p>These concepts appear all the time in real-world iOS development, especially when using protocols, abstracted logic, or UIKit classes like UIViewController.</p><p>I hope this article helped you better understand the four pillars of OOP! If I missed anything or if you have a different perspective, feel free to share your thoughts in the comments. I’d love to hear your experiences and any suggestions you might have, let’s learn together!</p><p>Also, feel free to reach out to me on <a href="https://www.linkedin.com/in/auliya-michelle-adhana-126a88184/">LinkedIn</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9857d7460438" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift and OOP: Simplifying Code with Object-Oriented Programming]]></title>
            <link>https://auliyamichellea.medium.com/swift-and-oop-simplifying-code-with-object-oriented-programming-07439b0f0f68?source=rss-113c7d7ac8ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/07439b0f0f68</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[swift-oop]]></category>
            <dc:creator><![CDATA[Auliyamichellea]]></dc:creator>
            <pubDate>Wed, 13 Aug 2025 07:28:23 GMT</pubDate>
            <atom:updated>2025-08-13T07:28:23.771Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HMLShVEj1zno-RiV" /><figcaption>Photo by <a href="https://unsplash.com/@davidkristianto?utm_source=medium&amp;utm_medium=referral">David Kristianto</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hello everybody! In this article, we’ll explore Object-Oriented Programming (OOP), its pros and cons, and how it’s used in real-world projects.</p><h4>Introduction</h4><p>Swift supports multiple programming paradigms, and object-oriented programming (OOP) is the most commonly used, especially in app development with UIKit. UIKit is fundamentally based on object-oriented principles. Even though SwiftUI primarily uses structs, we often rely on classes for data services, view models, and shared managers. <strong>OOP helps break down complex systems into clean, organized, reusable components by modeling things as objects.<br> </strong><br>Swift uses ARC (Automatic Reference Counting) to keep track of how many references exist to a class instance in memory. The more unnecessary objects that stay in memory, the slower the app may become. Using ARC efficiently means creating objects only when needed, and ensuring they’re released when no longer in use. Class instances, which are reference types stored in the heap, are managed by ARC. Structs and enums, being value types, are typically stored on the stack or copied when passed. <strong>Understanding OOP helps us structure our functions and classes in a way that uses ARC more efficiently.</strong></p><p>This article is part of my personal series on OOP, written to solidify my understanding and share it with others.</p><h4>What is Object Oriented Programming?</h4><p>Object-Oriented Programming (OOP) is a way of structuring code by grouping related data and behaviors into objects. In this approach, programs are organized around objects rather than just actions or logic. These objects are created from classes, which act like blueprints that define what data (called properties) an object holds and what actions (called methods) it can perform.</p><h4>Let’s Imagine ✨</h4><p>Let’s imagine having a task to organize a Giant concert with code.</p><p>Instead of writing one big chunk of code, you think in terms of objects, like the Giant (singer), the audience, or the concert.</p><p>Singer object has:</p><ul><li>Things it knows (called properties) — like name, the number of audience, or the volume of the microphone.</li><li>Things it can do (called methods) — like sing, scream, or break eardrums 😅.</li></ul><h4>How is object-oriented programming used in a real project?</h4><p>To understand how OOP is used in a real project, let’s look at a login flow. You might create a LoginViewController class that handles the login logic. The class might store user input like the username and password. Username and password variables are properties that belong to an object because they represent the data or state of that object. The <em>LoginViewController</em> class contains a login() method to authenticate the user, and it inherits from UIViewController to manage the screen’s layout and lifecycle.</p><h4>Pros of OOP</h4><p>By using OOP, <br><strong>1. Organize code </strong><br>OOP helps keep your code organized by grouping related properties and methods into objects. Each class defines a specific type of object, making your code more modular and easier to maintain. Instead of spreading logic across files, OOP encourages keeping related functionality in one place. <br><strong>2. Reusable code </strong><br>Through inheritance and polymorphism, OOP makes your code more reusable. The child class inherits the parent’s behavior, so the child class doesn’t need to duplicate the same code. Polymorphism concepts let you reuse logic across multiple parts of your app without duplicating code. <br><strong>3. Reduced Redundancy </strong><br>Through inheritance, OOP lets you avoid writing the same code repeatedly. You can create a base class with common functionality, and other classes can inherit from it and reuse that code. This reduces duplication and keeps your code DRY (Don’t Repeat Yourself).</p><h4>Cons Of OOP</h4><p>But OOP will have side effect:<br><strong>1. Complicated <br></strong>Inheritance can make your code harder to maintain. If you change something in the parent class, it might break the behavior of child classes , especially if they override or depend on the method. This creates a fragile chain of dependencies that can become difficult to manage in large projects. <br><strong>2. Large-Size</strong><br>OOP usually involves writing more code than procedural programming. You define classes, properties, methods, and relationships, which can lead to more memory use or indirect method calls. which <em>may</em> impact performance in certain cases. In modern compilers and devices are fast, object-oriented code can introduce performance overhead if not carefully managed, especially with deep inheritance trees or complex abstractions.<br><strong>3. Tricky </strong><br>When you’re new to OOP, it can feel confusing. You need to learn how to think in objects, not just steps. Concepts like polymorphism, inheritance, and abstraction take time to understand and apply effectively. It took me time, too — but with practice, it becomes more natural.</p><h4>Conclusion</h4><p>To wrap up, Object-Oriented Programming (OOP) is a powerful way to <strong>structure your code by thinking in terms of objects.</strong> By using classes as blueprints and organizing related data and actions together, <strong>OOP helps make your code more organized, reusable, and modular</strong>.</p><p>However, it’s not without its challenges. <strong>OOP can sometimes lead to complicated inheritance hierarchies, larger codebases, and a hard to learn.</strong> But with time and practice, the benefits of OOP become clear, especially when you start using it with Swift’s <strong>ARC</strong> for efficient memory management.</p><p>I hope this article helped clarify the basics of OOP! If I’ve missed something or if you have a different perspective, please feel free to share your thoughts in the comments. I’d love to hear your experiences and any corrections you might have — let’s learn together!</p><p>Feel free to reach out to me on <a href="https://www.linkedin.com/in/auliya-michelle-adhana-126a88184/">LinkedIn</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=07439b0f0f68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swiftlint: Common Encountered Problem or Warning]]></title>
            <link>https://auliyamichellea.medium.com/swiftlint-common-encountered-problem-or-warning-aaf3fbd309b8?source=rss-113c7d7ac8ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/aaf3fbd309b8</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swiftlint]]></category>
            <dc:creator><![CDATA[Auliyamichellea]]></dc:creator>
            <pubDate>Fri, 25 Aug 2023 06:55:37 GMT</pubDate>
            <atom:updated>2023-08-25T06:55:37.443Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MT2V-MUAXYP-4MIC" /><figcaption>Photo by <a href="https://unsplash.com/@bmpanaguiton?utm_source=medium&amp;utm_medium=referral">Breana Panaguiton</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Do you ever feel stressful face a lot of SwiftLint error and warning? Don’t worry, here I will explain some of SwiftLint rule that I commonly faced and the solution to fix.</p><h4>Trailing Whitespace Violation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UN0s4gr9_K7ubmdABKM4Eg.png" /><figcaption>Trailing Whitespace Violation</figcaption></figure><p><strong>Error explanation:</strong> This warning appears because there is some unnecessary whitespace (tab/ spaces).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m5rmKYl6gHY05oKsCYqouQ.gif" /></figure><p><strong>How to resolve:</strong> Remove whitespace</p><h4>Line Length Violation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ab0pGEyzyJe9uCo-e2e4Pg.png" /></figure><p><strong>Error explanation:</strong> This warning appears because in one line there are too many characters. By default, SwiftLint limit one line with 200 characters and will be giving warning if reach 120 characters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BLujZmHbnGxNCTa0Lnrz7Q.png" /></figure><p><strong>How to resolve: </strong>Remove unused code in that line or split to some line. See this link to know more how to split the code: <a href="https://google.github.io/swift/#line-wrapping">https://google.github.io/swift/#line-wrapping</a></p><h4>Force Cast Violation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T2k6GkEub6-_wL94R6zoCQ.png" /><figcaption>Force Cast Violation</figcaption></figure><p><strong>Error explanation</strong> : This error appears because you are using force-casting (symbol !). Force-casting should be avoid because if the object doesn’t throw anything, the code will be crashed.</p><p><strong>Resolve :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rj1iT2eqXLnehhOdR3SX1g.png" /><figcaption>Code that follow force cast rule</figcaption></figure><p><strong>How to resolve</strong>: Give handling if the object doesn’t throw anything. You can use downcasting (symbol ?) or giving guard let or if else to handling the object if doesn’t throw anything.</p><h4>Unused Closure Parameter Violation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W9URE-uEJE1N1E_Vnx_zeA.png" /><figcaption>Unused closure parameter violation</figcaption></figure><p><strong>Explanation:</strong> This warning appear because the closure parameter is not used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jxh4GTch4ComdLA_9gSqzw.png" /></figure><p><strong>How to resolve:</strong> Change the closure to “_”.</p><h4>Function Body Length Violation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V1yNy4u99apf6d3nKOAL2g.png" /></figure><p><strong>Explanation:</strong> This warning appear because one function has too much span or content. One function shouldn’t be filled with 50–100 lines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7o7QKnsZsv2_wQ38J0xm1w.png" /></figure><p><strong>How to resolve:</strong> Split the function into some small function or removed unused code or line space.</p><h4>Open for Discussions</h4><p>Please feel free to comment below, <strong>if you have any feedback or questions.</strong></p><p>If you enjoy this article, you’re welcome to share it with your friends and drop a comment. Additionally, you can click the 👏 applause icon.</p><p>Thank you for reading! 👩🏻‍💻</p><h4>Reference</h4><ul><li><a href="https://realm.github.io/SwiftLint/force_cast.html">force_cast Reference</a></li><li><a href="https://realm.github.io/SwiftLint/function_body_length.html">function_body_length Reference</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aaf3fbd309b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[useContext dan useReducer]]></title>
            <link>https://auliyamichellea.medium.com/usecontext-dan-usereducer-92be8470d7b9?source=rss-113c7d7ac8ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/92be8470d7b9</guid>
            <category><![CDATA[usecontext]]></category>
            <category><![CDATA[usereducer]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Auliyamichellea]]></dc:creator>
            <pubDate>Thu, 20 Apr 2023 04:35:34 GMT</pubDate>
            <atom:updated>2023-04-20T04:35:34.467Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Sebelum penjelasan tentang useContext dan useReducer saya akan menjelaskan terlebih dahulu tentang context. Context adalah state management pada react yang konsepnya seperti redux. Context menyediakan cara mengirim data antara component tree tanpa harus mengirim props ke bawah secara manual pada setiap level. useContext dan useReducer adalah hook yang digunakan pada context.</p><h3>useContext</h3><pre>import React, { useContext } from &quot;react&quot;;</pre><pre>import { CountContext } from &quot;./App&quot;;</pre><pre>function ComponentA() {<br>const countContext = useContext(CountContext);<br>return (<br> &lt;div&gt;<br>    ComponentA<br>   &lt;button onClick={() =&gt;countContext.countDispatch(&quot;increment&quot;)}&gt;<br>     increment<br>   &lt;/button&gt;<br>&lt;/div&gt;<br>   );<br>}</pre><p>usecontext digunakan untuk mengambil data dari pusat. Pada contoh di atas maka kita mengambil fungsi increment pada data pusat.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92be8470d7b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Tips To Manage Time Efficiently + Book Recommendation]]></title>
            <link>https://auliyamichellea.medium.com/5-tips-to-manage-time-efficiently-book-recommendation-762bcef7affd?source=rss-113c7d7ac8ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/762bcef7affd</guid>
            <category><![CDATA[time-management]]></category>
            <category><![CDATA[book-recommendations]]></category>
            <dc:creator><![CDATA[Auliyamichellea]]></dc:creator>
            <pubDate>Thu, 20 Apr 2023 04:34:52 GMT</pubDate>
            <atom:updated>2023-04-20T04:34:52.467Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F1wvJqTBTDrFDSIQ" /><figcaption>Photo by <a href="https://unsplash.com/@thomasbormans?utm_source=medium&amp;utm_medium=referral">Thomas Bormans</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><strong>Introduction</strong></h4><p>“Oh no, i ran out my time.” Ever feeling like this? I feel you. We have 24 hours each day with bunch of task to do. I know that manage time is hard to do for me and some of us. I still struggle with this too. Here I will give some tips to manage time that I got from “Wewomen.id Mentorship 2022” and book I’ve read. These tips help me to manage time and I hope it works for you either.</p><h4>How to manage time:</h4><ol><li><strong>Find your best principle</strong></li></ol><p>You can take a look at Pareto, ABC analysis, and Eisenhower matrix for time management principle.</p><p>- Pareto principle is do 20% task that can give 80% impact.</p><p>- ABC analysis divide task into three part. First is tasks that can be done by yourself, very important, and have highest value. Second, task that very important but delegable. Third is the least valuable task.</p><p>-Eisenhower matrix principle divide task into four. First is task that we should do right now, important and urgent task. Second is task that we must scheduled ,important but not urgent task. Third, delegable task,urgent but not important task. Last, delete task that not urgent and not important.</p><p><strong>2.Find things to make you enjoy your task</strong></p><p>We often procastinate our job because not enjoy with it not because we are lazy. We just find others thing to distract us to do our job. Because of that we must make our job to be fun and enjoyable. We can listen music or drink chocolate to boost our mood in doing jobs.</p><p><strong>3.Track your time</strong></p><p>I ever made time blocking to schedule my time, but it didn’t work and made me stress. It didn’t work because I did task over the time I have scheduled and it messed up my schedule. Have you ever feel like this? I know what is the root problem now. The root problem is I don’t know how much time I spend to do a task. So, it is important to track your time and know how much time do you spend with it.</p><p><strong>4. Know your productive time</strong></p><p>Each of us have different productive time. We must know our productive time. For now, I can be productive at 10:00 am — 12:00 am, 03:00 pm — 05:00 pm and 08:00 pm — 00:00 am. So I do the important task on that time. For me, It helps to manage and maximize my task.</p><p><strong>5. Make free time on weekend</strong></p><p>This free time means a block of time with nothing specific to do. Free time on weekend can we use to do all task from one week that have not been done because of limit time. By this free time we have no excuse to expand our time of task.</p><h4>Book recommendation:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/183/1*6PL1CTkDGd1RPoQ0JQZdFg.png" /><figcaption>indistractable book by Nir Eyal</figcaption></figure><p>This book is recommendation from kak there, my mentor. I also recommend you all to read this book. This book give new thought about time management and some tips inside.</p><h4>Closing</h4><p>That’s all from me. I hope you like this article. If there is any mistaken you can comment bellow to help me fixed. You’ve read all the article, thank you very much. For the last, I would like to ask you. How about you? How to manage your time?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=762bcef7affd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mengenal React Class dan Fuctional Component]]></title>
            <link>https://auliyamichellea.medium.com/mengenal-react-class-dan-fuctional-component-a4f636c8a938?source=rss-113c7d7ac8ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4f636c8a938</guid>
            <category><![CDATA[react-class-component]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-function-component]]></category>
            <category><![CDATA[react-indonesia]]></category>
            <dc:creator><![CDATA[Auliyamichellea]]></dc:creator>
            <pubDate>Sun, 01 Aug 2021 10:20:38 GMT</pubDate>
            <atom:updated>2021-08-01T10:21:51.344Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mengenal React Class and Fuctional Component</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pFnpDy4bRwHfKEwsc0AYlQ.png" /><figcaption>class vs functional</figcaption></figure><h3>Definisi</h3><p>React class component adalah kelas pada javascript yang mengharuskan extend dari React.Component. Sedangkan React functional component adalah fungsi pada javascript yang mengembalikan JSX.</p><h3>Perbedaan</h3><p>Terdapat beberapa perdedaan antara class dan functional:</p><ul><li>Component Lifecycle</li></ul><p>Jika pada class kita gunakan componentDidMount,componentWillUnmount, dll. Maka pada functional kita tidak dapat menggunakan component lifecycle dan sebagai gantinya kita dapat menggunakan hook, useEffect.</p><ul><li>State</li></ul><p>Di class kita menggunakan this.state={} untuk menulis nilai awal dan this.setState({}) untuk mengganti nilai awal sedangkan untuk functional kita akan menggunakan hook useState. Dimana const [state,setState] = useState() untuk menulis nilai awal dan setState() untuk mengganti nilai awal.</p><ul><li>Method render</li></ul><p>Di class component kita perlu membuat fungsi render yang akan mengembalikan react element sedangkan di functional component kita tidak perlu menggunakan hal tersebut.</p><h3>Pilih yang mana??</h3><p>Semenjak adanya hook kebanyakan programmer react memilih functional component. Beberapa alasan diantaranya adalah:</p><ol><li>Tidak perlu mengetik this.</li><li>Jumlah line koding lebih sedikit</li><li>Lebih mudah dibaca dan dipahami</li></ol><h3>Contoh perbandingan</h3><h4>Functional Component</h4><pre><em>/** @jsx jsx */</em></pre><pre><em>// import React from &quot;react&quot;;</em></pre><pre>import { jsx } from &quot;@emotion/core&quot;;</pre><pre>import PropTypes from &quot;prop-types&quot;;</pre><pre>import { useTheme } from &quot;emotion-theming&quot;;</pre><pre>import * as styles from &quot;./button.styles&quot;;<br></pre><pre>const Button = ({ text, onClick, color, align }) =&gt; {</pre><pre>const theme = useTheme();</pre><pre>return (</pre><pre>&lt;button css={styles.button({ align, color, theme })} onClick={onClick}&gt;</pre><pre>{text}</pre><pre>&lt;/button&gt;</pre><pre>);</pre><pre>};</pre><pre>Button.defaultProps = {</pre><pre>text: &quot;Button&quot;,</pre><pre>color: &quot;black&quot;,</pre><pre>align: &quot;left&quot;</pre><pre>};</pre><pre>Button.propTypes = {</pre><pre>text: PropTypes.string.isRequired,</pre><pre>onClick: PropTypes.func,</pre><pre>color: PropTypes.oneOf([&quot;black&quot;, &quot;red&quot;]),</pre><pre>align: PropTypes.oneOf([&quot;left&quot;, &quot;right&quot;])</pre><pre>};</pre><pre>export default Button;</pre><h4>Class Component</h4><pre>import React from &quot;react&quot;;</pre><pre>import styled from &quot;@emotion/styled&quot;;</pre><pre>import PropTypes from &quot;prop-types&quot;;</pre><pre>import { withTheme } from &quot;emotion-theming&quot;;<br></pre><pre>const StyledButton = styled.button`</pre><pre>font-size: 1.8rem;</pre><pre>font-family: &quot;Bungee&quot;, sans-serif;</pre><pre>color: ${(props) =&gt; props.textColor};</pre><pre><em>/* width: 24%; */</em></pre><pre>padding: 16px;</pre><pre>cursor: pointer;</pre><pre>background: unset;</pre><pre>border: unset;</pre><pre>outline: unset;</pre><pre>text-align: ${(props) =&gt; props.align};</pre><pre>`;</pre><pre>class Button extends React.Component {</pre><pre>render() {</pre><pre>const { text, onClick, color, align, theme } = this.props;</pre><pre>const {</pre><pre>color: { primary }</pre><pre>} = theme;</pre><pre>let textColor;</pre><pre>switch (color) {</pre><pre>case &quot;black&quot;:</pre><pre>textColor = primary.black;</pre><pre>break;</pre><pre>case &quot;red&quot;:</pre><pre>textColor = primary.red;</pre><pre>break;</pre><pre>default:</pre><pre>textColor = primary.black;</pre><pre>break;</pre><pre>}</pre><pre>return (</pre><pre>&lt;StyledButton textColor={textColor} align={align} onClick={onClick}&gt;</pre><pre>{text}</pre><pre>&lt;/StyledButton&gt;</pre><pre>);</pre><pre>}</pre><pre>static defaultProps = {</pre><pre>text: &quot;Button&quot;,</pre><pre>color: &quot;black&quot;,</pre><pre>align: &quot;left&quot;</pre><pre>};</pre><pre>static propTypes = {</pre><pre>text: PropTypes.string.isRequired,</pre><pre>onClick: PropTypes.func,</pre><pre>color: PropTypes.oneOf([&quot;black&quot;, &quot;red&quot;]),</pre><pre>align: PropTypes.oneOf([&quot;left&quot;, &quot;right&quot;])</pre><pre>};</pre><pre>}</pre><pre>export default withTheme(Button);</pre><p>untuk lebih jelas dapat mampir ke yang di bawah inii !!!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fnr1g6&amp;display_name=CodeSandbox&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fnr1g6&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fnr1g6%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/267d47e50f7533439657576b52435157/href">https://medium.com/media/267d47e50f7533439657576b52435157/href</a></iframe><h3>Referensi:</h3><ul><li><a href="https://www.geeksforgeeks.org/differences-between-functional-components-and-class-components-in-react/">Differences between Functional Components and Class Components in React - GeeksforGeeks</a></li><li><a href="https://blog.logrocket.com/react-functional-components-3-advantages-and-why-you-should-use-them-a570c83adb5e/">3 advantages of React functional components on an ecommerce site - LogRocket Blog</a></li><li><a href="https://www.twilio.com/blog/react-choose-functional-components">Understanding Functional Components vs. Class Components in React</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4f636c8a938" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mengenal React]]></title>
            <link>https://auliyamichellea.medium.com/mengenal-react-cf1bf676f2f2?source=rss-113c7d7ac8ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf1bf676f2f2</guid>
            <category><![CDATA[react-intro]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[apa-itu-react]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react-indonesia]]></category>
            <dc:creator><![CDATA[Auliyamichellea]]></dc:creator>
            <pubDate>Wed, 16 Jun 2021 14:43:40 GMT</pubDate>
            <atom:updated>2021-06-16T14:43:40.672Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PHuovopfSi7OQAvy" /><figcaption>Photo by <a href="https://unsplash.com/@filisantillan?utm_source=medium&amp;utm_medium=referral">Filiberto Santillán</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Apa itu react?</h3><p>React adalah library JavaScript untuk membangun antarmuka pengguna. React bersifat open source dan digunakan untuk bagian frontend. React dikembangkan oleh facebook.</p><h3>Apa masalah yang diselesaikan oleh react?</h3><p>React menyelesaikan masalah pada user interface yang complex dan bersifat dinamis(data sering berubah).<br>Ketika membuat aplikasi menggunakan javascript maka kita memerlukan DOM(Data Object Model) untuk mengubah tampilan sebuah website secara dinamis. Seringkali yang terjadi adalah performa aplikasi menjadi lambat dikarenakan element DOM. Contoh: Facebook. Di Facebook trending topik selalu berganti, iklan juga berganti. Sehingga membutuhkan banyak operasi DOM yang berjalan di background. Maka dari itu React hadir memberi solusi tanpa perlu menulis banyak kode tricky di Javascript dan membuat kinerja selama runtime dan skalabilitas cepat dari aplikasi baru.</p><h3>Bagaimana react menyelesaikan masalah di atas ?</h3><p>React menggunakan dom virtual(representasi pohon DOM di JavaScript) dan algoritma dif. Jadi ketika ada pembaruan data maka akan membuat perbedaan pada pohon DOM sebelumnya dengan yang baru, dan hanya akan memperbarui yang telah berubah. Dengan algoritma diff maka operasi penyegaran DOM berkurang, Sehingga performa meningkat.</p><h3>Referensi:</h3><ul><li><a href="https://en.wikipedia.org/wiki/React_(JavaScript_library)">React (JavaScript library) - Wikipedia</a></li><li><a href="https://www.conceptatech.com/blog/how-does-reactjs-solve-the-problem-of-data-changing-over-time">How Does ReactJS Solve the Problem of Data Changing Over Time?</a></li><li><a href="https://scotch.io/@anitashah/what-problems-does-reactjs-solve-when-must-you-select-reactjs">What Problems Does React.JS Solve? When Must You Select React.JS?</a></li><li><a href="https://askinglot.com/what-is-react-js-and-what-problems-does-it-try-and-solve">What is react JS and what problems does it try and solve?</a></li><li><a href="https://id.wikipedia.org/wiki/Document_Object_Model">Document Object Model - Wikipedia bahasa Indonesia, ensiklopedia bebas</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf1bf676f2f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mengenal Gitflow]]></title>
            <link>https://auliyamichellea.medium.com/mengenal-gitflow-3f788168c912?source=rss-113c7d7ac8ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f788168c912</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[gitflow]]></category>
            <dc:creator><![CDATA[Auliyamichellea]]></dc:creator>
            <pubDate>Sat, 15 May 2021 13:39:24 GMT</pubDate>
            <atom:updated>2021-05-15T13:39:24.691Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XSV1wgqPwPWa4gme" /><figcaption>Photo by <a href="https://unsplash.com/@synkevych?utm_source=medium&amp;utm_medium=referral">Roman Synkevych</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Gitflow adalah alur kerja Git yang membantu pengembangan perangkat lunak berkelanjutan dan menerapkan praktik DevOps. Ada berbagai macam branch dalam gitflow diantaranya:</p><ol><li>Feature Branches : feature digunakan saat membuat fitur baru. Feature tidak berinteraksi langsung dengan branch master. Jadi ketika feature branch selesai maka akan merge dengan branch develop.</li><li>Release Branches : Release digunakan saat semua fitur siap dirilis. Branch release merge dengan branch master dan diberi tag dengan nomor versi.</li><li>Hotfix Branches : Hotfix digunakan ketika perlu perbaikan dan perubahan di branch develop dan master. Hotfix dibuat dari master dan jika selesai maka akan merge ke master dan develop.</li><li>Bugfix Branches: Bugfix digunakan untuk perbaikan di branch develop saja. Bugfix dibuat dari develop. Ketika bugfix selesai maka akan dimerge hanya ke develop.</li></ol><p>Cara menggunakan gitflow feature:</p><ol><li>Install extension gitflow di visual studio code. Tujuannya adalah untuk mempermudah melakukan gitflow.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xcq30QxfyGR7OfPrDRcpnQ.png" /><figcaption>gitlow extension</figcaption></figure><p>2. Pastikan anda telah berada branch develop. Kemudian tekan ctrl+shift+p. Pilih Gitflow:Feature:start, lalu ketikkan nama fitur yang akan dibuat. Jika ini pertama kali membuat gitflow maka anda harus initialize terlebih dahulu.</p><p>3. Mengetik kode / Ngoding</p><p>4. Commit</p><p>5. Sebelum Git feature finish, pull dahulu pada bagian develop.</p><p>6. Kembali pada branch feature dan tekan ctrl+shift+p. Pilih Gitflow:feature:finish. Maka otomatis branch feature merge dengan branch develop.</p><p>7. Pastikan tidak ada conflict pada develop, Kemudia push</p><p>8. Selesai</p><p>Cara cara di atas dapat juga dilakukan untuk bugfix. Caranya sama hanya pilih command untuk bugfix start dan finish bukan feature.</p><p>Jika mengalami kesusahan dan membutuhkan anggota tim lain dalam menyelesaikan fitur kita dapat menggunakan publish a feature. Perintah gitflow publish a feature membuat anggota lain dapat melihat branch feature kita.</p><p>Untuk lebih lengkap dapat melihat laman berikut:</p><p><a href="https://danielkummer.github.io/git-flow-cheatsheet/">git-flow cheatsheet</a></p><p>Referensi:</p><p><a href="https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow#:~:text=Gitflow%20Workflow%20is%20a%20Git,designed%20around%20the%20project%20release">Gitflow Workflow | Atlassian Git Tutorial</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f788168c912" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mengenal React Hooks: UseState dan useEffect]]></title>
            <link>https://auliyamichellea.medium.com/mengenal-react-hooks-usestate-dan-useeffect-d61090f87a6c?source=rss-113c7d7ac8ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/d61090f87a6c</guid>
            <category><![CDATA[react-hook-useeffect]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react-hook-usestate]]></category>
            <category><![CDATA[react-hook]]></category>
            <dc:creator><![CDATA[Auliyamichellea]]></dc:creator>
            <pubDate>Thu, 29 Apr 2021 08:54:15 GMT</pubDate>
            <atom:updated>2021-04-29T08:54:53.836Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-htIeXGp512l34o0" /><figcaption>Photo by <a href="https://unsplash.com/@vishu_2star?utm_source=medium&amp;utm_medium=referral">Vishal Jadhav</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><strong>Apa Itu React Hook?</strong></h4><p>React hook adalah fungsi yang memungkinkan Anda “menghubungkan” React state dan fitur lifecycle dari komponen fungsi. <em>Hooks</em> merupakan fitur baru di React 16.8. Dengan <em>Hooks</em>, kita dapat menggunakan <em>state</em> dan fitur React yang lain tanpa perlu menulis sebuah kelas baru.</p><h4>Apa Saja fungsi dari React Hook?</h4><ul><li>memungkinkan menggunakan kembali logika stateful tanpa mengubah hierarki komponen.</li><li>memungkinkan membagi satu komponen besar menjadi fungsi yang lebih kecil berdasarkan bagian mana yang terkait (seperti menyiapkan subcription atau mengambil data)</li><li>tidak perlu menggunakan kelas. hanya menggunakan fungsi</li></ul><h4><strong>UseState</strong></h4><pre>import React, { useState } from &quot;react&quot;;</pre><pre>const ComponentC = () =&gt; {</pre><pre>const [number, setNumber] = useState(0);</pre><pre>return (</pre><pre>&lt;div&gt;<br>     Number: {number}<br>     &lt;button onClick={() =&gt; setNumber(number + 1)}&gt;Increase&lt;/button&gt;        &lt;/div&gt;</pre><pre>);};</pre><pre>export default ComponentC;</pre><p>jika sebelumnya Anda menggunakan komponen class maka Anda tidak asing dengan “this.setState”. Use state dapat diibaratkan seperti this.setState pada komponen fungsi. Berdasarkan contoh di atas, initial number bernilai 0. Lalu untuk mengatur nilai number maka menggunakan setNumber().</p><h4>useEffect</h4><p>useEffect adalah pengganti lifecycle method pada class (componentDidMount, componentWillUnmount, componentDidUpdate). Macam-macam useEffect menurut saya:</p><p><strong>A. useEffect murni atau tanpa embel-embel:</strong></p><pre>useEffect(() =&gt; {<br>document.title = `${number} times`;<br>});</pre><p>useEffect jenis ini akan dijalankan setelah initial render dan setelah setiap update atau perubahan yang terjadi. useEffect jenis ini sama seperti componentDidUpdate dan componentdidMount.</p><p><strong>B. useEffect array berisi value</strong></p><pre><em>useEffect(() =&gt; {<br>document.title = `${number} times`;<br>}, [number]);</em></pre><p>useEffect jenis ini hanya akan dijalankan ketika value di dalam array berubah. Jika menurut contoh di atas maka useEffect hanya akan dijalankan ketika nilai number berubah .</p><p><strong>C.useEffect berisi array kosong</strong></p><pre>useEffect(() =&gt; {<br>document.title = `${number} times`;<br>}, []);</pre><p>useEffect jenis ini hanya dijalankan pada initial render. Jadi jika ada perubahan apapun dia tidak berubah. penggunaan useEffect seperti ini sama seperti componentDidMount pada class.</p><p><strong>D. useEffect cleanup function</strong></p><pre>useEffect(() =&gt; {<br>    function handleStatusChange(status) {<br>      setIsOnline(status.isOnline);<br>    }<br><br>    ChatAPI.subscribeToFriendStatus(props.friend.id, handleStatusChange);<br>    return () =&gt; {<br>      ChatAPI.unsubscribeFromFriendStatus(props.friend.id, handleStatusChange);<br>    };<br>  });</pre><p>Penggunaan return pada useEffect ini seperti penggunaan componentWillUnmount pada class. Jika component di hapus dari DOM maka return()=&gt;{} di dalam useeffect akan dijalankan.</p><p>Referensi:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FcF2lQ_gZeA8%3Flist%3DPLC3y8-rFHvwisvxhZ135pogtX7_Oe3Q3A&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DcF2lQ_gZeA8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FcF2lQ_gZeA8%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/c727b6635d28e3a2d678084609b957a5/href">https://medium.com/media/c727b6635d28e3a2d678084609b957a5/href</a></iframe><p><a href="https://reactjs.org/docs/hooks-intro.html">Introducing Hooks - React</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d61090f87a6c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>