Move UserStoryMotivational to the motivational example file

Update the scrum state pattern example with description about some pitfalls of classsic implementation
This commit is contained in:
Petrutiu Mihai
2016-07-21 11:49:27 +03:00
parent 462ee43283
commit 8ced7d951b
4 changed files with 37 additions and 21 deletions

View File

@@ -11,8 +11,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "BehavioralPatterns", "src\BehavioralPatterns\BehavioralPatterns.xproj", "{E3092EE0-1282-4AB4-9FA2-0338348D8FD1}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ChainOfResponssibility", "src\ChainOfResponssibility\ChainOfResponssibility.xproj", "{89536824-683F-4351-8789-406D7BDD922D}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "CommandPattern", "src\CommandPattern\CommandPattern.xproj", "{454B2A43-8251-4667-8DE3-67E489908DB9}"
@@ -39,10 +37,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E3092EE0-1282-4AB4-9FA2-0338348D8FD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3092EE0-1282-4AB4-9FA2-0338348D8FD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3092EE0-1282-4AB4-9FA2-0338348D8FD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3092EE0-1282-4AB4-9FA2-0338348D8FD1}.Release|Any CPU.Build.0 = Release|Any CPU
{89536824-683F-4351-8789-406D7BDD922D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{89536824-683F-4351-8789-406D7BDD922D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{89536824-683F-4351-8789-406D7BDD922D}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -88,7 +82,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{E3092EE0-1282-4AB4-9FA2-0338348D8FD1} = {3820200F-354C-41E6-8F34-B301F5D621C2}
{89536824-683F-4351-8789-406D7BDD922D} = {3820200F-354C-41E6-8F34-B301F5D621C2}
{454B2A43-8251-4667-8DE3-67E489908DB9} = {3820200F-354C-41E6-8F34-B301F5D621C2}
{6F3B7F9A-4D9C-4506-A5F7-3FF5CF4376BD} = {3820200F-354C-41E6-8F34-B301F5D621C2}

View File

@@ -24,6 +24,12 @@ namespace StatePattern.ScrumExample
}
}
public class UserStoryMotivational
{
public string Name { get; set; }
public UserStoryState State { get; set; }
}
/// <summary>
/// User story states: New, Active, Resolved, Closed, Removed
/// Actions on user stories:

View File

@@ -9,6 +9,7 @@ namespace StatePattern.ScrumExample
{
public static void Run()
{
UserStory userStory = new UserStory();
userStory.RemoveFromBacklog();
userStory.MoveToBacklog();
@@ -18,6 +19,13 @@ namespace StatePattern.ScrumExample
userStory.AcceptanceTestsPassed();
userStory.StartImplementation();
//This is the first example where a state may not execute all transitions
//There is an active debate if this violates liskov substitution principle or not -> https://en.wikipedia.org/wiki/Liskov_substitution_principle
//but leaving that asside, assuming we will have to add another transition availalable that can be executed only from one state
//we will have to modify all the existing states, just to throw the exception.
}
}
@@ -98,26 +106,31 @@ namespace StatePattern.ScrumExample
public void AcceptanceTestsFail()
{
//throw the exception
Console.WriteLine("Implementation did not start yet, probably that's why the tests are failing");
}
public void AcceptanceTestsPassed()
{
//throw the exception
Console.WriteLine("Development didn't even started, you should check your tests");
}
public void CodeFinishedAnUnitTestsPassed()
{
//throw the exception
Console.WriteLine("Before you can finish the code, you should have started implementation");
}
public void MoveToBacklog()
{
//throw the exception
Console.WriteLine("Already in backlog");
}
public void RemoveFromBacklog()
{
//throw the exception
Console.WriteLine("User story removed");
}
@@ -139,11 +152,13 @@ namespace StatePattern.ScrumExample
public void AcceptanceTestsFail()
{
//throw the exception
Console.WriteLine("Implementation is not done yet, probably that's why tests are failing");
}
public void AcceptanceTestsPassed()
{
//throw the exception
Console.WriteLine("Development is not yet done");
}
@@ -155,17 +170,19 @@ namespace StatePattern.ScrumExample
public void MoveToBacklog()
{
//throw the exception
Console.WriteLine("Moved userstory to backlog");
}
public void RemoveFromBacklog()
{
//throw the exception
Console.WriteLine("You must first move the item to backlog");
}
public void StartImplementation()
{
//throw the exception
Console.WriteLine("You can start work only on user stories that are new, current user story state is: {0}", userStory.State);
}
}
@@ -193,21 +210,25 @@ namespace StatePattern.ScrumExample
public void CodeFinishedAnUnitTestsPassed()
{
//throw the exception
Console.WriteLine("The item was already resolved");
}
public void MoveToBacklog()
{
//throw the exception
Console.WriteLine("Item was already resolved, it can be moved to backlog, only if the acceptance tests failed");
}
public void RemoveFromBacklog()
{
//throw the exception
Console.WriteLine(@"The item was already resolved, it can be deleted only if the acceptance tests failed and moved to backlog");
}
public void StartImplementation()
{
//throw the exception
Console.WriteLine("You can start work only on user stories that are new, current user story state is: {0}", userStory.State);
}
}
@@ -223,16 +244,19 @@ namespace StatePattern.ScrumExample
public void AcceptanceTestsFail()
{
//throw the exception
Console.WriteLine("User story is already closed");
}
public void AcceptanceTestsPassed()
{
//throw the exception
Console.WriteLine("User story is already closed");
}
public void CodeFinishedAnUnitTestsPassed()
{
//throw the exception
Console.WriteLine("Item was already closed");
}
@@ -243,11 +267,13 @@ namespace StatePattern.ScrumExample
public void RemoveFromBacklog()
{
//throw the exception
Console.WriteLine("Once a User Story is Closed, it cannot be removed");
}
public void StartImplementation()
{
//throw the exception
Console.WriteLine("You can start work only on user stories that are new, current user story state is: {0}", userStory.State);
}
}
@@ -263,11 +289,13 @@ namespace StatePattern.ScrumExample
public void AcceptanceTestsFail()
{
//throw the exception
Console.WriteLine("Item was removed, you can only move it to backlog again");
}
public void AcceptanceTestsPassed()
{
//throw the exception
Console.WriteLine("Item was removed, you can only move it to backlog again");
}
@@ -284,11 +312,13 @@ namespace StatePattern.ScrumExample
public void RemoveFromBacklog()
{
//throw the exception
Console.WriteLine("Once a User Story is Closed, it cannot be removed");
}
public void StartImplementation()
{
//throw the exception
Console.WriteLine("You can start work only on user stories that are new, current user story state is: {0}", userStory.State);
}
}

View File

@@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace StatePattern.ScrumExample
{
public class UserStoryMotivational
{
public String Name { get; set; }
public UserStoryState State { get; set; }
}
}