Add code examples, and documentation

This commit is contained in:
Aaron Po
2026-08-12 00:03:32 -04:00
commit 77c16e69f6
79 changed files with 4458 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
namespace CarEngineFacade;
public class AirFlowController
{
public void TakeAir()
{
// implementation
}
public void Off()
{
// implementation
}
}

View File

@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>CarEngineFacade</RootNamespace>
<AssemblyName>CarEngineFacade</AssemblyName>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,14 @@
namespace CarEngineFacade;
public class CatalyticConverter
{
public void On()
{
// implementation
}
public void Off()
{
// implementation
}
}

View File

@@ -0,0 +1,19 @@
namespace CarEngineFacade;
public class CoolingController
{
public void Run()
{
// implementation
}
public void Stop()
{
// implementation
}
public void Cool()
{
// implementation
}
}

View File

@@ -0,0 +1,29 @@
namespace CarEngineFacade;
public class Facade
{
private readonly AirFlowController _air = new();
private readonly CatalyticConverter _cat = new();
private readonly CoolingController _cool = new();
private readonly FuelInjector _fuel = new();
private readonly Starter _start = new();
public void Start()
{
_air.TakeAir();
_fuel.On();
_fuel.Inject();
_start.Start();
_cool.Run();
_cat.On();
}
public void Stop()
{
_fuel.Off();
_cat.Off();
_cool.Cool();
_cool.Stop();
_air.Off();
}
}

View File

@@ -0,0 +1,19 @@
namespace CarEngineFacade;
public class FuelInjector
{
public void On()
{
// implementation
}
public void Inject()
{
// implementation
}
public void Off()
{
// implementation
}
}

View File

@@ -0,0 +1,38 @@
namespace CarEngineFacade;
internal class Program
{
private static void Main(string[] args)
{
//// without the facade, starting the engine involves creating all the objects
//var airflow = new AirFlowController();
//var fuel = new FuelInjector();
//var start = new Starter();
//var cool = new CoolingController();
//var cat = new CatalyticConverter();
//// then performing all the steps in the correct order
//airflow.TakeAir();
//fuel.On();
//fuel.Inject();
//start.Start();
//cool.Run();
//cat.On();
//// and shut down also requires steps in the correct order
//fuel.Off();
//cat.Off();
//cool.Cool();
//cool.Stop();
//airflow.Off();
// with the Facade, all creation is handled internally
var facade = new Facade();
// as is starting
facade.Start();
// and stopping
facade.Stop();
}
}

View File

@@ -0,0 +1,9 @@
namespace CarEngineFacade;
public class Starter
{
public void Start()
{
// implementation
}
}

View File

@@ -0,0 +1,14 @@
namespace CarEngineFacadeRecording;
public class AirFlowController
{
public void TakeAir()
{
// implementation
}
public void Off()
{
// implementation
}
}

View File

@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,14 @@
namespace CarEngineFacadeRecording;
public class CatalyticConverter
{
public void On()
{
// implementation
}
public void Off()
{
// implementation
}
}

View File

@@ -0,0 +1,19 @@
namespace CarEngineFacadeRecording;
public class CoolingController
{
public void Run()
{
// implementation
}
public void Stop()
{
// implementation
}
public void Cool()
{
// implementation
}
}

View File

@@ -0,0 +1,29 @@
namespace CarEngineFacadeRecording;
public class Facade
{
private readonly AirFlowController _air = new();
private readonly CatalyticConverter _cat = new();
private readonly CoolingController _cool = new();
private readonly FuelInjector _fuel = new();
private readonly Starter _start = new();
public void Start()
{
_air.TakeAir();
_fuel.On();
_fuel.Inject();
_start.Start();
_cool.Run();
_cat.On();
}
public void Stop()
{
_fuel.Off();
_cat.Off();
_cool.Cool();
_cool.Stop();
_air.Off();
}
}

View File

@@ -0,0 +1,19 @@
namespace CarEngineFacadeRecording;
public class FuelInjector
{
public void On()
{
// implementation
}
public void Inject()
{
// implementation
}
public void Off()
{
// implementation
}
}

View File

@@ -0,0 +1,36 @@
#region
using CarEngineFacadeRecording;
#endregion
//// without the facade, starting the engine involves creating all the objects
//var airflow = new AirFlowController();
//var fuel = new FuelInjector();
//var start = new Starter();
//var cool = new CoolingController();
//var cat = new CatalyticConverter();
//// then performing all the steps in the correct order
//airflow.TakeAir();
//fuel.On();
//fuel.Inject();
//start.Start();
//cool.Run();
//cat.On();
//// and shut down also requires steps in the correct order
//fuel.Off();
//cat.Off();
//cool.Cool();
//cool.Stop();
//airflow.Off();
// with the Facade, all creation is handled internally
var facade = new Facade();
// as is starting
facade.Start();
// and stopping
facade.Stop();

View File

@@ -0,0 +1,9 @@
namespace CarEngineFacadeRecording;
public class Starter
{
public void Start()
{
// implementation
}
}