<?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 Hafieludin Yusuf Rizana on Medium]]></title>
        <description><![CDATA[Stories by Hafieludin Yusuf Rizana on Medium]]></description>
        <link>https://medium.com/@hafie?source=rss-193fc3776854------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-eaQMLiUv3jZ4eyXHzCWPA.jpeg</url>
            <title>Stories by Hafieludin Yusuf Rizana on Medium</title>
            <link>https://medium.com/@hafie?source=rss-193fc3776854------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 20:29:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hafie/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[Migrating from .NET 5 to .NET 10 (Also Issues I Found Along the Way and How to Fix It)]]></title>
            <link>https://medium.com/@hafie/migrating-from-net-5-to-net-10-also-issues-i-found-along-the-way-and-how-to-fix-it-abee712f2105?source=rss-193fc3776854------2</link>
            <guid isPermaLink="false">https://medium.com/p/abee712f2105</guid>
            <category><![CDATA[net-core-5]]></category>
            <category><![CDATA[version-upgrade]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[net-core-10]]></category>
            <dc:creator><![CDATA[Hafieludin Yusuf Rizana]]></dc:creator>
            <pubDate>Wed, 04 Nov 2026 06:45:40 GMT</pubDate>
            <atom:updated>2026-11-04T07:02:35.536Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CbWLhcABlQz6a_Gn" /><figcaption>Photo by <a href="https://unsplash.com/@mfsili?utm_source=medium&amp;utm_medium=referral">Mohamed Fsili</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>In this article, I’ll share how I structured the migration from .NET 5 to .NET 10, the issues I hit along the way (Azure Functions runtime mismatch, Telerik Reporting’s JSON serializer switch, EF Core trigger conflicts), and the workflow that kept the process manageable.</blockquote><p>First things first, I created time-boxed spike branch. The branch is used for trial and error because this five-major-version gap gave me anxiety. The time-boxed spike will be my source of truth, so that I could create clean production-ready branch that replay only what worked. My app has some dependencies (such as Azure, Kendo, EF, Aspose, etc.) which also need to be upgraded to match .NET 10 compatibility. However, there is licensing that I need to consider. So, I tried not to jump on the newest version of the dependency. I outsourced AI agent to help me read release notes, map breaking changes to my code, and check the known vulnerabilities. After some consideration, I applied the maximum targeted versions for my perpetual license and performed testing. During the testing, I asked AI agent to log any issues I found and which version, then I asked agent to find the workaround and necessity to upgrade/downgrade the version.</p><p>I made mistake by not giving fixed days for breaking the spike branch, causing days of unnecessary exploration to find out if it is possible to migrate to .NET 10 without intermediate stops. So, I think it is mandatory to give fixed days and provide questions to answer for the migration and to address app limitations.</p><blockquote>Some questions that the spike need to answer:</blockquote><blockquote>1. Can I retarget straight to .NET 10, or do I need intermediate stops?</blockquote><blockquote>2. Which minimum version of each dependency supports .NET 10?</blockquote><blockquote>3. Which of those versions need a new license or subscription?</blockquote><blockquote>4. Which code changes are mandatory, and which are just warnings I can defer?</blockquote><blockquote>5. Does the app still build and run?</blockquote><blockquote>6. Does it break any features, middleware or UI (missing icons, layout shifting, etc.)?</blockquote><p>Some of my dependencies were Kendo, Aspose, Azure, and EF. I used Central Package management for versioning housekeeping, and to ease me with version trial.</p><p><strong>AI Agent Assistance</strong></p><p>- Determine targeted versions</p><p>First point is retargeting from .NET 5 to .NET 10, starting with the SDK and all projects. I ask agents for the least version of the dependencies that support .NET 10, vulnerabilities, and consequences (CVEs and GitHub security advisories). However, because AI has cutoff date, I cross-checked with tooling dotnet list package — vulnerable — include-transitive.</p><p>I prioritized dependencies that required to be upgraded because these packages must match the runtime’s major version (e.g. Entity Framework packages, ASP.NET Core packages, Azure packages).</p><p>- Code changes</p><p>Code changes are inevitable, because some dependencies on the new version updated syntax, helper, rendering rules, set some references to obsolete, etc. I outsourced agent to create plan for code changes based on the targeted versions. Some of them are unnecessary and we can easily find workaround for it. Ask agent to re-write the plan based on preferences and execute the plan.</p><p>- Verification</p><p>UI libraries sometimes update the classname, component’s element structure, styling on their recent version. This caused the customized css will not be picked up and some class that already obsolete broke the UI or even worse, will display raw javascript. I outsourced agent to test if the UI follow the old standard and components are still on their places by providing old version dev environment as test oracle.</p><p><strong>Some Issues I Encountered and Fixed</strong></p><p><strong>1. Runtime error: “There is no Functions runtime available that matches the version specified in the project.”</strong></p><p>This is usually the Azure Function Worker do not target the Isolated version of the recent .NET Core version. Azure Functions supports .NET 10 exclusively through the isolated worker process model. The in-process model was never updated to support .NET 10, so if any part of the project still reflects the in-process model, the Functions host cannot resolve a matching runtime, producing this exact error regardless of how recently Core Tools or the Functions extension has been updated.</p><p>The issue fixed by deleting <em>%LocalAppData%\AzureFunctionsTools</em> and restarting VS. Then, go on T<em>ools -&gt; Options -&gt; Projects &amp; Solutions -&gt; Azure functions</em> and click on the “Check for updates” button.</p><p><strong>2. Telerik Reporting view error: error ‘Cannot access the Reporting REST service. (serviceUrl = ‘/api/reports/’). Make sure the service address is correct and enable CORS if needed. (https://enable-cors.org)&#39;</strong></p><p><a href="https://www.telerik.com/support/whats-new/reporting/release-history/progress-telerik-reporting-2026-q1-(20-0-26-211)">Telerik Reporting 2026 Q1 (20.0.26.211+) serializes its REST payloads with System.Text.Json and no longer works with NewtonSoft.</a></p><p>The issue fixed by creating workaround to filter json result to keep Telerik Reporting Service on System.Text.Json while the rest of the application still on NewtonSoft.</p><pre>    public sealed class ReportsServiceJsonResultFilter : IAsyncResultFilter<br>    {<br>        private const string JsonContentType = &quot;application/json; charset=utf-8&quot;;<br><br>        private readonly JsonSerializerOptions _defaultOptions;<br><br>        public ReportsServiceJsonResultFilter(IOptions&lt;JsonOptions&gt; jsonOptions)<br>        {<br>            _defaultOptions = jsonOptions.Value.JsonSerializerOptions;<br>        }<br><br>        public Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)<br>        {<br>            switch (context.Result)<br>            {<br>                case JsonResult jsonResult:<br>                    var options = jsonResult.SerializerSettings as JsonSerializerOptions ?? _defaultOptions;<br>                    context.Result = ToContent(jsonResult.Value, options, jsonResult.StatusCode);<br>                    break;<br><br>                // Error responses (NotFound/BadRequest/StatusCode(...)) would otherwise go through the<br>                // global Newtonsoft output formatter and reach the viewer with PascalCase property names.<br>                case ObjectResult objectResult when objectResult.Value != null:<br>                    context.Result = ToContent(objectResult.Value, _defaultOptions, objectResult.StatusCode);<br>                    break;<br>            }<br><br>            return next();<br>        }<br><br>        private static ContentResult ToContent(object value, JsonSerializerOptions options, int? statusCode)<br>        {<br>            // Mirrors SystemTextJsonResultExecutor: serialize using the runtime type.<br>            var json = value == null<br>                ? &quot;null&quot;<br>                : JsonSerializer.Serialize(value, value.GetType(), options);<br><br>            return new ContentResult<br>            {<br>                Content = json,<br>                ContentType = JsonContentType,<br>                StatusCode = statusCode<br>            };<br>        }<br>    }<br><br>    /// &lt;summary&gt;<br>    /// Request side of the same problem: bodies posted to the Reporting REST service are written by<br>    /// Telerik&#39;s client for System.Text.Json, so they must not be bound by the global Newtonsoft<br>    /// input formatter. This formatter handles only /api/reports requests and delegates to the<br>    /// built-in System.Text.Json formatter.<br>    /// &lt;/summary&gt;<br>    public sealed class ReportsServiceSystemTextJsonInputFormatter : TextInputFormatter<br>    {<br>        private const string ReportsPath = &quot;/api/reports&quot;;<br><br>        private readonly SystemTextJsonInputFormatter _inner;<br><br>        public ReportsServiceSystemTextJsonInputFormatter(JsonOptions jsonOptions, ILogger&lt;SystemTextJsonInputFormatter&gt; logger)<br>        {<br>            _inner = new SystemTextJsonInputFormatter(jsonOptions, logger);<br><br>            SupportedEncodings.Add(UTF8EncodingWithoutBOM);<br>            SupportedEncodings.Add(UTF16EncodingLittleEndian);<br><br>            foreach (var mediaType in _inner.SupportedMediaTypes)<br>            {<br>                SupportedMediaTypes.Add(mediaType);<br>            }<br>        }<br><br>        public override bool CanRead(InputFormatterContext context)<br>        {<br>            return IsReportsRequest(context?.HttpContext) &amp;&amp; _inner.CanRead(context);<br>        }<br><br>        public override Task&lt;InputFormatterResult&gt; ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding)<br>        {<br>            return _inner.ReadRequestBodyAsync(context, encoding);<br>        }<br><br>        private static bool IsReportsRequest(HttpContext httpContext)<br>        {<br>            return httpContext != null<br>                &amp;&amp; httpContext.Request.Path.StartsWithSegments(ReportsPath, System.StringComparison.OrdinalIgnoreCase);<br>        }<br>    }<br><br>    /// &lt;summary&gt;<br>    /// Puts &lt;see cref=&quot;ReportsServiceSystemTextJsonInputFormatter&quot;/&gt; ahead of the Newtonsoft formatter.<br>    /// It only claims /api/reports requests, so every other endpoint still falls through to Newtonsoft.<br>    /// &lt;/summary&gt;<br>    public sealed class ReportsServiceJsonOptionsSetup : IConfigureOptions&lt;MvcOptions&gt;<br>    {<br>        private readonly IOptions&lt;JsonOptions&gt; _jsonOptions;<br>        private readonly ILoggerFactory _loggerFactory;<br><br>        public ReportsServiceJsonOptionsSetup(IOptions&lt;JsonOptions&gt; jsonOptions, ILoggerFactory loggerFactory)<br>        {<br>            _jsonOptions = jsonOptions;<br>            _loggerFactory = loggerFactory;<br>        }<br><br>        public void Configure(MvcOptions options)<br>        {<br>            options.InputFormatters.Insert(0, new ReportsServiceSystemTextJsonInputFormatter(<br>                _jsonOptions.Value,<br>                _loggerFactory.CreateLogger&lt;SystemTextJsonInputFormatter&gt;()));<br>        }<br>    }</pre><p><strong>3. EntityFrameworkCore.DbUpdateException: Could not save changes because the target table has database triggers</strong></p><p>Starting on EF 7, it saves with OUTPUT (no INTO), which sql server rejects on tables that have triggers. <em>SqlException: The target table ‘AspNetUsers’ of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.</em></p><p><a href="https://aka.ms/efcore-docs-sqlserver-save-changes-and-output-clause">The issue fixed by turning off output clause on the table with trigger.</a></p><p>In my case, not all table triggers is on repo’s schema, if I turn off output clause on table where HasTrigger is true, I will probably still get the error on some transaction. However, turning off output clause on all table will only costs performance on tables without triggers. We could run query in the database to get table with triggers and save it in repo and opt-out the clause only on those tables.</p><p><strong>Verification and testing</strong></p><ul><li>Build and Runtime are success</li><li>Passed Automation Test</li><li>EF Core/ORM: generated SQL for the heaviest queries, compared before and after</li><li>UI Library: Confirm grids, filters, exports, date picker, etc. work</li><li>Reporting and Aspose: generated the same reports/documents on both versions</li><li>RazorEngine: Confirm Template generator generates the same template</li><li>Azure: Confirm every Azure product used works</li><li>Licensing: confirmed the commercial licenses validate on the new versions in the deployed environment, not just locally</li></ul><p><strong>Production-Ready branch</strong></p><p>1. Upgrade dependencies in the order the spike found safest</p><p>2. Apply each code fix from the migration log, one logical change per commit, so each one can be reviewed and reverted alone.</p><p>3. Leave out the scaffolding (debug logging, commented-out experiments, temporary workarounds, packages tried and abandoned)</p><p>4. Re-run the vulnerability scan on the final package set</p><p><strong>Lessons learned</strong></p><ul><li>A spike only pays off if you log properly. Without the log, the replay is a second spike.</li><li>Commercial dependencies decide your path more than the framework does.</li><li>AI agents compress the reading. Perform double-check on the documentation.</li><li>Eventually, most of cases, license renewal is inevitable due to version incompatibility.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abee712f2105" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Cartesian Explosion and Avoiding It in Entity Framework Core]]></title>
            <link>https://medium.com/@hafie/understanding-cartesian-explosion-and-avoiding-it-in-entity-framework-core-968558713692?source=rss-193fc3776854------2</link>
            <guid isPermaLink="false">https://medium.com/p/968558713692</guid>
            <category><![CDATA[cross-product]]></category>
            <category><![CDATA[cartesian-product]]></category>
            <category><![CDATA[entity-framework-core]]></category>
            <category><![CDATA[n-plus-1-queries]]></category>
            <category><![CDATA[cartesian-explosion]]></category>
            <dc:creator><![CDATA[Hafieludin Yusuf Rizana]]></dc:creator>
            <pubDate>Mon, 08 Dec 2025 08:15:00 GMT</pubDate>
            <atom:updated>2025-12-09T06:43:32.625Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Understanding the N+1 problem in EF Core and avoiding it , while also trying to not create another problem.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q1fr14LPjMZOwdfc" /><figcaption>Photo by <a href="https://unsplash.com/@adriansiaril?utm_source=medium&amp;utm_medium=referral">Adrian Siaril</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>What is Cartesian Explosion?</strong></p><p>The term is derived from mathematics called Cartesian Product. It is an operation that pairs every element of one set with every element of another set.</p><p>For example, if A = {1,2} and B = {a,b,c}, then the Cartesian Product of A and B is {(1,a),(1,b),(1,c),(2,a),(2,b),(2,c)}</p><p>In database, a Join operation is a Cartesian Product. If a table has 100 rows and every row is related to 100 rows in the joined table, the query produces 10.000 rows.</p><p>The exponentially returned rows is a Cartesian Explosion, produced by queries involving collection navigations that is cross product. It could be a huge performance setbacks with a potential duplicate data that is not needed.</p><p><strong>Cartesian Explosion in Entity Framework Core</strong></p><p>In SQL, Cartesian Explosion is usually introduced by poorly written query that could be easily spotted. Meanwhile in some ORM Framework like Entity Framework Core (EF), Cartesian Explosion happens unobserved. EF eager loading retrieves related entities by introducing JOINS into a single query. Problems related to eager loading starts when many one-to-many joins and big databases are in the work. It will most likely load duplicate data that corresponds to rows and number of joins at the same level.</p><p>Demonstration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*RXWKZmiDQz2Duc-V0jZ1dw.png" /><figcaption>Sample data: Project table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*9LOI0FLsxAc2C0lZd5Imhw.png" /><figcaption>Sample data: Contractor table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*7y2Em_W1eBEPBGKEhILxnQ.png" /><figcaption>Sample data: Material table</figcaption></figure><p><strong>Example case:</strong> perform eager loading with multiple join at the same level. <em>Note that the performance setbacks will not be significant because we use small data just to demonstrate the Cartesian Explosion.</em></p><p>EF Core Query (Single Query)</p><pre>var projects = context.Projects<br>    .Include(p =&gt; p.Contractors)<br>    .Include(p =&gt; p.Materials)<br>    .ToList();</pre><p>Generated SQL</p><pre>SELECT <br>    [p].[ProjectId], <br>    [p].[ProjectName], <br>    [p].[Location],<br>    [c].[ContractorId], <br>    [c].[CompanyName], <br>    [c].[ContactPerson], <br>    [c].[ProjectId],<br>    [m].[MaterialId], <br>    [m].[MaterialName], <br>    [m].[Quantity], <br>    [m].[ProjectId]<br>FROM [Projects] AS [p]<br>LEFT JOIN [Contractors] AS [c] ON [p].[ProjectId] = [c].[ProjectId]<br>LEFT JOIN [Materials] AS [m] ON [p].[ProjectId] = [m].[ProjectId]<br>ORDER BY [p].[ProjectId], [c].[ContractorId]</pre><p>Query Result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*8Gu-OUFuPJnaT5pQ1gGPqg.png" /></figure><p>On above example, Contractors and Materials join are at the same level, each row from Contractors is joined with each row from Materials. If a Project has 3 Contractors and 4 Materials, the query returns 12 rows for a single Project. If it has like 20 Contractors and 20 materials, the number can be significantly rose. This Cartesian Explosion, or N+1 problem, can cause performance issue and produce duplicate data unintentionally. Referring to the Query above, each row returned contains properties from both the Project and Contractor tables. This means that Project properties are duplicated for each Contractor and Material that the Project has.</p><p><strong>Split Query Solution</strong></p><p>The Entity Framework, starting from EF Core 5.0, provide work around called ‘Split Query’ to specify if the LINQ query should be split into multiple SQL queries. Instead of one large query with multiple JOINs, Split Query will break down the query into smaller, more manageable pieces and execute them separately.</p><p>EF Core Query (Split Query)</p><pre>var projects = context.Projects<br>    .Include(p =&gt; p.Contractors)<br>    .Include(p =&gt; p.Materials)<br>    .AsSplitQuery()  // &lt;-- This prevents cartesian explosion<br>    .ToList();</pre><p>Generated SQL</p><pre>-- get Project<br>SELECT <br>    [p].[ProjectId], <br>    [p].[ProjectName], <br>    [p].[Location]<br>FROM [Projects] AS [p]<br>ORDER BY [p].[ProjectId]<br><br>-- get Contractor<br>SELECT <br>    [c].[ContractorId], <br>    [c].[CompanyName], <br>    [c].[ContactPerson], <br>    [c].[ProjectId],<br>    [p].[ProjectId]<br>FROM [Contractors] AS [c]<br>INNER JOIN [Projects] AS [p] ON [c].[ProjectId] = [p].[ProjectId]<br>ORDER BY [p].[ProjectId]<br><br>-- get Material<br>SELECT <br>    [m].[MaterialId], <br>    [m].[MaterialName], <br>    [m].[Quantity], <br>    [m].[ProjectId],<br>    [p].[ProjectId]<br>FROM [Materials] AS [m]<br>INNER JOIN [Projects] AS [p] ON [m].[ProjectId] = [p].[ProjectId]<br>ORDER BY [p].[ProjectId]</pre><p>Result of query is similar to sample data above, 8 rows returned (1 + 3 + 4) instead of 12.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*2IiQqx4jha632oT8XIIoQQ.png" /><figcaption>Single Query vs Split Query</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*jGCgG9PjEF0ynEj-lu-2nw.png" /><figcaption>Performance Comparison</figcaption></figure><p><strong>Global Configuration</strong></p><p>Split Query can also be configured globally and make it default behavior. However, when it is configured globally, we can add “.AsSingleQuery” to cancel the split query and generate the LINQ as single query.</p><pre>protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)<br>{<br>    optionsBuilder<br>        .UseSqlServer(<br>            @&quot;Server=(localdb)\mssqllocaldb;Database=EFQuerying;Trusted_Connection=True;ConnectRetryCount=0&quot;,<br>            o =&gt; o.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery));<br>}</pre><p><strong>Potential Problem in Split Query</strong></p><p>1. Split Query might not work well with server-side pagination, be sure to make the LINQ ordering fully unique or it will potentially return incorrect data. Take a note on their <a href="https://learn.microsoft.com/en-us/ef/core/querying/single-split-queries">documentation </a>in regards to pagination:</p><blockquote>When using split queries with Skip/Take, pay special attention to making your query ordering fully unique; not doing so could cause incorrect data to be returned. For example, if results are ordered only by date, but there can be multiple results with the same date, then each one of the split queries could each get different results from the database. Ordering by both date and ID (or any other unique property or combination of properties) makes the ordering fully unique and avoids this problem. Note that relational databases do not apply any ordering by default, even on the primary key.</blockquote><p>2. It could cause data inconsistency, because the queries execute separately, there’s a small chance that data could change between queries. For example, if someone deletes a contractor between Query 1 and Query 2, you might get inconsistent results. In practice, this is rarely an issue for read operations.</p><p>3. Split Query might cause additional network roundtrip to the database, which will cause additional network traffic. However, this might not be a problem if you use Azure SQL in the same region (minimal latency for multiple round trips).</p><p>4. Some database without MARS (Multiple Active Result Sets) support will buffer previous queries when multiple queries are executed simultaneously. It leads to increased memory requirements.</p><p><strong>Conclusion</strong></p><p>While Split Query looks like it could increase performance, it has many trade-offs that need to be considered. Based on the Microsoft documentation, it looks like Split Query mainly focus on avoiding cartesian explosion. Thus, using Split Query in every case is not the best approach. Consider the need in data consistency and database characteristics and always examine the execution plan and compare the performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=968558713692" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handling Decimal Calculations Correctly in JavaScript]]></title>
            <link>https://medium.com/@hafie/handling-decimal-calculations-correctly-in-javascript-a0cd87723d5d?source=rss-193fc3776854------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0cd87723d5d</guid>
            <category><![CDATA[ieee-754-standard]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <dc:creator><![CDATA[Hafieludin Yusuf Rizana]]></dc:creator>
            <pubDate>Tue, 10 Jun 2025 17:27:15 GMT</pubDate>
            <atom:updated>2025-06-10T17:27:15.841Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8JARXQDI6M6wNQJX" /><figcaption>Photo by <a href="https://unsplash.com/@silvanarnet?utm_source=medium&amp;utm_medium=referral">Silvan Arnet</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>When you noticed that 0.1 + 0.2 ≠ 0.3, this is not a JavaScript bug — it is a fundamental characteristic of how computer handle decimal numbers.</h4><p><strong>It’s Not Just JavaScript — It’s Everywhere<br></strong>This mathematical mayhem exists in every programming language. Computer always think in binary. When we write a decimal number 0.1, the computer has to translate it to binary. This is where the problem begins — some decimal numbers can’t be represented precisely in binary, just like 1/3 cannot be represented precisely in decimal (0.33333….).</p><p>The inaccurate translation is a tradeoff for performance. A computer has finite memory and making a precise translation requires processing power. Instead, they use a standardized format for a “good enough” decimal translation while being fast.</p><p>Almost all programming language implement the IEEE 754 standard for floating point arithmetic. It allocates 64 bits to represent a number: 1 bit for the sign, 11 bits for the exponent, and 52 bits for the fraction. This gives us about 15–17 decimal digits of precision, sounds like a lot until some simple decimal numbers require infinite precision to represent in binary.</p><p><strong>Example: 0.1 + 0.2<br></strong>In decimal: 0.1<br>In binary: 0.0001100110011001100110011… (repeating forever)<br>In IEEE 754: 0.1000000000000000055511151231257827021181583404541015625</p><p>In decimal: 0.2A<br>In binary: 0.001100110011001100110011…(repeating forever)<br>In IEEE 754: 0.200000000000000011102230246251565404236316680908203125</p><p>Adding them resulting in 0.3000000000000000444089209850062616169452667236328125<br>which display as 0.30000000000000004</p><pre>console.log(0.1 + 0.2); // 0.30000000000000004<br>console.log(0.1 + 0.2 === 0.3); // false</pre><blockquote>Understanding this helps us think that JavaScript is not being buggy, it’s mathematical limitations of representing infinite in finite space.</blockquote><p><strong>Why JavaScript Get the Popularity for This Wrong?<br></strong>JavaScript’s dynamic typing don’t explicitly declare number types, making the floating-point arithmetic result looks like a dumb bug. Many language “hide” it better because they have smarter default formatting (like python) and provide built-in decimal types.</p><p><strong>Solutions for Precise Floating-Point Arithmetic in JavaScript<br></strong>Method 1: Rounding<br>Works well only for simple calculation.</p><pre>javascript// Using toFixed() for display purposes<br>const result = 0.1 + 0.2;<br>console.log(result.toFixed(1)); // &quot;0.3&quot; (string)<br>console.log(+result.toFixed(1)); // 0.3 (number)<br><br>// Using Math.round() for calculations<br>function roundToPrecision(num, precision) {<br>    const factor = Math.pow(10, precision);<br>    return Math.round(num * factor) / factor;<br>}<br><br>console.log(roundToPrecision(0.1 + 0.2, 1)); // 0.3</pre><p>Method 2: Using dedicated library<br>Use dedicated library like <a href="https://mikemcl.github.io/decimal.js/">decimal.js</a> for precise calculations and easier development.</p><pre>// Using decimal.js<br>import Decimal from &#39;decimal.js&#39;;<br><br>const a = new Decimal(0.1);<br>const b = new Decimal(0.2);<br>console.log(a.plus(b).toString()); // &#39;0.3&#39;</pre><p>Method 3(for comparing only): Epsilon comparison<br>For comparisons, use JavaScript’s Number.EPSILON to determine if numbers are &quot;close enough&quot;</p><pre>function areEqual(a, b, epsilon = Number.EPSILON) {<br>    return Math.abs(a - b) &lt; epsilon;<br>}<br><br>console.log(areEqual(0.1 + 0.2, 0.3)); // true<br>console.log(0.1 + 0.2 === 0.3); // false<br><br>// For larger numbers, you might need a relative epsilon<br>function areEqualRelative(a, b, relativeEpsilon = Number.EPSILON) {<br>    return Math.abs(a - b) &lt;= relativeEpsilon * Math.max(Math.abs(a), Math.abs(b));<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0cd87723d5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kendo UI/MVC in .NET: A Growing Collection of Solutions and Hard-Won Lessons from the Trenches]]></title>
            <link>https://medium.com/@hafie/kendo-ui-mvc-in-net-a-growing-collection-of-solutions-and-hard-won-lessons-from-the-trenches-b305d2bc9c46?source=rss-193fc3776854------2</link>
            <guid isPermaLink="false">https://medium.com/p/b305d2bc9c46</guid>
            <category><![CDATA[kendo-ui]]></category>
            <category><![CDATA[mvc]]></category>
            <category><![CDATA[telerik]]></category>
            <dc:creator><![CDATA[Hafieludin Yusuf Rizana]]></dc:creator>
            <pubDate>Sat, 07 Jun 2025 16:30:05 GMT</pubDate>
            <atom:updated>2025-12-08T08:48:27.465Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kO442x1zsoqpqIDv" /><figcaption>Photo by <a href="https://unsplash.com/@medbadrc?utm_source=medium&amp;utm_medium=referral">Med Badr Chemmaoui</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>After years of building application with Kendo in .Net environments, I have encountered many Kendo mysterious bugs, component malfunction, and limitation of semi-customization that need a workaround.</p><p>This article is a living collection of workarounds and solution I have discovered throughout my development journey with Kendo. I will be updating the list regularly as I encounter new challenges as part of my “learning”, or if I remember my past solutions and workarounds. You may bookmark this page and check back later for fresh insights.</p><ol><li><strong>Combobox ‘0’ Text in the Grid Editor(Fixed)</strong></li></ol><p>When creating a new record in Kendo Grid with Kendo Combo Box in the window editor, non-nullable fields display ‘0’ even with AutoBind is set to False.</p><p><strong>Issue:</strong> The model automatically initializes non-nullable integer properties to 0, causing the combobox to show an invalid selection instead of the placeholder.</p><p><strong>Solution:</strong> Manually set these foreign key properties to null in the Grid’s Edit event when a new record is being created. This prevents unwanted default values and ensures the combobox displays the placeholder text correctly.</p><pre>function onEdit(e) {<br>    if (e.model.isNew()) {<br>        e.model.set(&quot;M2MRoleId&quot;, null);<br>        e.model.set(&quot;DelayCodeId&quot;, null);<br>    }<br>}</pre><p><strong>2. Multi-Filtering of Columns in the Same Attribute Binding</strong></p><p>When applying multi-filtering to on columns that are configured to be bound to the same attribute, only last filter will be sent to the server-side.</p><pre>Html.Kendo().Grid&lt;ALTRAD.MROnline.Models.SystemUserModel&gt;()<br>                    .Name(&quot;grid&quot;)<br>                    .Columns(columns =&gt;<br>                    {<br>                        columns.Command(c =&gt;<br>                        {<br>                            c.Custom(&quot;ViewDetails&quot;).Text(&quot; &quot;).IconClass(&quot;k-icon k-i-folder-open&quot;).Click(&quot;showDetails&quot;);                              <br>                        }).Width(90);<br><br>                        columns.Bound(p =&gt; p.Username).Title(&quot;Username&quot;);<br><br>                        columns.Group(group =&gt; group.Title(&quot;Roles&quot;).HeaderHtmlAttributes(new { style = &quot;align: center&quot; })<br>                        .Columns(r =&gt;<br>                        {<br>                            foreach (var role in roles)<br>                            {<br>                                r.Bound(p =&gt; p.RoleIds)<br>                                .Filterable(f =&gt; f.Multi(true).BindTo(new object[] { new { RoleIds = $&quot;Is {role.Value} member&quot; }, new { RoleIds = $&quot;Is not {role.Value} member&quot;} }))<br>                                .Width(120)<br>                                .ClientTemplate(&quot;#= RoleIds.some(function(f) { return f === \&quot;&quot; + role.Id + &quot;\&quot;; }) ? &#39;&lt;center&gt;&lt;i class=\&quot;fas fa-check-circle text-success\&quot;&gt;&lt;/i&gt;&lt;/center&gt;&#39; : &#39;&#39; #&quot;)<br>                            .Title(role.Value)<br>                            ;<br>                                            <br>                        }<br>                    }));</pre><p><strong>Issue:</strong> Kendo uses attribute name as the FieldId for each filter. If same attribute name exists multiple times, only last filter will remain and others are overwritten.</p><p><strong>Solution:</strong> Using Kendo grid event triggers, override functions Filter and FilterMenuOpen.</p><ul><li>On Filter function, alter each field name (add something that make them unique) and store each filter to window variable. Then, perform datasource filter using all the stored filters.</li><li>On FilterMenuOpen function, check if there is stored filter for opened filter menu so user can accurately see if the column has filter on it. If you skip this step, only one applied filter is displayed on the filter menu eventhough there are multiple filters applied.</li></ul><pre>&lt;script type=&quot;text/javascript&quot;&gt;<br><br>   window.storedFilters = {};<br><br>   function onFilterMenuOpen(e) {<br><br>       // Loop through all storedFilters keys<br>       for (var key in window.storedFilters) {<br>           if (!window.storedFilters.hasOwnProperty(key)) continue;<br><br>           // Only process keys for this field<br>           if (key.startsWith(e.field + &quot;_&quot;)) {<br>               var filterObj = window.storedFilters[key];<br>               var value = filterObj.value; // e.g., &quot;Is Administrator member&quot;<br><br>               // Find all checkbox labels in the filter menu<br>               $(e.container).find(&quot;label&quot;).each(function() {<br>                   var labelText = $(this).text().trim();<br>                   if (labelText === value) {<br>                       // Check the corresponding checkbox<br>                       var checkbox = $(this).find(&quot;input[type=checkbox]&quot;);<br>                       if (checkbox.length) {<br>                           checkbox.prop(&quot;checked&quot;, true);<br>                       }<br>                   }<br>               });<br>           }<br>       }<br>   }<br>   function onFilter(e) {<br>       var merged = [];<br>       if (!e.filter) {<br>           if(e.field){<br>               //Remove filter from the window variable when user clear the filter<br>               Object.keys(window.storedFilters).forEach(key =&gt; {<br>                   if (key.includes(e.field)) {<br>                       delete window.storedFilters[key];<br>                   }<br>               });<br>           }else return;<br>       }<br>       else{<br>       var filters = e.filter.filters || [];            <br><br>       //modify the field as Id<br>       for (var i = 0; i &lt; filters.length; i++) {<br>           var f = filters[i];<br>            if (f.field === &quot;RoleIds&quot;){<br>           var match = f.value.toString().match(/(?&lt;=[Is|Not] ).*(?= member)/);<br>           var roleName = match ? match[0].replace(/^not /, &#39;&#39;) : &quot;&quot;;<br>           var key = &quot;RoleIds_&quot;+roleName;<br>           var filter ={ field: key, operator: &quot;eq&quot;, value: f.value };<br>           window.storedFilters[key] = filter;<br>       } else if (f.field === &quot;EntityIds&quot;){<br>           var match = f.value.toString().match(/(?&lt;=[Is|Not] ).*(?= member)/);<br>           var roleName = match ? match[0].replace(/^not /, &#39;&#39;) : &quot;&quot;;<br>           var key = &quot;EntityIds_&quot;+roleName;<br>           var filter ={ field: key, operator: &quot;eq&quot;, value: f.value };<br>           window.storedFilters[key] = filter;<br>       } <br>          <br>       }<br>           window.storedFilters[f.field] = f;<br>       }<br><br>       //use all the stored filters<br>       for (var key in window.storedFilters) {<br>           if (window.storedFilters.hasOwnProperty(key)) {<br>               merged.push(window.storedFilters[key]);<br>           }<br>       }<br>       e.sender.dataSource.filter({ logic: e.filter? e.filter.logic : &quot;and&quot;, filters: merged });<br>       e.preventDefault();<br>   }<br><br>&lt;/script&gt;</pre><p><strong>3. Stored Procedure not found in the Telerik Report</strong></p><p>When using Telerik Report as export or displayed it on a page, it sometimes return error ‘Stored Procedure not found’. Sometimes, the issue is not on the connection string but rather on the Stored Procedure parameters passing.</p><p><strong>Issue: </strong>Telerik report is successfully previewed but return Stored Procedure not found in the web. The root cause is parameter passing. On most of my cases the culprit is date-type parameter. When the date parameter is passed with incorrect date format, the Telerik Report returns this error. This could be because of difference on acceptable date format between client and server.<br><strong>Solution:</strong> Ensure that the parameters are passed successfully by debugging it. If there is difference between Client’s timezone and Server’s timezone, ensure the date-type parameter is passed with correct date time format or change it into string and parse it in the Stored Procedure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b305d2bc9c46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Async and Await in C#]]></title>
            <link>https://medium.com/@hafie/async-and-await-in-c-e4d5a447653b?source=rss-193fc3776854------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4d5a447653b</guid>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[asyncawait]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <dc:creator><![CDATA[Hafieludin Yusuf Rizana]]></dc:creator>
            <pubDate>Wed, 07 May 2025 15:31:34 GMT</pubDate>
            <atom:updated>2025-06-07T16:49:15.418Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ayo_hPN_3118D3st" /><figcaption>Photo by <a href="https://unsplash.com/@poetolu?utm_source=medium&amp;utm_medium=referral">Tolu Akinyemi 🇳🇬</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Orchestrating Async and Await in C#</h3><p>I did not think much about my software performance when I was in college. Then, there comes the day when I need to take it into account. I worked on massive database, that the sight of the spinning wheel sometimes caused the project managers sigh and create yet another urgent Jira ticket tagged “Performance Issue”. The constant pressure from stakeholders and the business impact of slow performance forced me to dive deeper into advanced optimization techniques beyond basic indexing and query optimization (nope, we used ORM lol). This is where the need for asynchronous operations became evident, allowing for smoother user experience even when processing tasks are underway.</p><h3><strong>Asynchronous Execution</strong></h3><p>In short, asynchronous programming is a technique that allows code to be executed concurrently without blocking the execution of the calling thread.</p><p>In C#, any method we normally create is synchronous by default. Some lengthy operation such as reading/writing files will block the UI, leaving end user with a bad experience.</p><p>There are mainly three asynchronous patterns in C#:</p><p>1. Asynchronous Programming Model (APM)</p><p>2. Event-Based Asynchronous Pattern (EAP)</p><p>3. Task-Based Asynchronous Pattern (TAP)</p><p>With the introduction of C# 5.0, TAP has become the preferred and more modern approach to asynchronous programming.</p><p>TAP is built around the ‘TASK’ and ‘TASK&lt;T&gt;’ types. It makes asynchronous programming more readable by using methods that return tasks representing asynchronous operations. The ‘async’ and ‘await’ are like a well-choreographed dance. The ‘async’ keyword signals the start of an asynchronous performance, intertwining with the ‘await’ keyword, which acts as a pause button for the dependent tasks, allowing the async task to take the spotlight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*Vt071RaICMEWPBMx.png" /></figure><p>In my own case, when doing synchronous data retrieval, I got error “Entity Framework: There is already an open DataReader associated with this Command”. This is because there are multiple data retrieval commands executed on single connection (or single command with multiple selects) while next DataReader is executed before first one has completed the reading. One way to fix this is to use async and await, it will allow the connection to properly manage multiple data operations without collision. This not only resolves immediate errors but also improves overall database interaction efficiency, especially when working with larger datasets in enterprise applications. In the .NET ecosystem, asynchronous patterns becomes important when building web applications that need to maintain responsiveness under heavy load conditions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4d5a447653b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Security Through Obscurity: The Case for Hiding Your Server Version]]></title>
            <link>https://medium.com/@hafie/iis-server-version-vulnerability-f729997ecb69?source=rss-193fc3776854------2</link>
            <guid isPermaLink="false">https://medium.com/p/f729997ecb69</guid>
            <category><![CDATA[software-security]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Hafieludin Yusuf Rizana]]></dc:creator>
            <pubDate>Wed, 07 May 2025 13:34:08 GMT</pubDate>
            <atom:updated>2025-06-07T16:43:01.947Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2IrbS-0ahjwLiddm" /><figcaption>Photo by <a href="https://unsplash.com/@towfiqu999999?utm_source=medium&amp;utm_medium=referral">Towfiqu barbhuiya</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Years ago, while I was completing my project, the Software Security Experts gave me feedback to remove the Server Header Version before putting the web app into live. This seemingly small detail was actually a significant security vulnerability that could expose our technology stack.<br>As a Software Engineer, I was still in a beginning stage of learning Software Security. Securing applications beyond functional requirements were relatively new territory for me, requiring a shift in my development mindset. I used to rely on the proprietary framework I used in my previous project, which handled many security considerations automatically behind the scenes. This dependence created a knowledge gap that became apparent when I started working on more exposed systems. Though, I read the OWASP top ten, this theoretical knowledge hadn’t fully translated into practical implementation skills across all aspects of application security.</p><p>By and large, disclosing detailed system configuration information to public is not safe. Potential attacker might abuse infamous vulnerability for the particular server version. Also, removing Server Header Version is often advised by security experts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*a_OGkW5mKvzdTmbLIs1R3g.png" /><figcaption>HTTP Header response before the Server Version removed.</figcaption></figure><p>Starting from IIS 10.0, this web.config configuration works to remove the unnecessary headers from the response</p><pre>&lt;system.web&gt;<br>    &lt;!-- Removes version headers from response --&gt;<br>    &lt;httpRuntime enableVersionHeader=&quot;false&quot; /&gt;<br>&lt;/system.web&gt;<br><br>&lt;system.webServer&gt;<br>    &lt;httpProtocol&gt;<br>        &lt;customHeaders&gt;<br>            &lt;!--Removes X-Powered-By header from response --&gt;<br>            &lt;clear /&gt;<br>        &lt;/customHeaders&gt;<br>    &lt;/httpProtocol&gt;<br><br>    &lt;security&gt;<br>        &lt;!--Removes Server header from response--&gt;<br>        &lt;requestFiltering removeServerHeader =&quot;true&quot; /&gt;<br>    &lt;/security&gt;<br>&lt;/system.webServer&gt;</pre><p>Also, starting from IIS 7, the Server Headers content could be rewritten using outboundRule. The Server Header will still be displayed but the content will be empty.</p><pre>&lt;rewrite&gt;    <br>  &lt;outboundRules rewriteBeforeCache=&quot;true&quot;&gt;<br>    &lt;rule name=&quot;Remove Server header&quot;&gt;<br>      &lt;match serverVariable=&quot;RESPONSE_Server&quot; pattern=&quot;.+&quot; /&gt;<br>      &lt;action type=&quot;Rewrite&quot; value=&quot;&quot; /&gt;<br>    &lt;/rule&gt;<br>  &lt;/outboundRules&gt;<br>&lt;/rewrite&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f729997ecb69" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>