<?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 Heitor Helmer Herzog on Medium]]></title>
        <description><![CDATA[Stories by Heitor Helmer Herzog on Medium]]></description>
        <link>https://medium.com/@heitorhherzog?source=rss-deb40f524474------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hdaeKvpCHWHlALkt15jAng.jpeg</url>
            <title>Stories by Heitor Helmer Herzog on Medium</title>
            <link>https://medium.com/@heitorhherzog?source=rss-deb40f524474------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 04:45:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@heitorhherzog/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[How to track an active file in solution explorer in Visual Studio while editing a file.]]></title>
            <link>https://heitorhherzog.medium.com/how-to-track-an-active-file-in-solution-explorer-in-visual-studio-while-editing-a-file-fafaa26cc892?source=rss-deb40f524474------2</link>
            <guid isPermaLink="false">https://medium.com/p/fafaa26cc892</guid>
            <category><![CDATA[shortcut-keys]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[visual-studio]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <dc:creator><![CDATA[Heitor Helmer Herzog]]></dc:creator>
            <pubDate>Wed, 09 Jun 2021 18:07:42 GMT</pubDate>
            <atom:updated>2021-06-09T18:07:42.422Z</atom:updated>
            <content:encoded><![CDATA[<p>Go to Tools &gt; Options &gt; Projects and Solutions &gt; General</p><p>And check T<strong>rack Active item in Solution</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*WIIf0EO5YdBIoSfti6zGKA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fafaa26cc892" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the difference between href=“”, href=“#” and href=“javascript:void(0)”]]></title>
            <link>https://heitorhherzog.medium.com/what-is-the-difference-between-href-href-and-href-javascript-void-0-54e3cf31c9bd?source=rss-deb40f524474------2</link>
            <guid isPermaLink="false">https://medium.com/p/54e3cf31c9bd</guid>
            <category><![CDATA[difference]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Heitor Helmer Herzog]]></dc:creator>
            <pubDate>Mon, 03 Jun 2019 18:26:55 GMT</pubDate>
            <atom:updated>2019-06-03T18:26:55.021Z</atom:updated>
            <content:encoded><![CDATA[<h4>The Short Answer:</h4><p>href=&quot;#&quot; will scroll the current page to the top</p><p>href=”javascript: void(0)” will do nothing.</p><p>href=&quot;#0&quot; will do nothing.</p><h3>Empty HREF</h3><p>Empty HREF links basically mean <em>re-navigate the current page</em>. It’s like a Refresh operation which resubmits to the server.</p><h3># by itself</h3><p>Actually is not a do-nothing navigation. It causes navigation to the the top of the page.</p><p>If you encourage the use of #, and prevent the default behaviour <strong>(scroll to the top of the document)</strong>, it inevitably leads to some using the return false value of the function in the onclick event :</p><pre>&lt;a href=&quot;#&quot; onclick=&quot;<strong>return false</strong>;&quot;&gt;Hey&lt;/a&gt;</pre><pre><strong>&lt;!-- Or --&gt;</strong></pre><pre>&lt;a href=&quot;#&quot; id=&quot;link&quot;&gt;Hey&lt;/a&gt;    </pre><pre>&lt;script&gt;<br> document.getElementById(&quot;link&quot;).addEventListener(&quot;click&quot;,function(){<br>       <strong> return false</strong>;<br>    },false);<br>&lt;/script&gt;</pre><h3>Javascript: Tags</h3><p>You may ocassionally encounter an HTML document that uses href=&quot;JavaScript:Void(0);&quot; within an <a href="https://www.quackit.com/html/tags/html_a_tag.cfm">&lt;a&gt;</a> element.</p><p>Another way to do this is to provide essentially a null JavaScript link. There are a number of variations for this:</p><p>&lt;a href=”javascript:void(0)”&gt; <br>&lt;a href=”javascript:{}”&gt;<br>&lt;a href=”javascript:null”&gt;</p><p>The links and text are harmless as they literally do nothing, but javascript tangs violates <a href="https://en.wikipedia.org/wiki/Content_Security_Policy">Content Security Policy </a>. See more <a href="https://en.wikipedia.org/wiki/Content_Security_Policy">here</a></p><h3>Href=&quot;#0&quot;</h3><p>Unless you have a named link or an ID named 0 - This will work. No navigation and no scrolling.</p><p>If for some reason you have an ID or named link called 0 use a different non-existing value for the hash works too.</p><h3>Use a Button or a Span</h3><p>If your link doesn’t go anywhere, don’t use an &lt;a&gt; element. Use a &lt;span&gt; or &lt;button&gt;or something else appropriate and add CSS (:hover) to style it as you wish.</p><p>Now some frameworks like Bootstrap and Material Design provide custom styling for buttons so that buttons can be styled as links.</p><p>For example in bootstrap you can use:</p><pre>&lt;button class=&quot;btn btn-link btn-sm&quot; id=&quot;btnlink&quot;&gt;Click Here&lt;/button&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54e3cf31c9bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Find Out What Your Entity Framework Query Is Really Doing]]></title>
            <link>https://heitorhherzog.medium.com/find-out-what-your-entity-framework-query-is-really-doing-f8109ca9fa94?source=rss-deb40f524474------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8109ca9fa94</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[entity-framework]]></category>
            <dc:creator><![CDATA[Heitor Helmer Herzog]]></dc:creator>
            <pubDate>Thu, 04 Apr 2019 20:22:04 GMT</pubDate>
            <atom:updated>2019-04-04T20:22:04.386Z</atom:updated>
            <content:encoded><![CDATA[<p><em>You can turn on logging for your Entity Framework code </em>by making some changes in your config file</p><p>Assuming that you’re using Entity Framework 6, you already have a logging tool that can give you some insights into the SQL your queries are generating and the time they take to run.</p><pre>&lt;interceptors&gt;<br>  &lt;interceptor type=<br>    &quot;System.Data.Entity.Infrastructure.Interception.DatabaseLogger, EntityFramework&quot;&gt;<br>    &lt;parameters&gt;<br>      &lt;parameter value=&quot;C:\Logs\MyApp.txt&quot;/&gt;<br>    &lt;/parameters&gt;<br>  &lt;/interceptor&gt;<br>&lt;/interceptors&gt;</pre><p>Here’s what the output looks like:</p><pre>Opened connection at 04-FEV-19 12:15:51 PM -05:00<br><br>SELECT TOP (1) <br>  [c].[Id] AS [Id], <br>  [c].[FirstName] AS [FirstName], <br>  [c].[LastName] AS [LastName], <br>  [c].[CustCreditStatus] AS [CustCreditStatus], <br>  [c].[CreditLimit] AS [CreditLimit], <br>  [c].[RenewalDate] AS [RenewalDate], <br>  [c].[Valid] AS [Valid]<br>  FROM [dbo].[Customers] AS [c]<br>-- Executing at 04-FEV-19 12:15:51 PM -05:00<br>-- Completed in 3 ms with result: SqlDataReader<br>Closed connection at 04-FEV-19 12:15:51 PM -05:00</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8109ca9fa94" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tips for cleaner code: Cleaning up IF statements]]></title>
            <link>https://heitorhherzog.medium.com/tips-for-cleaner-code-cleaning-up-if-statements-381804bcb784?source=rss-deb40f524474------2</link>
            <guid isPermaLink="false">https://medium.com/p/381804bcb784</guid>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Heitor Helmer Herzog]]></dc:creator>
            <pubDate>Wed, 07 Nov 2018 00:09:56 GMT</pubDate>
            <atom:updated>2018-11-07T00:09:56.503Z</atom:updated>
            <content:encoded><![CDATA[<p>We know that IF statements are very crucial in our<br>development we can’t really get out of using them.</p><p>We are going to apply two very basic rules to just<br>tidy up the way that we actually use them.</p><p><strong>1 — Always return what you’re expecting last</strong></p><p>if(firstName == ‘’ &amp;&amp; lastName == ‘’)<br> return null;</p><p>if(age &lt; 18)<br> return null;<br><br> return firstName +’ ‘ + lastName;</p><p>With this approach we avoid nested ifs</p><p><strong>2 — Negate ifs to avoid nesting blocks of if-else</strong></p><p>The wrong approach:</p><pre><strong>if</strong>(file)<br>{<br>  <strong>if</strong>(array.Leght &gt; 0)<br>  {<br>    // your code are<br>  }<br>  <strong>else</strong><br>  {<br>    return;<br>  }<br>}<br><strong>else</strong><br>{<br>  //thrown error redirect<br>}</pre><p>The correrct approach:</p><pre><strong>if</strong>(!file){<br>  //trhown error redirect<br>}</pre><pre><strong>if</strong>(array.Leght == 0){<br>  //error redirect<br>}</pre><p>These are very basic tips, but they avoid a lot of headaches.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=381804bcb784" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intentions of design patterns — Part 3]]></title>
            <link>https://heitorhherzog.medium.com/intentions-of-design-patterns-part-3-20b52e1d625d?source=rss-deb40f524474------2</link>
            <guid isPermaLink="false">https://medium.com/p/20b52e1d625d</guid>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Heitor Helmer Herzog]]></dc:creator>
            <pubDate>Sat, 18 Aug 2018 21:00:57 GMT</pubDate>
            <atom:updated>2018-08-18T21:01:16.166Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Behavioral patterns</strong></p><p>The motivations of behavioral patterns are centered on the responsibilities and relationships of objects. That is, they are used to capture intentions focused on what an object can do and how it relates to others.</p><p><strong>Chain of Responsability </strong>— its intention is to decouple the send-object from a request of the supposed object-receivers, allowing multiple object-receivers to be dynamically queued to handle the request transparently.</p><p><strong>Command </strong>— Its intent is to make a command request be encapsulated as a uniform object, allowing client objects to be flexibly parameterized with different object-interchange commands.</p><p><strong>Interpreter </strong>— its intention is to define objects that can represent and interpret interchangeably any given textual grammar.</p><p><strong>Iterator</strong> — its intent is to define a way in which aggregate objects within an object can be sequentially accessed by other objects without exposing the internal details of their relationships and implementations.</p><p><strong>Mediator </strong>— its intention is to define an object used to encapsulate the relationship between two other objects, making the given relationship of these two target objects to be implemented in an indirect, flexible and interchangeable way.</p><p><strong>Memento </strong>— its intent is to define a way to capture and store the state of an object so that it can be restored to its original state.</p><p><strong>Observer </strong>— Your intent is to define a form that enables an aggregator object to automatically notify and update other dependent aggregate objects when a state change in the aggregator object occurs.</p><p><strong>State </strong>— its intent is to define a form that enables an object to vary its behavior interchangeably when internal changes in its state occur.</p><p><strong>Strategy</strong> — its intention is to define an object that has certain behaviors that undergo interchange variations depending on other client objects that manipulate them.</p><p><strong>Template Method </strong>— Its intent is to define objects that implement a previously formatted algorithm within a behavior, causing other objects to interchangeably replace parts of the algorithm’s functionality.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20b52e1d625d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intentions of design patterns Part-2]]></title>
            <link>https://heitorhherzog.medium.com/intentions-of-design-patterns-part-2-837cf32e106b?source=rss-deb40f524474------2</link>
            <guid isPermaLink="false">https://medium.com/p/837cf32e106b</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Heitor Helmer Herzog]]></dc:creator>
            <pubDate>Sat, 28 Jul 2018 19:20:33 GMT</pubDate>
            <atom:updated>2018-10-02T21:22:22.002Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Structural standards</strong></h3><p>The motivations of structural patterns are centered on the organization and composition of classes and their objects. They are used to capture intentions focused on the structural composition of objects.</p><p><strong>Adapter </strong>— Your intention is to convert the interface from one class to another required interface, defining an intermediate link point to promote communication between two incompatible interfaces.</p><p><strong>Bridge </strong>— Its intention is to separate the abstraction of an action from its different implementations, so that both can be flexibly interchangeable.</p><p><strong>Composite </strong>— Its intention is to make an object can be generically operated in a way that represents a hierarchical dynamic structure of object compositions.</p><p><strong>Decorator </strong>— Its intent is to define an alternate means of inheritance from adding responsibilities to an object in a flexible and dynamic way at runtime.</p><p><strong>Facade </strong>— its intention is to define an easy, simple and unified interface for one or more sets of operations related to internal subsystems.</p><p><strong>Flyweight </strong>— your intent is to define an efficient sharing point that supports a large number of manipulations of reusable fine grain objects.</p><p><strong>Proxy </strong>— its intention is to define a substitute object for a real object, so that the substitute object can transparently intermediate the interactions for that real object.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=837cf32e106b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intentions of design patterns Part-1]]></title>
            <link>https://heitorhherzog.medium.com/intentions-of-design-patterns-part-1-36865f358073?source=rss-deb40f524474------2</link>
            <guid isPermaLink="false">https://medium.com/p/36865f358073</guid>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Heitor Helmer Herzog]]></dc:creator>
            <pubDate>Sat, 14 Jul 2018 14:24:49 GMT</pubDate>
            <atom:updated>2018-07-14T22:31:22.029Z</atom:updated>
            <content:encoded><![CDATA[<p>In this first part we will discuss about patterns of creation</p><p>You only have to worry about memorizing only the “core intent” of a pattern so that when the architectural setting appears, it can easily identify the case of applicability.</p><h3>Patterns of creation</h3><p><strong>Builder </strong>— its intention is to define a point of creation of a complex object of its representation so that this point of construction can be parameterized to construct different variations of that same object.</p><p><strong>Singleton </strong>— Your intent is to define a point of creation of objects that need to be instantiated only once during the entire execution cycle of the solution and provide a single point of access for that reference.</p><p><strong>Prototype </strong>— Your intent is to define a point of creation of objects that need to be instantiated using as a basis the copy of another mold object called “prototype”. All created objects come into existence containing values copied from this supposed prototype object.</p><p><strong>Abstract Factory</strong> — its intention is to define a creation point for a family of related or dependent objects in which the concrete types of all these objects to be used are not known. The Abstract Factory is basically a “mass extension” of the Factory Method pattern.</p><p><strong>Factory Method</strong> — its intent is to define a creation point for an object type in which the concrete type to be used is not known.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36865f358073" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Converting T-SQL queries in LINQ]]></title>
            <link>https://heitorhherzog.medium.com/converting-t-sql-queries-in-linq-aa59afbf6dbe?source=rss-deb40f524474------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa59afbf6dbe</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[t-sql]]></category>
            <dc:creator><![CDATA[Heitor Helmer Herzog]]></dc:creator>
            <pubDate>Tue, 15 May 2018 01:05:48 GMT</pubDate>
            <atom:updated>2018-05-15T01:05:48.578Z</atom:updated>
            <content:encoded><![CDATA[<p>If you have had and / or have enough experience with the T-SQL language and today you are faced with a software that has an ORM to do the transactions with the database, there may be some doubts about how to “convert” one T-SQL query in the “language” that the ORM understands.</p><p>Below is the template I used to make it easier to understand the queries.</p><h4>Select with TOP</h4><pre><strong>T-SQL <br></strong>SELECT TOP 2 Name FROM Artist;<br><strong>LINQ</strong><br>var result = (from a in context.Artist select a.Name).Take(2);<br><strong>LAMBDA<br></strong>var result = context.Artist.Select(a =&gt; a.Name).Take(2);</pre><h4>Select with WHERE</h4><pre><strong>T-SQL</strong><br>SELECT Name  FROM Artist WHERE Name = &quot;InFlames&quot;;<br><strong>LINQ<br></strong>var result = (from a in context.Artist<br>                    where a.Name.Equals(&quot;InFlames&quot;) <br>                    select a.Name).ToList();</pre><pre><strong>LAMBDA<br></strong>var result = context.Artist<br>                    .Where(a =&gt; a.Name.Equals(&quot;InFlames&quot;))<br>                    .Select(a =&gt; a.Name).ToList();</pre><h4>Select with INNER JOIN</h4><pre><strong>T-SQL</strong><br>SELECT a.Name, al.Tile FROM Artist a <br>       		INNER JOIN Album al ON al.ArtistId = a.ArtistId;</pre><pre><strong>LINQ</strong><br>var result = (from a in context.Artist<br>            join al in context.Album on a.ArtistId equals al.ArtistId<br>            select new<br>            {<br>                a.Name,<br>                al.Title<br>            }).ToList();</pre><pre><strong>LAMBDA</strong><br>var result = context.Artist<br>            .Join(context.Album, artist =&gt; artist.ArtistId, album =&gt; album.ArtistId,<br>            (artist, album) =&gt; new { Artist = artist, Album = album })<br>            .Select(a =&gt; new { <br>                Name = a.Artist.Name, <br>                Title = a.Album.Title<br>            }).ToList();</pre><p><strong>Select with two conditions in the same Inner Join</strong></p><pre><strong>T-SQL</strong><br>SELECT DISTINCT a.Name, al.Title FROM Artist a <br>        		INNER JOIN Album al ON al.ArtistId = a.ArtistId AND al.Title = a.Name;<br><strong>LINQ<br></strong>var result = (from a in context.Artist<br>            join al in context.Album on<br>            new { C1 = a.ArtistId, C2 = a.Name } equals <br>            new { C1 = al.ArtistId, C2 = al.Title}<br>            select new<br>            {<br>                a.Name,<br>                al.Title<br>            }).ToList();<br><strong>LAMBDA<br></strong>var result = context.Artist<br>        .Join(context.Album, artist =&gt; new { C1 = artist.ArtistId, C2 = artist.Name }, <br>            album =&gt; new { C1 = album.ArtistId, C2 = album.Title},<br>            (artist, album) =&gt; new { Artist = artist, Album = album })<br>        .Select(a =&gt; new { <br>            Name = a.Artist.Name, <br>            Title= a.Album.Title<br>        }).ToList();</pre><p><strong>Select with two INNER JOINS</strong></p><pre><strong>T-SQL</strong><br>SELECT a.Name, al.Title, f.Name FROM Artist a<br>INNER JOIN Album al ON al.ArtistId = a.ArtistId<br>INNER JOIN Track f ON f.AlbumId = al.AlbumId;</pre><pre><strong>LINQ<br></strong>var result = (from a in context.Artist<br>        join al in context.Album on a.ArtistId equals al.ArtistId<br>        join f in context.Track on al.AlbumId equals f.AlbumId<br>        select new<br>        {<br>            Artist = a.Name,<br>            Album = al.Title,<br>            Track = f.Name<br>         }).ToList();</pre><pre><strong>LAMBDA<br></strong>var result = context.Artist<br>        .Join(context.Album, artist =&gt; artist.ArtistId, album =&gt; album.ArtistId,<br>            (artist, album) =&gt; new { Artist = artista, Album = album })<br>        .Join(context.Track, album =&gt; album.Album.AlbumId, track=&gt; track.AlbumId,<br>            (album, track) =&gt; new { Album = album, Track= track})<br>        .Select(a =&gt; new { <br>            Name = a.Album.Artist.Name, <br>            Titulo = a.Album.Album.Title, <br>            Track= a.Track.Name <br>        }).ToList();</pre><p><strong>Select with LEFT JOIN</strong></p><pre><strong>T-SQL</strong><br>SELECT a.Name, al.Title FROM Artist a<br>        	LEFT JOIN Album al ON al.ArtistId = a.ArtistaId;<br><strong>LINQ<br></strong>var result = (from a in context.Artist<br>            join al in context.Album on a.ArtistId equals al.ArtistId <br>                into All from al in All.DefaultIfEmpty()<br>            select new<br>            {<br>                a.Name,<br>                al.Title<br>            }).ToList();<br><strong>LAMBDA<br></strong>var result = context.Artist<br>            .GroupJoin(context.Album, artist =&gt; artist.ArtistId, album =&gt; album.ArtistId,<br>                (artist, album) =&gt; new { Artist = artist, Album = album.DefaultIfEmpty() })<br>            .SelectMany(a =&gt; a.Album, (a, album) =&gt; new { <br>                a.Artist.Name, <br>                album.Title<br>            }).ToList();<br></pre><p><strong>Select with two LEFT JOINS, GROUP BY and COUNT</strong></p><pre><strong>T-SQL</strong><br>SELECT DISTINCT a.Name, <br>              (SELECT COUNT(*) AS Album FROM Album WHERE ArtistId = a.ArtistId) AS Album, <br>            	COUNT(f.TrackId) AS Track<br>        	FROM Artist a<br>LEFT JOIN Album al ON al.ArtistId = a.ArtistId<br>LEFT JOIN Track f ON f.AlbumId = al.AlbumId<br>GROUP BY a.Name, a.ArtistId;</pre><pre><strong>LINQ<br></strong>var result = (from a in context.Artist<br>        join al in context.Album on a.ArtistId equals al.ArtistId <br>            into All1 from al in All1.DefaultIfEmpty()<br>        join f in context.Track on al.AlbumId equals f.AlbumId <br>            into All2<br>        from f in All2.DefaultIfEmpty()<br>        group a by a into grouped<br>        let totalAlbuns = grouped.Key.Album.Count()<br>        let totalTracks = grouped.Count(x =&gt; x.Album.Count &gt; 0)<br>        select new<br>        {<br>            Artist = grouped.Key.Name,<br>            Albuns = totalAlbuns,<br>            Tacks = totalTracks<br>        }).ToList();<br><strong>LAMBDA<br></strong>var result = context.Artist<br>            .GroupJoin(context.Album, artist =&gt; artista.ArtistId, album =&gt; album.ArtistId,<br>                (artist, album) =&gt; album<br>.Select(x =&gt; new<br>            { <br>               Artist = artist, <br>               Album = x <br>           })<br>            .DefaultIfEmpty(new { <br>                Artista = artist, <br>                Album = (Albuns)null <br>            }))<br>            .SelectMany(x =&gt; x)<br>            .GroupJoin(context.Track, <br>album =&gt; album.Album.AlbumId, <br>track =&gt; track.Album.AlbumId,<br>               	 (album, track) =&gt; track.Select(y =&gt; new { <br>                                                Artist = album.Artista, <br>                                                Album = album.Album, <br>                                                Track= y <br>                                            })<br>            .DefaultIfEmpty(new { <br>                Artist = album.Artist, <br>                Album = album.Album, <br>                Track = (Tracks)null <br>            }))<br>            .SelectMany(y =&gt; y)<br>            .GroupBy(grouped =&gt; new { grouped.Artist })<br>            .Select(g =&gt; new<br>            {<br>                Artist = g.Key.Artist.Name,<br>                Albuns = g.Key.Artist.Album.Count(),<br>                Tracks = g.Count(x =&gt; x.Album.Track.Count &gt; 0)<br>            }).ToList();</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa59afbf6dbe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Common Mistakes in C# Programming]]></title>
            <link>https://heitorhherzog.medium.com/common-mistakes-in-c-programming-7966656655e1?source=rss-deb40f524474------2</link>
            <guid isPermaLink="false">https://medium.com/p/7966656655e1</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Heitor Helmer Herzog]]></dc:creator>
            <pubDate>Sat, 21 Apr 2018 14:50:06 GMT</pubDate>
            <atom:updated>2018-04-21T14:50:06.577Z</atom:updated>
            <content:encoded><![CDATA[<ol><li><strong>Using string concatenation incorrectly</strong><br>In older languages, it was common just to use the plus sign to concatenate strings. The problem with this is that it’s an inefficient way to concatenate strings, so Microsoft introduced StringBuilder to help with memory and performance issues.<br>Use <strong>StringBuilder </strong>whenever you want to concatenate strings or manipulate them throughout your code. You don’t always need to use them for simple, basic strings, but it’s useful when you need to take a list of values such as those from a file and put them together to create one input that you then output to the user, or store to your database.</li><li><strong>Not disposing of objects</strong><br>Memory leaks (also called resource leaks) are a real problem for any application. C# provides you with a convenient way to call the Dispose method after you’re finished with an object, so you don’t even need to remember to use it. The “using” statement will dispose of an object and avoid troublesome memory leaks.</li></ol><p>Inefficient<br>file.Read(buffer, 0, 100);</p><p>In the code above, if you don’t dispose of the file object, you create a memory leak in the application. You can avoid this situation with the using statement.</p><p>Efficient<br>using (FileStream file = File.OpenRead(“numbers.txt”)) {<br>file.Read(buffer, 0, 100);<br>}</p><p>Now the application reads a file and disposes of the object when it’s finished.</p><p><strong>3. Iterating through values instead of using linq</strong><br>In almost any application, you’ll eventually need to enumerate values and store them in a List or a Collection. You could end up having to iterate through thousands of records. Consider pulling a list of customers, for example. If you have 100,000 customers, iterating through each of them just to find a specific data set isn’t efficient. Instead of using a foreach or for loop, use LINQ (Language-Integrated Query), which is an integrated .NET feature that’s designed to make it easier to query objects such as collections and lists.</p><p>Here’s an example:</p><p><strong>Inefficient Way</strong></p><p>foreach (Customer customer in CustomerList) {<br> if (customer.State == &quot;FL&quot;) {<br> tax += customer.Balance;<br> }<br> }</p><p><strong>Efficient Way</strong></p><p>var customers = (from customer in CustomerList<br>where customer.State == &quot;FL&quot;<br>select customer.Balance).Sum();</p><p>One line of LINQ code is all you have to execute, and it returns 1000 customers, instead of grabbing 100,000 customers. Working with 1,000 customers at a time is much more efficient than iterating through each of the 100,000.</p><p><strong>4 . Not using yield return</strong><br>When enumerating over objects for another caller you should use yield return instead of creating a return collection. Some benefits of this pattern are that:<br>* You don’t have to keep the whole collection in memory (it might be pretty big)<br>* Yield return immediately returns control to the caller after each iteration<br>* You only process results that actually are used (why iterate the whole collection if the caller just wants the first item?)</p><p><strong>5 .Parsing ambiguous dates</strong></p><p>Be sure to specify a format provider when you parse ambiguous dates. For example, it is not clear what part of the date string “03/04/05” that are the month, day, and year and it <strong>can lead to serious errors</strong> for a user. Use DateTime.ParseExact / DateTimeOffset.ParseExact to provide the specific format:</p><pre>var date = DateTime.ParseExact(&quot;01/12/2000&quot;, &quot;MM/dd/yyyy&quot;, null)</pre><h4>6 . Rethrowing Exceptions with an exception instance</h4><p>If you want to catch and rethrow an exception, be sure to use the simple <strong>throw;</strong> syntax. If you use <strong>throw ex;</strong> it will not preserve the exception call stack.</p><p>DO:</p><pre><strong>catch</strong>(SomeException ex)<br>{<br>    logger.<strong>log</strong>(ex);<br>    <strong>throw</strong>;<br>}</pre><p>DON’T:</p><pre><strong>catch</strong>(SomeException ex)<br>{<br>    logger.<strong>log</strong>(ex);<br>    <strong>throw</strong> ex;<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7966656655e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[MySQL] — Improving Performance and Avoiding Problems]]></title>
            <link>https://heitorhherzog.medium.com/mysql-improving-performance-and-avoiding-problems-1f5f403de970?source=rss-deb40f524474------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f5f403de970</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Heitor Helmer Herzog]]></dc:creator>
            <pubDate>Fri, 23 Mar 2018 16:42:43 GMT</pubDate>
            <atom:updated>2018-03-23T16:42:43.201Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>1</strong> — When creating a Stored Procedure, do not use the same name in the query parameter in the Where clause and the field name in the query. It will return all records.</p><pre>DELIMITER $$<br>CREATE PROCEDURE `getCategoriasPorId`(IN <strong>CategoryID </strong>INT)  <br>BEGIN  <br>   SELECT CategoryID,CategoryName FROM categories WHERE <strong>CategoryID</strong>=<strong>CategoryID</strong>;    <br>END;<br>$$<br>DELIMITER ;</pre><p><strong>2 </strong>— Use the <strong>EXISTS </strong>clause, this improves query response time.</p><pre>if(select count(*) from categories) &gt; 0</pre><pre>if <strong>EXISTS</strong>(select count(*) from categories) &gt; 0</pre><p><strong>3</strong> — Avoid using functions in indexed columns , using the function will override the purpose of the indexed column.</p><pre>select CategoryName from categories Where UPPER(CategoryName) LIKE`J%`</pre><pre>select CategoryName from categories Where CategoryName LIKE `J%`</pre><p><strong>4</strong>— Prefer to use <strong>ENUM </strong>to <strong>VARCHAR </strong>in columns with multiple values (eg gender, status, etc.) . Response time is best with <strong>ENUM</strong></p><pre><strong>-- VARCHAR </strong> <br>CREATE TABLE Aluno(  <br>id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,  <br>nome VARCHAR(50) NOT NULL,  <br>sexo VARCHAR(50)  <br>)ENGINE=MyISAM;</pre><pre><strong>-- ENUM  </strong><br>CREATE TABLE Aluno(  <br>id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,  <br>nome VARCHAR(50) NOT NULL,  <br>sexo ENUM(&#39;Male&#39;,&#39;Female&#39;)  <br>)ENGINE=MyISAM;</pre><p><strong>6</strong> — Avoid using <strong>SELECT * . </strong>If you are selecting only a few columns from a table, avoid using <strong>SELECT *</strong>.</p><p>Although it is easier to write, this will impact the performance of the query. By selecting only the columns you need, you are reducing the size of the results table, reducing network traffic, and further increasing performance.</p><p><strong>7</strong> — Avoid using the <strong>GROUP BY</strong> clause without using aggregate functions.</p><p>The query will always retrieve the first record by the grouped column, so that it will be different if we expect all records, which are based on a grouped column.</p><pre>SELECT CategoryID, Description, CategoryName FROM categories GROUP BY CategoryName;</pre><pre>SELECT CategoryName, count(*) as count FROM categories GROUP BY CategoryName;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f5f403de970" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>