Pages

Saturday, December 22, 2018

SOLID - Liskov Substitution Principle

If S is a subtype of T, then objects of type T can be substituted by objects of type S without breaking the program.

public class Employee {
    public string Firstname {get; set;}
    public string Lastname { get; set;}

    public virtual void AssignManager (Employee Manager)
    {
          // set manager for employee
    }
}


Employee emp = new Employee();
emp.AssignManager();


Above, Employee type is T.


public class Staff : Employee {
    public string Dept {get; set;}
    public string Manager {get; set;}
}

Above, Staff (S) is a subtype of T (Employee). Liskov says that since S is a subtype of T, then this should work:


Employee emp = new Staff();
emp.AssignManager();


Let's create another subtype of Employee (T).

public class CEO : Employee{
       public string Rating {get; set;}
       public override void AssignManager(Employee manager)
       {
               throw new Exception("CEO does not have a manager");
       }
}


Above, CEO is subtype of Employee. However, this does not work and thus, it violates the Liskov Principle:

Employee emp = new CEO();
emp.AssignManager();

This code throws an exception because 1) CEO does not have a manager  2) code is set to throw error for invalid method.

Liskov Sub Principle states that Staff() should be a TRUE Employee().
CEO should be a TRUE Employee(), but it is not. So LSP is violated.

How to fix so that even CEO (subtype object of T) can be substituted for the objects of T? So that above code works?

Wednesday, December 19, 2018

Agile Methodology

2 week sprints.

Weekly PAR review. Small group reviews new defects.

BACKLOG GROOMING (every 2 weeks):
- Stories: discuss story and using pointingPoker.com to point. Goal is to create a score to help estimate relative complexity. Stories are items that add value for customer (e.g., product feature, performance improvements, etc.)
- Tasks do not get pointed. Tasks are items good things to do, but does not correlate directly to a benefit for a customer.
- Review defects (high level)
- Move priority items to top of backlog

SPRINT PLANNING (every 2 weeks):
- Occurs at the start of a sprint. 4 hrs allocated and then we officially start the sprint.
- Assess total team hours available
- Add items to sprint and check team hours remaining
- For stories, create sub-tasks
- For defects, set hours

START SPRINT
- Tickets are prioritized
- Tickets are not assigned so anyone can take
- If a bug is found during a story, create a BUG subtask and take hours from the story's time bank.

SPRINT RETROSPECTIVE (when sprint ends):
- Discuss good and bad points
- Action items (past and future)

Monday, December 17, 2018

GIT Cheat sheet

REBASE:

git rebase -i HEAD~3     > pulls up the latest 3 commits

[INSERT] Edit the interactive screen
[ESC]
[Shift :]
wq!         > saves and exits

git log    view new rebased log

git push -f origin bug/sample-1000   > pushes latest changes to origin



RESET:

git reset --hard HEAD~1    > undo prior commit and delete it
git reset --soft HEAD~1     > undo prior commit and keep changes