<?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 Francesco Maselli on Medium]]></title>
        <description><![CDATA[Stories by Francesco Maselli on Medium]]></description>
        <link>https://medium.com/@francescomaselli?source=rss-9479252818b8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*omnJO0viarkI4V9AqGRD0A.jpeg</url>
            <title>Stories by Francesco Maselli on Medium</title>
            <link>https://medium.com/@francescomaselli?source=rss-9479252818b8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 16:49:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@francescomaselli/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[HTMX: Are We Overengineering Frontend Development?]]></title>
            <link>https://javascript.plainenglish.io/htmx-are-we-overengineering-frontend-development-c7a436f40c56?source=rss-9479252818b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7a436f40c56</guid>
            <category><![CDATA[htmx]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Francesco Maselli]]></dc:creator>
            <pubDate>Mon, 02 Nov 2026 17:39:48 GMT</pubDate>
            <atom:updated>2026-11-02T17:39:48.225Z</atom:updated>
            <content:encoded><![CDATA[<p>Remember when building an interactive website didn’t require dozens of dependencies, a complex build system, state management libraries, and an entire frontend framework?</p><p>Today, even relatively simple applications can involve React, Redux, API clients, routing libraries, and layers of state management.</p><p>These tools solve real problems, but sometimes I wonder: <strong>Have we made frontend development more complicated than it needs to be?</strong></p><p>What if we could build interactive web applications with less JavaScript and fewer dependencies?</p><p>That’s where HTMX comes in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BtGChKRD2FFlGUXE0C047g.png" /></figure><h4>Meet HTMX: What If Your Backend Returned HTML Instead of JSON?</h4><p>HTMX is a lightweight JavaScript library that allows you to build modern, interactive web applications directly from HTML.</p><p>Its philosophy is surprisingly simple: instead of writing JavaScript to handle every interaction, you can use HTML attributes to describe what should happen.</p><p>For example, HTMX provides attributes such as:</p><ul><li>hx-get : Send an HTTP GET request</li><li>hx-post : Send an HTTP POST request</li><li>hx-delete : Send an HTTP DELETE request</li><li>hx-target : Specify which element should receive the response</li><li>hx-swap : Control how the response is inserted into the page</li><li>hx-trigger : Define what event triggers the request</li></ul><p>The interesting part is how HTMX handles server responses.</p><p>In a typical frontend architecture, your backend returns JSON, and your frontend is responsible for transforming that data into HTML.</p><p>With HTMX, your backend can return an HTML fragment directly, and HTMX updates the relevant part of the page.</p><p>Let’s look at a simple example.</p><p>Imagine you want to load a list of users when someone clicks a button.</p><p>With JavaScript, you might write something like this:</p><pre>async function loadUsers() {<br>    const response = await fetch(&#39;/users&#39;);<br>    const users = await response.json();<br><br>    const list = document.getElementById(&#39;user-list&#39;);<br><br>    list.innerHTML = users<br>        .map(user =&gt; `&lt;li&gt;${user.name}&lt;/li&gt;`)<br>        .join(&#39;&#39;);<br>}</pre><p>This is perfectly valid JavaScript. However, you need to handle the request, process the response, and update the DOM yourself.</p><p>With HTMX, the implementation becomes much simpler:</p><pre>&lt;button<br>    hx-get=&quot;/users&quot;<br>    hx-target=&quot;#user-list&quot;<br>    hx-swap=&quot;innerHTML&quot;&gt;<br>    Load Users<br>&lt;/button&gt;<br><br>&lt;ul id=&quot;user-list&quot;&gt;&lt;/ul&gt;</pre><p>Your backend simply returns an HTML fragment:</p><pre>&lt;li&gt;John&lt;/li&gt;<br>&lt;li&gt;Sarah&lt;/li&gt;<br>&lt;li&gt;Michael&lt;/li&gt;</pre><p>HTMX handles the request and inserts the returned HTML into the target element.</p><p>No custom fetch logic. No manual DOM manipulation. No additional client-side state management.</p><p>The browser receives HTML, just as it was originally designed to do.</p><h4>HTMX in Action: Three Practical Examples</h4><p>The best way to understand HTMX is to see how it handles everyday frontend interactions.</p><p>Let’s explore three examples.</p><h4>1. Live Search Without Writing JavaScript</h4><p>Imagine building a search feature that displays matching users as someone types.</p><p>With a traditional JavaScript implementation, you would probably need an event listener, a debounce function, an API request, and some code to render the results.</p><p>HTMX provides most of this functionality through HTML attributes.</p><p>Here’s what the implementation looks like:</p><pre>&lt;input<br>    type=&quot;search&quot;<br>    name=&quot;q&quot;<br>    placeholder=&quot;Search users...&quot;<br>    hx-get=&quot;/search&quot;<br>    hx-trigger=&quot;keyup changed delay:300ms&quot;<br>    hx-target=&quot;#search-results&quot;<br>    hx-indicator=&quot;#loading&quot;&gt;<br><br>&lt;span id=&quot;loading&quot; class=&quot;htmx-indicator&quot;&gt;<br>    Searching...<br>&lt;/span&gt;<br><br>&lt;div id=&quot;search-results&quot;&gt;&lt;/div&gt;</pre><p>Let’s break down what’s happening:</p><ul><li>hx-get=&quot;/search&quot; sends a GET request to the search endpoint.</li><li>hx-trigger=&quot;keyup changed delay:300ms&quot; triggers the request when the input changes, with a 300ms delay.</li><li>hx-target=&quot;#search-results&quot; specifies where the response should appear.</li><li>hx-indicator displays a loading indicator while the request is being processed.</li></ul><p>On the backend, you receive the search query and return matching HTML.</p><p>For example, your endpoint might return:</p><pre>&lt;ul&gt;<br>    &lt;li&gt;John Smith&lt;/li&gt;<br>    &lt;li&gt;Sarah Johnson&lt;/li&gt;<br>&lt;/ul&gt;</pre><p>HTMX automatically replaces the previous search results.</p><p>That’s it. No custom event listeners, no fetch calls, and no frontend rendering logic.</p><h4>2. Submit Forms Without Reloading the Page</h4><p>Form submissions are another common use case.</p><p>Traditionally, submitting an HTML form causes a full page reload. With HTMX, you can submit the form asynchronously and update only the relevant section.</p><p>Here’s an example of a simple comment form:</p><pre>&lt;form<br>    hx-post=&quot;/comments&quot;<br>    hx-target=&quot;#comments&quot;<br>    hx-swap=&quot;beforeend&quot;&gt;<br><br>    &lt;input<br>        type=&quot;text&quot;<br>        name=&quot;comment&quot;<br>        placeholder=&quot;Write a comment...&quot;<br>        required&gt;<br><br>    &lt;button type=&quot;submit&quot;&gt;<br>        Post Comment<br>    &lt;/button&gt;<br>&lt;/form&gt;<br><br>&lt;div id=&quot;comments&quot;&gt;&lt;/div&gt;</pre><p>Notice that we’re using hx-post instead of a regular form submission.</p><p>When the user submits the form, HTMX sends the request to /comments.</p><p>The backend processes the comment and returns an HTML fragment:</p><pre>&lt;div class=&quot;comment&quot;&gt;<br>    &lt;strong&gt;John&lt;/strong&gt;<br>    &lt;p&gt;Thanks for sharing your thoughts!&lt;/p&gt;<br>&lt;/div&gt;</pre><p>Because we specified hx-swap=&quot;beforeend&quot;, the new comment is appended to the existing comments.</p><p>The page doesn’t reload, and we don’t need to manually update the DOM.</p><p>The server remains responsible for processing the data and generating the updated HTML.</p><h4>3. Delete Items Without Refreshing the Page</h4><p>Let’s consider another common interaction: deleting an item from a list.</p><p>With HTMX, you can handle this directly from an HTML button.</p><pre>&lt;div id=&quot;task-42&quot;&gt;<br>    &lt;span&gt;Finish the documentation&lt;/span&gt;<br><br>    &lt;button<br>        hx-delete=&quot;/tasks/42&quot;<br>        hx-target=&quot;#task-42&quot;<br>        hx-swap=&quot;outerHTML&quot;<br>        hx-confirm=&quot;Are you sure?&quot;&gt;<br><br>        Delete<br>    &lt;/button&gt;<br>&lt;/div&gt;</pre><p>Here’s what happens:</p><ol><li>The user clicks the Delete button.</li><li>HTMX sends a DELETE request to /tasks/42.</li><li>The backend deletes the task.</li><li>HTMX removes the targeted element from the page.</li></ol><p>For this example, the backend can return an empty response with HTTP status 200, allowing HTMX to swap the targeted element with nothing.</p><p>Of course, the backend should still validate the request, check authorization, and handle errors appropriately.</p><p>These examples demonstrate something interesting: many interactions we traditionally implement with JavaScript can be handled directly through HTML and server responses.</p><p>And that’s where HTMX starts to become particularly interesting.</p><h4>HTMX vs React: Two Different Approaches</h4><p>At this point, you might be wondering: does HTMX mean we no longer need React?</p><p>Not really.</p><p>Although both technologies help us build interactive web applications, they approach the problem from different directions.</p><p>React is built around components, client-side rendering, and managing UI state in JavaScript.</p><p>HTMX takes a more server-driven approach. Instead of building and managing much of the UI in the browser, it allows the server to return HTML fragments that update specific parts of the page.</p><p>Neither approach is inherently better.</p><p>React makes a lot of sense when building applications with complex client-side interactions, sophisticated state management, rich dashboards, or extensive browser-side functionality.</p><p>HTMX, on the other hand, is particularly attractive for applications where most interactions involve sending requests to a backend and displaying the resulting HTML.</p><p>Think about admin panels, internal tools, CRUD applications, dashboards, and content-driven websites.</p><p>In many of these cases, you might not need an entire frontend framework.</p><p>The important question isn’t which technology is more modern.</p><p>It’s which technology solves your actual problem with the least unnecessary complexity.</p><h4>Is HTMX Really Better? The Trade-Offs</h4><p>HTMX looks great in simple examples, but it’s important to understand that it isn’t a silver bullet. Its simplicity comes with trade-offs.</p><h4><strong>1. More responsibility on the server</strong></h4><p>With HTMX, the server often generates the HTML that gets displayed in the browser.</p><p>This means your backend becomes more involved in rendering the UI.</p><p>For teams building applications around JSON APIs and completely independent frontend and backend deployments, this might not fit their existing architecture.</p><h4><strong>2. Complex client-side interactions</strong></h4><p>Applications with sophisticated client-side state, complex drag-and-drop interactions, extensive animations, or rich browser-side processing may benefit more from React, Vue, or similar frameworks.</p><p>HTMX can work alongside custom JavaScript, but it doesn’t eliminate the need for more advanced frontend tooling when the application genuinely requires it.</p><h4><strong>3. Offline functionality</strong></h4><p>Since HTMX commonly relies on server requests to update the page, applications requiring extensive offline functionality or complex offline-first experiences may need a different architecture.</p><h4>Final Thoughts: Maybe We Don’t Need More JavaScript</h4><p>HTMX doesn’t mean React is obsolete, nor does it mean JavaScript frameworks were a mistake.</p><p>These technologies have transformed frontend development and made it possible to build incredibly sophisticated applications.</p><p>But HTMX reminds us of something we’ve gradually forgotten: the browser is already an incredibly powerful platform, and not every application needs an elaborate frontend architecture.</p><p>Sometimes, we spend more time managing dependencies, configuring build tools, synchronizing application state, and maintaining frontend infrastructure than actually building the features users need.</p><p>Maybe the next step in frontend development isn’t adding another framework, another state management library, or another layer of abstraction.</p><p>Maybe it’s learning when not to use them.</p><p>HTMX is a good reminder that we don’t always need to introduce more complexity to build better software.</p><p><strong>Sometimes, the simplest solution really is the best one.</strong></p><h4>Conclusion</h4><p>Are we overengineering frontend development, or has this complexity become a necessary part of building modern applications?</p><p>Have you tried HTMX in a real-world project? I’d love to hear your thoughts in the comments.</p><p>If you enjoyed this article, give it a clap and follow me for more discussions about software engineering and web development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7a436f40c56" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/htmx-are-we-overengineering-frontend-development-c7a436f40c56">HTMX: Are We Overengineering Frontend Development?</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring AOP Demystified: What Really Happens When You Call a Method?]]></title>
            <link>https://levelup.gitconnected.com/spring-aop-demystified-what-really-happens-when-you-call-a-method-ff88dc0450a0?source=rss-9479252818b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff88dc0450a0</guid>
            <category><![CDATA[spring-framework]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Francesco Maselli]]></dc:creator>
            <pubDate>Mon, 19 Oct 2026 15:47:48 GMT</pubDate>
            <atom:updated>2026-10-19T15:47:48.445Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine you have a Spring service that processes payments. You want to log execution time every time a payment is processed.</p><p>You could add logging directly to the method, but what happens when you need the same behavior across dozens of services?</p><p>Duplicating that code makes your application harder to maintain.</p><p>This is where <strong>Spring AOP (Aspect-Oriented Programming)</strong> comes in.</p><p>The central question is simple: <strong>How can Spring execute extra code before or after a method call without modifying the method itself?</strong></p><p>The answer lies in proxies, advice, pointcuts, and interceptors.</p><p>Let’s understand how these pieces work by building one small example step by step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WWWoqxJqIBGLHEn6" /><figcaption>Photo by <a href="https://unsplash.com/@kyleszegedi?utm_source=medium&amp;utm_medium=referral">Kyle Szegedi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Why Does a Method Execute Extra Code?</h4><p>Spring AOP allows us to separate cross-cutting concerns from business logic.</p><p>A cross-cutting concern is behavior that applies to multiple parts of an application rather than belonging to a single business operation.</p><p>Common examples include:</p><ul><li>Logging</li><li>Transaction management</li><li>Authorization checks</li><li>Metrics and monitoring</li></ul><p>Instead of placing this behavior inside every service method, we define it separately and let Spring apply it where needed.</p><p>Consider this simple service:</p><pre>@Service<br>public class PaymentService {<br><br>    public void processPayment() {<br>        System.out.println(&quot;Processing payment...&quot;);<br>    }<br>}</pre><p>We want to execute logging before and after processPayment() without changing its implementation.</p><p>Spring AOP makes this possible by exposing the service through a <strong>proxy</strong> that intercepts eligible method calls.</p><p>The business method stays focused on processing payments, while the aspect handles logging.</p><h4>The 4 Concepts Every Spring AOP Developer Should Understand</h4><p>Before writing an aspect, let’s clarify the four concepts that make Spring AOP easier to understand.</p><h4>1. Aspect</h4><p>An aspect groups cross-cutting logic into one place. For example, we might want to log the execution of service methods without adding logging code to every service.</p><h4>Example</h4><pre>@Aspect<br>@Component<br>public class LoggingAspect {<br><br>    @Before(&quot;execution(* com.example.service.*.*(..))&quot;)<br>    public void logBefore() {<br>        System.out.println(&quot;A service method is about to execute&quot;);<br>    }<br>}</pre><p>@Aspect identifies the class as an aspect, while @Component allows Spring to discover it through component scanning.</p><p>The aspect contains both the behavior we want to execute and the rule that determines where it applies.</p><h4>2. Advice</h4><p>Advice defines what code runs when a method invocation is intercepted. Spring AOP provides several types of advice:</p><ul><li>@Before : runs before the method executes</li><li>@After : runs after the invocation completes, whether it succeeds or throws</li><li>@AfterReturning : runs after successful completion</li><li>@AfterThrowing : runs when the method throws an exception</li><li>@Around : runs around the invocation, with control over proceeding</li></ul><h4>Example</h4><pre>@Before(&quot;execution(* com.example.service.*.*(..))&quot;)<br>public void logBefore() {<br>    System.out.println(&quot;A service method is about to execute&quot;);<br>}</pre><p>In the example above, our @Before advice prints a message before a matching service method executes.</p><h4>3. Pointcut</h4><p>A pointcut defines which method executions should be intercepted. For example, we might want to apply our logging aspect to every method in the service package:</p><h4>Example</h4><pre>@Pointcut(&quot;execution(* com.example.service.*.*(..))&quot;)<br>public void serviceMethods() {}</pre><p>The expression matches methods on types directly within com.example.service, regardless of their return type, name, or arguments.</p><p>The empty method body is intentional: serviceMethods() names the pointcut so that advice can reference it.</p><p>The pointcut defines where the behavior applies; the advice defines what happens.</p><h4>4. Join Point</h4><p>A join point represents an execution point where advice can be applied. In Spring AOP, join points are method executions intercepted through Spring’s proxy-based mechanism.</p><p>Spring provides a JoinPoint object that lets us inspect the intercepted method.</p><h4>Example</h4><pre>@Before(&quot;execution(* com.example.service.*.*(..))&quot;)<br>public void logMethod(JoinPoint joinPoint) {<br>    System.out.println(<br>        &quot;Executing: &quot; + joinPoint.getSignature().getName()<br>    );<br>}</pre><p>If PaymentService.processPayment() is intercepted, this advice prints Executing: processPayment.</p><p>The JoinPoint gives us information about the invocation without requiring changes to the original business method.</p><p>With these concepts in mind, let’s build our first aspect.</p><h4>Build Your First Custom Aspect</h4><p>First, add Spring AOP to your Maven project:</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>    &lt;artifactId&gt;spring-boot-starter-aop&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><p>Now create the aspect:</p><pre>@Aspect<br>@Component<br>public class LoggingAspect {<br><br>    @Around(<br>        &quot;execution(* com.example.service.PaymentService.*(..))&quot;<br>    )<br>    public Object logExecutionTime(<br>            ProceedingJoinPoint joinPoint) throws Throwable {<br><br>        long start = System.nanoTime();<br><br>        try {<br>            System.out.println(&quot;Before method execution&quot;);<br><br>            return joinPoint.proceed();<br><br>        } finally {<br>            long duration = System.nanoTime() - start;<br><br>            System.out.println(<br>                &quot;Execution time: &quot; + duration + &quot; ns&quot;<br>            );<br>        }<br>    }<br>}</pre><p>The key line is:</p><pre>return joinPoint.proceed();</pre><p>It continues the invocation through the remaining interceptor chain, eventually executing the target method unless the chain changes that behavior.</p><p>The finally block measures execution time even if the method throws an exception.</p><p>Now, when another Spring bean calls paymentService.processPayment(), the output resembles:</p><pre>Before method execution<br>Processing payment...<br>Execution time: 85000 ns</pre><p>The actual duration will vary.</p><p>We’ve added behavior without modifying the original business method.</p><h4>What Does the Pointcut Expression Actually Mean?</h4><p>Consider this expression:</p><pre>execution(* com.example.service.PaymentService.*(..))</pre><p>Here’s how to read it:</p><ul><li>execution(...) matches method executions.</li><li>the first * matches any return type.</li><li>com.example.service.PaymentService identifies the target type.</li><li>the second * matches any method name.</li><li>(..) matches any number of arguments, including none.</li></ul><p>In other words, the expression selects methods on PaymentService regardless of their names, return types, or parameter lists.</p><p>Understanding pointcuts helps you control exactly where your cross-cutting logic applies.</p><h4>The Internals: How Spring Intercepts the Method</h4><p>Spring AOP works primarily through proxies. Depending on the configuration, Spring can use:</p><ul><li><strong>JDK dynamic proxies</strong>, which implement interfaces.</li><li><strong>Class-based proxies</strong>, commonly created using CGLIB.</li></ul><p>When a method is called through the proxy, Spring identifies the applicable advice and executes it through an interceptor chain before delegating to the target method.</p><p>Conceptually:</p><pre>Client<br>  |<br>  v<br>Proxy<br>  |<br>  v<br>Advice / Interceptor Chain<br>  |<br>  v<br>Target Method</pre><p>Multiple concerns, such as logging and transaction management, can participate in this chain.</p><p>However, <strong>the call must pass through the proxy</strong> for ordinary Spring AOP advice to run.</p><p>This leads to one of its most common pitfalls.</p><h4>The Self-Invocation Problem</h4><p>Imagine adding another method to our service:</p><pre>public void processPayment() {<br>    System.out.println(&quot;Processing payment...&quot;);<br>    validatePayment();<br>}<br><br>public void validatePayment() {<br>    System.out.println(&quot;Validating payment...&quot;);<br>}</pre><p>Suppose an aspect targets both methods.</p><p>When an external caller invokes processPayment() through the proxy, the aspect can intercept that call.</p><p>But validatePayment() is called directly from inside the target object. The call doesn&#39;t pass through the proxy.</p><p>As a result, <strong>the advice on </strong>validatePayment()<strong> normally won&#39;t execute for this internal call</strong>.</p><p>This is called self-invocation.</p><p>A clean solution is to move validatePayment() into a separate Spring-managed service and call it through an injected dependency. That creates a new bean boundary through which proxy-based advice can run.</p><p>Remember: Spring AOP intercepts eligible calls through proxies, not every method call inside an object.</p><h4>When Is Spring AOP Not Enough?</h4><p>Spring AOP is ideal for service-layer concerns such as logging, transactions, metrics, and auditing.</p><p>However, proxy-based AOP does not intercept private methods, field access, object construction, or self-invocations in the usual way. It also doesn’t automatically proxy arbitrary objects outside the Spring container.</p><p>When you need broader interception capabilities, <strong>AspectJ</strong> may be a better choice. It supports additional join points and bytecode weaving, including scenarios that proxy-based Spring AOP cannot handle.</p><p>For most application-level cross-cutting concerns, though, Spring AOP is a good starting point.</p><h4>Conclusion</h4><p>Let’s return to our original question:</p><p><strong>How can Spring execute extra code before or after a method call without modifying the method itself?</strong></p><p>Spring exposes eligible beans through proxies. Those proxies intercept method calls, apply matching advice through an interceptor chain, and delegate to the original business logic.</p><p>The aspect defines the behavior, the pointcut selects the methods, and the proxy connects everything.</p><p>Once you understand this mechanism, Spring AOP becomes less like magic and more like a predictable design tool.</p><p>Have you ever encountered a @Transactional annotation or custom aspect that mysteriously didn&#39;t execute?</p><p>Share your experience in the comments. If this article helped you understand Spring AOP, give it a clap and follow for more practical Java and Spring tutorials.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff88dc0450a0" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/spring-aop-demystified-what-really-happens-when-you-call-a-method-ff88dc0450a0">Spring AOP Demystified: What Really Happens When You Call a Method?</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java After Version 8: 10 Features That Reduce Boilerplate and Improve Readability]]></title>
            <link>https://levelup.gitconnected.com/java-after-version-8-10-features-that-reduce-boilerplate-and-improve-readability-96bdfaf85aa7?source=rss-9479252818b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/96bdfaf85aa7</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[modern-java]]></category>
            <category><![CDATA[java21]]></category>
            <dc:creator><![CDATA[Francesco Maselli]]></dc:creator>
            <pubDate>Mon, 14 Sep 2026 15:37:38 GMT</pubDate>
            <atom:updated>2026-09-14T15:37:38.560Z</atom:updated>
            <content:encoded><![CDATA[<p>What if the reason your Java code feels heavy… isn’t Java itself?</p><p>What if most of the complexity you deal with every day isn’t business logic, but habits you carried over from Java 8 (or earlier)?</p><p>For years, developers relied on external libraries, annotations, and frameworks just to reduce boilerplate. Entire architectural decisions were made just to avoid writing repetitive code.</p><p>But here’s the twist: <strong>modern Java has quietly evolved</strong>.</p><p>Between Java 9 and Java 21, the language introduced features that eliminate much of that verbosity natively, no hacks, no extra dependencies, no workarounds.</p><p>If you’ve ever felt that Java is too verbose, too rigid, or simply outdated, this article might change your perspective.</p><p>Let’s explore the features that are redefining how senior developers write Java today.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n-cmNJT4k4rGBEXb" /><figcaption>Photo by <a href="https://unsplash.com/@fl__q?utm_source=medium&amp;utm_medium=referral">Taiki Ishikawa</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>1. Local Variable Type Inference (var)</h4><p>Introduced in Java 10, var allows developers to declare local variables without explicitly specifying their types, as the compiler automatically infers them from the assigned value. This reduces repetitive type declarations and improves readability, particularly when dealing with complex generic types that would otherwise make code verbose and harder to follow. In traditional Java code, long type signatures often cluttered local variable declarations, shifting focus away from the actual logic. With var, Java reduces this noise and makes code easier to read by emphasizing intent over explicit type repetition. When used appropriately in local scopes, it helps produce cleaner, more maintainable code without sacrificing type safety.</p><h4>Before</h4><pre>Map&lt;String, List&lt;Integer&gt;&gt; map = new HashMap&lt;&gt;();</pre><h4>After</h4><pre>var map = new HashMap&lt;String, List&lt;Integer&gt;&gt;();</pre><h4>2. Text Blocks</h4><p>Introduced in Java 15, Text Blocks offer a cleaner and more natural way to define multi-line strings, eliminating the need for string concatenation and excessive escape characters. In earlier Java versions, representing structured content like JSON, SQL queries, or XML often required verbose and error-prone string building, which reduced readability and increased maintenance overhead. Text Blocks solve this by allowing developers to write multi-line text in a format that closely resembles its actual structure, preserving indentation and layout. This makes embedded data significantly easier to read, write, and maintain, while also reducing the risk of formatting and escaping errors. Overall, Text Blocks bring much-needed clarity to one of the most historically cumbersome areas of Java development.</p><h4>Before</h4><pre>String json = &quot;{\n&quot; +<br>              &quot; \&quot;name\&quot;: \&quot;John\&quot;,\n&quot; +<br>              &quot; \&quot;age\&quot;: 30\n&quot; +<br>              &quot;}&quot;;</pre><h4>After</h4><pre>String json = &quot;&quot;&quot;<br>    {<br>      &quot;name&quot;: &quot;John&quot;,<br>      &quot;age&quot;: 30 <br>    } <br>    &quot;&quot;&quot;;</pre><h4>3. Records</h4><p>Introduced in Java 16, Records provide a compact and expressive way to model immutable data. They automatically generate constructors, accessors, and implementations of equals(), hashCode(), and toString(), removing the need for boilerplate code in data classes. In traditional Java development, defining a simple data carrier often required writing or generating multiple methods, making classes unnecessarily verbose and harder to maintain. Records solve this by turning a full data model into a single, declarative line of code. This shifts the developer’s focus from repetitive implementation details to the actual structure and meaning of the data. As a result, code becomes cleaner, more consistent, and significantly easier to maintain, especially in use cases like DTOs and immutable domain models.</p><h4>Before</h4><pre>public class User {<br>    private final String name;<br>    private final int age;<br><br>    // constructor, getters, equals, hashCode, toString... <br>}</pre><h4>After</h4><pre>public record User(String name, int age) {}</pre><h4>4. Switch Expressions</h4><p>Modern Java introduces Switch Expressions, which return a value and can be used directly in assignments or return statements. Compared to the traditional switch statement, which relies on multiple case blocks and mandatory break statements to avoid fall-through, Switch Expressions provide a more structured and expressive alternative. Using the arrow syntax (-&gt;), each branch clearly maps a condition to a result, eliminating ambiguity in control flow. This design removes the need for break, reduces boilerplate, and prevents a common source of bugs caused by unintended fall-through behavior. Overall, Switch Expressions make conditional logic more readable, predictable, and aligned with modern functional-style programming practices.</p><h4>Before</h4><pre>String result;<br>switch (day) {<br>    case MONDAY: <br>        result = &quot;Start&quot;;<br>        break; <br>    case FRIDAY: <br>        result = &quot;End&quot;;<br>        break; <br>    default: <br>        result = &quot;Middle&quot;; <br>}</pre><h4>After</h4><pre>String result = switch (day) {<br>    case MONDAY -&gt; &quot;Start&quot;; <br>    case FRIDAY -&gt; &quot;End&quot;; <br>    default -&gt; &quot;Middle&quot;; <br>};</pre><h4>5. Sealed Classes</h4><p>Introduced in Java 17, Sealed Classes restrict inheritance by explicitly defining which classes are allowed to extend or implement them. This mechanism gives developers precise control over their class hierarchies by limiting extension to a known and fixed set of subclasses. Unlike traditional inheritance, where any class can potentially extend another, sealed classes enforce boundaries at the language level, making the design more intentional and predictable. This is particularly useful in domain modeling, where only specific variations of a concept should exist. As a result, Sealed Classes improve code safety, readability, and long-term maintainability by preventing uncontrolled or accidental inheritance.</p><h4>Example</h4><pre>public sealed interface Shape permits Circle, Rectangle {}<br><br>public final class Circle implements Shape {}<br>public final class Rectangle implements Shape {}</pre><h4>6. Pattern Matching for instanceof</h4><p>Introduced in Java 16, Pattern Matching for instanceof removes the need for explicit casting by combining type checking and variable binding in a single expression. In traditional Java code, developers had to check an object’s type and then manually cast it before using it, which resulted in repetitive and cluttered code. With pattern matching, Java automatically performs the cast within the instanceof check, making the variable immediately available in a strongly typed form. This reduces boilerplate, improves readability, and leads to safer and more expressive code when working with polymorphic types or object hierarchies.</p><h4>Before</h4><pre>if (obj instanceof String) {<br>    String s = (String) obj; <br>    System.out.println(s.length()); <br>}</pre><h4>After</h4><pre>if (obj instanceof String s) {<br>    System.out.println(s.length()); <br>}</pre><h4>7. Java Platform Module System (JPMS)</h4><p>Introduced in Java 9, the Java Platform Module System (JPMS) brings true modularity to Java by enabling applications to define explicit dependencies and enforce strong encapsulation between modules. Unlike the traditional classpath-based approach, JPMS allows developers to structure applications into well-defined modules, each with clearly declared dependencies and controlled access to internal APIs. This makes large codebases significantly easier to manage, as it reduces hidden coupling and improves clarity around how different parts of the system interact. By enforcing boundaries at the language level, JPMS helps teams design more maintainable, scalable, and reliable applications, especially in complex enterprise environments.</p><h4>Example</h4><pre>module com.example.app {<br>    requires java.sql; <br>    exports com.example.service;<br>}</pre><h4>8. Unnamed Classes and Instance main() Methods</h4><p>Introduced in Java 21, Unnamed Classes and Instance Main Methods aim to simplify the structure of small Java programs. Traditionally, even the most basic program in Java required a full class declaration and a static main method. This new approach removes that requirement, allowing developers to write top-level code without boilerplate structure. The result is a more streamlined and approachable programming model, especially for beginners, scripting, and quick experimentation. By eliminating unnecessary syntax overhead, Java allows developers to focus directly on logic rather than structure, making small programs faster and more natural to write.</p><h4>Before</h4><pre>public class HelloWorld {<br>    public static void main(String[] args) {<br>        System.out.println(&quot;Hello, World!&quot;);<br>    }<br>}</pre><h4>After</h4><pre>void main() {<br>    System.out.println(&quot;Hello, World!&quot;);<br>}</pre><h4>9. Virtual Threads</h4><p>Introduced in Java 21, Virtual Threads are lightweight threads that dramatically simplify concurrent programming. Unlike traditional platform threads, they consume minimal system resources, allowing applications to handle thousands or even millions of concurrent tasks efficiently. This eliminates the need for complex thread pools or reactive programming models, making it easier to build high-throughput systems. The result is simpler, more readable code that scales without the usual concurrency overhead.</p><h4>Before (Traditional Threads)</h4><pre>Thread t = new Thread(() -&gt; process()); <br>t.start();</pre><h4>After (Virtual Threads)</h4><pre>Thread.startVirtualThread(() -&gt; process());</pre><h4>10. Stream API Enhancements</h4><p>Streams didn’t stop evolving after Java 8. New additions like takeWhile and dropWhile make stream processing more expressive and precise. These methods allow condition-based, order-sensitive operations where elements are processed only until a condition holds (takeWhile) or skipped while a condition is true (dropWhile). Unlike a general filter, they can short-circuit processing in ordered streams, making pipelines more intuitive and potentially more efficient for large datasets.</p><h4>Example</h4><pre>List&lt;Integer&gt; numbers = List.of(1, 2, 3, 4, 5);<br><br>List&lt;Integer&gt; result = numbers.stream() <br>    .takeWhile(n -&gt; n &lt; 4) <br>    .toList();</pre><h4>Conclusion</h4><p>Java didn’t suddenly become verbose overnight and it didn’t magically become concise either. It evolved. Quietly. Incrementally. And if you haven’t been paying attention, you might still be writing Java the old way without realizing there’s a better one.</p><p>Now here’s the important part: reading about these features won’t change your codebase, <strong>using them will</strong>.</p><p>Pick one feature from this list today. Just one.<br>Refactor a small part of your code with it. Replace a DTO with a Record. Convert a switch statement. Introduce a virtual thread where it makes sense.</p><p>You’ll immediately feel the difference.</p><p>And once you do, you won’t go back.</p><p>If you found this useful, consider sharing it with your team or saving it for your next refactoring session.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96bdfaf85aa7" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/java-after-version-8-10-features-that-reduce-boilerplate-and-improve-readability-96bdfaf85aa7">Java After Version 8: 10 Features That Reduce Boilerplate and Improve Readability</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a VS Code-Like JSON Editor in Angular with Monaco Editor]]></title>
            <link>https://javascript.plainenglish.io/build-a-vs-code-like-json-editor-in-angular-with-monaco-editor-5fa51375e56e?source=rss-9479252818b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fa51375e56e</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ngx-monaco-editor]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Francesco Maselli]]></dc:creator>
            <pubDate>Thu, 30 Jul 2026 10:44:52 GMT</pubDate>
            <atom:updated>2026-07-30T10:44:52.294Z</atom:updated>
            <content:encoded><![CDATA[<p>Most Angular admin panels still rely on plain textarea elements for editing JSON. They get the job done but they don’t provide the experience developers are used to.</p><p>I wanted a real developer experience directly inside the browser, so I embedded Monaco Editor, the same editor that powers Visual Studio Code.</p><p>The result is a JSON editor with syntax highlighting, IntelliSense, formatting, validation, and an editing experience that feels almost identical to VS Code, all inside an Angular application.</p><p>In this article, we’ll build exactly that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4aJ_YAy_RyIG3ECV" /><figcaption>Photo by <a href="https://unsplash.com/@zakiego?utm_source=medium&amp;utm_medium=referral">M. Zakiyuddin Munziri</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Why Monaco Editor?</h4><p>If you’ve used Visual Studio Code, you’ve already used Monaco Editor.</p><p>Monaco is Microsoft’s browser-based code editor that serves as the editing engine behind VS Code. While VS Code includes additional features like extensions, Git integration, and debugging, the editor itself is Monaco.</p><p>Instead of building syntax highlighting, autocomplete, formatting, and validation yourself, Monaco gives you a production-ready editor that has already been tested by millions of developers.</p><p>Some of the capabilities you’ll get out of the box include:</p><ul><li>Syntax highlighting</li><li>IntelliSense and code completion</li><li>Real-time error detection and validation</li><li>Automatic formatting</li><li>Code folding</li><li>Find &amp; Replace</li><li>Support for dozens of programming languages</li><li>Themes including VS Code Light and Dark</li></ul><p>For JSON editing specifically, Monaco understands the language structure and immediately highlights syntax errors, making it far more reliable than a simple textarea.</p><h4>Let’s Build a VS Code-Like JSON Editor</h4><p>Instead of another “Hello World” example, let’s build a JSON configuration editor like the ones found in admin dashboards, developer portals, and cloud management tools.</p><p>Our editor should:</p><ul><li>display JSON</li><li>validate it while typing</li><li>allow formatting</li><li>detect invalid syntax</li><li>notify Angular whenever the content changes</li></ul><h4>Step 1 — Project Setup</h4><p>We’ll use the official Angular wrapper around Monaco.</p><p>Install the required packages:</p><pre>npm install monaco-editor ngx-monaco-editor-v2</pre><p>Import the editor module in your application and configure Monaco once.</p><h4>Step 2— Create the editor component</h4><pre>import { Component } from &#39;@angular/core&#39;;<br><br>@Component({<br> selector: &#39;app-json-editor&#39;,<br> templateUrl: &#39;./json-editor.component.html&#39; <br>}) <br>export class JsonEditorComponent {<br><br> json = `{ <br> &quot;name&quot;: &quot;Angular&quot;,<br> &quot;version&quot;: 20,<br> &quot;production&quot;: false <br>}`;<br><br> editorOptions = { <br>language: &#39;json&#39;,<br>theme: &#39;vs-dark&#39;,<br>automaticLayout: true, <br>minimap: { enabled: false }, <br>formatOnPaste: true, <br>formatOnType: true <br>}; <br><br>}</pre><p>Notice that we don’t need to configure syntax highlighting or validation; they’re already built into Monaco.</p><h4>Step 3— Add the editor</h4><pre>&lt;ngx-monaco-editor<br> [options]=&quot;editorOptions&quot; <br> [(ngModel)]=&quot;json&quot;&gt; <br>&lt;/ngx-monaco-editor&gt;</pre><p>That’s enough to get a working JSON editor inside Angular.</p><p>You now have:</p><ul><li>syntax highlighting</li><li>validation</li><li>automatic indentation</li><li>formatting</li><li>bracket matching</li></ul><p>without writing any custom editor logic.</p><h4>Step 4— Validate JSON</h4><p>Although Monaco detects syntax errors visually, your Angular application may also need to know whether the JSON is valid before saving.</p><pre>isValidJson(): boolean {<br> try {<br>   JSON.parse(this.json);<br>   return true; <br>} catch { <br>   return false; <br>} <br><br>}</pre><h4>Step 5— Format JSON</h4><p>Users often paste minified JSON.</p><p>Adding a Format button dramatically improves readability.</p><pre>formatJson() {<br> this.json = JSON.stringify(<br> JSON.parse(this.json),<br> null,<br> 2 <br>); <br>}</pre><p>After formatting, the editor immediately displays properly indented JSON.</p><h4>Step 6— React to Changes</h4><p>Since Monaco integrates with Angular forms, reacting to edits is straightforward.</p><pre>onJsonChanged(value: string) {<br> console.log(value); <br>}</pre><pre>&lt;ngx-monaco-editor <br>[(ngModel)]=&quot;json&quot; <br>(ngModelChange)=&quot;onJsonChanged($event)&quot;&gt; <br>&lt;/ngx-monaco-editor&gt;</pre><p>This makes it easy to:</p><ul><li>auto-save</li><li>validate against APIs</li><li>compare versions</li><li>enable undo workflows</li><li>update live previews</li></ul><h4>Why This Feels Like VS Code</h4><p>The biggest advantage isn’t just syntax highlighting.</p><p>It’s that users instantly recognize the editing experience.</p><p>Features like:</p><ul><li>automatic bracket completion</li><li>indentation</li><li>hover information</li><li>IntelliSense</li><li>error markers</li><li>formatting shortcuts</li></ul><p>all contribute to a familiar environment that reduces friction for developers working in browser-based tools.</p><p>Instead of learning a custom editor, they’re using one they already know.</p><h4>Where Monaco Shines</h4><p>Monaco is an excellent choice when your application includes:</p><ul><li>Admin dashboards</li><li>Developer portals</li><li>API management tools</li><li>Configuration editors</li><li>Infrastructure dashboards</li><li>Workflow builders</li><li>Cloud management interfaces</li><li>Internal developer platforms</li></ul><p>Anywhere users spend significant time editing structured text, Monaco dramatically improves usability.</p><h4>Conclusion</h4><p>Monaco Editor isn’t the right solution for every application, but when users need to work with code or structured data, it provides a professional editing experience that would be extremely difficult to build yourself.</p><p>Monaco gives your Angular application the editing experience developers already expect from modern tooling, making complex JSON editing faster, safer, and far more enjoyable.</p><p>If you found this article helpful, leave a clap, share it with other Angular developers, and follow me on Medium for more practical Angular tutorials covering modern UI components, performance, architecture, and real-world developer tools.</p><h3>Before you go</h3><ul><li>Please take a moment to like the post and follow the writer!</li><li>Did you know that over 400,000 developers share what they’re building, learning, and discovering across our platforms every month? Learn how you can contribute <a href="https://plainenglish.io/write-for-us">here</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fa51375e56e" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/build-a-vs-code-like-json-editor-in-angular-with-monaco-editor-5fa51375e56e">Build a VS Code-Like JSON Editor in Angular with Monaco Editor</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Object-Oriented Programming in JavaScript Explained Simply]]></title>
            <link>https://javascript.plainenglish.io/object-oriented-programming-in-javascript-explained-simply-9cbbf70c1989?source=rss-9479252818b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cbbf70c1989</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Francesco Maselli]]></dc:creator>
            <pubDate>Thu, 04 Jun 2026 11:37:52 GMT</pubDate>
            <atom:updated>2026-06-04T11:37:52.754Z</atom:updated>
            <content:encoded><![CDATA[<p>When I first learned JavaScript OOP, every tutorial sounded like a computer science textbook.</p><p>Terms like <em>encapsulation</em>, <em>inheritance</em>, and <em>polymorphism</em> felt overly complicated, even though the actual concepts were not that hard.</p><p>So in this article, we’ll break Object-Oriented Programming (OOP) down in the simplest way possible with practical JavaScript examples you can actually understand and use.</p><p>By the end of this guide, you’ll understand:</p><ul><li>What OOP is</li><li>Why developers use it</li><li>Objects and classes</li><li>Constructors and methods</li><li>The 4 pillars of OOP</li></ul><p>Let’s get started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EHvaZQZ45enXjE5Z" /><figcaption>Photo by <a href="https://unsplash.com/@ianhutchinson92?utm_source=medium&amp;utm_medium=referral">Ian Hutchinson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>What Is Object-Oriented Programming (OOP)?</h4><p>Object-Oriented Programming is a programming style where we organize code into <strong>objects</strong>.</p><p>An object is simply something that contains:</p><ul><li>Data → properties</li><li>Behavior → methods</li></ul><p>For example, a User object can contain:</p><ul><li>name</li><li>email</li><li>login functionality</li></ul><p>Instead of writing scattered variables and functions, OOP groups related logic together.</p><h4>Why Do Developers Use OOP?</h4><p>Developers use OOP because it helps make code:</p><ul><li>More organized</li><li>Easier to maintain</li><li>Reusable</li><li>Easier to scale in large applications</li></ul><p>Imagine building a game with 100 players.</p><p>Without OOP, your code could become chaotic very quickly. With OOP, you can create a Player blueprint and generate multiple players easily.</p><h4>Objects in JavaScript</h4><p>Everything in JavaScript revolves around objects. Objects are one of the most important building blocks in the language because they allow us to store related data and functionality together in a single structure. In JavaScript, objects can represent real-world things like users, products, or cars, making code more organized, reusable, and easier to manage.</p><h4>Example</h4><pre>const user = {<br>  name: &quot;John&quot;,<br>  age: 25,<br><br>  greet() {<br>    console.log(`Hello, my name is ${this.name}`);<br>  }<br>};<br><br>user.greet();</pre><h4>Classes in JavaScript</h4><p>A class is like a blueprint for creating objects. It defines the properties and behaviors that the objects created from it will have. Instead of manually creating multiple similar objects one by one, we can use classes to generate them more efficiently and keep our code cleaner and more organized. Classes make it easier to reuse code and are especially useful when building larger applications with many similar objects.</p><h4>Example</h4><pre>class User {<br>  constructor(name, age) {<br>    this.name = name;<br>    this.age = age;<br>  }<br><br>  greet() {<br>    console.log(`Hello, my name is ${this.name}`);<br>  }<br>}<br><br>const user1 = new User(&quot;Alice&quot;, 28);<br>const user2 = new User(&quot;Bob&quot;, 32);<br><br>user1.greet();<br>user2.greet();</pre><h4>Constructors</h4><p>The constructor() method runs automatically when a new object is created from a class. It is used to initialize the object’s properties with specific values at the moment of creation. This allows each instance of a class to start with its own unique data. The constructor plays a key role in setting up the initial state of an object and making sure it is ready to use right away.</p><h4>Example</h4><pre>constructor(name, age) {<br>  this.name = name;<br>  this.age = age;<br>}</pre><h4>Methods</h4><p>Methods define the behavior of an object. They are functions that belong to a class or object and describe what the object can do. Instead of only storing data, methods allow objects to perform actions and interact with that data. This makes objects more powerful and closer to real-world entities, where things don’t just have properties but also behaviors.</p><h4>Example</h4><pre>greet() {<br>  console.log(&quot;Hello!&quot;);<br>}</pre><h4>The 4 Pillars of OOP</h4><p>Now let’s explore the core concepts of Object-Oriented Programming.</p><h4>1. Encapsulation</h4><p>Encapsulation means keeping data and methods together inside a class while controlling how that data is accessed or modified from the outside. It helps protect the internal state of an object and ensures that it can only be changed in controlled and predictable ways. Think of it like a capsule that wraps and protects internal data from being changed incorrectly or accidentally. By using encapsulation, we make our code more secure, organized, and easier to maintain over time.</p><h4>Example</h4><pre>class BankAccount {<br>  #balance = 0;<br><br>  deposit(amount) {<br>    this.#balance += amount;<br>  }<br><br>  getBalance() {<br>    return this.#balance;<br>  }<br>}<br><br>const account = new BankAccount();<br><br>account.deposit(500);<br><br>console.log(account.getBalance());</pre><p>Here:</p><ul><li>#balance is private</li><li>It cannot be accessed directly outside the class</li><li>The data is protected</li></ul><p>This helps prevent accidental modifications.</p><h4>2. Inheritance</h4><p>Inheritance allows one class to inherit properties and methods from another class, making it possible to build new classes based on existing ones. This promotes code reuse and helps reduce repetition, since shared functionality can be defined once in a parent class and automatically used by child classes. It also makes code easier to extend and maintain, because you can add or modify behavior without rewriting everything from scratch.</p><h4>Example</h4><pre>class Animal {<br>  speak() {<br>    console.log(&quot;Animal makes a sound&quot;);<br>  }<br>}<br><br>class Dog extends Animal {<br>  bark() {<br>    console.log(&quot;Dog barks&quot;);<br>  }<br>}<br><br>const dog = new Dog();<br><br>dog.speak();<br>dog.bark();</pre><p>Dog inherits functionality from Animal.</p><h4>3. Polymorphism</h4><p>Polymorphism means “many forms.” It allows different classes to have methods with the same name, but with different implementations depending on the object that is using them. This means the same method call can behave in different ways based on the context. Polymorphism makes code more flexible and easier to extend, because you can work with different types of objects in a consistent way without needing to know their exact class.</p><h4>Example</h4><pre>class Animal {<br>  makeSound() {<br>    console.log(&quot;Some generic sound&quot;);<br>  }<br>}<br><br>class Cat extends Animal {<br>  makeSound() {<br>    console.log(&quot;Meow&quot;);<br>  }<br>}<br><br>class Dog extends Animal {<br>  makeSound() {<br>    console.log(&quot;Woof&quot;);<br>  }<br>}<br><br>const animals = [new Cat(), new Dog()];<br><br>animals.forEach(animal =&gt; animal.makeSound());</pre><p>The same method behaves differently depending on the object.</p><h4>4. Abstraction</h4><p>Abstraction means hiding unnecessary details and showing only the essential functionality to the user. It helps simplify complex systems by exposing only what is needed while keeping the internal implementation hidden. For example, when driving a car, you use the steering wheel, pedals, and buttons without needing to understand how the engine or internal mechanics work. In programming, abstraction allows us to work with objects and methods at a higher level without worrying about the complex logic happening behind the scenes, making code easier to use and understand.</p><h4>Example</h4><pre>class Car {<br>  start() {<br>    this.#igniteEngine();<br>    console.log(&quot;Car started&quot;);<br>  }<br><br>  #igniteEngine() {<br>    console.log(&quot;Engine ignited&quot;);<br>  }<br>}<br><br>const car = new Car();<br><br>car.start();</pre><p>The user only interacts with start(). The internal engine logic remains hidden.</p><h4>When Should You Use OOP?</h4><p>OOP is especially useful when:</p><ul><li>Building large applications</li><li>Creating reusable components</li><li>Managing complex systems</li><li>Working with teams</li></ul><p>However, not every project needs OOP. For very small scripts, functional or procedural programming may be simpler.</p><p>The goal is to choose the right tool for the problem.</p><h4>Conclusion</h4><p>Object-Oriented Programming can seem intimidating at first, but the core ideas are actually very practical.</p><p>Once you understand objects, classes, and the four pillars of OOP, writing scalable and maintainable JavaScript becomes much easier.</p><p>Remember, OOP is just a tool and not every project needs it. But learning it will improve the way you think about structuring code and solving problems in JavaScript.</p><p>The best way to truly master OOP is by building projects, experimenting with code, and practicing consistently.</p><p>I hope this article helped make Object-Oriented Programming in JavaScript easier to understand. If you have any thoughts, questions, or personal experiences with OOP, feel free to share them in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cbbf70c1989" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/object-oriented-programming-in-javascript-explained-simply-9cbbf70c1989">Object-Oriented Programming in JavaScript Explained Simply</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>