Skip to content

Commit

Permalink
refactor demeter
Browse files Browse the repository at this point in the history
  • Loading branch information
gamousquesORT committed Oct 1, 2023
1 parent 626421a commit 086dfa4
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 3 deletions.
10 changes: 10 additions & 0 deletions CleanCode/Ejemplos/ConditionalTofunct/ConditionalTofunct.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
23 changes: 23 additions & 0 deletions CleanCode/Ejemplos/ConditionalTofunct/PlaceHolder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Security.Cryptography.X509Certificates;

namespace ConditionalTofunct;

public class PlaceHolder
{
public DateTime FechaExpiracion { get; set; }
public bool AprobadoParaConsumo { get; set; }
public int IdInspector { get; set; }

public bool IsComestible()
{
if (FechaExpiracion > DateTime.Now && AprobadoParaConsumo
&& AprobadoParaConsumo == true && IdInspector !=0)
{
return true;
}
else
{
return false;
}
}
}
3 changes: 3 additions & 0 deletions CleanCode/Ejemplos/ConditionalTofunct/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// See https://aka.ms/new-console-template for more information

Console.WriteLine("Hello, World!");
6 changes: 6 additions & 0 deletions CleanCode/Ejemplos/Ejemplos.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RefactorCleanCodeTests", "R
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RefactorCleanCodeSource", "RefactorCleanCodeSource\RefactorCleanCodeSource.csproj", "{F688DAE3-C6B5-456B-8540-62B970442062}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConditionalTofunct", "ConditionalTofunct\ConditionalTofunct.csproj", "{0927109E-E341-4171-9551-89900ABBBEB5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -42,5 +44,9 @@ Global
{F688DAE3-C6B5-456B-8540-62B970442062}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F688DAE3-C6B5-456B-8540-62B970442062}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F688DAE3-C6B5-456B-8540-62B970442062}.Release|Any CPU.Build.0 = Release|Any CPU
{0927109E-E341-4171-9551-89900ABBBEB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0927109E-E341-4171-9551-89900ABBBEB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0927109E-E341-4171-9551-89900ABBBEB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0927109E-E341-4171-9551-89900ABBBEB5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions CleanCode/Ejemplos/WithoutDemeter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

using Ejemplos;

Commerce commerce = new Commerce();
Store store = new Store();
Customer customer = new Customer();
Wallet w = customer.Wallet;
w.Money = 100;
commerce.Checkout(customer, 110);
store.Checkout(customer, 110);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Ejemplos;

public class Commerce
public class Store
{
public void Checkout(Customer customer, decimal amount)
{
Expand Down

0 comments on commit 086dfa4

Please sign in to comment.