<?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 Shantanu Kalamdane on Medium]]></title>
        <description><![CDATA[Stories by Shantanu Kalamdane on Medium]]></description>
        <link>https://medium.com/@life_and_routes?source=rss-caad80aad1a5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OhbgCQCZeW_4POWmvmmr3w.jpeg</url>
            <title>Stories by Shantanu Kalamdane on Medium</title>
            <link>https://medium.com/@life_and_routes?source=rss-caad80aad1a5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 23:32:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@life_and_routes/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[LINQ in Action: Streamlining Data Manipulation in C#]]></title>
            <link>https://medium.com/techverito/linq-in-action-streamlining-data-manipulation-in-c-2d8d55ca96c5?source=rss-caad80aad1a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d8d55ca96c5</guid>
            <category><![CDATA[data-manipulation]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[linq]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Shantanu Kalamdane]]></dc:creator>
            <pubDate>Wed, 22 Jan 2025 11:32:57 GMT</pubDate>
            <atom:updated>2025-01-22T11:32:57.014Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qlzDQDF9smCH3Uvnl1uRAw.jpeg" /></figure><p>When I first started working with C#, one of the hurdles I faced was data manipulation. I can’t count how many times I found myself writing repetitive loops for arrays and collections, only to end up with code that felt clunky and error-prone. Then I stumbled upon LINQ — and let me tell you, it completely changed how I approach working with data.</p><p>Language Integrated Query (LINQ) isn’t just another tool; it’s a total game-changer. It simplifies everything — querying, filtering, transforming — you name it. And the best part? It’s built right into C#. In this blog, I’ll walk you through my experience with LINQ, sharing why it’s become my go-to for handling data and how it can make your coding life easier.</p><p>Let’s dive in !</p><h3>What is LINQ ?</h3><p>Think of it as a bridge between your C# code and your data. Whether it’s arrays, lists, or even databases, LINQ offers a consistent way to query and manipulate data. It’s like having SQL seamlessly integrated into your code.</p><blockquote>A LINQ query is a first-class language construct, just like classes and methods.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LKBLj0GYypJn_NV1oXMWUA.jpeg" /></figure><h3>Basic Syntax</h3><p>There are two main ways to write queries using LINQ :</p><ol><li><strong>Query Syntax (SQL-Like)</strong></li></ol><pre>var numbers = new[] { 1, 2, 3, 4, 5 };<br>var evenNumbers = from n in numbers<br>                  where n % 2 == 0<br>                  select n;<br><br>foreach (var num in evenNumbers)<br>{<br>    Console.WriteLine(num);<br>}</pre><p>What is happening in this code snippet ?</p><ul><li><strong>from n in numbers</strong> : Iterating through array of numbers</li><li><strong>where n % 2 == 0</strong> : Filtering to get only even numbers</li><li><strong>select n</strong> : Specifying what to include in the final output (here it’s the number itself)</li></ul><p><em>Doesn’t this feel cleaner than writing a for loop with an if condition ?</em></p><p><strong>2. Method Syntax (Fluent API style)</strong></p><pre>var evenNumbers = numbers.Where(n =&gt; n % 2 == 0);</pre><p>This does the same thing as the query syntax but uses method calls and lambda expressions.</p><p><em>Personally, I find this syntax quick to write and more versatile.</em></p><h3>Common LINQ Methods</h3><p>Following are some of the most commonly used LINQ methods :</p><ul><li><strong>Where</strong> : Filter elements</li><li><strong>Select</strong> : Projects or Transforms elements</li><li><strong>OrderBy</strong> : Sorts elements</li><li><strong>Sum</strong>, <strong>Average</strong>, <strong>Count</strong> : Performs aggregate operations</li><li><strong>Take</strong>, <strong>Skip</strong> : Fetch specific subsets of data</li></ul><p>Example :</p><pre>var names = new[] { &quot;Alice&quot;, &quot;Bob&quot;, &quot;Charlie&quot;, &quot;David&quot; };<br>var filteredNames = names.Where(name =&gt; name.StartsWith(&quot;C&quot;));<br><br>foreach (var name in filteredNames)<br>{<br>    Console.WriteLine(name);<br>}</pre><p>Here, we’re filtering the names array to only include names that start with “C.”</p><p><em>Pretty intuitive, right?</em></p><p>There are also several operators worth highlighting, as they can significantly simplify development and make your life much easier.</p><ul><li><strong>Zip</strong> : Combines two sequences into one</li></ul><pre>var numbers = new[] { 1, 2, 3 };<br>var letters = new[] { &quot;A&quot;, &quot;B&quot;, &quot;C&quot; };<br>var zipped = numbers.Zip(letters, (num, letter) =&gt; $&quot;{num}-{letter}&quot;);<br><br>foreach (var item in zipped)<br>{<br>    Console.WriteLine(item);<br>}</pre><p>Here, the Zip operator pairs each number with a letter, resulting in output — “1-A” “2-B” and so on. It comes in handy when you need to merge related data from different sources.</p><ul><li><strong>GroupBy</strong> : Groups elements by common key</li></ul><pre>var people = new[]<br>{<br>    new { Name = &quot;Alice&quot;, Age = 30 },<br>    new { Name = &quot;Bob&quot;, Age = 30 },<br>    new { Name = &quot;Charlie&quot;, Age = 25 }<br>};<br><br>var grouped = people.GroupBy(p =&gt; p.Age);<br><br>foreach (var group in grouped)<br>{<br>    Console.WriteLine($&quot;Age: {group.Key}&quot;);<br>    foreach (var person in group)<br>    {<br>        Console.WriteLine(person.Name);<br>    }<br>}</pre><p>This groups people by age and outputs the names in each age group.</p><p>One important thing to note is that the GroupBy operator returns a key-value pair, where the key represents the element used for grouping, and the value is the sequence of elements that share the same key.</p><p><em>That is very straightforward !</em></p><ul><li><strong>Aggregate</strong> : Used for creating custom aggregations</li></ul><pre>var numbers = new[] { 1, 2, 3, 4 };<br>var product = numbers.Aggregate((acc, num) =&gt; acc * num);<br>Console.WriteLine(product); // Output: 24</pre><p>Here, we multiply each number in sequence with each other cumulatively.</p><pre>string sentence = &quot;it is a sunny day outside !&quot;;<br>string[] words = sentence.Split(&#39; &#39;);<br><br>string reversed = words.Aggregate((workingSentence, next) =&gt;<br>                                      next + &quot; &quot; + workingSentence);<br><br>Console.WriteLine(reversed);<br><br>// Output:<br>// ! outside day sunny a is it</pre><p>Here, we can use the aggregate function to reverse the order of the sentence without much hassle.</p><ul><li><strong>Distinct</strong> : removes duplicates from a collection</li></ul><pre>var duplicates = new[] { 1, 2, 2, 3 };<br>var unique = duplicates.Distinct();<br><br>foreach (var item in unique)<br>{<br>    Console.WriteLine(item);<br>}</pre><p>If you’ve ever needed to remove duplicates, you’ll appreciate how clean and effective “Distinct()” is.</p><h3>Joins and Nested Data</h3><p>Dealing with joins head-on can sometimes be intimidating. However, with LINQ, we can easily handle them:</p><pre>var students = new[] { <br>  new { Id = 1, Name = &quot;Alice&quot; }, <br>  new { Id = 2, Name = &quot;Bob&quot; } <br>};<br>var scores = new[] { <br>  new { StudentId = 1, Score = 95 }, <br>  new { StudentId = 2, Score = 88 } <br>};<br><br>var query = from student in students<br>            join score in scores on student.Id equals score.StudentId<br>            select new { student.Name, score.Score };<br><br>foreach (var result in query)<br>{<br>    Console.WriteLine($&quot;{result.Name}: {result.Score}&quot;);<br>}</pre><p>Here we’re combining two collections based on a joining condition specified. The result ? A combined view of students and their scores.</p><p><strong>Example</strong> :</p><p>Let’s say if we have a nested data :</p><pre>var orders = new[]<br>{<br>    new { OrderId = 1, Products = new[] { &quot;Apple&quot;, &quot;Banana&quot; } },<br>    new { OrderId = 2, Products = new[] { &quot;Carrot&quot;, &quot;Date&quot; } }<br>};</pre><p>And we would like to print it in a readable manner. Then it would go something like this -</p><pre>var query = orders.SelectMany(order =&gt; order.Products,<br>    (order, product) =&gt; new { order.OrderId, Product = product });<br><br>foreach (var item in query)<br>{<br>    Console.WriteLine($&quot;Order {item.OrderId}: {item.Product}&quot;);<br>}</pre><p><strong>SelectMany</strong> : Flattens nested data, making it easier to work with.</p><h3>Creating custom LINQ Extension Methods</h3><p>Custom LINQ extension methods enable you to add your own query operators to existing types, such as collections or arrays, allowing for more readable and reusable code.</p><p><strong>Understanding :</strong></p><p>In LINQ, extension methods are defined as static classes. The first parameter is of type IEnumerable&lt;T&gt; (<em>used with any in-memory data collection</em>) or IQueryable&lt;T&gt; (<em>used for remote data sources like databases</em>), and is referred to as the “this” parameter. It indicates to the compiler that the method can be called on any object that implements IEnumerable&lt;T&gt; or IQueryable&lt;T&gt;.</p><pre>public static class MyLinqExtensions<br>{<br>    public static IEnumerable&lt;T&gt; MyCustomMethod&lt;T&gt;(this IEnumerable&lt;T&gt; source)<br>    {<br>        // Implementation code here..<br>    }<br>}</pre><p><strong>Example</strong> :</p><p>Let’s say you want to create a custom LINQ extension method to break larger collections into smaller, fixed-size chunks — perhaps for pagination purposes.</p><p>A <strong>ChunkBy</strong> method could take an input collection and divide it into chunks of a specified size.</p><pre>public static class MyLinqExtensions<br>{<br>    public static IEnumerable&lt;IEnumerable&lt;T&gt;&gt; ChunkBy&lt;T&gt;(this IEnumerable&lt;T&gt; source, int chunkSize)<br>    {<br>        if (chunkSize &lt;= 0) throw new ArgumentException(&quot;Chunk size must be greater than zero.&quot;, nameof(chunkSize));<br>        <br>        List&lt;T&gt; chunk = new List&lt;T&gt;();<br><br>        foreach (var item in source)<br>        {<br>            chunk.Add(item);<br><br>            if (chunk.Count &gt;= chunkSize)<br>            {<br>                yield return chunk;<br>                chunk = new List&lt;T&gt;();<br>            }<br>        }<br><br>        if (chunk.Any())<br>        {<br>            yield return chunk;<br>        }<br>    }<br>}</pre><p>The method uses List&lt;T&gt; to accumulate items until desired chunk size is reached. Once the chunk is full, it’s returned using yield return, and the process continues with a new chunk. At the end if there are any remaining elements in the list that did not suffice within the chunk size, then those are returned as the last chunk.</p><p><strong>Use-case :</strong></p><pre>var numbers = new List&lt;int&gt; { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };<br>int chunkSize = 3;<br><br>var chunks = numbers.ChunkBy(chunkSize);<br><br>foreach (var chunk in chunks)<br>{<br>    Console.WriteLine(string.Join(&quot;, &quot;, chunk));<br>}<br><br>// Output : <br><br>1, 2, 3<br>4, 5, 6<br>7, 8, 9<br>10</pre><p>A key takeaway is that LINQ can be tailored to your unique requirements, making your code more declarative, efficient, and maintainable.</p><h4>Learn more about it here :</h4><p><a href="https://learn.microsoft.com/en-us/dotnet/csharp/linq/how-to-extend-linq">How to: Write your own extensions to LINQ - C#</a></p><h3>Efficiency and Performance</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*U232pD6ZYdKhiIfLDXtSvg.jpeg" /></figure><p>As Uncle Ben told Peter Parker,</p><blockquote>With great power comes great responsibility</blockquote><p>Similarly, if the power of LINQ is not used responsibly, it can lead to poor performance and bottlenecks — especially when dealing with large data collections or database records at the enterprise level.</p><p>These are some of the key learnings or best practices that have taken me time to grasp, and I’d like to share them with you:</p><ul><li><strong>Leverage deferred execution</strong> : LINQ queries are not executed immediately but only when enumerated (e.g. in foreach loop). So we should take advantage of this flexibility to avoid repetitive enumeration of the same query.</li><li><strong>Filter early</strong> : Applying the “Where()” clause or other filtering methods early on always helps with more efficient data processing downstream.</li></ul><pre>var filtered = numbers.Where(n =&gt; n &gt; 10).Select(n =&gt; n * 2); // Better<br>var transformed = numbers.Select(n =&gt; n * 2).Where(n =&gt; n &gt; 10); // Worse</pre><ul><li><strong>Minimize Immediate Execution</strong> : “ToList()”, “FirstOrDefault()” or “ToArray()”, etc, trigger query execution so use them sparingly.</li><li><strong>Avoid multiple Where() clauses</strong> : Wherever possible, combine all filtering conditions into a single “Where()” clause, rather than using a separate clause for each condition.</li><li><strong>Batching</strong> : Process data in batches to prevent execution of query on huge amount of data at one single time (by making use of “Take()” and “Skip()”)</li></ul><h3>Debugging LINQ queries</h3><p>Although LINQ comes with great power, debugging issues can sometimes be tricky. However, it’s definitely possible to tackle it!</p><ul><li><strong>Using “ToList()”</strong> : While LINQ queries are deferred, you can force execution of queries at specific points by calling “ToList()” to check the output at the intermediate step.</li><li><strong>Break down the query</strong> : Split your queries and execute them step by step to understand where the issue is.</li></ul><pre>var filtered = numbers.Where(n =&gt; n &gt; 10);<br>var transformed = filtered.Select(n =&gt; n * 2);</pre><ul><li><strong>Enable Query logging</strong> : When working with Entity Framework, you can log the SQL generated by LINQ queries to understand what’s happening under the hood</li><li><strong>Use Debugging tools</strong> : Along with above stated solutions, IDE like Visual Studio offers a user friendly way to debug LINQ queries using breakpoints. Apart from IDE there are some external tools which also are used for debugging LINQ queries like <a href="https://www.linqpad.net/">LinqPad</a></li></ul><h3>Summary</h3><p>LINQ revolutionizes the way developers work with data in C#. By diving into its basics, exploring advanced operators, optimizing performance, and utilizing debugging tools, we can tap into its full potential to write clean, efficient, and maintainable code. Let’s start experimenting with LINQ today and see how it can streamline your development process!</p><p>I hope you found my learnings helpful. And thank you for sticking with me till the end !</p><p><em>For more on LINQ, do refer the following :</em></p><p><a href="https://learn.microsoft.com/en-us/dotnet/csharp/linq/">Language Integrated Query (LINQ) - C#</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d8d55ca96c5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techverito/linq-in-action-streamlining-data-manipulation-in-c-2d8d55ca96c5">LINQ in Action: Streamlining Data Manipulation in C#</a> was originally published in <a href="https://medium.com/techverito">TechVerito</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Java Collections Through the Lens of Football]]></title>
            <link>https://medium.com/@life_and_routes/exploring-java-collections-through-the-lens-of-football-6a5b2dd480a3?source=rss-caad80aad1a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a5b2dd480a3</guid>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[java-collection]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Shantanu Kalamdane]]></dc:creator>
            <pubDate>Mon, 04 Dec 2023 17:30:37 GMT</pubDate>
            <atom:updated>2023-12-04T17:30:37.297Z</atom:updated>
            <content:encoded><![CDATA[<p>While going over basic Java concepts, I found myself grappling with somewhat intimidating realm of “Java Collections.” Despite its importance, tackling it felt a bit daunting. However, acknowledging its significance, I decided to face it head-on without any fear. Given my love for football, I thought, why not blend what I enjoy with what I need to learn? This article is my attempt to make sense of Java Collections using a simple football analogy, aiming to make the learning journey both approachable and enjoyable.</p><p>In the vibrant realm of football strategy, coaches Alex and Sarah embarked on a coding adventure, exploring the nuances of Java collections — ArrayLists, LinkedLists, HashSets, LinkedHashSets, TreeSets, HashMaps, LinkedHashMaps, and TreeMaps. Little did they know that these collections would shape the success of their teams in the upcoming match.</p><blockquote><strong><em>The Championship Kick-off: Lists in Action</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*qLaAruzsTxwkF95JvJM1Cg.jpeg" /></figure><p>As the championship kick-off approached, Coach Alex faced the pivotal task of crafting the player line-up. Armed with the versatility of <strong>ArrayLists</strong>, he harnessed their power in scenarios where <strong>quick access</strong> was vital — akin to referencing player statistics promptly. It was like navigating a well-organized playbook, where Alex efficiently arranged players, ensuring seamless access during the crucial moments of the game.</p><p>On the opposite end of the field, Coach Sarah recognized the need for flexibility in the line-up, given the dynamics of the game. She wisely opted for <strong>LinkedLists</strong>, understanding their expertise in <strong><em>a</em>ccommodating frequent substitutions — ideal for write-heavy operations</strong>. Much like adapting a playbook in real-time, LinkedLists mirrored the flexibility needed for a dynamic line-up, allowing for swift changes as the game unfolded.</p><p>In the rhythm of the championship, the collaboration of ArrayLists and LinkedLists formed the foundation for a <strong>strategic and adaptive</strong> player line-up, a crucial element in the team’s pursuit of victory.</p><blockquote><strong><em>The Championship Trophy Challenge: Sets in Harmony</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*I-goUjEbN4kxswITzNQ7VA.jpeg" /></figure><p>Amidst the excitement of a championship match, Sarah embraced a new challenge — the creation of a unique trophy collection to honour the team’s victories. <strong>HashSet </strong>became her trusted tool for quick uniqueness checks, efficiently managing scenarios where the order of trophies wasn’t crucial. It was like assembling a diverse set of accolades, <strong>each trophy representing a distinct achievement</strong> in the team’s storied history.</p><p>In the pursuit of both uniqueness and a sense of accomplishment, <strong>LinkedHashSet </strong>stepped into the spotlight. Sarah, desiring to maintain the insertion order of her collected trophies, found LinkedHashSet to be the perfect compromise. It was like organizing a trophy wall where <strong>both the uniqueness and the chronological order of victories</strong> were celebrated, telling the story of triumphs over the seasons.</p><blockquote><strong><em>The All-Star Celebration: Trees in the Spotlight</em></strong></blockquote><p>As the championship match approached, the coaches faced the delightful challenge of organizing an all-star celebration for the team’s most valuable players. <strong>TreeSet</strong> emerged as the solution, perfect for scenarios requiring a specific order. Coach Alex skilfully organized the all-star <strong><em>s</em>eating based on the players’ performance criteria, ensuring a sorted and exclusive experience</strong> for the most dedicated contributors to the team’s success. The scene was set for a grand celebration, akin to an exclusive VIP gala where each all-star had a designated place of honour. The precision offered by TreeSet ensured that the most deserving players enjoyed a well-organized and distinguished seating arrangement, creating an unforgettable experience for the team and their dedicated supporters.</p><blockquote><strong><em>The Winning Playbook: Maps Guiding Strategies</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t5tCKf6DGrUZ91VbKaWvxQ.jpeg" /></figure><p>Amidst the intense moments of a critical football match, Coach Sarah, faced with pivotal decisions, turned to her coaching armoury, unveiling a set of <strong>HashMaps</strong> akin to a magical playbook. In this playbook, <strong>each key represented a distinct play or tactical decision</strong>, while the <strong>associated value held intricate details such as success rates and insights</strong> from past matches. Visualizing it as a treasure chest of strategic moves, Sarah navigated the HashMaps swiftly, accessing keys like secret codes to unlock specific strategies. This dynamic duo of keys and values empowered her to make well-informed decisions in real-time, orchestrating the team’s moves with the precision of a master strategist, ultimately shaping the destiny of the game.</p><p>In another scenario, <strong>LinkedHashMap </strong>took the stage. Coach Sarah, desiring a balanced approach between quick access and <strong>maintaining insertion order,</strong> it was like creating a playbook that struck a harmonious balance between HashMap and TreeMap characteristics.</p><p>As the teams battled on the field, Coach Sarah envisioned a long-term strategic plan. <strong>TreeMap</strong>, with its ability to provide a sorted order, became the go-to tool for scenarios requiring a meticulous approach. It was like designing a playbook for the season, where <strong>plays were organized based on their strategic importance.</strong></p><blockquote><strong><em>The Championship Celebration: A Symphony of Collections</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*karxZWzMFWRcLfXt0yC1lw.jpeg" /></figure><p>In the post-championship celebrations, Java collections worked their magic, creating a seamless symphony. The player lineup, guided by ArrayLists and LinkedLists, danced effortlessly to the rhythm, each player contributing to the melodic success.</p><p>The trophy collection, a harmonious set orchestrated by HashSets and LinkedHashSets, showcased unique trophies in the cabinet, forming a symphony of achievements echoing through the team’s history.</p><p>Honouring VIPs and all-stars, the grandeur continued with prioritized seating, orchestrated by TreeSets. The stadium transformed into an exclusive gala, a symphony of recognition for the team’s dedicated contributors.</p><p>Drawing strength from HashMaps, LinkedHashMaps, and TreeMaps, the strategic playbook remained resilient and strong. Each decision during the match became a note in the playbook, contributing to the strategic melody that guided the team to victory.</p><p>As the final celebrations echoed through the stadium, the message resonated — a symphony of <strong>Java collections</strong> composing triumphs beyond the field. The lesson remained clear: understand your tools, orchestrate them wisely, and lead your team to victory. In both the world of football and coding, the symphony of collections brought forth victories to savour. Happy coding, and may your strategies be as successful as those on the grand championship stage!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a5b2dd480a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I used Figma ,CSS Grid and CSS Flexbox to build a landing page]]></title>
            <link>https://uxdesign.cc/how-i-used-figma-css-grid-and-css-flexbox-to-build-a-landing-page-be861f397fee?source=rss-caad80aad1a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/be861f397fee</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[css-flexbox]]></category>
            <category><![CDATA[css-grid]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[figma]]></category>
            <dc:creator><![CDATA[Shantanu Kalamdane]]></dc:creator>
            <pubDate>Fri, 22 May 2020 07:18:56 GMT</pubDate>
            <atom:updated>2020-05-27T14:25:07.820Z</atom:updated>
            <content:encoded><![CDATA[<h3>How I used Figma, CSS Grid and CSS Flexbox to build a landing page</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3FBp4TaGffw9waO1rVvWtg.png" /></figure><p>I enjoy looking at website designs that are on platforms like Behance, Dribble, etc. as they are visually very pleasing to the eye. While scrolling through these designs, I always wonder about one thing, that is, how difficult would it be to express these same designs as a code. The reason behind this curiosity is that I have come to realize that sometimes it is not easy to translate the design into its corresponding code. And when I say translation, I’m talking about the positioning of elements to be specific. There have been times while coding, I had to alter my design since it was difficult to represent the position of content in the original design. Also, from my personal experience, I can say that it is very frustrating to use tables, floats, positioning, and inline-block as all of these techniques miss out on a few major functionalities (vertical alignment, for example).</p><p>For a recent personal project, I had to develop a landing page for a website. I had a rough idea regarding how I want the landing page to look and feel. My basic objective here was to replicate the design of the landing page which I will be doing beforehand, into a coded webpage version without any design compromises. While looking for an efficient way to build more design-oriented web pages, I came across CSS Grid and CSS Flexbox which are basically responsive layout models. These models not only allow us to tackle the positioning problem but also make the code easier to understand and maintain. Therefore, I decided to combine these two layout models along with my knowledge of working with <a href="https://www.figma.com/">Figma</a>, which is an amazing online website design tool and this article explains that process.</p><h3>What’s the flow?</h3><ol><li>Design the landing page using Figma.</li><li>Use CSS Grid to setup a parent grid.</li><li>Use CSS Flexbox to position the content.</li></ol><h3>How to start?</h3><h4>Design the layout</h4><p>First things first, I created the design in Figma. It has a pre-built website frame, which is like a blank canvas and a good place to start.</p><p>As I had decided that I am going to use CSS Grid, I knew that it divides the web page into rows and columns. Therefore, it would be practical to carry out the same division while designing by dividing the layout into three basic row sections which are present in almost all websites i.e. a header, a body, and a footer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iw1hol7N3Vb1Se6-hRCrAg.png" /></figure><p>My rule was to <strong>distribute the content into different possible rows and columns as it will make every element independent of each other</strong>. This will lead to more number of cells for more number of elements but will guarantee more positioning ease. So keeping that in mind, I initially divided the header section into two columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zmOM3r8zmx8acl44S3rA3A.png" /></figure><p>But I wanted to maintain some spacing between each element for consistency purposes. Also, the Hamburger menu, which is much of an icon representing an inactive section, does not need much space. That’s why having 3 varying columns instead of 2 would be a better choice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mPCHg0lLD0xOSMhmW9vAcg.png" /></figure><p>Now there are two things that I kept in mind going forward with this design strategy:</p><ul><li>Spacing between cells</li><li>Size of the cells with respect to its content(elements).</li></ul><p>Next, I divided the Body section into different rows and columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CrEd8_-81boOLEV8918O2Q.png" /></figure><p>left_space and right_space are blank columns that are present to provide a feel of center alignment. Footer section will also be divided into 3 columns which is similar to the header section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6w-tPmZS2AtHrT12kaWVvg.png" /></figure><p>Now after laying out the landing page design in terms of grids, the next thing to do was to layout the content with respect to the background of the web page.</p><p>The hierarchy of the web page is logically in the following form:</p><ol><li>Web page has a Background</li><li>Grid goes on top the Background</li><li>Content is laid out on the grid</li></ol><p>The dependency between background and the grid is decided by what comes first. In my process, I preferred the grid to be laid out first and then the background under it. I grabbed a background image from <a href="https://www.pexels.com/"><strong>Pexels </strong></a>and then resized and positioned it according to the grid on the web page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LFh8mEXcQxWgusG-pPjrng.png" /></figure><p>Now it was time to lay out the content using the designed grid system.</p><blockquote>Lesson learned: Use standard alignments i.e. left, center and right for approximate positioning. Then precisely position the content using padding and/or margins.</blockquote><p>As the content is going to be inside different cells, it can have different positions. And this requirement can be fulfilled by Flexbox. My major objective behind using Flexbox inside cells was to use it’s pre-built position attributes which can be used for alignment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dGFQBM4RURKuU70aj-vRYg.png" /></figure><p>If you observe each part of the content, it is approximately either on the left or right or in the center in each cell. This will make it easier to mimic the design in the coding phase.</p><h3>What’s next ?</h3><h4>Code the layout</h4><p>As mentioned earlier I am going to require two things to bring the design to life.</p><ul><li>CSS Grid</li><li>CSS Flexbox</li></ul><p><em>For CSS grid, there are some concepts that are required to be familiar with beforehand, so if you have not looked up Grids before, I urge you to take this </em><a href="https://css-tricks.com/snippets/css/complete-guide-grid/"><em>tutorial</em></a><em> or watch </em><a href="https://www.youtube.com/watch?v=EFafSYg-PkI"><em>this</em></a><em>. I’m going to mention some of the few concepts which I have used in this project:</em></p><ul><li>grid-template-columns/grid-template-rows</li></ul><p>Defines the columns and rows of the grid with a space-separated list of values. The values represent the track size, and the space between them represents the grid line. The fr unit allows you to set the size of a track as a fraction of the free space of the grid container.</p><pre>.container {<br>  grid-template-columns:  ... |   ...;<br>  grid-template-rows:  ... |   ...;<br>}</pre><ul><li>grid-template-areas</li></ul><p>Defines a grid template by referencing the names of the grid areas which are specified with the grid-area property. Repeating the name of a grid area causes the content to span those cells.</p><pre>.container {   <br>  grid-template-areas:      <br>    &quot; | . | none | ...&quot;     <br>    &quot;...&quot;;  <br>}</pre><ul><li>grid-area</li></ul><p>Gives an item a name so that it can be referenced by a template created with the grid-template-areas property.</p><pre>.item {   <br>  grid-area: &lt;name&gt; | &lt;row-start&gt; / &lt;column-start&gt; / &lt;row-end&gt; / &lt;column-end&gt;; <br>}</pre><p><strong><em>Firstly, let’s setup the grid structure in HTML</em></strong></p><pre>&lt;div class=&quot;grid-container&quot;&gt;<br>  &lt;div class=&quot;header&quot;&gt;<br>    &lt;div class=&quot;header1&quot;&gt;Head1&lt;/div&gt;<br>    &lt;div class=&quot;header2&quot;&gt;Head2&lt;/div&gt;<br>    &lt;div class=&quot;header3&quot;&gt;Head3&lt;/div&gt;<br>   &lt;/div&gt;<br>  &lt;div class=&quot;left_space&quot;&gt;Left_Space&lt;/div&gt;<br>  &lt;div class=&quot;main&quot;&gt;<br>    &lt;div class=&quot;main1&quot;&gt;Main1&lt;/div&gt;<br>    &lt;div class=&quot;main2&quot;&gt;Main2&lt;/div&gt;<br>    &lt;div class=&quot;main3&quot;&gt;Main3&lt;/div&gt;<br>   &lt;/div&gt;  <br>  &lt;div class=&quot;right_space&quot;&gt;Right_Space&lt;/div&gt;<br>  &lt;div class=&quot;footer&quot;&gt;<br>    &lt;div class=&quot;footer1&quot;&gt;Footer1&lt;/div&gt;<br>    &lt;div class=&quot;footer2&quot;&gt;Footer2&lt;/div&gt;<br>    &lt;div class=&quot;footer3&quot;&gt;Footer3&lt;/div&gt;<br>   &lt;/div&gt;<br>&lt;/div&gt;</pre><p>Here the header section is divided into 3 parts i.e. three columns: header1, header2 and header3. Further the body section contains three rows: main1, main2 and main3 and two columns: left_space and right_space. left_space and right_space are just space fillers to force the focus to the center of the page. Footer section is divided into three columns: footer1, footer2 and footer3.</p><p><strong><em>Now it was time to bring in some CSS</em></strong></p><ul><li>Header Section</li></ul><pre>.header{ <br>  grid-area: header; <br>  display:grid;<br>  grid-template-columns: 2fr 2fr 2fr 2fr;<br>  grid-template-areas:<br>  &#39;header1 header2 header2 header3&#39;;<br>  grid-gap: 10px;<br>}<br><br>.header1{ grid-area:header1;}<br>.header2{ grid-area:header2; }<br>.header3{ grid-area:header3; }</pre><ul><li>Body Section</li></ul><pre>.left_space{}<br>.main{ <br>  grid-area: main;<br>  display:grid;<br>  grid-template-rows: 3fr 3fr 1fr;<br>  grid-template-areas:<br>  &#39;main1&#39;<br>  &#39;main2&#39;<br>  &#39;main3&#39;;<br>  grid-gap: 10px;<br>}<br>.right_space{}<br><br>.main1{ grid-area:main1; }<br>.main2{ grid-area:main2; }<br>.main3{ grid-area:main3; }</pre><ul><li>Footer Section</li></ul><pre>.footer{ <br>  grid-area: footer;<br>  display:grid;<br>  grid-template-columns: 9fr 1fr 1fr;<br>  grid-template-areas:<br>  &#39;footer1 footer2 footer3&#39;;<br>  grid-gap: 10px;<br>}<br>.footer1 { grid-area: footer1; }<br>.footer2 { grid-area: footer2; }<br>.footer3 { grid-area: footer3; }</pre><ul><li>Root grid-container</li></ul><pre>.grid-container {<br>  display: grid;<br>  grid-template-rows: 1fr 6fr 1fr;<br>  grid-template-areas:<br>  &#39;header header header header&#39;<br>  &#39;left_space main main right_space&#39;<br>  &#39;footer footer footer footer&#39;;<br>  grid-gap: 10px;<br>  padding: 10px;<br>  height:100vh;<br>  overflow: hidden; <br>}</pre><p>After the grid was built, it was time to work inside each cell of the grid along with the content positioning. This was the most fun part of the process. This is where CSS Flexbox came into picture.</p><p><em>For CSS Flexbox, there are some concepts which are required to be familiar with beforehand, so if you have not looked up Flexbox before, I urge you to take this </em><a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/"><em>tutorial </em></a><em>or watch </em><a href="https://www.youtube.com/watch?v=FTlczfR82mQ"><em>this</em></a><em>. I’m going to mention some of the few concepts which I have used in this project:</em></p><ul><li>flex-direction</li></ul><p>This establishes the main-axis, thus defining the direction flex items are placed in the flex container.</p><pre>.container {<br>  flex-direction: row | row-reverse | column | column-reverse;<br>}</pre><ul><li>justify-content</li></ul><p>This defines the alignment along the main axis. It helps distribute extra free space leftover when either all the flex items on a line are inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow the line.</p><pre>.container {<br>  justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly | start | end | left | right ... + safe | unsafe;<br>}</pre><ul><li>align-items</li></ul><p>This defines the default behavior for how flex items are laid out along the cross axis on the current line. Think of it as the justify-content version for the cross-axis (perpendicular to the main-axis).</p><pre>.container {<br>  align-items: stretch | flex-start | flex-end | center | baseline | first baseline | last baseline | start | end | self-start | self-end + ... safe | unsafe;<br>}</pre><p>As I have positioned the content elements using standard alignment techniques in the design, I was able to directly make use of Flexbox attributes “justify-content” and “align-items” to quickly position the elements exactly mimicking the design :)</p><p>This was similar to positioning elements according to x-axis and y-axis.</p><p><strong>Header Section</strong></p><pre>&lt;!-- HTML --&gt;<br>&lt;div class=&quot;header2&quot;&gt;Alphonso&lt;/div&gt;</pre><pre>/* CSS */<br>.header2 { <br>  grid-area: header2; <br>  display: flex;<br>  justify-content: centre; //Vertical alignment<br>	align-items: centre; //Horizontal alignment<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XYwMwMIRmML8S3L9_FyMVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jrifcp0OQSokEbdyGOluzA.png" /><figcaption>Before vs After</figcaption></figure><p><strong>Body Section</strong></p><pre>&lt;!-- HTML --&gt;<br>&lt;div class=&quot;main1&quot;&gt;<br>&lt;h2&gt;Enjoy&lt;/h2&gt;<br>&lt;h3&gt;Luxury&lt;/h3&gt;<br>&lt;/div&gt;</pre><pre>&lt;div class=&quot;main3&quot;&gt;<br>&lt;p&gt;Contrary to popular belief, Lorem Ipsum... &lt;/p&gt;<br>&lt;/div&gt;</pre><pre>/* CSS */<br>.main1 { <br>  grid-area: header2; <br>  display: flex;<br> flex-direction: column;<br>  justify-content: flex-start; //Vertical alignment<br> align-items: flex-end; //Horizontal alignment<br> color: #fff;<br> margin: 20px;<br>}</pre><pre>.main3 {<br> grid-area: main3;<br>  display: flex;<br>  flex-direction: column;<br>  justify-content: center;<br>  align-items: center;<br>  color: #fff;<br>  margin: 20px;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jrifcp0OQSokEbdyGOluzA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c_d4H0bG24LYinsHk3ZgPA.png" /><figcaption>Before vs After</figcaption></figure><p>So finally I got something like this,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ba_RIRQ2SneTTCWPF0-2VQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*skFET8FKD6hGwUt2qUsw6g.png" /><figcaption>With Grids vs Without Grids</figcaption></figure><p>Another advantage of combining Grids and Flexbox together is its flexibility to be responsive. With the help of media queries, it is quite easy to just change the structure of grid with respect to the size of the screen.</p><p>This is not the only technique to use for developing landing pages but it is something that I figured out while going through the process myself. And like every other process this may also have some flaws but in the end, it worked out well for me. That’s why I decided to share my experience through this post.</p><p>Thank you for giving it a read :)</p><h4>Full code available on my GitHub</h4><p><a href="https://github.com/Shanty97/The_Ben">Shanty97/The_Ben</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be861f397fee" width="1" height="1" alt=""><hr><p><a href="https://uxdesign.cc/how-i-used-figma-css-grid-and-css-flexbox-to-build-a-landing-page-be861f397fee">How I used Figma ,CSS Grid and CSS Flexbox to build a landing page</a> was originally published in <a href="https://uxdesign.cc/">UX Collective</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>