<?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 Ibnu Arseno on Medium]]></title>
        <description><![CDATA[Stories by Ibnu Arseno on Medium]]></description>
        <link>https://medium.com/@ibnua_?source=rss-271742272be9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vOKqlUYbMCw9UlIMd1PEhQ.jpeg</url>
            <title>Stories by Ibnu Arseno on Medium</title>
            <link>https://medium.com/@ibnua_?source=rss-271742272be9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 07:53:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ibnua_/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[Vue 3 and Modern State Management: Is It Time to Ditch Vuex for Pinia?]]></title>
            <link>https://medium.com/@ibnua_/vue-3-and-modern-state-management-is-it-time-to-ditch-vuex-for-pinia-c3959f02e67e?source=rss-271742272be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3959f02e67e</guid>
            <category><![CDATA[vuex]]></category>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[pinia]]></category>
            <category><![CDATA[vue-3]]></category>
            <dc:creator><![CDATA[Ibnu Arseno]]></dc:creator>
            <pubDate>Sun, 04 May 2025 10:09:54 GMT</pubDate>
            <atom:updated>2025-05-04T10:09:54.370Z</atom:updated>
            <content:encoded><![CDATA[<p>State management is a cornerstone of building Vue applications that scale beyond simple to-do lists. As apps grow and business logic becomes more intricate, managing state efficiently becomes crucial. In the Vue.js world, two major players dominate this conversation: <strong>Vuex</strong> and <strong>Pinia</strong>.</p><p>But the question is: <strong>Is Vuex still relevant in the Vue 3 era? Or is it time to switch to Pinia for a more modern and enjoyable development experience?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q5rYL4P51AZpptTW" /><figcaption>Photo by <a href="https://unsplash.com/@_lewis_f?utm_source=medium&amp;utm_medium=referral">Lewis Fagg</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Understanding the Essence of State Management</h3><p>State management is the structured technique for storing, managing, and sharing data (or <em>state</em>) across components within an application. Without proper state management, large applications can quickly become difficult to maintain, understand, and even prone to bugs.</p><p>In the Vue.js ecosystem, before the arrival of Vue 3, <strong>Vuex</strong> was the official solution and the go-to choice for developers. However, since Vue 3 was released with its revolutionary Composition API, <strong>Pinia</strong> has emerged as a fresher alternative and now holds the status of the <strong>official recommendation</strong> from the Vue core team.</p><h3>A Closer Look at Vuex: The Former Standard</h3><p>Vuex, as a mature state management library, became the <em>de facto</em> standard in the Vue 2 era and in the early adoption of Vue 3. Its strength lies in its structured principles like:</p><ul><li><strong>Centralized store:</strong> A single container to hold all the application’s state.</li><li><strong>Mutations:</strong> The only synchronous way to alter the state.</li><li><strong>Actions:</strong> The place to handle asynchronous logic and commit mutations.</li><li><strong>Getters:</strong> Functions to derive state based on the existing state.</li></ul><p>Despite its merits, some limitations of Vuex became apparent, especially in the context of Vue 3: it can be <strong>verbose</strong> with a lot of boilerplate, especially for small to medium-sized applications. It also has <strong>limited composability</strong>, feeling less natural to use with the Composition API, and <strong>modularization and reusability</strong> of logic can feel less granular and intuitive.</p><h3>Pinia: A Breath of Fresh Air in Vue 3 State Management</h3><p>Pinia arrived as an elegant answer to the limitations of Vuex, designed from the ground up with the Vue 3 architecture and Composition API as its foundation. Here are the key features that make it an attractive choice:</p><ul><li>💡 <strong>More Concise and Intuitive:</strong> A simpler and more direct syntax, reducing the need for excessive boilerplate.</li><li>🚀 <strong>Native Integration with Composition API:</strong> Seamless and natural to use alongside the setup() function and reactive references.</li><li>🧩 <strong>Exceptional Modularity:</strong> Allows for the division of the store into smaller, well-organized, and easily manageable modules, ideal for applications of any scale.</li><li>🔍 <strong>Improved Devtools Support:</strong> Deeper integration with Vue Devtools, making debugging and tracking state changes easier.</li><li>🧪 <strong>TypeScript Support Out-of-the-Box:</strong> A much smoother developer experience with TypeScript without the need for complex additional configurations.</li></ul><p>A simple example using Pinia:</p><pre>// stores/counter.ts<br>import { defineStore } from &#39;pinia&#39;<br><br>export const useCounterStore = defineStore(&#39;counter&#39;, {<br>  state: () =&gt; ({<br>    count: 0<br>  }),<br>  actions: {<br>    increment() {<br>      this.count++<br>    }<br>  }<br>})</pre><p>That’s it! With Pinia, you can define state, actions (encompassing both synchronous and asynchronous logic), and even getters within a single, concise store. No more rigid separation between mutations and actions like in Vuex.</p><h3>Head-to-Head: Comparing Pinia and Vuex</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*shZoph36_4D8BO0OkuT7Rg.png" /></figure><h3>When Might You Still Consider Vuex?</h3><p>Despite the numerous advantages of Pinia, Vuex still has its place, particularly in a few scenarios:</p><ul><li><strong>Large, Legacy Applications:</strong> If your application is already built extensively with Vuex and has a large codebase, migrating to Pinia might require significant effort and should be carefully considered based on cost and benefit. Stability might be the primary concern in such cases.</li><li><strong>Teams Not Ready to Migrate:</strong> If your development team is deeply familiar with the Vuex workflow and doesn’t have the time or resources to learn Pinia, sticking with Vuex might be the more practical choice in the short term.</li><li><strong>Specific Feature Requirements (Though Rare):</strong> While Pinia is rapidly evolving, there might be some very specific features in Vuex 4 that haven’t (or won’t) be implemented in Pinia. However, these cases are becoming increasingly rare.</li></ul><p>However, for <strong>new projects built with Vue 3</strong>, considering the ease of use, better integration, and flexibility it offers, <strong>Pinia is the more modern, lightweight, and developer-friendly choice.</strong></p><h3>Conclusion: The New Era of Vue 3 State Management</h3><p>With Pinia, managing state in Vue 3 becomes simpler, more intuitive, and better integrated. <strong>For any new Vue 3 application you’re building, strongly consider Pinia as your state management solution.</strong> The benefits it offers in terms of development ease, code maintainability, and performance often outweigh the initial learning curve.</p><h4>Let’s Discuss!</h4><p>Have you tried Pinia in your Vue 3 projects? What has your experience been compared to Vuex? Or are you still sticking with Vuex?</p><p>Feel free to <strong>share your experiences and opinions</strong> in the comments below! Let’s learn and exchange insights together.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3959f02e67e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scalability Without the Drama: Mastering Vue 3’s Composition API for Large Projects]]></title>
            <link>https://medium.com/@ibnua_/scalability-without-the-drama-mastering-vue-3s-composition-api-for-large-projects-41eefb9c854d?source=rss-271742272be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/41eefb9c854d</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[composition-api]]></category>
            <category><![CDATA[vue-3]]></category>
            <category><![CDATA[vuejs]]></category>
            <dc:creator><![CDATA[Ibnu Arseno]]></dc:creator>
            <pubDate>Sat, 03 May 2025 13:55:05 GMT</pubDate>
            <atom:updated>2025-05-03T13:55:05.758Z</atom:updated>
            <content:encoded><![CDATA[<p>As Vue.js projects begin to grow and complexity increases, many developers start to wonder: “Is my code structure scalable enough?”, “How can I keep the code clean and easy to maintain?”</p><p>The answer to these questions often boils down to one crucial feature in Vue 3: the <strong>Composition API</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dbx1HuQTWkowmRjs" /><figcaption>Photo by <a href="https://unsplash.com/@imaginebuddy?utm_source=medium&amp;utm_medium=referral">Imagine Buddy</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this article, we’ll discuss how the <strong>Composition API helps build large-scale Vue applications</strong> in a more modular, organized, and maintainable way for both small and large teams.</p><h3>Why the Composition API?</h3><p>Before Vue 3, Vue was known for its <strong>Options API</strong> — a declarative approach that’s easy to grasp for small to medium-sized applications. However, as feature complexity and component interactions grew, the Options API started to feel limiting. Here are some common challenges that arose:</p><ul><li>Code was fragmented across options like data, methods, computed, etc.</li><li>It was difficult to group related logic in one place.</li><li>Code reusability was limited and inflexible.</li></ul><p>The Composition API arrived as a solution to all of this. Let’s look at a simple comparison:</p><p>Options API:</p><pre>export default {<br>  data() {<br>    return {<br>      count: 0<br>    }<br>  },<br>  methods: {<br>    increment() {<br>      this.count++<br>    }<br>  },<br>  computed: {<br>    doubleCount() {<br>      return this.count * 2<br>    }<br>  }<br>}</pre><p>Composition API:</p><pre>import { ref, computed } from &#39;vue&#39;<br><br>export default {<br>  setup() {<br>    const count = ref(0)<br>    const increment = () =&gt; {<br>      count.value++<br>    }<br>    const doubleCount = computed(() =&gt; count.value * 2)<br><br>    return {<br>      count,<br>      increment,<br>      doubleCount<br>    }<br>  }<br>}</pre><p>In the example above, the Composition API allows us to group count, increment, and doubleCount together within the setup() function, making it easier to see the related logic.</p><h3>Benefits of the Composition API in Large-Scale Applications</h3><h4><strong>High Modularity</strong></h4><ul><li>With the setup() function, you can group related logic in one place, instead of scattering it across many options.</li><li>It’s perfect for dividing logic into reusable functions like useForm(), useAuth(), or useChart().</li></ul><h4><strong>Reusability &amp; Scalability</strong></h4><ul><li>Logic can be broken down into composables (reusable and testable functions).</li><li>You avoid the need for mixins, which can lead to namespace conflicts.</li></ul><h4><strong>Improved Readability for Teams</strong></h4><ul><li>The code structure is cleaner and focuses on features, not just the format.</li><li>It’s ideal for teams working in parallel on different features.</li></ul><h4><strong>Ease of Testing</strong></h4><ul><li>By isolating logic into composables, unit testing becomes much simpler. You can test these functions independently without needing to render the entire Vue component.</li></ul><h4><strong>Better Integration with State Management</strong></h4><ul><li>The Composition API integrates seamlessly with state management solutions like Pinia or Vuex. Complex business logic can be encapsulated in actions or stores and then used in various components through composables, keeping components focused on presentation.</li></ul><h4><strong>Long-Term Investment in Learning</strong></h4><ul><li>While there might be an initial learning curve for developers accustomed to the Options API, investing time in understanding the Composition API will be highly rewarding in the long run. The improved code structure, higher reusability, and ease of testing will significantly enhance productivity and project maintainability.</li></ul><h3>Case Study: Authentication Management in an Enterprise Project</h3><p>Imagine you’re managing the authentication system in a complex enterprise application. You can separate all the authentication logic into a useAuth() composable like this:</p><pre>// composables/useAuth.ts<br>import { ref } from &#39;vue&#39;<br>import { api } from &#39;@/api&#39; // Assuming you have an API instance<br><br>const user = ref(null)<br><br>export function useAuth() {<br>  const login = async (credentials) =&gt; {<br>    try {<br>      const response = await api.post(&#39;/login&#39;, credentials)<br>      user.value = response.data.user<br>      localStorage.setItem(&#39;token&#39;, response.data.token) // Example token storage<br>      // Redirect or perform other actions after successful login<br>    } catch (error) {<br>      console.error(&#39;Login failed:&#39;, error)<br>      // Handle login error<br>      throw error<br>    }<br>  }<br><br>  const logout = () =&gt; {<br>    user.value = null<br>    localStorage.removeItem(&#39;token&#39;)<br>    // Redirect to the login page or perform other actions after logout<br>  }<br><br>  const isAuthenticated = computed(() =&gt; !!user.value &amp;&amp; !!localStorage.getItem(&#39;token&#39;))<br><br>  // Function to fetch user information when the application mounts<br>  const initializeAuth = async () =&gt; {<br>    const token = localStorage.getItem(&#39;token&#39;)<br>    if (token) {<br>      try {<br>        const response = await api.get(&#39;/me&#39;, {<br>          headers: {<br>            Authorization: `Bearer ${token}`<br>          }<br>        })<br>        user.value = response.data.user<br>      } catch (error) {<br>        console.error(&#39;Failed to initialize auth:&#39;, error)<br>        logout() // Clear token if invalid<br>      }<br>    }<br>  }<br><br>  return {<br>    user,<br>    login,<br>    logout,<br>    isAuthenticated,<br>    initializeAuth<br>  }<br>}</pre><p>Then, in any component, you can simply use it:</p><pre>import { useAuth } from &#39;@/composables/useAuth&#39;<br>import { onMounted } from &#39;vue&#39;<br><br>export default {<br>  setup() {<br>    const { user, login, logout, isAuthenticated, initializeAuth } = useAuth()<br><br>    onMounted(initializeAuth) // Call the initialization function when the component mounts<br><br>    const credentials = ref({<br>      email: &#39;&#39;,<br>      password: &#39;&#39;<br>    })<br><br>    const handleLogin = async () =&gt; {<br>      try {<br>        await login(credentials.value)<br>        console.log(&#39;Login successful, user:&#39;, user.value)<br>        // Redirect to the dashboard page<br>      } catch (error) {<br>        // Handle error in the component<br>      }<br>    }<br><br>    const handleLogout = () =&gt; {<br>      logout()<br>      console.log(&#39;Logged out&#39;)<br>      // Redirect to the login page<br>    }<br><br>    return {<br>      user,<br>      credentials,<br>      isAuthenticated,<br>      handleLogin,<br>      handleLogout<br>    }<br>  }<br>}</pre><p>With this pattern, other teams can work on useDashboard(), usePermission(), or useNotification() composables without interfering with each other.</p><h3>Practical Tips for Using the Composition API</h3><ul><li>Use a <strong>composables/ folder</strong> for all your reusable logic.</li><li>Be consistent with <strong>naming conventions</strong> like useXyz().</li><li>Leverage <strong>TypeScript</strong> for maximum benefits like autocompletion and type validation.</li><li>Don’t hesitate to break down a long setup() function into smaller, more readable functions.</li><li>Consider creating composables that are highly specific and focus on a single responsibility.</li><li>Document your composables well, especially if they are used by other team members.</li></ul><h3>Conclusion</h3><p>The Composition API isn’t just a new feature in Vue 3 — it’s a new way of thinking that <strong>prioritizes scalability, modularity, and maintainability</strong>. By adopting the principles of the Composition API, you can build Vue applications that are ready to grow without losing control over the code structure and quality. Investing in understanding and adopting the Composition API will pay off in the long run, especially for large projects and growing teams.</p><h3>🚀 Want Cleaner and More Modular Vue Code?</h3><p>If you found this article helpful, don’t hesitate to:</p><p>👉 Leave a comment and share your experiences with the Composition API. 👉 Follow my profile for more articles on Vue.js and frontend development. 👉 Share this article with your fellow developers who are building large projects with Vue.</p><p>See you in the next article!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41eefb9c854d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Say Goodbye to Vue 2, Embrace Vue 3’s Powerful Performance: A Step-by-Step, Hassle-Free Migration]]></title>
            <link>https://medium.com/@ibnua_/say-goodbye-to-vue-2-embrace-vue-3s-powerful-performance-a-step-by-step-hassle-free-migration-78a6b3ba68d2?source=rss-271742272be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/78a6b3ba68d2</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[vue-3]]></category>
            <category><![CDATA[nuxtjs]]></category>
            <dc:creator><![CDATA[Ibnu Arseno]]></dc:creator>
            <pubDate>Wed, 30 Apr 2025 10:18:41 GMT</pubDate>
            <atom:updated>2025-04-30T10:18:41.033Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Vue.js developers! If you’re still working with Vue 2, you’re not alone. However, are you aware that Vue 3 comes packed with significant performance improvements, exciting new features, and a better architecture? Migration might sound daunting, but with the right guidance, the process can be smoother than you think.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VlWKckYt5KVqJ_1e" /><figcaption>Photo by <a href="https://unsplash.com/@drscythe?utm_source=medium&amp;utm_medium=referral">Dominik Scythe</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This article serves as your compass, guiding you step-by-step through the migration from Vue 2 to Vue 3, complete with solutions for common challenges you might encounter. Ready to experience a better Vue development journey? Let’s begin!</p><h3>Why Migrate to Vue 3?</h3><p>Before we dive into the migration steps, let’s understand why Vue 3 is so compelling to move to. Some of the key advantages of Vue 3 include:</p><ol><li><strong>Superior Performance:</strong> Vue 3 is built with Proxy instead of Object.defineProperty for its reactivity system. This results in more efficient change detection and significantly faster rendering performance.</li><li><strong>Composition API:</strong> This revolutionary feature allows you to organize component logic based on features, rather than options like data, methods, and computed. This leads to cleaner, more readable, and reusable code.</li><li><strong>Improved TypeScript Support:</strong> TypeScript support in Vue 3 is much better, providing stronger type safety and a smoother development experience for TypeScript users.</li><li><strong>Tree-shaking:</strong> Vue 3 is designed to be more tree-shakable, meaning only the code you actually use will be included in your application’s final bundle. This results in smaller bundle sizes and faster loading times.</li><li><strong>Suspense and </strong><strong>&lt;script setup&gt;:</strong> New features like Suspense for handling asynchronous dependencies more elegantly and &lt;script setup&gt; for a more concise component syntax further enhance the development experience.</li></ol><h3>Step-by-Step Guide to Migrating from Vue 2 to Vue 3</h3><p>Migration isn’t a task that can be completed overnight, but with careful planning, you can minimize risks and ensure a smooth transition. Here are the general steps you can follow:</p><h4><strong>Understand the Breaking Changes</strong></h4><p>The first crucial step is to understand the significant changes (breaking changes) between Vue 2 and Vue 3. You can refer to the highly comprehensive official Vue 3 Migration Guide. Some important changes include:</p><ul><li>Changes to the Reactivity API (Vue.observable is replaced with reactive and ref).</li><li>Removal of global Filters (it’s now recommended to use methods or computed properties).</li><li>Changes to Lifecycle Hooks (some names have changed, and the order might be different).</li><li>Changes to Template Directives (v-if and v-for with &lt;template&gt; behave slightly differently).</li><li>Changes to Render Functions and JSX.</li><li>Changes to the Global API (Vue.config and other global APIs).</li></ul><h4><strong>Update Vue CLI (If Used)</strong></h4><p>If your project uses Vue CLI, ensure you are using the latest version that supports Vue 3. You can update Vue CLI globally with the following command:</p><pre>npm install -g @vue/cli<br># OR<br>yarn global add @vue/cli</pre><h4><strong>Create a New Branch</strong></h4><p>Before making any major changes, it’s always recommended to create a new branch in your version control system (e.g., Git). This allows you to revert to the previous version if any issues arise.</p><pre>git checkout -b migrate-to-vue3</pre><h4><strong>Install Vue 3</strong></h4><p>Remove Vue 2 dependencies and install Vue 3:</p><pre>npm uninstall vue vue-template-compiler<br>npm install vue@next<br># OR<br>yarn remove vue vue-template-compiler<br>yarn add vue@next</pre><h4><strong>Update Dependencies and Plugins</strong></h4><p>Many third-party libraries and plugins may need to be updated to be compatible with Vue 3. Check the documentation of each library and install the appropriate versions. Popular plugins like Vue Router and Vuex also have Vue 3 compatible versions (e.g., vue-router@4 and vuex@4).</p><pre>npm install vue-router@4 vuex@4 # Example for Vue Router and Vuex<br># Update other plugins as needed</pre><h4><strong>Configure Build (If Necessary)</strong></h4><p>Some build configurations may need adjustments, especially if you are using tools like Webpack directly. Ensure your configuration supports Vue 3 syntax.</p><h4><strong>Start Migrating Components</strong></h4><p>This is the core part of the migration process. You need to review each of your Vue 2 components and make the necessary changes to align with Vue 3. Focus on the following areas:</p><ul><li><strong>Reactivity:</strong> Replace the use of Vue.observable with reactive or ref from the Composition API.</li><li><strong>Lifecycle Hooks:</strong> Update lifecycle hook names according to Vue 3 (e.g., beforeDestroy becomes beforeUnmount, destroyed becomes unmounted).</li><li><strong>Filters:</strong> Replace the use of global filters with methods or computed properties within the component.</li><li><strong>Template Directives:</strong> Check the behavior of v-if and v-for with &lt;template&gt;.</li><li><strong>Composition API:</strong> Consider adopting the Composition API for more complex component logic. This might require significant structural changes to your components.</li></ul><h4><strong>Thoroughly Test Your Application</strong></h4><p>After making changes to the components, perform thorough testing on your entire application. Pay attention to functionality, performance, and appearance. Use unit tests, integration tests, and end-to-end tests if you have them.</p><h4><strong>Address Warnings and Errors</strong></h4><p>Vue 3 will provide warnings in the console if there is incompatible code or the use of deprecated features. Address all warnings and errors before proceeding.</p><h4><strong>Optimize Performance</strong></h4><p>Once the migration is complete, take advantage of Vue 3’s performance features like lazy-loading components and other optimizations to improve your application’s speed.</p><h3>Solutions for Common Challenges</h3><p>During the migration process, you might encounter some common challenges. Here are some solutions that can help:</p><ul><li><strong>Incompatible Third-Party Components:</strong> Check if there is a Vue 3 version of the library or plugin you are using. If not, you might need to look for alternatives or contribute to the library to add Vue 3 support.</li><li><strong>Significant Changes to Application Structure:</strong> If your Vue 2 application has a less structured architecture, migrating to Vue 3 can be a good opportunity to refactor and adopt the Composition API for better code organization.</li><li><strong>Team Unfamiliar with Vue 3:</strong> Ensure your team has sufficient resources to learn Vue 3, such as official documentation, tutorials, or training.</li><li><strong>Gradual Migration Process:</strong> For large applications, consider performing the migration in stages. You can start by migrating small parts of the application first and gradually expand.</li></ul><h3>Performance Comparison: Vue 2 vs Vue 3</h3><p>One of the main reasons to migrate to Vue 3 is the significant performance improvement. Here’s a brief comparison:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3pZMuGiabgyQTsMDbDUyaw.png" /></figure><p>Overall, Vue 3 offers substantial performance improvements compared to Vue 2, resulting in more responsive and efficient applications.</p><p>Migrating to Vue 3 is a worthwhile investment for the future of your web applications. With better performance, modern features, and an improved architecture, Vue 3 opens up new possibilities for building more sophisticated and efficient applications.</p><p>While the migration process may require time and effort, this guide hopefully helps you navigate it with more confidence. Don’t hesitate to explore the official Vue 3 documentation and its active community if you encounter any difficulties. Happy migrating, and enjoy the improved Vue development experience with Vue 3!</p><p>Share your experiences, tips, and any challenges you faced in the comments below! Let’s learn and grow together in the exciting world of Vue 3.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78a6b3ba68d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ The Secret to Cleaner, Scalable Vue Code with Composition API (And How to Migrate Smoothly)]]></title>
            <link>https://medium.com/@ibnua_/the-secret-to-cleaner-scalable-vue-code-with-composition-api-and-how-to-migrate-smoothly-7418285ee11e?source=rss-271742272be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/7418285ee11e</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[code-refactoring]]></category>
            <dc:creator><![CDATA[Ibnu Arseno]]></dc:creator>
            <pubDate>Thu, 24 Apr 2025 15:25:59 GMT</pubDate>
            <atom:updated>2025-04-24T15:27:13.379Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Secret to Cleaner, Scalable Vue Code with Composition API (And How to Migrate Smoothly)</h3><blockquote><em>“Wait… where did I put that method again?”</em><br> If you’ve ever found yourself scrolling through a massive Vue file trying to trace feature logic, you’re not alone. The Options API works — until it doesn’t scale. That’s where the <strong>Composition API</strong> shines.</blockquote><p>In this article, we’ll walk through the key differences between the Options and Composition API, why the shift matters (especially for growing codebases), and how to <strong>migrate smoothly</strong>. You’ll also get a real-world Todo feature example — using both APIs — to see the impact firsthand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q1en_N_H0zN2jMsP" /><figcaption>Photo by <a href="https://unsplash.com/@jcraice?utm_source=medium&amp;utm_medium=referral">Julia Craice</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>🧠 A Shift in Mindset: Core Concept Differences</h3><p>The <strong>Options API</strong> organizes code by types: data, methods, computed, watch. Sounds good—until a single feature touches <em>all of them</em>. Logic ends up scattered and hard to maintain.</p><p>The <strong>Composition API</strong> flips that around: it groups code by logical <strong>concerns</strong> instead. All the logic for a single feature stays together — making your components easier to read, refactor, and test.</p><p>✅ <strong>Why it matters:</strong> In large components, grouping by feature (not type) makes your logic easier to reason about and much more scalable.</p><h3>🧱 Structure That Encourages Scalability</h3><p>With Composition API, you can extract feature logic into <strong>composables</strong> — essentially reusable Vue-specific functions that encapsulate state and behavior.</p><p>This not only promotes reuse and consistency, but also helps <strong>keep components small and focused</strong>.</p><h3>⚡️ Fine-Grained Reactivity with ref() and reactive()</h3><p>No more Vue “magic.” You explicitly create reactivity using:</p><pre>const counter = ref(0)<br>const user = reactive({ name: &#39;Jane&#39;, age: 25 })</pre><p>You’ll always know <strong>where your state lives</strong>, how it’s updated, and how it’s reactive. Perfect for debugging and testing.</p><h3>🎯 More Control with computed() and watch()</h3><p>Need derived state? Need to react to changes? You can use computed() and watch() anywhere inside setup() or inside composables.</p><p>✅ <strong>Why it matters:</strong> You encapsulate logic where it makes sense — not just where Vue tells you to.</p><h3>♻️ Reusable Logic with Composables</h3><p>Here’s the real power move 👇</p><pre>// useCounter.js<br>export function useCounter() {<br>  const count = ref(0)<br>  const increment = () =&gt; count.value++<br>  return { count, increment }<br>}</pre><p>✅ <em>Why it matters:</em> Say goodbye to repeated logic across components. Composables make your app <strong>DRY, testable, and consistent</strong>.</p><h3>🧪 Real-World Case: Building a Simple Todo Feature</h3><p>Let’s compare the exact same feature — <strong>a simple Todo list</strong> — built with both APIs.</p><h4>🚪 Options API</h4><pre>&lt;template&gt;<br>  &lt;div&gt;<br>    &lt;input v-model=&quot;newTask&quot; placeholder=&quot;Enter a task&quot; /&gt;<br>    &lt;button @click=&quot;addTodo&quot;&gt;Add&lt;/button&gt;<br>    &lt;ul&gt;<br>      &lt;li v-for=&quot;todo in todos&quot; :key=&quot;todo.id&quot;&gt;<br>        &lt;label&gt;<br>          &lt;input type=&quot;checkbox&quot; v-model=&quot;todo.completed&quot; /&gt;<br>          &lt;span :style=&quot;{ textDecoration: todo.completed ? &#39;line-through&#39; : &#39;none&#39; }&quot;&gt;<br>            {{ todo.text }}<br>          &lt;/span&gt;<br>        &lt;/label&gt;<br>      &lt;/li&gt;<br>    &lt;/ul&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;<br><br>&lt;script&gt;<br>export default {<br>  data() {<br>    return {<br>      newTask: &#39;&#39;,<br>      todos: []<br>    }<br>  },<br>  methods: {<br>    addTodo() {<br>      if (this.newTask.trim()) {<br>        this.todos.push({<br>          id: Date.now(),<br>          text: this.newTask,<br>          completed: false<br>        })<br>        this.newTask = &#39;&#39;<br>      }<br>    }<br>  }<br>}<br>&lt;/script&gt;</pre><h4>⚙️ Composition API (with &lt;script setup&gt;)</h4><pre>&lt;script setup&gt;<br>import { ref } from &#39;vue&#39;<br><br>const newTask = ref(&#39;&#39;)<br>const todos = ref([])<br><br>const addTodo = () =&gt; {<br>  if (newTask.value.trim()) {<br>    todos.value.push({<br>      id: Date.now(),<br>      text: newTask.value,<br>      completed: false<br>    })<br>    newTask.value = &#39;&#39;<br>  }<br>}<br>&lt;/script&gt;<br><br>&lt;template&gt;<br>  &lt;div&gt;<br>    &lt;input v-model=&quot;newTask&quot; placeholder=&quot;Enter a task&quot; /&gt;<br>    &lt;button @click=&quot;addTodo&quot;&gt;Add&lt;/button&gt;<br>    &lt;ul&gt;<br>      &lt;li v-for=&quot;todo in todos&quot; :key=&quot;todo.id&quot;&gt;<br>        &lt;label&gt;<br>          &lt;input type=&quot;checkbox&quot; v-model=&quot;todo.completed&quot; /&gt;<br>          &lt;span :style=&quot;{ textDecoration: todo.completed ? &#39;line-through&#39; : &#39;none&#39; }&quot;&gt;<br>            {{ todo.text }}<br>          &lt;/span&gt;<br>        &lt;/label&gt;<br>      &lt;/li&gt;<br>    &lt;/ul&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>🧠 <strong>What’s better with Composition API?</strong><br> The logic is <strong>self-contained</strong>. Easier to scan, reuse, and eventually extract into a useTodo() composable.</p><h3>⏱ Lifecycle Hooks? Still Here — And Better</h3><p>Use onMounted(), onUnmounted(), etc., inside setup() or your composables. No more breaking logic apart—<strong>even your lifecycle can stay modular.</strong></p><h3>✨ Going Further with &lt;script setup&gt;</h3><p>Vue’s &lt;script setup&gt; is a <strong>game-changer</strong>:</p><p>✅ No need to return anything<br>✅ Fewer lines of boilerplate<br>✅ Faster performance under the hood</p><pre>&lt;script setup&gt;<br>const count = ref(0)<br>const increment = () =&gt; count.value++<br>&lt;/script&gt;<br><br>&lt;template&gt;<br>  &lt;button @click=&quot;increment&quot;&gt;Clicked {{ count }} times&lt;/button&gt;<br>&lt;/template&gt;</pre><h3>📦 Global State? Use It Seamlessly</h3><p>Whether you use <strong>Vuex</strong> or <strong>Pinia</strong>, Composition API plays well with both. You can even use your store <strong>directly in composables</strong>, keeping your components ultra-clean.</p><h3>🚀 Migration Tips (Step-by-Step)</h3><p>Start with confidence:</p><ol><li>Pick small components first (preferably stateless ones).</li><li>Move data() and methods into setup().</li><li>Then migrate computed and watch.</li><li>Extract reusable logic into composables.</li><li>Try &lt;script setup&gt; for future-proof code.</li></ol><h3>🎢 The Learning Curve Is Real — But Worth It</h3><p>Yes, Composition API introduces new concepts: ref, reactive, composables... it’s a lot. But once you grasp it, you’ll wonder how you ever lived without it.</p><h3>🔚 Final Thoughts: Compose a Better Vue Today</h3><p>To recap:</p><ul><li>✅ Cleaner, modular, testable logic</li><li>✅ Better scaling for large apps</li><li>✅ Composables = power &amp; reusability</li><li>✅ &lt;script setup&gt; = less boilerplate, better performance</li></ul><p>🎯 <strong>Your next move?</strong> Try refactoring a small component with &lt;script setup&gt; and Composition API.</p><p>Have questions or feedback? Drop them in the comments — I’d love to hear how you’re approaching migration or help with a tricky piece of logic.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7418285ee11e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Torn Between Front-Ends? This Vue vs React Comparison for 2025 is a Must-Read!]]></title>
            <link>https://medium.com/@ibnua_/torn-between-front-ends-this-vue-vs-react-comparison-for-2025-is-a-must-read-38093edfec05?source=rss-271742272be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/38093edfec05</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[nuxtjs]]></category>
            <category><![CDATA[compassion]]></category>
            <dc:creator><![CDATA[Ibnu Arseno]]></dc:creator>
            <pubDate>Sun, 20 Apr 2025 08:40:45 GMT</pubDate>
            <atom:updated>2025-04-20T08:40:45.598Z</atom:updated>
            <content:encoded><![CDATA[<p>The world of front-end development continues its rapid evolution. In 2025, Vue and React remain two dominant forces in building interactive and dynamic user interfaces. Both have matured, boast large communities, and continue to innovate. However, with ongoing developments, which one is truly the better fit for your projects this year? Let’s delve deeper!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tw77OLAOgicmpYK1" /><figcaption>Photo by <a href="https://unsplash.com/@iantalmacs?utm_source=medium&amp;utm_medium=referral">Ian Talmacs</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>A Look Back at Technology and Community in 2025</h3><p>Both Vue and React have come a long way since their inception. By 2025, both have embraced modern features and the latest development paradigms.</p><p><a href="https://react.dev/"><strong>React</strong></a><strong>:</strong> Backed by Meta, React continues to lead in innovation with a strong focus on concurrent rendering and server components. Its community remains massive and diverse, with abundant contributions in the form of libraries and tooling. Its popularity among large enterprises remains robust.</p><p><a href="https://vuejs.org/"><strong>Vue</strong></a><strong>:</strong> With a strong emphasis on a smooth developer experience, Vue 3 has become the standard with its Composition API, offering enhanced code flexibility and reusability. The Vue community continues to grow rapidly, known for its welcoming nature and excellent documentation. Vue’s adoption is expanding, not only for single-page applications (SPAs) but also for progressive integration into existing applications.</p><p>Here’s a brief comparison of their communities:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t-qXb6s1Axz_OOw5KcWZyA.png" /></figure><h3>Performance, Learning Curve, and Ecosystem</h3><p>Choosing between Vue and React also involves considering technical and practical aspects:</p><p><strong>Performance:</strong> Both offer excellent performance in modern browsers. React, with its virtual DOM and potential for concurrent rendering, provides deep optimization capabilities. Vue 3, leveraging proxy-based change detection, is also highly efficient and tends to have a smaller bundle size for small to medium-sized projects.</p><p><strong>Learning Curve:</strong> This is where Vue often shines. Its more intuitive and structured syntax, along with comprehensive documentation, allows new developers to quickly grasp the fundamental concepts and become productive. React, with its high flexibility and various paradigms (Class Components, Functional Components, Hooks), might present a slightly steeper learning curve, especially for beginners.</p><p><strong>Ecosystem:</strong> Both frameworks boast rich and mature ecosystems.</p><ul><li><strong>React:</strong> Supported by numerous popular libraries such as Redux, Zustand, React Router, and Next.js for full-stack frameworks. Its ecosystem is vast and flexible, allowing developers to choose the tools that best suit their project needs.</li><li><strong>Vue:</strong> Features a solid official ecosystem including Vuex (although Pinia is a popular alternative), Vue Router, and Nuxt.js for full-stack frameworks. Vue’s ecosystem is known for its seamless integration and excellent developer experience.</li></ul><p>Here’s a brief comparative table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mnQtQb3icwIuzzw3X49yfw.png" /></figure><h3>Small Case Study: A To-Do Component</h3><p>To provide a more concrete illustration, let’s look at a simple To-Do component implementation in both Vue and React (assuming functional components and hooks in React, and the Composition API in Vue):</p><p>React:</p><pre>import React, { useState } from &#39;react&#39;;<br><br>function TodoItem({ todo, onDelete }) {<br>  return (<br>    &lt;li&gt;<br>      {todo.text}<br>      &lt;button onClick={() =&gt; onDelete(todo.id)}&gt;Delete&lt;/button&gt;<br>    &lt;/li&gt;<br>  );<br>}<br><br>function TodoList() {<br>  const [todos, setTodos] = useState([]);<br>  const [inputValue, setInputValue] = useState(&#39;&#39;);<br><br>  const handleAddTodo = () =&gt; {<br>    if (inputValue.trim()) {<br>      setTodos([...todos, { id: Date.now(), text: inputValue }]);<br>      setInputValue(&#39;&#39;);<br>    }<br>  };<br><br>  const handleDeleteTodo = (id) =&gt; {<br>    setTodos(todos.filter(todo =&gt; todo.id !== id));<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;input<br>        type=&quot;text&quot;<br>        value={inputValue}<br>        onChange={(e) =&gt; setInputValue(e.target.value)}<br>      /&gt;<br>      &lt;button onClick={handleAddTodo}&gt;Add Todo&lt;/button&gt;<br>      &lt;ul&gt;<br>        {todos.map(todo =&gt; (<br>          &lt;TodoItem key={todo.id} todo={todo} onDelete={handleDeleteTodo} /&gt;<br>        ))}<br>      &lt;/ul&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default TodoList;</pre><p>Vue:</p><pre>&lt;script setup&gt;<br>import { ref } from &#39;vue&#39;;<br><br>const todos = ref([]);<br>const newTodo = ref(&#39;&#39;);<br><br>const addTodo = () =&gt; {<br>  if (newTodo.value.trim()) {<br>    todos.value.push({ id: Date.now(), text: newTodo.value });<br>    newTodo.value = &#39;&#39;;<br>  }<br>};<br><br>const deleteTodo = (id) =&gt; {<br>  todos.value = todos.value.filter(todo =&gt; todo.id !== id);<br>};<br>&lt;/script&gt;<br><br>&lt;template&gt;<br>  &lt;div&gt;<br>    &lt;input type=&quot;text&quot; v-model=&quot;newTodo&quot; /&gt;<br>    &lt;button @click=&quot;addTodo&quot;&gt;Add Todo&lt;/button&gt;<br>    &lt;ul&gt;<br>      &lt;li v-for=&quot;todo in todos&quot; :key=&quot;todo.id&quot;&gt;<br>        {{ todo.text }}<br>        &lt;button @click=&quot;deleteTodo(todo.id)&quot;&gt;Delete&lt;/button&gt;<br>      &lt;/li&gt;<br>    &lt;/ul&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>From this simple case study, we can observe that Vue offers a more concise and declarative syntax for data binding and event handling. React, on the other hand, is more explicit and relies on plain JavaScript.</p><h3>Recommendations Based on Use-Cases</h3><p>The choice between Vue and React heavily depends on the specific needs of your project:</p><p><strong>Choose React if:</strong></p><ul><li>You are building large and complex applications requiring high flexibility.</li><li>Your team has strong JavaScript experience and familiarity with the React ecosystem.</li><li>Advanced performance optimizations and fine-grained control are top priorities.</li><li>You need a mature full-stack solution like Next.js.</li><li>Integration with a wide variety of third-party libraries and tooling is crucial.</li></ul><p><strong>Choose Vue if:</strong></p><ul><li>You need a framework that is easy to learn and quick to develop with, especially for small to medium-sized projects.</li><li>A smooth developer experience and excellent documentation are high priorities.</li><li>You want to progressively integrate front-end into existing applications.</li><li>You prefer a clean and structured syntax with good built-in tooling.</li><li>Rapid prototyping is essential.</li></ul><p>Ultimately, the best choice depends on the specific context of your project, your team’s expertise, and your personal preferences. Both are excellent frameworks with their own strengths and weaknesses. Rather than focusing on which is “better,” concentrate on which one best aligns with your needs in 2025.</p><p>I hope this article provides valuable insights as you consider the choice between Vue and React for your projects! Feel free to share your thoughts and experiences in the comments below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38093edfec05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Master Higher-Order Functions: The JavaScript Superpower That Will Transform Your Coding Style]]></title>
            <link>https://medium.com/@ibnua_/master-higher-order-functions-the-javascript-superpower-that-will-transform-your-coding-style-9db7abf2b9e1?source=rss-271742272be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/9db7abf2b9e1</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Ibnu Arseno]]></dc:creator>
            <pubDate>Mon, 02 Dec 2024 02:12:54 GMT</pubDate>
            <atom:updated>2024-12-02T04:09:34.342Z</atom:updated>
            <content:encoded><![CDATA[<p>Every developer has felt the pain of writing code that’s hard to read, impossible to maintain, and takes forever to debug. What if I told you there’s a JavaScript technique that could cut your code length by half, make it more readable, and supercharge your programming efficiency? Enter Higher-Order Functions — the secret weapon that transforms messy, traditional JavaScript into elegant, modern code that speaks clarity and precision.🚀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_69fCAgzTMIDiktW" /><figcaption>Photo by <a href="https://unsplash.com/@supergios?utm_source=medium&amp;utm_medium=referral">Jonny Gios</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What Exactly Are Higher-Order Functions?</h3><p>Higher-Order Functions are the Swiss Army knives of JavaScript. They’re functions that can do two mind-blowing things:</p><ul><li>📥 Accept other functions as arguments</li><li>🔄 Return brand new functions</li></ul><p>Think of them as code alchemists that can manipulate functions just like any other data type. But why should you care? Because HOFs empower you to:</p><ul><li>✂️ Write more concise code</li><li>🧩 Create modular code structures</li><li>🔬 Improve code testability</li><li>🔁 Reduce repetitive coding patterns</li></ul><h3>The Magic of Transformation: Practical Examples</h3><h4>map(): Transforming Data with Elegance</h4><p>The map() method creates a new array by transforming each element of the original array without altering it.</p><pre>const numbers = [1, 2, 3, 4, 5];<br><br>// The Old Way: Multiplying numbers manually<br>const doubledNumbers = [];<br>for (let i = 0; i &lt; numbers.length; i++) {<br>  doubledNumbers.push(numbers[i] * 2);<br>}<br>// Output: [2, 4, 6, 8, 10]<br><br>// The HOF Way: Clean, Declarative, Powerful 🎉<br>const elegantDoubledNumbers = numbers.map(num =&gt; num * 2);<br>// Output: [2, 4, 6, 8, 10] </pre><h4>filter(): Smart Data Filtering</h4><p>The filter() method selects elements from an array based on a given condition.</p><pre>const ages = [18, 21, 15, 30];<br><br>// Traditional Age Filtering<br>const adults = [];<br>for (let i = 0; i &lt; ages.length; i++) {<br>  if (ages[i] &gt;= 18) {<br>    adults.push(ages[i]);<br>  }<br>}<br>// Output: [18, 21, 30]<br><br>// HOF Filtering: Crystal Clear 💡<br>const elegantAdults = ages.filter(age =&gt; age &gt;= 18);<br>// Output: [18, 21, 30] </pre><h4>reduce(): Aggregate Like a Pro</h4><p>The reduce() method accumulates values in an array to produce a single output, such as a total or average.</p><pre>const cart = [<br>  { name: &#39;Apple&#39;, price: 5000 },<br>  { name: &#39;Banana&#39;, price: 3000 },<br>  { name: &#39;Orange&#39;, price: 7000 },<br>];<br><br>// Calculating total spending (traditional way) <br>let totalCost = 0;<br>for (let i = 0; i &lt; cart.length; i++) {<br>  totalCost += cart[i].price;<br>}<br>// Output: 15000<br><br>// Calculating total spending (HOF way) 💡<br>const elegantTotalCost = cart.reduce((total, product) =&gt; total + product.price, 0);<br>// Output: 15000 </pre><h4>find(): Locate the First Match</h4><p>The find() method returns the first element that matches a given condition.</p><pre>const users = [<br>  { id: 1, name: &#39;Alice&#39; },<br>  { id: 2, name: &#39;Bob&#39; },<br>];<br><br>// Search for user (traditional way)<br>let foundUser = null;<br>for (let i = 0; i &lt; users.length; i++) {<br>  if (users[i].id === 2) {<br>    foundUser = users[i];<br>    break;<br>  }<br>}<br>// Output: { id: 2, name: &#39;Bob&#39; }<br><br>// Search for user (HOF way) 💡<br>const elegantFoundUser = users.find(user =&gt; user.id === 2);<br>// Output: { id: 2, name: &#39;Bob&#39; } </pre><h4>findIndex(): Discover Element Position</h4><p>The findIndex() method returns the index of the first element that matches a condition.</p><pre>const users = [<br>  { id: 1, name: &#39;Alice&#39; },<br>  { id: 2, name: &#39;Bob&#39; },<br>  { id: 3, name: &#39;Charlie&#39; },<br>];<br><br>// Traditional Way<br>let index = -1;<br>  for (let i = 0; i &lt; users.length; i++) {<br>    if (users[i].id === 2) {<br>   index = i;<br>   break;<br>    }<br>  }<br>// Output: 1<br><br>// HOF way 💡<br>const foundUserGetIndex = users.findIndex(user =&gt; user.id === 2);<br>// Output: 1</pre><h4>forEach(): Iterate Without Side Effects</h4><p>The forEach() method performs a function on each element without creating a new array.</p><pre>const cart = [<br>  { name: &#39;Apple&#39;, price: 5000 },<br>  { name: &#39;Banana&#39;, price: 3000 },<br>  { name: &#39;Orange&#39;, price: 7000 },<br>];<br><br>// Print the name of each product (traditional way)<br>for (let i = 0; i &lt; cart.length; i++) {<br>    console.log(`Product: ${cart[i].nama}`);<br>}<br>// Output:<br>// Product: Apple<br>// Product: Banana<br>// Product: Orange<br><br>// Print the name of each product (HOF way) 💡<br>cart.forEach(product =&gt; console.log(`Product: ${product.name}`));<br>// Output:<br>// Product: Apple<br>// Product: Banana<br>// Product: Orange</pre><h4>some(): Check Any Condition</h4><p>The some() method returns true if at least one element satisfies a condition.</p><pre>const scores = [45, 50, 75];<br><br>// Traditional way<br>let hasPassed = false;<br>  for (let i = 0; i &lt; scores.length; i++) {<br>    if (scores[i] &gt; 50) {<br>   hasPassed = true;<br>   break;<br>    }<br>  }<br>// Output: true<br><br>// HOF way 💡<br>const elegantHasPassed = scores.some(score =&gt; score &gt; 50);<br>// Output: true</pre><h4>every(): Validate All Elements</h4><p>The every() method returns true only if all elements satisfy a condition.</p><pre>const scores = [60, 70, 80];<br><br>// Traditional way<br>let allPassed = true;<br> for (let i = 0; i &lt; scores.length; i++) {<br>  if (scores[i] &lt; 50) {<br>   allPassed = false;<br>   break;<br>  }<br>}<br>// Output: true<br><br>// HOF way 💡<br>const elegantAllPassed = scores.every(score =&gt; score &gt;= 50); <br>// Output: true</pre><h4>includes(): Simple Search</h4><p>The includes() method checks whether an array contains a specific value.</p><pre>const categories = [&#39;fruit&#39;, &#39;vegetable&#39;, &#39;meat&#39;];<br><br>// Traditional way<br>let hasFruit = false;<br>  for (let i = 0; i &lt; categories.length; i++) {<br>    if (categories[i] === &#39;fruit&#39;) {<br>   hasFruit = true;<br>   break;<br>    }<br>  }<br>// Output: true<br><br>// HOF way 💡<br>const elegantHasFruit = categories.includes(&#39;fruit&#39;);<br>// Output: true</pre><h4>sort(): Organize Data</h4><p>The sort() method arranges elements in a specific order.</p><pre>const names = [&#39;Charlie&#39;, &#39;Alice&#39;, &#39;Bob&#39;];<br><br>// Traditional way<br>for (let i = 0; i &lt; names.length; i++) {<br>  for (let j = 0; j &lt; names.length - i - 1; j++) {<br>   if (names[j] &gt; names[j + 1]) {<br>     const temp = names[j];<br>     names[j] = names[j + 1];<br>     names[j + 1] = temp;<br>    }<br>  }<br>}<br>// Output: [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;]<br><br>// HOF way 💡<br>const elegantSorted = names.sort();<br>// Output: [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;]</pre><h3>A Real-World Authentication Example</h3><p>Let’s see how Higher-Order Functions can create flexible, powerful authentication systems:</p><pre>// Creating a dynamic authorization function<br>function createAuthorization(role) {<br>  return function(access) {<br>    const accessRights = {<br>      admin: [&#39;read&#39;, &#39;write&#39;, &#39;delete&#39;],<br>      editor: [&#39;read&#39;, &#39;write&#39;],<br>      viewer: [&#39;read&#39;]<br>    };<br><br>    return accessRights[role]?.includes(access) || false;<br>  };<br>}<br><br>// Usage<br>const isAdmin = createAuthorization(&#39;admin&#39;);<br>console.log(isAdmin(&#39;delete&#39;));  // true<br>console.log(isAdmin(&#39;login&#39;));   // false</pre><h3>Pro Tips for Mastering Higher-Order Functions</h3><h4>🚫 Common Pitfalls to Avoid</h4><ul><li>Don’t create overly complex Higher-Order Functions</li><li>Be mindful of performance for repetitive operations</li><li>Use arrow functions for more concise code</li></ul><h4>✅ Best Practices</h4><ul><li>Choose clear, descriptive function names</li><li>Maintain pure, side-effect-free functions</li><li>Leverage function composition techniques</li></ul><h4>Your Personal Challenge 💪</h4><ul><li>Pick an existing project with traditional loops</li><li>Refactor using Higher-Order Functions</li><li>Compare the before and after — you’ll be amazed!</li></ul><h3>Beyond the Basics: Keep Learning</h3><p>Higher-Order Functions aren’t just a technique — they’re a programming philosophy. They transform how you think about code: more declarative, more functional, more human.</p><p>Want to dive deeper? Check out these resources:</p><ul><li><a href="https://www.geeksforgeeks.org/functional-programming-in-javascript/">Functional Programming in JavaScript</a></li><li><a href="https://dev.to/snehalkadwe/essential-javascript-es6-methods-every-developer-should-know-4fnk">Essential JavaScript Methods</a></li></ul><p><strong>Did this article spark a coding revelation for you? Share your HOF experiences in the comments below!</strong></p><p>Enjoyed this piece? Clap 👏 and follow for more JavaScript deep dives!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9db7abf2b9e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Object Oriented Programming Concepts in Java]]></title>
            <link>https://medium.com/@ibnua_/object-oriented-programming-concepts-in-java-f3a62046c839?source=rss-271742272be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3a62046c839</guid>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[java-oop]]></category>
            <category><![CDATA[object-oriented-program]]></category>
            <category><![CDATA[oop-concepts]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Ibnu Arseno]]></dc:creator>
            <pubDate>Thu, 26 Jan 2023 14:15:40 GMT</pubDate>
            <atom:updated>2023-01-26T14:15:40.760Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*807GCDjJACkN-uNX" /><figcaption>Photo by <a href="https://unsplash.com/@retrosupply?utm_source=medium&amp;utm_medium=referral">RetroSupply</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Object-oriented programming (OOP) is a programming paradigm that is based on the concept of “objects”, which can contain data and methods. In OOP, a class is used as a blueprint for creating objects, and objects can interact with each other through methods. Java is an object-oriented programming language, and it follows the OOP concepts of abstraction, encapsulation, inheritance, and polymorphism.</p><h3><strong>Objects</strong></h3><p>In object-oriented programming, an object is an instance of a class. It is a self-contained entity that has its own state and behavior. An object can be thought of as a real-world object, such as a car or a person, that has certain properties and can perform certain actions.</p><p>In Java, an object is created by instantiating a class. To create an object of a class, you use the ‘<strong>new</strong>’ keyword followed by the constructor of the class. For example, the following code creates an object of the class ‘<strong>Person</strong>’:</p><pre>Person p = new Person(&quot;John Doe&quot;, 25);</pre><p>Here ‘<strong>p</strong>’ is the object of class ‘<strong>Person</strong>’, and it has its own copy of the fields defined in the class.</p><p>An object can access and modify the data stored in its fields through the methods defined in the class. For example, the following code sets the name of the ‘<strong>p</strong>’ object to “<strong>Jane Doe</strong>”:</p><pre>p.setName(&quot;Jane Doe&quot;);</pre><p>An object can also interact with other objects by calling methods on them. For example, an object of class ‘<strong>Car</strong>’ can call a method on an object of class ‘<strong>Driver</strong>’ to set the driver of the car.</p><p>In summary, an object in Java is an instance of a class that has its own state and behavior. It is created by instantiating a class, and it can access and modify the data stored in its fields and interact with other objects through the methods defined in the class.</p><h3><strong>Classes</strong></h3><p>In Java, a class is a blueprint for creating objects. It is a template that defines the properties and methods that an object of that class will have. A class can contain fields (also known as attributes or properties), which are used to store data, and methods, which are used to perform operations on the data stored in the fields.</p><p>A class is defined using the ‘<strong>class</strong>’ keyword, followed by the name of the class. The body of the class contains the fields and methods that the class will have. For example, the following is a simple class called ‘Person’ that has two fields (name and age) and one method (getAge()):</p><pre>class Person {<br>    private String name;<br>    private int age;<br>    <br>    public Person(String name, int age) {<br>        this.name = name;<br>        this.age = age;<br>    }<br>    <br>    public int getAge() {<br>        return age;<br>    }<br>}</pre><p>In this example, the class ‘<strong>Person</strong>’ has two fields, ‘<strong>name</strong>’ and ‘<strong>age</strong>’, and one method, ‘<strong>getAge()</strong>’. The class also has a constructor, which is a special method that is used to create an instance of the class.</p><p>Once a class is defined, it can be used to create objects. An object is an instance of a class, and it has its own copy of the fields defined in the class. Objects can interact with each other by calling the methods defined in the class. For example, the following code creates an object of the class ‘<strong>Person</strong>’ and calls the ‘<strong>getAge()</strong>’ method:</p><pre>Person p = new Person(&quot;John Doe&quot;, 25);<br>System.out.println(p.getAge()); // prints 25</pre><h3><strong>Abstraction</strong></h3><p>Abstraction in object-oriented programming refers to the process of hiding the implementation details of an object and exposing only the essential features to the outside world. It allows the user to focus on the object’s behavior and functionality, rather than its internal workings.</p><p>In Java, abstraction is implemented using abstract classes and interfaces.</p><p>An abstract class is a class that cannot be instantiated, but it can be inherited by other classes. An abstract class can contain both abstract and non-abstract methods. Abstract methods are methods without a body, which means they don’t have any implementation. Subclasses of the abstract class must provide an implementation for these methods.</p><p>For example, the following is an example of an abstract class called ‘<strong>Shape</strong>’ that has an abstract method called ‘<strong>draw()</strong>’:</p><pre>abstract class Shape {<br>    public abstract void draw();<br>}</pre><p>An interface is similar to an abstract class, but it can only contain abstract methods and constants. Interfaces are used to define a contract that specifies the methods that a class must implement.</p><p>For example, the following is an example of an interface called ‘<strong>Drawable</strong>’ that has an abstract method called ‘<strong>draw()</strong>’:</p><pre>interface Drawable {<br>    public void draw();<br>}</pre><p>By using abstraction, we can create a flexible and reusable codebase, as the implementation details of the class are hidden, and the class can be extended or implemented by other classes without affecting the existing code.</p><p>In summary, abstraction in Java is a technique for hiding the implementation details of an object and exposing only the essential features to the outside world, it is implemented by using abstract classes and interfaces. An abstract class can contain both abstract and non-abstract methods, while an interface can only contain abstract methods and constants.</p><h3><strong>Encapsulation</strong></h3><p>Encapsulation is the process of hiding the internal state and behavior of an object from the outside world. It ensures that the internal state of the object is protected from being modified by external entities. In Java, encapsulation is achieved through the use of access modifiers such as ‘<strong>private</strong>’, ‘<strong>protected</strong>’, and ‘<strong>public</strong>’.</p><ul><li>The ‘<strong>private</strong>’ access modifier is used to restrict access to a class or method, so that it can only be accessed within the same class.</li><li>The ‘<strong>protected</strong>’ access modifier is used to restrict access to a class or method, so that it can only be accessed within the same package or subclass.</li><li>The ‘<strong>public</strong>’ access modifier is used to allow access to a class or method from anywhere.</li></ul><p>For example, if a class has an attribute ‘<strong>private int x</strong>’, it means that the attribute x can only be accessed within the class and not outside of it. This ensures that the internal state of the object is protected from being modified by external entities.</p><h3><strong>Inheritance</strong></h3><p>Inheritance is the process of creating a new class that inherits the properties and methods of an existing class. The new class is called a subclass or derived class, and the existing class is called the superclass or base class. Inheritance allows for code reuse and promotes a hierarchical organization of classes. In Java, a class can inherit from another class using the ‘<strong>extends</strong>’ keyword. For example, if we have a class ‘<strong>Car</strong>’ and we want to create a subclass ‘<strong>SportsCar</strong>’, we can do it as follows:</p><pre>class SportsCar extends Car {<br>  // additional attributes and methods specific to SportsCar<br>}</pre><p>In this example, the ‘<strong>SportsCar</strong>’ class inherits all the attributes and methods of the ‘<strong>Car</strong>’ class. Also, the ‘<strong>SportsCar</strong>’ class can add additional attributes and methods that are specific to it.</p><h3><strong>Polymorphism</strong></h3><p>Polymorphism is the ability of an object to take on many forms. Polymorphism allows objects of different classes to be used interchangeably. In Java, polymorphism is achieved through the use of interfaces and abstract classes. An interface defines a set of methods that a class must implement, while an abstract class can contain both abstract methods (methods without a body) and concrete methods (methods with a body).</p><p>For example, if we have an interface ‘<strong>Shape</strong>’ with an abstract method ‘<strong>draw()</strong>’, we can have multiple classes like ‘<strong>Circle</strong>’, ‘<strong>Square</strong>’, ‘<strong>Triangle</strong>’ that implements the ‘<strong>Shape</strong>’ interface and overrides the ‘<strong>draw()</strong>’ method.</p><pre>interface Shape {<br>   void draw();<br>}<br>class Circle implements Shape {<br>   @override<br>   void draw() {<br>       //drawing code for circle<br>   }<br>}<br>class Square implements Shape {<br>   @override<br>   void draw() {<br>       //drawing code for square<br>   }<br>}</pre><p>In this example, the ‘<strong>Circle</strong>’, ’<strong>Square</strong>’.</p><p>In summary, polymorphism in Java is the ability of an object to take on multiple forms, or to be treated as an instance of its parent class or interface. It allows objects of different classes to be used interchangeably, as long as they implement the same methods or interfaces. It is achieved through inheritance and interfaces.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3a62046c839" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Difference Between Primitive and Non Primitive]]></title>
            <link>https://medium.com/codestorm/difference-between-primitive-and-non-primitive-98d4f7cdf92c?source=rss-271742272be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/98d4f7cdf92c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[primitive-data-types]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[non-primitive-datatypes]]></category>
            <dc:creator><![CDATA[Ibnu Arseno]]></dc:creator>
            <pubDate>Wed, 23 Mar 2022 02:16:49 GMT</pubDate>
            <atom:updated>2022-03-30T18:42:04.657Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_Kxc35-EtHjIjrF7" /><figcaption>Photo by <a href="https://unsplash.com/@raphaelphotoch?utm_source=medium&amp;utm_medium=referral">Raphael Schaller</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Data structure means managing data that is in memory, Data can be organized in two ways namely Linear and non-linear.</p><p>There are two types of data structures available for programming purposes:<br>1. primitive data structures.<br>2. non-primitive data structure.</p><h3>Primitive data structure</h3><p>Primitive data structures can only hold one value in one particular location, unlike non-primitive data structures which can be in a both linear and non-linear order.</p><p>Primitive data structures are predefined data types that are supported in programming languages. The size and type of the variable value are specified, and there are no additional methods.</p><p>Primitive data structures contain only the values provided by the programmer. The four main data structures found in every language are int, float, character, and boolean. but in general, there are 8 data types namely boolean, byte, char, short, int, long, float, and double.</p><h4>boolean data type</h4><p>The Boolean data type can only take up to two values, namely TRUE or FALSE. For the most part, boolean values are used for conditional tests.</p><h4>byte data type</h4><p>It is an 8-bit signed two’s complement integer. It stores whole numbers ranging from -128 to 127. A byte data type helps save memory in large amounts.</p><h4>char data type</h4><p>The character data type is used to store single word characters, both uppercase and lowercase, such as ‘Z’ or ‘z’. Alternatively, you can also use ASCII values ​​to display certain characters.</p><h4>short data type</h4><p>A short data type is greater than bytes in terms of size and less than an integer. It stores the value that ranges from -32,768 to 32767.<br>Generally applied to 16-bit computers, which are now increasingly rare.</p><h4>int data type</h4><p>Integers are used to represent numeric data. Integers generally store integers that can be positive or negative. Long can be used in cases where the range of the integer data type is not large enough.</p><h4>long data type</h4><p>This type is used for certain cases whose values ​​are outside the range of the int type because this type has the highest range than Integer. By default, the size of a long data type is 64 bit and its value ranges from -263 to 263–1.</p><h4>float data type</h4><p>This type is used to denote values ​​that contain single-precision or single-precision values ​​that use 32-bit storage space. Single precision is usually faster for certain processors and takes up half as much storage space as double precision. Note that you should end the value with an “f”.</p><h4>double data type</h4><p>This type contains a level of double-precision or double precision and uses 64-bit storage space to store values. The double type is certainly faster to perform mathematical calculations than the float type. For calculations that are real numbers and produce more accurate results, it is better to use the double type.<br>Note that you should end the value with a “d”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*_V2YDcTBeB2JblHY9B8ITw.jpeg" /></figure><h3><strong>Non-primitive data structure</strong></h3><p>Non-primitive data types are types defined by the programmer. They are further classified into linear and nonlinear data types. They are also called ‘variable references’ or ‘reference objects’ because they refer to memory locations that store data.</p><p>Non-Primitive data types refer to objects and hence they are called reference types. Examples of non-primitive types include Strings, Arrays, Classes, Interfaces, etc.</p><h4>Strings</h4><p>The string data structure can be defined as an array of characters. The main difference between the character array and the string data structure is that string data structures terminate with a special character called NULL denoted as ‘\0’. The common operations performed on the string data structure are concatenation, copying, replacing, counting, and searching.</p><h4><strong>Arrays</strong></h4><p>An array data structure can hold a fixed number of primitive data structures (such as integers, characters, etc.). All array elements must have the same primitive data structure type, arrays cannot store separate data types such as integers with characters. Arrays are a common data structure used in many algorithms. The basic operations that can be performed on arrays are insertion, deletion, search, update, and array search.</p><h4><strong>class</strong></h4><p>A class can be defined as a blueprint (blueprint) or prototype/framework that defines the variables (data) and general methods (behavior) of an object. In other words, a class is an integrated entity between methods and data that refers to an object.</p><p>class is used to declare a variable which is an object. Variables in the form of objects are often referred to as object references.</p><h4><strong>Interface</strong></h4><p>An interface is a collection of methods that only contains method declarations and structures, without implementation details. While the details of the method are in the class that implements the interface. Interfaces are used when you want to apply a specific method, which is not obtained from the more restrictive inheritance process. The data types that are allowed on the interface are only constant data types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*aQ_HdP4wCMmUTvlsZGiQwQ.jpeg" /></figure><h3>Difference between primitive and non-primitive data types</h3><p>The difference between primitive and non-primitive data types are as follows:</p><ul><li>Non Primitive types can be used to call methods to perform certain operations, while primitive types cannot.</li><li>A primitive type always has a value, whereas non-primitive types can be null.</li><li>A primitive type starts with a lowercase letter, while non-primitive types start with an uppercase letter.</li><li>The size of a primitive type depends on the data type, while non-primitive types all have the same size.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98d4f7cdf92c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codestorm/difference-between-primitive-and-non-primitive-98d4f7cdf92c">Difference Between Primitive and Non Primitive</a> was originally published in <a href="https://medium.com/codestorm">Code Storm</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linear and Non-linear Data Structure]]></title>
            <link>https://medium.com/codestorm/linear-and-non-linear-data-structure-7f10dc9e9a9f?source=rss-271742272be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f10dc9e9a9f</guid>
            <category><![CDATA[non-linear]]></category>
            <category><![CDATA[linear]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[data-structures]]></category>
            <dc:creator><![CDATA[Ibnu Arseno]]></dc:creator>
            <pubDate>Sat, 19 Mar 2022 16:17:19 GMT</pubDate>
            <atom:updated>2022-03-30T18:40:48.602Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*PB26FaOCYMJb6NX22gSDww.jpeg" /></figure><h4><strong>What is Data structure?</strong></h4><p>The data structure is a method or way of compiling, organizing, and storing various data contained in storage in a system so that it can be used efficiently. in computer science.</p><p>Data structures are classified into two categories:<br>1. linear data structure.<br>2. non-linear data structure.</p><h3><strong>Linear Data Structure</strong></h3><p>The linear data structure is where the data elements are arranged sequentially or linearly where the elements are connected to the previous and next elements. because the elements are stored sequentially, so they can be accessed or traversed in a single run. implementation of linear data structures is easier because the elements are arranged sequentially in memory. Its examples are array, stack, queue, linked list.</p><h4><strong>Array</strong></h4><p>The array is a type of data structure that stores elements of the same data type. this is the most basic data structure. The data stored in each array is assigned a positive value called the index of the element. An index helps identify the location of an element in an array. The index value starts with 0 for the first element in the case of an array.</p><p>if for example want to store 10 student names, then we can create an array data structure and store all student name data together, so there is no need to create 10 String variables separately.</p><h4><strong>Stack</strong></h4><p>Stack is a type of data structure that is linear and follows a certain order. by using the LIFO (Last In-First Out) rule where the data added last will be deleted first. Adding a data element to a stack is known as a push operation, and removing a data element forming a list is known as a pop operation.</p><h4><strong>Queue</strong></h4><p>A queue is a type of linear data structure that follows a certain order, namely FIFO (First In First Out). So, the data that enters the first time is the data that is first retrieved. A simple analogy that describes this type is people who are waiting in line. Who comes first, that’s served first.</p><h4><strong>Linked list</strong></h4><p>It is a collection of nodes that are made up of two parts, i.e., data element and reference to the next node in the sequence. The use of a pointer is that it points or points to the node that is next to the element in the sequence.</p><h3><strong>Non-linear Data Structure</strong></h3><p>Nonlinear data structures are those data structures in which data items are not arranged in a sequence. As the arrangement is nonsequential, the data elements cannot be traversed or accessed in a single run. Non-linear data structures are not easy to implement in comparison to linear data structures. Examples of Non-linear Data structures are tree and graph.</p><h4>Tree</h4><p>A tree can be defined as a finite set of data items (nodes) in which data items are arranged in branches and sub-branches according to requirements. Trees represent the hierarchical relationship between various elements. Tree consists of nodes connected by an edge, the node represented by a circle, and the edge lives connecting to the circle.</p><h4>Graph</h4><p>The graph itself is a non-linear data structure and consists of a collection of nodes. The nodes are connected by a certain line. <br>Nodes — It is a finite set consisting of vertices.<br>Edges — A finite set of ordered pairs in the form of (x,y) that connects any two vertices of the graph.</p><h3>Difference between Linear and Non-linear Data Structures:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*JOnFtvbezR4WWaTk20EHQw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*JfJRLmnKQEvS_JVNUzAh-A.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f10dc9e9a9f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codestorm/linear-and-non-linear-data-structure-7f10dc9e9a9f">Linear and Non-linear Data Structure</a> was originally published in <a href="https://medium.com/codestorm">Code Storm</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reflection in Java]]></title>
            <link>https://medium.com/codestorm/reflection-in-java-4f55c16e00a7?source=rss-271742272be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f55c16e00a7</guid>
            <category><![CDATA[java-reflection]]></category>
            <category><![CDATA[java-reflection-api]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[reflection-in-java-17]]></category>
            <category><![CDATA[reflection-in-java]]></category>
            <dc:creator><![CDATA[Ibnu Arseno]]></dc:creator>
            <pubDate>Tue, 08 Feb 2022 15:47:26 GMT</pubDate>
            <atom:updated>2022-02-12T08:59:31.573Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will discuss reflection in java, what is a reflection in java and what are features that we can use in the projects we make.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TlVUHL7M69ra-88u" /><figcaption>Photo by <a href="https://unsplash.com/@maxweisbecker?utm_source=medium&amp;utm_medium=referral">Maximilian Weisbecker</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Java reflection is a Java feature that allows Java programs to learn or modify themselves. When the application is on-runtime, the application can modify itself or even see its structure of itself.</p><p>For example, we can see the structure of a java class starting from all fields, methods, constructors, and others when the application is running. Java reflection is widely used by frameworks because it is very powerful.</p><p>the features of java reflection are contained in 2 packages, namely in <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/package-summary.html">java.lang</a> and <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/reflect/package-summary.html">java.lang.reflect</a>. There are lots of classes in Java Reflection, and we will discuss them in this article.</p><h3>Inspecting Java Classes</h3><p>java.lang.Class&lt;T&gt; is a reflection representation for Java Class, Interface, and Enum. Sometimes when creating a Java Class, Interface, or Enum we add fields and methods. With the capability of java.lang.Class, we can read all member data (such as fields or methods) contained in a Java Class, Interface, or Enum when the application is running. we can read the details in the <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Class.html">documentation</a>.</p><p>to create a Class&lt;T&gt; we can do several ways:</p><ol><li>use the .class keyword after the name of the Java Class, Interface, or Enum. example: Person.class, Repository.class, or Gender.class.</li><li>using String using the static method Class.forClass(“com.example.Person”) class name must be followed by its package name.</li><li>or we can retrieve the Class&lt;T&gt; of the object, by using the getClass() method.</li></ol><p>we will create a Person class as an example:</p><pre>public class Person {</pre><pre>  private String firstName;</pre><pre>  private String lastName;</pre><pre>  public Person() {}</pre><pre>  public Person(String firstName, String lastName) {</pre><pre>    this.firstName = firstName;</pre><pre>    this.lastName = lastName;</pre><pre>  }</pre><pre>// getter setter</pre><pre>// to String</pre><pre>}</pre><p>to create a Java Reflection Class by:</p><pre>Class&lt;Person&gt; personClass = Person.class;</pre><p>The result is a Java reflection Class with a generic type Person. or by using String like:</p><pre>Class&lt;?&gt; personClass = Class.forName(&quot;com.example.Person&quot;)</pre><p>when using the generic type String use &lt;?&gt;. Or by retrieving the Class&lt;?&gt; of the object using the getClass() method:</p><pre>Person person = new Person()</pre><pre>Class&lt;? extends Person&gt; personClass = person.getClass();</pre><p>Class&lt;T&gt; has a lot of methods. such as to get fields, methods, constructors, annotations, superclasses, interfaces, and others. We can read all the details of the method in the <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Class.html">Javadoc</a>.</p><h3>Inspecting Fields</h3><p>The field is a representation of the Java Field contained in the Java Class. to get a public Field, we can use the getFields() method. or if you want to get all fields with all visibility, we can use the getDeclaredField() method. or you can also get a Field based on its Field name using the getField(field name) or getDeclaredField(field name) methods.</p><p>The field is the same as for Class&lt;T&gt;, it has a lot of methods that can be used to view the details of the field, such as data type, field name, annotation, and others. For more details, see the <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/reflect/Field.html">documentation</a>. sample program to get Field:</p><pre>Class&lt;Person&gt; personClass = Person.class;</pre><pre>Field[] fields = personClass.getDeclaredFields();</pre><pre>for (Field field : fields) {</pre><pre>  System.out.println(field.getName() + &quot; : &quot; + field.getType().getName());</pre><pre>}</pre><h4><strong>Retrieve or change a Field Object</strong></h4><p>Fields can retrieve and modify fields from existing objects. For example, we have created a Field, then we have an Object person1, then we want to take the value of the Field or change it, we can use the setXxx() or getXxx() methods on the field.</p><p>sample program to get Field value:</p><pre>Class&lt;Person&gt; personClass = Person.class;</pre><pre>Field firstName = personClass.getDeclaredField(&quot;firstName&quot;);</pre><pre>firstName.setAccessible(true);</pre><pre>Person person1 = new Person(&quot;Evans&quot;, &quot;Frank&quot;);</pre><pre>String result = (String) firstName.get(person1);</pre><pre>System.out.println(result);</pre><p>sample code to change Field value:</p><pre>Class&lt;Person&gt; personClass = Person.class;</pre><pre>Field firstName = personClass.getDeclaredField(&quot;firstName&quot;);</pre><pre>firstName.setAccessible(true);</pre><pre>Person person1 = new Person(&quot;Evans&quot;, &quot;Frank&quot;);</pre><pre>firstName.set(person1, &quot;Max&quot;); // person1.setFirstName(&quot;Max&quot;);</pre><pre>System.out.println(person1.getFirstName());</pre><p>in the example code above we use the previous Person class, for example, we take a Field with value firstName. so that the Field can be accessed the <strong>setAccessible(true)</strong> method is set to true.</p><h3>Inspecting Methods</h3><p>besides Field, we can also get Methods available in Class&lt;T&gt;. the way to get it is the same as Field, we can use the getMethods(), getDeclaredMethod(), getMethode(name), and getDeclaredMethod(name) methods.</p><p>in Method, many methods can be used to get information such as return value, name annotation, parameters, and others. For more details, see the <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/reflect/Parameter.html">documentation</a>. Sample code to get Parameters:</p><pre>Class&lt;Person&gt; personClass = Person.class;<br>    Method[] methods = personClass.getDeclaredMethods();<br>    for (Method method : methods) {<br>      System.out.println(method.getName());<br>      Parameter[] parameters = method.getParameters();<br>      for (Parameter parameter : parameters) {<br>        System.out.println(&quot;Parameter Name : &quot; + parameter.getName());<br>      }<br>    }</pre><h3>Inspecting Constructors</h3><p>Constructor&lt;T&gt; is a representation of Java Constructor in Java Class. Constructor&lt;T&gt; is similar to Method, in that it has parameters. to create a Constructor we get it via Class&lt;T&gt;.</p><p>Constructor&lt;T&gt; is a generic data type, following the generic data type of Class&lt;T&gt;. For more details, see the <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/reflect/Constructor.html">documentation</a>. Sample code to get the Constructor:</p><pre>Class&lt;Person&gt; personClass = Person.class;</pre><pre>Constructor&lt;?&gt;[] constructors = personClass.getDeclaredConstructors();</pre><pre>for (Constructor&lt;?&gt; constructor : constructors) {</pre><pre>System.out.println(constructor.getName());</pre><pre>System.out.println(Arrays.toString(constructor.getParameterTypes()));</pre><pre>}</pre><h3>Super Class</h3><p>In many cases, especially when using a Java class library or built-in class, we may not know in advance the superclass of the object we are using, this subsection will show you how to obtain this information.</p><p>by using Java Reflection, we can also find out the Super Class of a Java Class. there is a getSuperclass() method in Class&lt;T&gt; to get the Super Class. when creating a class if you don’t add a super class, the super class will automatically be the java.lang.Object class. For more details, see the <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Class.html#getSuperclass()">documentation</a>. Sample code to get Super Class:</p><pre>Class&lt;Person&gt; personClass = Person.class;</pre><pre>System.out.println(personClass);</pre><pre>Class&lt;? super Person&gt; objectClass = personClass.getSuperclass();</pre><pre>System.out.println(objectClass);</pre><h3>Implemented Interfaces</h3><p>using Java Reflection we can also get a list of interfaces implemented by a particular class.</p><p>for the sample code, add a Nameable interface then implement it on Class Person:</p><pre>public interface Nameable {</pre><pre>  String getFirstName();</pre><pre>  String getLastName();</pre><pre>}</pre><p>sample code to get interface:</p><pre>Class&lt;Person&gt; personClass = Person.class;</pre><pre>System.out.println(Arrays.toString(personClass.getInterfaces()));</pre><p>It is therefore worth noting that only those interfaces that a class explicitly declares as implemented with the implements keyword appear in the returned array.</p><h3>Package Information</h3><p>Using Java reflection, we can also get information about packages from any class or object. We can get Package from Class&lt;T&gt; by using getPackage() method. For more details, see the <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Package.html">documentation</a>. Sample code to retrieve the package name:</p><pre>Class&lt;Person&gt; personClass = Person.class;</pre><pre>Package aPackage = personClass.getPackage();</pre><pre>System.out.println(aPackage.getName());</pre><h3>Class Modifiers</h3><p>A modifier is a representation of Java Modifier, such as private, protected, public, abstract, and others. We can determine the modifiers used in a class by calling the getModifiers method which returns an Integer. Each modifier is a flag bit that is either set or cleared. For more details, see the <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/reflect/Modifier.html">documentation</a>. Sample code to get Modifier:</p><pre>Class&lt;Person&gt; personClass = Person.class;</pre><pre>System.out.println(Modifier.isPublic(personClass.getModifiers()));</pre><pre>System.out.println(Modifier.isFinal(personClass.getModifiers()));</pre><pre>System.out.println(Modifier.isStatic(personClass.getModifiers()));</pre><h3>Conclusion</h3><p>In this article, we covered the Java Reflection API and saw how to use it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f55c16e00a7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codestorm/reflection-in-java-4f55c16e00a7">Reflection in Java</a> was originally published in <a href="https://medium.com/codestorm">Code Storm</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>