Software Craftsmanship for New Developers Tech Foundations - - PowerPoint PPT Presentation

software craftsmanship for new developers
SMART_READER_LITE
LIVE PREVIEW

Software Craftsmanship for New Developers Tech Foundations - - PowerPoint PPT Presentation

Software Craftsmanship for New Developers Tech Foundations Louisville January 22, 2019 Who is Chad Green? Data & Solutions Architect at ProgressiveHealth Community Involvement Code PaLOUsa Conference Chair Louisville .NET Meetup


slide-1
SLIDE 1

Software Craftsmanship for New Developers

Tech Foundations Louisville January 22, 2019

slide-2
SLIDE 2

Data & Solutions Architect at ProgressiveHealth Community Involvement Code PaLOUsa Conference Chair Louisville .NET Meetup Organizer Louisville Tech Leaders Meetup Organizer Louisville Tech Ladies Co-Organizer Contact Information chadgreen@chadgreen.com chadgreen.com @ChadGreen ChadwickEGreen

Who is Chad Green?

slide-3
SLIDE 3

What is Software Craftsmanship

Software Craftsmanship for New Developers

slide-4
SLIDE 4

Software Craftsmanship for Non Developers

What Software Craftsmanship is not

page 04

  • Beautiful code
  • Test-Driven Development
  • Self-selected group of people
  • Specific technologies or methodologies
  • Certifications
  • Religion
slide-5
SLIDE 5

Software Craftsmanship for Non Developers

What is Software Craftsmanship

page 05

  • Software developers have had hard time defining themselves:
  • Historically practitioners of well-defined statistical analysis and

mathematical rigor of a scientific approach with computational theory

  • Changed to an engineering approach with connotations of

precision, predictability, measurement, risk mitigation, and professionalism

slide-6
SLIDE 6

Software Craftsmanship for Non Developers

Craft, Trade, Engineering, Science, or Art

page 06

  • Craft/Trade – Profession that requires particular skills and knowledge of skilled work
  • Engineering – Creative application of science, mathematical methods, and empirical

evidence to the innovation, design, construction, operation, and maintenance of structures, machines, materials, devices, systems, processes, and organizations

  • Science – Systematic enterprise that builds and organizes knowledge in the form of

testable explanations and predictions about the universe

  • Art – Diverse range of human activities in creating visual, auditory, or performing

artifacts, expressing the author’s imaginative, conceptual idea, or technical skill, intended to be appreciated for their beauty or emotional power

slide-7
SLIDE 7

Software Craftsmanship for Non Developers

What is Software Craftsmanship

page 07

Agile Manifesto question some these assumptions

Individuals and interactions over processes and tools

slide-8
SLIDE 8

Software Craftsmanship is about professionalism in software development.

slide-9
SLIDE 9

Software Craftsmanship for Non Developers

Software Craftsmanship History

page 09

  • 1992 – Jack W. Reeves publishes “What Is Software Design?” essay
  • 1997 – Andrew Hunt and David Thomas publish The Pragmatic Programmer
  • 2001 – Pete McBreen publishes Software Craftsmanship
  • 2002 – Software Apprenticeship Summit
  • 2006 – 8th Light Founded
  • 2008 – Bob Martin proposes fifth value for the Agile Manifesto:

Craftsmanship over Crap

  • 2008 – Bob Martin publishes Clean Code: A Handbook of Agile Software

Craftsmanship

  • 2008 – Software Craftsmanship Summit
  • 2009 – Manifesto for Software Craftsmanship
  • 2011 – Bob Martin publishes The Clean Coder: A Code of Conduct for

Professional Programmers

slide-10
SLIDE 10

Software Craftsmanship for Non Developers

Manifesto for Software Craftsmanship

page 010

Not only working software, but also well-crafted software Not only responding to change, but also steadily adding value Not only individuals and interactions, but also a community of professionals Not only customer collaboration, but also productive partnerships

slide-11
SLIDE 11

Software Craftsmanship for Non Developers

Manifesto for Software Craftsmanship

page 011

Not only working software, but also well-crafted software

slide-12
SLIDE 12

Software Craftsmanship for Non Developers

Manifesto for Software Craftsmanship

page 012

Not only responding to change, but also steadily adding value

slide-13
SLIDE 13

Try and leave this world a little better than you found it, and when you turn comes to die you can die happy in feeling that at any rate you have not wasted your time but have done your best. Robert Stephenson Smyth Bader-Powell, founder of The Scout Association

slide-14
SLIDE 14

Software Craftsmanship for Non Developers

Manifesto for Software Craftsmanship

page 014

Not only individuals and interactions, but also a community of professionals

slide-15
SLIDE 15

Software Craftsmanship for Non Developers

Manifesto for Software Craftsmanship

page 015

Not only customer collaboration, but also productive partnerships

slide-16
SLIDE 16

Technical Debt

Software Craftsmanship for Non-Developers

slide-17
SLIDE 17

Software Craftsmanship for Non Developers

What is Technical Debt

page 017

  • Reflects the implied cost of additional rework caused by choosing

an easy solution now instead of using a better approach that would take longer

  • Technical debt can be compared to monetary debt – If not repaid, it

can accumulate interest, making it hard to implement changes later

  • n
slide-18
SLIDE 18

Software Craftsmanship for Non Developers

Example of Technical Debt

page 018

  • Start writing an application and there is no need for user roles –

everyone can do everything

  • Requirement comes in for a permission for a specific requirement
  • Some time later another things requires the differentiation of users,

and then another and another

  • The company has the opportunity to add five customers in a week –

but really need another permission change in a couple of days

slide-19
SLIDE 19

Software Craftsmanship for Non Developers

Common Causes of Technical Debt

page 019

  • Insufficient up-front definition
  • Business pressures
  • Lack of process or understanding
  • Tightly-coupled components
  • Lack of a test suite
  • Lack of documentation
  • Lack of collaboration
  • Parallel development
  • Delayed refactoring
  • Lack of alignment to standards
  • Lack of knowledge
  • Lack of ownership
  • Poor technological leadership
  • Last minute specification

changes

slide-20
SLIDE 20

SOLID Principles

Software Craftsmanship for Non-Developers

slide-21
SLIDE 21

Software Craftsmanship for Non Developers

S.O.L.I.D.

page 021

  • First five object-oriented design principles
  • S – Single-responsibility principle
  • O – Open-closed principle
  • L – Liskov substitution principle
  • I – Interface segregation principle
  • D – Dependency Inversion Principle
slide-22
SLIDE 22

Software Craftsmanship for Non Developers

Single Responsibility Principle (SRP)

page 022

  • A module should have one, and only one, reason to change
  • A module should be responsible to one, and only one, actor
slide-23
SLIDE 23

Software Craftsmanship for Non Developers

Single Responsibility Principle (SRP)

page 023

  • A module should be responsible to one, and only one, actor

CFO COO CTO Employee

+ Caculate Pay + ReportHours + Save

Class violates the SRB because the three methods are responsible to different actors

  • The CalculatePay method is specified by the

accounting department, which reports to the CFO

  • The ReportHours method is specified and used by

the human resources department, which reports to the COO

  • The Save method is specified b the database

administrators, who report to the CTO

slide-24
SLIDE 24

Software Craftsmanship for Non Developers

Open-Closed Principle (OCP)

page 024

  • A software artifact should be open for extension but closed for

modification

slide-25
SLIDE 25

Software Craftsmanship for Non Developers

Liskov Substitution Principle (LSP)

page 025

  • Let q(x) be a property provable about objects of x of type T. Then

q(y) should be provable for objects y of type y where S is a subtype

  • f T
  • Every subclass/derived class should be substitutable for their

base/parent class

Billing License

+ CalculateFee()

Personal License

+ CalculateFee()

Business License

+ CalculateFee()

slide-26
SLIDE 26

Software Craftsmanship for Non Developers

Interface Segregation Principle (ISP)

page 026

  • A client should never be forced to implement an interface that it

does not use or clients should not be forced to depend on methods they do not use

slide-27
SLIDE 27

Software Craftsmanship for Non Developers

Dependency Inversion Principle (DIP)

page 027

  • Entities must depend on abstractions not on concretions. It states

that the high level module must not depend on the low level module, but they should depend on abstractions.

slide-28
SLIDE 28

Other Key Principles

Software Craftsmanship for Non-Developers

slide-29
SLIDE 29

Software Craftsmanship for Non Developers

DRY – Don’t Repeat Yourself

page 029

  • Every piece of knowledge must have a single, unambiguous,

authoritative representation within a system

  • Alternative is to have the same thing expressed in two or more
  • place. If you change one, you have to remember to change the
  • thers.
  • It isn’t a question of whether you will remember: it’s a question of

when you will forget

slide-30
SLIDE 30

If you write it once, think about encapsulating it. If you write it twice, you have to encapsulate it. If you write it three times, programming isn’t for you. Phil Japikse, Microsoft MVP, ASPInsider, MCSD, MCDBA, PSM II, PSD, CSM, Consultant, Coach, Author, Trainer

slide-31
SLIDE 31

Software Craftsmanship for Non Developers

KISS – Keep it Simple Stupid

page 031

  • The simplest explanation tends to be the right one
slide-32
SLIDE 32

Software Craftsmanship for Non Developers

YAGNI – You Aren’t Going to Need It

page 032

  • Always implement things when you actually need them, never when

you just foresee that you need them

  • Principle behind XP practice of “do the simplest thing that could

possibly work”

slide-33
SLIDE 33

Key Practices

Software Craftsmanship for Non-Developers

slide-34
SLIDE 34

Software Craftsmanship for Non Developers

TDD – Test Driven Development

page 034

  • Software development process that relies on the repetition of very

short development cycle: requirements are turned into very specific test cases, then the software is improved to pass the new tests,

  • nly
  • Three Laws of TDD
  • 1. You are not allowed to write any production code until you

have first written a failing unit test.

  • 2. You are not allowed to write more of a unit test than is

sufficient to fail – and not compiling is failing

  • 3. You are not allowed to write more production code that is

sufficient to pass the currently failing unit test

slide-35
SLIDE 35

Software Craftsmanship for Non Developers

Pair Programming

page 035

  • Technique in which two programmers work together at one

workstation

  • The driver writes code while the observer reviews each line of

code as it is typed

slide-36
SLIDE 36

Software Craftsmanship for Non Developers

Practicing – Coding Katas

page 036

  • Practice, Practice, Practice
  • Practice on how to solve the problem
  • Katas – simple coding exercises
  • codingdojo.org/kata
  • codekata.com
  • codewars.com
slide-37
SLIDE 37

Code Smells

Software Craftsmanship for Non-Developers

slide-38
SLIDE 38

Software Craftsmanship for Non Developers

Code Smells - Comments

page 038

  • Inappropriate Information
slide-39
SLIDE 39

Software Craftsmanship for Non Developers

Code Smells - Comments

page 039

  • Inappropriate Information
  • Obsolete Comment
slide-40
SLIDE 40

Software Craftsmanship for Non Developers

Code Smells - Comments

page 040

  • Inappropriate Information
  • Obsolete Comment
  • Redundant Comment

i++ // increment i

slide-41
SLIDE 41

Software Craftsmanship for Non Developers

Code Smells - Comments

page 041

  • Inappropriate Information
  • Obsolete Comment
  • Redundant Comment
  • Poorly Written Comment
slide-42
SLIDE 42

Software Craftsmanship for Non Developers

Code Smells - Comments

page 042

  • Inappropriate Information
  • Obsolete Comment
  • Redundant Comment
  • Poorly Written Comment
  • Commented-Out-Code
slide-43
SLIDE 43

Software Craftsmanship for Non Developers

Code Smells - Environment

page 043

  • Build Requires More Than One Step
slide-44
SLIDE 44

Software Craftsmanship for Non Developers

Code Smells - Environment

page 044

  • Build Requires More Than One Step
  • Tests Require More Than One Step
slide-45
SLIDE 45

Software Craftsmanship for Non Developers

Code Smells - Functions

page 045

  • Dead Function
slide-46
SLIDE 46

Software Craftsmanship for Non Developers

Code Smells - General

page 046

  • Obvious Behavior is Unimplemented
slide-47
SLIDE 47

Software Craftsmanship for Non Developers

Code Smells - General

page 047

  • Obvious Behavior is Unimplemented
  • Incorrect Behavior at the Boundaries
slide-48
SLIDE 48

Software Craftsmanship for Non Developers

Code Smells - General

page 048

  • Obvious Behavior is Unimplemented
  • Incorrect Behavior at the Boundaries
  • Overridden Safeties
slide-49
SLIDE 49

Software Craftsmanship for Non Developers

Code Smells - General

page 049

  • Obvious Behavior is Unimplemented
  • Incorrect Behavior at the Boundaries
  • Overridden Safeties
  • Duplication (DRY – Don’t Repeat Yourself)
slide-50
SLIDE 50

Software Craftsmanship for Non Developers

Code Smells - General

page 050

  • Obvious Behavior is Unimplemented
  • Incorrect Behavior at the Boundaries
  • Overridden Safeties
  • Duplication
  • Dead Code
slide-51
SLIDE 51

Software Craftsmanship for Non Developers

Code Smells - General

page 051

  • Obvious Behavior is Unimplemented
  • Incorrect Behavior at the Boundaries
  • Overridden Safeties
  • Duplication
  • Dead Code
  • Inconsistency
slide-52
SLIDE 52

Software Craftsmanship for Non Developers

Code Smells - General

page 052

  • Obvious Behavior is Unimplemented
  • Incorrect Behavior at the Boundaries
  • Overridden Safeties
  • Duplication
  • Dead Code
  • Inconsistency
  • Clutter
slide-53
SLIDE 53

Software Craftsmanship for Non Developers

Code Smells - General

page 053

  • Obvious Behavior is Unimplemented
  • Incorrect Behavior at the Boundaries
  • Overridden Safeties
  • Duplication
  • Base Classes Depending on their Derivatives
  • Dead Code
  • Inconsistency
  • Clutter
  • Misplaced Responsibility
slide-54
SLIDE 54

Software Craftsmanship for Non Developers

Code Smells - General

page 054

  • Obvious Behavior is Unimplemented
  • Incorrect Behavior at the Boundaries
  • Overridden Safeties
  • Duplication
  • Base Classes Depending on their Derivatives
  • Dead Code
  • Inconsistency
  • Clutter
  • Misplaced Responsibility
  • Function Names Should Say What They Do

DateTime newDate = date.add(5) DateTime newDate = date.AddDays(5)

slide-55
SLIDE 55

Software Craftsmanship for Non Developers

Code Smells - General

page 055

  • Obvious Behavior is Unimplemented
  • Incorrect Behavior at the Boundaries
  • Overridden Safeties
  • Duplication
  • Base Classes Depending on their Derivatives
  • Dead Code
  • Inconsistency
  • Clutter
  • Misplaced Responsibility
  • Function Names Should Say What They Do
  • Follow Standard Conventions
slide-56
SLIDE 56

Software Craftsmanship for Non Developers

Code Smells - General

page 056

  • Replace Magic Numbers with Named Constants

3.141592653589793 3.141592753589793 3.141592753589793

slide-57
SLIDE 57

Software Craftsmanship for Non Developers

Code Smells - General

page 057

  • Replace Magic Numbers with Named Constants
  • Functions Should Do One Thing
slide-58
SLIDE 58

Software Craftsmanship for Non Developers

Code Smells - Names

page 058

  • Chose Descriptive Names
slide-59
SLIDE 59

Software Craftsmanship for Non Developers

Code Smells – Names: Choose Descriptive Names

page 059

CREATE PROCEDURE dbo.HII_Mobile_Cond_Workout_Activities_Log_View @ID INT = 0, @cond_workout_ID INT = 0 AS BEGIN SELECT al.ID, al.cond_workout_ID, al.activity, al.mins, al.cal_burn, a.Category, ai.ID AS intensity_id, ai.Intensity FROM HII_Mobile_Cond_Workout_Activities_Log al INNER JOIN HII_Cond_Activities a ON a.ID = al.activity LEFT JOIN HII_Cond_Activities_Intensity ai ON ai.Activity_ID = a.ID AND ai.ID=al.intensity WHERE al.active=1 AND (cond_workout_ID = @cond_workout_ID OR al.Id = @ID) ORDER BY al.created_date END CREATE PROCEDURE dbo.HII_Mobile_Cond_Workout_Activities_Log_View @ID INT = 0, @cond_workout_ID INT = 0 AS BEGIN SELECT al.ID, al.cond_workout_ID, al.activity, al.mins, al.cal_burn, a.Category, ai.ID AS intensity_id, ai.Intensity FROM HII_Mobile_Cond_Workout_Activities_Log al INNER JOIN HII_Cond_Activities a ON a.ID = al.activity LEFT JOIN HII_Cond_Activities_Intensity ai ON ai.Activity_ID = a.ID AND ai.ID=al.intensity WHERE al.active=1 AND (cond_workout_ID = @cond_workout_ID OR al.Id = @ID) ORDER BY al.created_date END CREATE PROCEDURE dbo.GetWorkActivitiesLog @Id INT = 0, @WorkoutId INT = 0 AS BEGIN SELECT ActivityLog.ID, ActivityLog.cond_workout_ID, ActivityLog.activity, ActivityLog.mins, ActivityLog.cal_burn, Activities.Category, Intensity.ID AS intensity_id, Intensity.Intensity FROM HII_Mobile_Cond_Workout_Activities_Log AS ActivityLog INNER JOIN HII_Cond_Activities AS Activities ON a.ID = ActivityLog.activity LEFT JOIN HII_Cond_Activities_Intensity Intensity ON Intensity.Activity_ID = a.ID AND ai.ID=ActivityLog.intensity WHERE ActivityLog.active=1 AND (ActivityLog.cond_workout_ID = @WorkoutId OR ActivtyLog.Id = @ID) ORDER BY ActivityLog.created_date END

slide-60
SLIDE 60

Software Craftsmanship for Non Developers

Code Smells - Names

page 060

  • Chose Descriptive Names
  • Avoid Encodings

intRepeat repeatCount

slide-61
SLIDE 61

Software Craftsmanship for Non Developers

Code Smells - Names

page 061

  • Chose Descriptive Names
  • Avoid Encodings
  • Names Should Describe Side-Effects

public void GetFoo() { } public void CreateAndGetFoo() { }

slide-62
SLIDE 62

Software Craftsmanship for Non Developers

Code Smells - Tests

page 062

  • Insufficient Tests
slide-63
SLIDE 63

Software Craftsmanship for Non Developers

Code Smells - Tests

page 063

  • Insufficient Tests
  • Use a Test Coverage Tool
slide-64
SLIDE 64

Software Craftsmanship for Non Developers

Code Smells - Tests

page 064

  • Insufficient Tests
  • Use a Test Coverage Tool
  • Don’t Skip Trivial Tests
slide-65
SLIDE 65

Software Craftsmanship for Non Developers

Code Smells - Tests

page 065

  • Insufficient Tests
  • Use a Test Coverage Tool
  • Don’t Skip Trivial Tests
  • Test Boundary Conditions
slide-66
SLIDE 66

Software Craftsmanship for Non Developers

Code Smells - Tests

page 066

  • Insufficient Tests
  • Use a Test Coverage Tool
  • Don’t Skip Trivial Tests
  • Test Boundary Conditions
  • Exhaustively Test Near Bugs
slide-67
SLIDE 67

Software Craftsmanship for Non Developers

Code Smells - Tests

page 067

  • Insufficient Tests
  • Use a Test Coverage Tool
  • Don’t Skip Trivial Tests
  • Test Boundary Conditions
  • Exhaustively Test Near Bugs
  • Tests Should Be Fast
slide-68
SLIDE 68

Getting More

Software Craftsmanship for Non-Developers

slide-69
SLIDE 69

Software Craftsmanship for Non Developers

Getting More – Books

page 069

slide-70
SLIDE 70

Software Craftsmanship for Non Developers

Getting More – Podcasts

page 070

slide-71
SLIDE 71

Software Craftsmanship for Non Developers

Getting More – Meetups

page 071

Tech Foundations Louisville Louisville Tech Ladies Deep Learning and AI For Louisville Derby DevOps Louisville Business Intelligence & Big Data Analytics Meetup Louisville Jenkins Area Meetup Louisville Microsoft Azure User Group Louisville Ruby Brigade Louisville Open Source Programming Meetup Group

slide-72
SLIDE 72

Software Craftsmanship for Non Developers

Getting More – Conferences

page 072

slide-73
SLIDE 73

Software Craftsmanship is about professionalism in software development.

slide-74
SLIDE 74

chadgreen@chadgreen.com chadgreen.com @ChadGreen ChadwickEGreen

slide-75
SLIDE 75

thank you.