Add another example of the memento pattern

This commit is contained in:
Petrutiu Mihai
2016-06-23 21:03:26 +03:00
parent 37151a23c7
commit 05709db77e
7 changed files with 175 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
using MememntoPattern.Employee;
using MememntoPattern.EmployeeSerialized;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -25,6 +26,15 @@ namespace MememntoPattern
EmployeeExample empExample = new EmployeeExample();
empExample.Run();
GoToNextStep();
EmployeeSerializedExample empSerExample = new EmployeeSerializedExample();
empSerExample.Run();
GoToNextStep();
Console.WriteLine(GetPitfalls());
}
string GetWhenToUse()
@@ -51,6 +61,14 @@ Caretaker: keeps the mementos
Memento: (Magic cookie) internal state of the object";
}
string GetPitfalls()
{
return @"
Can be expensive
Deltes/history
Exposing information only to memento so that we don't brake encapsulation";
}
private static void GoToNextStep()
{
Console.ReadKey();