├── README.md ├── SOLIDPrinciples ├── App.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Lab2_OCP │ ├── GoodExample │ │ ├── Shape.cs │ │ ├── Circle.cs │ │ ├── Rectangle.cs │ │ └── AreaCalculator.cs │ └── BadExample │ │ ├── Rectangle.cs │ │ └── AreaCalculator.cs ├── Lab3_LSP │ ├── GoodExample │ │ ├── Car.cs │ │ ├── IAirConditionable.cs │ │ ├── Ferrari.cs │ │ └── Tofas.cs │ └── BadExample │ │ ├── Car.cs │ │ ├── Ferrari.cs │ │ └── Tofas.cs ├── Lab1_SRP │ ├── GoodExample │ │ ├── SQLDeveloper.cs │ │ ├── BackEndDeveloper.cs │ │ └── FrontEndDeveloper.cs │ └── BadExample │ │ └── FullStackDeveloper.cs ├── Form1.cs ├── Program.cs ├── Lab4_ISP │ ├── BadExample │ │ └── Bad.cs │ └── GoodExample │ │ └── Good.cs ├── Form1.Designer.cs ├── SOLIDPrinciples.csproj └── Form1.resx ├── SOLIDPrinciples.sln ├── .gitattributes └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | 2 | [GitBook Solid Araştırmalarım](https://mehmetozdemir.gitbook.io/solid-prensipleri/) 3 | -------------------------------------------------------------------------------- /SOLIDPrinciples/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab2_OCP/GoodExample/Shape.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab2_OCP.GoodExample 8 | { 9 | public abstract class Shape 10 | { 11 | public abstract double Area(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab3_LSP/GoodExample/Car.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab3_LSP.GoodExample 8 | { 9 | public abstract class Car 10 | { 11 | public abstract string Run(); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab3_LSP/GoodExample/IAirConditionable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab3_LSP.GoodExample 8 | { 9 | public interface IAirConditionable 10 | { 11 | string OpenAirConditioning(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab2_OCP/BadExample/Rectangle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab2_OCP.BadExample 8 | { 9 | public class Rectangle 10 | { 11 | public double Width { get; set; } 12 | public double Height { get; set; } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab3_LSP/BadExample/Car.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab3_LSP.BadExample 8 | { 9 | public abstract class Car 10 | { 11 | public abstract string Run(); 12 | 13 | 14 | public abstract string OpenAirConditioning(); 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab1_SRP/GoodExample/SQLDeveloper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab1_SRP.GoodExample 8 | { 9 | public class SQLDeveloper 10 | { 11 | public void WriteSQLCode() 12 | { 13 | Console.WriteLine("I can write SQL."); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab1_SRP/GoodExample/BackEndDeveloper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab1_SRP.GoodExample 8 | { 9 | public class BackEndDeveloper 10 | { 11 | public void WriteCSharpCode() 12 | { 13 | Console.WriteLine("I can write C#."); 14 | } 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace SOLIDPrinciples 12 | { 13 | public partial class Form1 : Form 14 | { 15 | public Form1() 16 | { 17 | InitializeComponent(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab2_OCP/GoodExample/Circle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab2_OCP.GoodExample 8 | { 9 | public class Circle : Shape 10 | { 11 | public double Radius { get; set; } 12 | 13 | 14 | public override double Area() 15 | { 16 | return Radius * Radius * Math.PI; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab2_OCP/GoodExample/Rectangle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab2_OCP.GoodExample 8 | { 9 | public class Rectangle : Shape 10 | { 11 | public double Width { get; set; } 12 | public double Height { get; set; } 13 | 14 | public override double Area() 15 | { 16 | return Width * Height; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab3_LSP/BadExample/Ferrari.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab3_LSP.BadExample 8 | { 9 | public class Ferrari : Car 10 | { 11 | public override string Run() 12 | { 13 | return "Araba Çalıştı."; 14 | } 15 | 16 | public override string OpenAirConditioning() 17 | { 18 | return "Klima açıldı."; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab3_LSP/GoodExample/Ferrari.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab3_LSP.GoodExample 8 | { 9 | public class Ferrari : Car, IAirConditionable 10 | { 11 | public string OpenAirConditioning() 12 | { 13 | return "Klima Çalıştı"; 14 | } 15 | 16 | public override string Run() 17 | { 18 | return "Araba Çalıştı"; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab1_SRP/GoodExample/FrontEndDeveloper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab1_SRP.GoodExample 8 | { 9 | public class FrontEndDeveloper 10 | { 11 | public void WriteJavaScriptCode() 12 | { 13 | Console.WriteLine("I can write JavaScript."); 14 | } 15 | 16 | public void WriteCSSCode() 17 | { 18 | Console.WriteLine("I can write CSS."); 19 | } 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab3_LSP/GoodExample/Tofas.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab3_LSP.GoodExample 8 | { 9 | public class Tofas : Car 10 | { 11 | public override string Run() 12 | { 13 | return "Araba Çalıştı."; 14 | } 15 | } 16 | } 17 | //Klima özelliğini sadece Ferrari için implement ettiğimizden dolayı, hiç kimse tofaş için OpenAirConditioning 18 | //metotuna erişemiyecek ve herhangi bir problem ile karşılaşılmayacaktır. -------------------------------------------------------------------------------- /SOLIDPrinciples/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace SOLIDPrinciples 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab3_LSP/BadExample/Tofas.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab3_LSP.BadExample 8 | { 9 | public class Tofas : Car 10 | { 11 | public override string OpenAirConditioning() 12 | { 13 | return null; //burda Null verdik aslında program patlamadı ama yapmamız gereken bu değil solid prensibine uymadık 14 | 15 | //tofas model arabanın klima özelliği olmayabilir 16 | } 17 | 18 | public override string Run() 19 | { 20 | return "Araba Çalıştı."; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab2_OCP/GoodExample/AreaCalculator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab2_OCP.GoodExample 8 | { 9 | public class AreaCalculator 10 | { 11 | public double Area(Shape[] shapes) 12 | 13 | { 14 | double area = 0; 15 | foreach (var shape in shapes) 16 | { 17 | area += shape.Area(); 18 | } 19 | return area; 20 | 21 | } 22 | } 23 | } 24 | 25 | //Artık her ne kadar farklı hesaplama ve şekil isteği gelse de biliyoruz ki bizim için farketmez, kolaylıkla metodumuzu genişletebiliriz. -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab1_SRP/BadExample/FullStackDeveloper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab1_SRP.BadExample 8 | { 9 | public class FullStackDeveloper 10 | { 11 | 12 | public void WriteCSharpCode() 13 | { 14 | Console.WriteLine("I can write C#."); 15 | } 16 | 17 | public void WriteSQLCode() 18 | { 19 | Console.WriteLine("I can write SQL."); 20 | } 21 | 22 | public void WriteJavaScriptCode() 23 | { 24 | Console.WriteLine("I can write JavaScript."); 25 | } 26 | 27 | public void WriteCSSCode() 28 | { 29 | Console.WriteLine("I can write CSS."); 30 | } 31 | 32 | //“FullStackDeveloper” sınıfımız C#, SQL, JavaScript ve CSS kodu yazabilen bir yazılım geliştiricisini temsil etsin. 33 | //Tek bir geliştiriciye bu kadar işin yüklenmesi geliştiricinin hata yapma olasılığını yükseltecektir. Çünkü, bir 34 | //yerden sonra kafa çorbası içilmeye hazır hale gelecektir. 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | 12 | namespace SOLIDPrinciples.Properties 13 | { 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 17 | { 18 | 19 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 20 | 21 | public static Settings Default 22 | { 23 | get 24 | { 25 | return defaultInstance; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SOLIDPrinciples.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30717.126 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SOLIDPrinciples", "SOLIDPrinciples\SOLIDPrinciples.csproj", "{1EE16C3A-1090-4BB0-B439-7328C9A47E22}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1EE16C3A-1090-4BB0-B439-7328C9A47E22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {1EE16C3A-1090-4BB0-B439-7328C9A47E22}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {1EE16C3A-1090-4BB0-B439-7328C9A47E22}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {1EE16C3A-1090-4BB0-B439-7328C9A47E22}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {5A219D1A-1260-4077-B787-0B567ECD9870} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab4_ISP/BadExample/Bad.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab4_ISP.BadExample 8 | { 9 | public class Bad 10 | { 11 | public interface IWorker 12 | { 13 | void Work(); 14 | void Eat(); 15 | } 16 | public class Worker : IWorker 17 | { 18 | public void Work() 19 | { 20 | Console.WriteLine("Az is yapar"); 21 | } 22 | public void Eat() 23 | { 24 | Console.WriteLine("Az yemek yer"); 25 | } 26 | } 27 | public class SuperWorker : IWorker 28 | { 29 | public void Work() 30 | { 31 | Console.WriteLine("Cok is yapar"); 32 | } 33 | public void Eat() 34 | { 35 | Console.WriteLine("Cok yemek yer"); 36 | } 37 | } 38 | public class Manager 39 | { 40 | IWorker worker; 41 | public void SetWorker(IWorker w) 42 | { 43 | worker = w; 44 | } 45 | public void Manage() 46 | { 47 | worker.Work(); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SOLIDPrinciples")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SOLIDPrinciples")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1ee16c3a-1090-4bb0-b439-7328c9a47e22")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace SOLIDPrinciples 3 | { 4 | partial class Form1 5 | { 6 | /// 7 | /// Required designer variable. 8 | /// 9 | private System.ComponentModel.IContainer components = null; 10 | 11 | /// 12 | /// Clean up any resources being used. 13 | /// 14 | /// true if managed resources should be disposed; otherwise, false. 15 | protected override void Dispose(bool disposing) 16 | { 17 | if (disposing && (components != null)) 18 | { 19 | components.Dispose(); 20 | } 21 | base.Dispose(disposing); 22 | } 23 | 24 | #region Windows Form Designer generated code 25 | 26 | /// 27 | /// Required method for Designer support - do not modify 28 | /// the contents of this method with the code editor. 29 | /// 30 | private void InitializeComponent() 31 | { 32 | this.SuspendLayout(); 33 | // 34 | // Form1 35 | // 36 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); 37 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 38 | this.ClientSize = new System.Drawing.Size(1061, 545); 39 | this.Name = "Form1"; 40 | this.Text = "Form1"; 41 | this.ResumeLayout(false); 42 | 43 | } 44 | 45 | #endregion 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab4_ISP/GoodExample/Good.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab4_ISP.GoodExample 8 | { 9 | public class Good 10 | { 11 | public interface IWorkable 12 | { 13 | void Work(); 14 | } 15 | public interface IFeedable 16 | { 17 | void Eat(); 18 | } 19 | public class Worker : IWorkable, IFeedable 20 | { 21 | public void Work() 22 | { 23 | Console.WriteLine("Az is yapar"); 24 | } 25 | public void Eat() 26 | { 27 | Console.WriteLine("Az yemek yer"); 28 | } 29 | } 30 | public class SuperWorker : IWorkable, IFeedable 31 | { 32 | public void Work() 33 | { 34 | Console.WriteLine("Cok is yapar"); 35 | } 36 | public void Eat() 37 | { 38 | Console.WriteLine("Cok yemek yer"); 39 | } 40 | } 41 | public class Robot : IWorkable 42 | { 43 | public void Work() 44 | { 45 | Console.WriteLine("Cok fazla is yapar, yemek yemez"); 46 | } 47 | } 48 | public class Manager 49 | { 50 | IWorkable worker; 51 | public void SetWorker(IWorkable w) 52 | { 53 | worker = w; 54 | } 55 | public void Manage() 56 | { 57 | worker.Work(); 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Lab2_OCP/BadExample/AreaCalculator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SOLIDPrinciples.Lab2_OCP.BadExample 8 | { 9 | public class AreaCalculator 10 | { 11 | public double Area(Rectangle[] shapes) 12 | { 13 | double area = 0; 14 | foreach (var shape in shapes) 15 | { 16 | area += shape.Width * shape.Height; 17 | } 18 | return area; 19 | 20 | } 21 | } 22 | } 23 | //Evet her şey oldukça güzel görünüyor değil mi? Rectangle’ın alanını hesaplayabiliyoruz.Peki müşterimizden 24 | //gelen bir istek ile Circle(Daire)’ında alanını hesaplamak istediğini belirtti bize. 25 | //Aklımıza gelen ilk şey olarak artık Rectangle tipinde bir dizi yerine object tipinde dizi tanımlayarak bunu da ufak 26 | //bir if else bloğuna sokarak bir type kontrolü ile halledebiliriz sanırım 27 | 28 | /* public class AreaCalculator 29 | { 30 | public double Area(object[] shapes) 31 | { 32 | double area=0; 33 | foreach(var shape in shapes) 34 | { 35 | if(shape is Retangle) 36 | { 37 | Rectangle rec=(Rectangle)shape; 38 | area+=rec.Width* rec.Height; 39 | } 40 | else 41 | { 42 | 43 | Circle circ=(Circle)shape; 44 | area+=circ.Radius* circ.Radius*Math.PI; 45 | } 46 | } 47 | 48 | return area; 49 | } 50 | 51 | */ 52 | 53 | 54 | /*Şuan için yine oldukça güzel duruyor Sanırım müşterimizin isteğini yerine getirmiş olduk ve artık Circle’ın da alanını hesaplayabiliyoruz. 55 | Her şey güzel gidiyor derken müşterimizden gelen bir haber ile tekrar bir yeni isteği olduğunu belirtiyor. 56 | Bu seferde Triangles (Üçgen) için bir alan hesaplamak istiyor. Elbette bunu 57 | hesaplamak çok zor değil fakat yine kodumuzda değişiklikler gerekiyor. 58 | Git gide open-closed’a karşı bir yapı kuruyoruz. Gelişime açık, değişime kapalı olmamız 59 | gerekirken sürekli kodumuzu değiştiriyoruz. Bu duruma hemen open-closed prensibine uygun bir yaklaşımla 60 | bakarsak AreaCalculator class’ımız değişime kapalı değildir aksine yeni istek için sürekli değiştirmemiz gerekmektedir. 61 | */ 62 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | 12 | namespace SOLIDPrinciples.Properties 13 | { 14 | /// 15 | /// A strongly-typed resource class, for looking up localized strings, etc. 16 | /// 17 | // This class was auto-generated by the StronglyTypedResourceBuilder 18 | // class via a tool like ResGen or Visual Studio. 19 | // To add or remove a member, edit your .ResX file then rerun ResGen 20 | // with the /str option, or rebuild your VS project. 21 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 22 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 23 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 24 | internal class Resources 25 | { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() 33 | { 34 | } 35 | 36 | /// 37 | /// Returns the cached ResourceManager instance used by this class. 38 | /// 39 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 40 | internal static global::System.Resources.ResourceManager ResourceManager 41 | { 42 | get 43 | { 44 | if ((resourceMan == null)) 45 | { 46 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SOLIDPrinciples.Properties.Resources", typeof(Resources).Assembly); 47 | resourceMan = temp; 48 | } 49 | return resourceMan; 50 | } 51 | } 52 | 53 | /// 54 | /// Overrides the current thread's CurrentUICulture property for all 55 | /// resource lookups using this strongly typed resource class. 56 | /// 57 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 58 | internal static global::System.Globalization.CultureInfo Culture 59 | { 60 | get 61 | { 62 | return resourceCulture; 63 | } 64 | set 65 | { 66 | resourceCulture = value; 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /SOLIDPrinciples/SOLIDPrinciples.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {1EE16C3A-1090-4BB0-B439-7328C9A47E22} 8 | WinExe 9 | SOLIDPrinciples 10 | SOLIDPrinciples 11 | v4.7.2 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Form 51 | 52 | 53 | Form1.cs 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | Form1.cs 78 | 79 | 80 | ResXFileCodeGenerator 81 | Resources.Designer.cs 82 | Designer 83 | 84 | 85 | True 86 | Resources.resx 87 | 88 | 89 | SettingsSingleFileGenerator 90 | Settings.Designer.cs 91 | 92 | 93 | True 94 | Settings.settings 95 | True 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /SOLIDPrinciples/Form1.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb --------------------------------------------------------------------------------