Skip to content

Commit 93d371b

Browse files
committed
compeleting the factory pattern
1 parent 46bf107 commit 93d371b

13 files changed

Lines changed: 64 additions & 47 deletions

DesignPattern.FactoryMethod/ISoftwareProduct.cs renamed to DesignPattern.FactoryMethod/Abstraction/ISoftwareProduct.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace DesignPattern.FactoryMethod;
1+
namespace DesignPattern.FactoryMethod.Abstraction;
22

33
public interface ISoftwareProduct
44
{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using DesignPattern.FactoryMethod.Abstraction;
2+
using DesignPattern.FactoryMethod.Creator;
3+
using DesignPattern.FactoryMethod.Products;
4+
5+
namespace DesignPattern.FactoryMethod.ConcreteCreators;
6+
7+
public class MobileAppCreator : SoftwareCreator
8+
{
9+
public override ISoftwareProduct CreateProduct() => new MobileApplication();
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using DesignPattern.FactoryMethod.Abstraction;
2+
using DesignPattern.FactoryMethod.Creator;
3+
using DesignPattern.FactoryMethod.Products;
4+
5+
namespace DesignPattern.FactoryMethod.ConcreteCreators;
6+
public class WebApplicationCreator : SoftwareCreator
7+
{
8+
public override ISoftwareProduct CreateProduct() => new WebApplication();
9+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using DesignPattern.FactoryMethod.Abstraction;
2+
3+
namespace DesignPattern.FactoryMethod.Creator;
4+
5+
public abstract class SoftwareCreator
6+
{
7+
public abstract ISoftwareProduct CreateProduct();
8+
9+
public void SomeOperation()
10+
{
11+
ISoftwareProduct software = CreateProduct();
12+
software.Develop();
13+
}
14+
}

DesignPattern.FactoryMethod/GlobalUsings.cs

Whitespace-only changes.

DesignPattern.FactoryMethod/MobileAppCreator.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

DesignPattern.FactoryMethod/MobileApplication.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
using DesignPattern.FactoryMethod.Abstraction;
3+
4+
namespace DesignPattern.FactoryMethod.Products;
5+
6+
public class MobileApplication : ISoftwareProduct
7+
{
8+
public void Develop()
9+
{
10+
Console.WriteLine("MobileApplication software is running...");
11+
}
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using DesignPattern.FactoryMethod.Abstraction;
2+
3+
namespace DesignPattern.FactoryMethod.Products;
4+
5+
public class WebApplication : ISoftwareProduct
6+
{
7+
public void Develop()
8+
{
9+
Console.WriteLine("WebApplication software is running...");
10+
}
11+
}
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
using DesignPattern.FactoryMethod;
1+
using DesignPattern.FactoryMethod.ConcreteCreators;
22

33
MobileAppCreator mobileAppCreator = new MobileAppCreator();
4-
var software = mobileAppCreator.CreateProduct();
5-
Console.WriteLine(software);
4+
mobileAppCreator.SomeOperation();
5+
6+
7+
WebApplicationCreator webAppCreator = new WebApplicationCreator();
8+
webAppCreator.SomeOperation();
9+
610
Console.Read();

0 commit comments

Comments
 (0)