<?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 Cagri Goksu Ustundag on Medium]]></title>
        <description><![CDATA[Stories by Cagri Goksu Ustundag on Medium]]></description>
        <link>https://medium.com/@cagrigoksu?source=rss-b3150c8ad495------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nh_OO8dlCket_MsIApUFMQ@2x.jpeg</url>
            <title>Stories by Cagri Goksu Ustundag on Medium</title>
            <link>https://medium.com/@cagrigoksu?source=rss-b3150c8ad495------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 17:04:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cagrigoksu/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[Securing Connection Strings in an ASP.Net Project Deployed on Azure Web Services]]></title>
            <link>https://medium.com/@cagrigoksu/securing-connection-strings-in-an-asp-net-project-deployed-on-azure-web-services-b276360e924f?source=rss-b3150c8ad495------2</link>
            <guid isPermaLink="false">https://medium.com/p/b276360e924f</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[azure-services]]></category>
            <category><![CDATA[aspnet]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Cagri Goksu Ustundag]]></dc:creator>
            <pubDate>Fri, 13 Sep 2024 15:35:11 GMT</pubDate>
            <atom:updated>2024-10-09T17:49:32.877Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jC7AV3wZHA_C2pjVJ3zFwQ.png" /></figure><p>Databases are frequently used in modern software programs to read and write data, involving the usage of a connection string both in development and in production.</p><p>However, the connection string should never be accessible by the public to safeguard the database’s security. As a result, it is crucial to secure the connection string using several kinds of techniques. In this article, I will show you how to secure connection strings using environment variables of Azure Web Services.</p><p>Suppose we have a local project and our configuration files contain a connection string. Next, we directly deploy the project onto an Azure Web Service. Since our local environment and Azure servers are not mediated by an outside entity, our connection string is private and has not been disclosed to any third parties.</p><p>Now, consider a more complex scenario in which we wish to publish this project in a public GitHub repository and have GitHub automatically deploy it to the Azure Web Service following a successful build and test. The connection string becomes publicly available when we push our project to the remote repository, thus everyone who visits our repository can view it. To avoid this, we need to use a technique to secure our connection string and we will use environment variables. Let’s start with how…</p><h4><strong><em>Example Scenario</em></strong></h4><blockquote><strong>1.</strong> ASP.Net Web API project</blockquote><blockquote><strong>2.</strong> This app is connecting to an Azure SQL database.</blockquote><blockquote><strong>3.</strong> The app will be deployed to an Azure Web Service. (assuming you already created an Azure web service)</blockquote><p>Normally our configuration would look like this:</p><p><strong>appsettings.json</strong></p><pre>{<br>  &quot;ConnectionStrings&quot;: {<br>    &quot;AzureSQLConnection&quot;: &quot;Server=xxx.database.windows.net; Database=database_name; User ID=user_id; Password=password; Trusted_Connection=False; Encrypt=True;&quot;<br>  },<br>  &quot;Logging&quot;: {<br>    &quot;LogLevel&quot;: {<br>      &quot;Default&quot;: &quot;Information&quot;,<br>      &quot;Microsoft.AspNetCore&quot;: &quot;Warning&quot;<br>    }<br>  },<br>  &quot;AllowedHosts&quot;: &quot;*&quot;<br>}</pre><p><strong>Program.cs</strong></p><pre>builder.Services.AddDbContext&lt;Project_Name.AppDbContext&gt;(options =&gt;<br>    options.UseSqlServer(configuration.GetConnectionString(&quot;AzureSQLConnection&quot;)));</pre><p>As you can see, the connection string includes extremely sensitive information. Now, we will make some changes to hide the connection string.</p><h3><strong>Step-by-Step Solution</strong></h3><ol><li>Change the connection string to a dummy value. So, the <em>appsettings.json</em> file will look like the below:</li></ol><pre>{<br>  &quot;ConnectionStrings&quot;: {<br>    &quot;AzureSQLConnection&quot;: &quot;Connection_String&quot;<br>  },<br>  &quot;Logging&quot;: {<br>    &quot;LogLevel&quot;: {<br>      &quot;Default&quot;: &quot;Information&quot;,<br>      &quot;Microsoft.AspNetCore&quot;: &quot;Warning&quot;<br>    }<br>  },<br>  &quot;AllowedHosts&quot;: &quot;*&quot;<br>}</pre><p>2. Change the previous logic of DbContext in the <em>Program.cs</em> file to the following; in order to get <em>AzureSQLConnection </em>value from environment variables:</p><pre>var connString = Environment.GetEnvironmentVariable(&quot;AzureSQLConnection&quot;);<br><br>builder.Services.AddDbContext&lt;Project_Name.AppDbContext&gt;( options =&gt;<br>    options.UseSqlServer(connString));</pre><p>3. Change Azure Web Services settings:</p><p>First, go to your Azure portal and navigate to your web service (our example: secure-connection-string).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vcieThhCOcNZ7MAwxcDoxg.png" /><figcaption>Azure App Services Page</figcaption></figure><p>On the opened window, go to <strong><em>Settings, </em></strong>then go to <strong><em>Environment variables</em></strong>. Here, click on <strong><em>Add </em></strong>under the <strong><em>App settings</em></strong> tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0BDlaq1GFktv3aUzG4LA9Q.png" /><figcaption>Web Service Environment variables window</figcaption></figure><p>Add your environment variable name and the value here and click Apply. Here, you need to pay attention to the variable name.</p><blockquote>The variable name has to be the same as declared in the Program.cs file.</blockquote><p>Then click Apply on the App settings tab again and, confirm the save changes pop-up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HFHTyQDkWn_O2mUK0MPX-w.png" /><figcaption>Add/Edit application setting window</figcaption></figure><p>After Azure updates the app settings, we are done! Now our connection string is stored by Azure Web Service. Using this method, you can share your code publicly. Only people accessing the Azure Portal can see the connection string.</p><p>The application of this method is really easy. So, without changing many code blocks, you can secure your connection strings. You can also use this method to store other sensitive values in a secure system.</p><h3>Conclusion</h3><p>Connection strings in apps include sensitive information. Sharing it opens our application and databases to possible attacks and data leakage. That is why this information should not be shared publicly to achieve a secure environment.</p><p>In this article, we have seen an ASP.Net Web API example deployed onto an Azure web service. Environment variables of Azure web services are one of the methods to secure our connection strings.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b276360e924f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOLID Object-Oriented Design Principles using C#]]></title>
            <link>https://medium.com/@cagrigoksu/solid-object-oriented-design-principles-using-c-b4d22cd84278?source=rss-b3150c8ad495------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4d22cd84278</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[object-oriented-design]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[solid]]></category>
            <dc:creator><![CDATA[Cagri Goksu Ustundag]]></dc:creator>
            <pubDate>Mon, 22 Apr 2024 03:20:04 GMT</pubDate>
            <atom:updated>2024-10-09T17:50:24.090Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A5uPdjbbCV9IEcNDCt8YKA.png" /><figcaption>SOLID principles</figcaption></figure><p>For a software development project, each new feature adds some complexity to the code. As the code extends, maintaining the project gets harder. If you work with a team, that means you have many parts in the code that you need to understand to use.</p><p>For instance, you should know the purpose of a method to implement and use it. If there is a bug or a new extension in the code, you need to fix the affected parts in all implementations. However, giving individual tasks to objects and encapsulating them will ease this problem. There are some approaches to solving these problems.</p><p>SOLID consists of five object-oriented design principles. These practices help to create maintainable, easy-to-understand, and extendable software development designs. The principles of SOLID are:</p><h4><strong>SOLID Principles</strong></h4><blockquote><strong>S: </strong>Single Responsibility Principle (SRP)</blockquote><blockquote><strong>O: </strong>Open-Close Principle (OCP)</blockquote><blockquote><strong>L: </strong>Liskov Substitution Principle (LSP)</blockquote><blockquote><strong>I: </strong>Interface Segregation Principle (ISP)</blockquote><blockquote><strong>D: </strong>Dependency Inversion Principle (DIP)</blockquote><p>In this article, we will apply these principles in a basic manner in C#. For each principle, there will be a scenario that violates the principle and an approach as a solution to apply SOLID design.</p><h4>1. Single Responsibility Principle (SRP)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*au0JN3FvisH8QXEYtFG5jg.png" /><figcaption>Single Responsibility Principle (SRP)</figcaption></figure><p>This principle emphasizes that every class should have only one responsibility, and therefore it should only have one reason to change. For a better view, let’s take an example. Consider that we have a class for operating subscriber-based jobs.</p><pre>public class Subscriber<br>{<br>    public void AddSubscriber() { }<br>    public void DeleteSubscriber() { }<br>    public void SendEmail() { }<br>    public void EmailVerification() { }<br>    public void GetAnnualPaymentAmount() { }<br>}</pre><p>As you can see above, we have several methods in <em>Subscriber.cs</em>. This class has several responsibilities, such as managing subscribers, email operations, and payment operations. Instead, giving a single responsibility to each class will be a better approach.</p><p>Check the code below. Now, we have three classes, and the <em>Subscriber</em> class will only change for subscriber management, not for payment or email operations.</p><pre>    public class Subscriber<br>    {<br>        public void AddSubscriber() { }<br>        public void DeleteSubscriber() { }<br>    } <br>    public class Email<br>    {<br>        public void SendEmail() { }<br>        public void EmailVerification() { }<br>        <br>    } <br>    public class Payment<br>    {<br>        public void GetAnnualPaymentAmount() { }<br>    }</pre><p>This principle eases teamwork and helps to solve bugs and conflicts. Tracking the file changes in the version control system will also be easier.</p><h4>2. Open-Close Principle (OCP)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*GOP7-qwQJVYIxjtRxnPbUw.png" /><figcaption>Open-Close Principle (OCP)</figcaption></figure><p>The OCP underlines that all entities in software should be <strong>open</strong> for extension but <strong>closed</strong> for modification. What does it mean? When we add new features, the codes should easily adapt to the new extension without changing the base. The example below shows that we have two types of subscriptions. When using <strong>GetAnnualPaymentAmount()</strong>, it returns the annual amount by calculating the discounted monthly amount.</p><pre> public enum SubscriptionType<br> {<br>     gold,<br>     platinum<br> }<br><br> public class Payment<br> {<br>     public double GetAnnualPaymentAmount(SubscriptionType sType)<br>     {<br>         double monthlyAmount = 50, total = 0;<br><br>         if (sType == SubscriptionType.gold)<br>         {<br>             // 5% discount for gold members<br>             total = (monthlyAmount * (100 - 5)/100) * 12; <br>         }<br>         else<br>         {<br>             // 25% discount for platinum members<br>             total = (monthlyAmount * (100 - 25)/100) * 12;<br>         }<br><br>         return total;<br>     }<br> }</pre><p>What if we add a new subscription type? We need to change the GetAnnualPaymentAmount() method. This means we are getting open to new bugs, adding complexity to the code, and hardening maintainability. How do we solve it? Using abstraction and interfaces... Below, we changed our previous Payment class to an abstract class.</p><pre>public enum SubscriptionType<br>{<br>    gold,<br>    platinum<br>}<br><br>public abstract class Payment<br>{<br>    public abstract double GetAnnualPaymentAmount();<br>}<br><br>public class GoldMemberPayment : Payment<br>{<br>    public override double GetAnnualPaymentAmount()<br>    {<br>        double monthlyAmount = 50;<br><br>        // 5% discount for gold members<br>        return (monthlyAmount * (100 - 5) / 100) * 12;<br>    }<br>}<br><br>public class PlatinumMemberPayment : Payment<br>{<br>    public override double GetAnnualPaymentAmount()<br>    {<br>        double monthlyAmount = 50;<br><br>        // 25% discount for platinum members<br>        return (monthlyAmount * (100 - 25) / 100) * 12;<br>    }<br>}</pre><blockquote>An abstract class contains a set of behaviors and acts as a base class. You cannot instantiate an abstract class to access its members. In order to access them, abstract classes need to be inherited. Using inheritance, we can override methods of the base class. C# supports <strong>single</strong> class inheritance.</blockquote><p>As you can see, using the approach above, if we add a new member type, we can define its GetAnnualPaymentAmount() method by overriding. Therefore, this method won’t be changed for the gold or platinum members’ method. So, we will extend our code but not change it.</p><h4>3. Liskov Substitution Principle (LSP)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*lx9091XsPtMUsbQBO-A0Ag.png" /><figcaption>Liskov Substitution Principle (LSP)</figcaption></figure><p>In this principle, all objects in a child class should be replaceable with the object of its base class. Let <em>P</em> be a parent class. The objects of a child class <em>C</em> who inherits from <em>P</em> should be replaceable with those of class <em>P</em>.</p><p>We expect a derived class to work as its base class. It means that we expect the same behavior from the objects of the derived class as from the base class, and this should not break the correctness of the code. Below, the code shows that the members have read/write access to a path. However, silver members do not have write access and this method throws an exception. This is where the SilverMemberAccess class violates LSP. Because throwing an exception stops the processes; however, the base method works fine.</p><pre> public class MemberAccess<br> {<br>     public string accessPath { get; set; }<br><br>     public virtual void ReadData()<br>     {<br>         Console.WriteLine($&quot;Read data from {accessPath}.&quot;);<br>     }<br><br>     public virtual void WriteData()<br>     {<br>         Console.WriteLine($&quot;Write data to {accessPath}.&quot;);<br>     }<br> }<br><br> public class GoldMemberAccess: MemberAccess<br> {<br>     public override void ReadData()<br>     {<br>         Console.WriteLine($&quot;Read data from {accessPath}.&quot;);<br>     }<br>     public override void WriteData()<br>     {<br>         Console.WriteLine($&quot;Write data to {accessPath}.&quot;);<br>     }<br> }<br> public class SilverMemberAccess: MemberAccess<br> {<br>     public override void ReadData()<br>     {<br>         Console.WriteLine($&quot;Read data from {accessPath}.&quot;);<br>     }<br>     public override void WriteData()<br>     {<br>         throw new AccessViolationException(&quot;Silver Member does not have write access.&quot;);<br>     }<br> }</pre><p>Abstract classes and interfaces are commonly used in order to approach this problem with solutions. In the code below, we created two interfaces, IReadData and IWriteData. For gold member access and silver member access, we will inherit from these interfaces.</p><blockquote>C# supports <strong>multiple </strong>interface inheritance.</blockquote><pre>public interface IReadData<br>{<br>    void ReadData();<br>}  <br>public interface IWriteData<br>{<br>    void WriteData();<br>}<br> public class GoldMemberAccess : IReadData, IWriteData<br> {<br>     public string accessPath { get; set; }<br>     public void ReadData()<br>     {<br>         Console.WriteLine($&quot;Read data from {accessPath}.&quot;);<br>     }<br><br>     public void WriteData()<br>     {<br>         Console.WriteLine($&quot;Write data to {accessPath}.&quot;);<br>     }<br> }<br> public class SilverMemberAccess : IReadData<br> {<br>     public string accessPath { get; set; }<br>     public void ReadData()<br>     {<br>         Console.WriteLine($&quot;Read data from {accessPath}.&quot;);<br>     }<br> }</pre><p>Using this approach, our derived classes behave like their bases without any logic problems.</p><h4>4. Interface Segregation Principle (ISP)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*OuhX0FRqlu31UIeQr3NZJw.png" /><figcaption>Interface Segregation Principle (ISP)</figcaption></figure><p>The interface segregation principle states that classes should not implement any interfaces that they don’t use. In order to approach this solution, avoid using large interfaces with many methods. Instead, segregate the interfaces into smaller pieces. Then, use only related interfaces for the classes. Below, you will see our previous example.</p><pre>public interface IReadData<br>{<br>    void ReadData();<br>}  <br>public interface IWriteData<br>{<br>    void WriteData();<br>}<br> public class GoldMemberAccess : IReadData, IWriteData<br> {<br>     public string accessPath { get; set; }<br>     public void ReadData()<br>     {<br>         Console.WriteLine($&quot;Read data from {accessPath}.&quot;);<br>     }<br><br>     public void WriteData()<br>     {<br>         Console.WriteLine($&quot;Write data to {accessPath}.&quot;);<br>     }<br> }<br> public class SilverMemberAccess : IReadData<br> {<br>     public string accessPath { get; set; }<br>     public void ReadData()<br>     {<br>         Console.WriteLine($&quot;Read data from {accessPath}.&quot;);<br>     }<br> }</pre><p>Instead of using an integrated interface for both ReadData and WriteData, we split the interface into smaller, more relevant pieces. Therefore, we could avoid using WriteData for silver members because it would be unnecessary since those members don’t have write access.</p><h4>5. Dependency Inversion Principle (DIP)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*tzy3pN6FSM-U5fa32ngBDA.png" /><figcaption>Dependency Inversion Principle (DIP)</figcaption></figure><p>This last principle of SOLID states that high-level modules should not depend on low-level modules. Instead, both should depend on abstractions. Therefore, extending the code base will be easier without changing many code blocks. In the code below, the high-level gold member access class is tightly coupled to the low-level write access class. This violates DIP.</p><pre>public class WriteAccess<br>{<br>    public void WriteData(string path)<br>    {<br>        Console.WriteLine($&quot;Write data to {path}.&quot;);<br>    }<br>}<br><br>public class GoldMemberAccess<br>{<br>    private readonly WriteAccess _writeAccess;<br><br>    public GoldMemberAccess()<br>    {<br>        _writeAccess = new WriteAccess();<br>    }<br><br>    public void PrepareAndWriteData(string path)<br>    {<br>        // Prepare data<br>        _writeAccess.WriteData(path);<br>    }<br>}</pre><p>Instead, we will change the code loose coupling using abstractions.</p><pre> public interface IWriteAccess<br> {<br>     void WriteData(string path);<br> }<br><br> public class WriteAccess: IWriteAccess<br> {<br>     public void WriteData(string path)<br>     {<br>         Console.WriteLine($&quot;Write data to {path}.&quot;);<br>     }<br> }<br><br> public class GoldMemberAccess<br> {<br>     private readonly IWriteAccess _writeAccess;<br><br>     public GoldMemberAccess(IWriteAccess writeAccess)<br>     {<br>         _writeAccess = writeAccess;<br>     }<br>     <br>     public void PrepareAndWriteData(string path)<br>     {<br>         // Prepare data<br>         _writeAccess.WriteData(path);<br>     }<br> }</pre><h4>Conclusion</h4><p>SOLID object-oriented design principles help to avoid creating complex codes and ease the addition of new extensions within code, maintainability, and debugging. Therefore, these principles lead to a time-saving and effective working environment in the project.</p><p>Even though using SOLID principles is not an obligation, they are highly recommended to use within our approaches to achieve better quality, easy-to-understand code. The simple examples in this post will give you some insight into some scenarios in SOLID principles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4d22cd84278" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Object Detection Using Detectron2: Training with Custom Dataset]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@cagrigoksu/object-detection-using-detectron2-training-with-custom-dataset-2fe5d3849416?source=rss-b3150c8ad495------2"><img src="https://cdn-images-1.medium.com/max/827/1*BECtDMg2nZ3luAo0kKHvDQ.png" width="827"></a></p><p class="medium-feed-snippet">Cagri Goksu Ustundag</p><p class="medium-feed-link"><a href="https://medium.com/@cagrigoksu/object-detection-using-detectron2-training-with-custom-dataset-2fe5d3849416?source=rss-b3150c8ad495------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@cagrigoksu/object-detection-using-detectron2-training-with-custom-dataset-2fe5d3849416?source=rss-b3150c8ad495------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fe5d3849416</guid>
            <category><![CDATA[detectron2]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[object-detection]]></category>
            <dc:creator><![CDATA[Cagri Goksu Ustundag]]></dc:creator>
            <pubDate>Tue, 10 Oct 2023 14:05:41 GMT</pubDate>
            <atom:updated>2023-10-10T14:05:41.789Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Object Detection Using YOLOv8: Building a Simple and Accurate Detection Model]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@cagrigoksu/object-detection-using-yolov8-building-a-simple-and-accurate-detection-model-61e2f6fd2fb0?source=rss-b3150c8ad495------2"><img src="https://cdn-images-1.medium.com/max/1920/1*9gavyPR_Z0NHBm8mu6Z5dA.png" width="1920"></a></p><p class="medium-feed-snippet">Cagri Goksu Ustundag</p><p class="medium-feed-link"><a href="https://medium.com/@cagrigoksu/object-detection-using-yolov8-building-a-simple-and-accurate-detection-model-61e2f6fd2fb0?source=rss-b3150c8ad495------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@cagrigoksu/object-detection-using-yolov8-building-a-simple-and-accurate-detection-model-61e2f6fd2fb0?source=rss-b3150c8ad495------2</link>
            <guid isPermaLink="false">https://medium.com/p/61e2f6fd2fb0</guid>
            <category><![CDATA[yolov8]]></category>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[yolo]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Cagri Goksu Ustundag]]></dc:creator>
            <pubDate>Thu, 21 Sep 2023 17:36:27 GMT</pubDate>
            <atom:updated>2023-10-10T13:34:26.200Z</atom:updated>
        </item>
    </channel>
</rss>