best practices seeqnce - 2324-02-2012

113
Best Practices Youssef Chaker February 23-24 2012 Presented by Monday, February 27, 12

Post on 19-Oct-2014

2.052 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Best practices   seeqnce - 2324-02-2012

Best PracticesYoussef Chaker

February 23-24 2012

Presented by

Monday, February 27, 12

Page 2: Best practices   seeqnce - 2324-02-2012

Day 1

The Why, What and How

Monday, February 27, 12

Page 3: Best practices   seeqnce - 2324-02-2012

but first...

Who am I and why should you listen to me?

Monday, February 27, 12

Page 4: Best practices   seeqnce - 2324-02-2012

Monday, February 27, 12

Page 5: Best practices   seeqnce - 2324-02-2012

Why?

Monday, February 27, 12

Page 6: Best practices   seeqnce - 2324-02-2012

Developers are not code monkeys

Monday, February 27, 12

Page 7: Best practices   seeqnce - 2324-02-2012

Better relationships with customers and business dev people

Monday, February 27, 12

Page 8: Best practices   seeqnce - 2324-02-2012

Professionalism...remember that one?

Monday, February 27, 12

Page 9: Best practices   seeqnce - 2324-02-2012

<warning>

Monday, February 27, 12

Page 10: Best practices   seeqnce - 2324-02-2012

Ariane 5 Flight 501

Flight 501, which took place on June 4, 1996, was the first, and unsuccessful, test flight of the European Ariane 5 expendable launch system.

Due to an error in the software design (inadequate protection from integer overflow), the rocket veered off its flight path 37 seconds after launch and was destroyed by its automated self-destruct system when high aerodynamic forces caused the core of the vehicle to disintegrate. It is one of the most infamous computer bugs in history.The breakup caused the loss of four Cluster mission spacecraft, resulting in a loss of more than US$370 million

10

Monday, February 27, 12

Page 11: Best practices   seeqnce - 2324-02-2012

Therac-25

The Therac-25 was a radiation therapy machine produced by Atomic Energy of Canada Limited (AECL) [...]. It was involved with at least six accidents between 1985 and 1987, in which patients were given massive overdoses of radiation, approximately 100 times the intended dose. Three of the six patients died as a direct consequence. These accidents highlighted the dangers of software control of safety-critical systems, and they have become a standard case study in health informatics and software engineering.[...]A commission has concluded that the primary reason should be attributed to the bad software design and development practices, and not explicitly to several coding errors that were found. In particular, the software was designed so that it was relatively impossible to test it in a clean automated way.

Monday, February 27, 12

Page 12: Best practices   seeqnce - 2324-02-2012

More online: http://en.wikipedia.org/wiki/List_of_software_bugs

Monday, February 27, 12

Page 13: Best practices   seeqnce - 2324-02-2012

</warning>

Monday, February 27, 12

Page 14: Best practices   seeqnce - 2324-02-2012

what not to do!

Monday, February 27, 12

Page 15: Best practices   seeqnce - 2324-02-2012

source: http://thedailywtf.com/Articles/Flexible-Spending.aspx#pic2Monday, February 27, 12

Page 16: Best practices   seeqnce - 2324-02-2012

Shortcuts

Quick & dirty

Cutting Corners

Monday, February 27, 12

Page 17: Best practices   seeqnce - 2324-02-2012

Live Coding

Monday, February 27, 12

Page 18: Best practices   seeqnce - 2324-02-2012

A Simple Prayer

Lord, please protect our biggest VPS from Eric's installed software

- including but not limited to plugins and gems written by 11 year old  Pakistanis.

May his apps be well behaved and may they be considerate of CPU and RAM.

Lord, if any of these terms are unfamiliar to you, look them up on Wikipedia.

Peace be to all other apps and all other VPSs on the same physical server.

Amen.

Monday, February 27, 12

Page 19: Best practices   seeqnce - 2324-02-2012

what to do?

Monday, February 27, 12

Page 20: Best practices   seeqnce - 2324-02-2012

What You Already Know• Follow coding standards.

• Be consistent. If you do operations in a specific way, do that kind of operations in the same way (e.g. defining variable/method/class names, parenthesis usage etc.).

• More code does not mean better code. Keep it simple and reduce complexity.

• Catch specific exceptions instead of highest level class 'Exception'. This will provide understandability and more performance.

• Use understandable and long names for variables. Loop variable names can be i, j, k, index etc., local variable names must be longer than loop variables, parameter names must be longer than local variables and static variable names must be longer than parameters; proportional with scope size.

• Don't use magic numbers and strings directly in the code. Use constants. This method provides more modularity and understandability.

• Use understandable comments. Bad comment is worse than no comment.

• Method names must include "what is done by this method" information.

Monday, February 27, 12

Page 21: Best practices   seeqnce - 2324-02-2012

• Package related classes (that changed together and/or used together) together.

• Use positive conditionals. Readability of positive conditionals are better than negative ones.

• Use dependency injection to manage too many singletons.

• Use exceptions only for catching exceptions, not for control flow. Think as required and perform control flow with control statements/conditionals.

• Don't use so many arguments with methods. Keep the number at most 8-10. If more is required, review your design.

• Don't use method alternatives with boolean flag variables (public void someMethod(bool flag)). Write more than one method for each flag condition.

• Think twice before defining a method as static and be sure if you really need to. Static methods are harder to manage.

• Avoid using methods with reference parameters. Use multi attributed object parameters instead.

• Number of interface methods must be minimized to decrease coupling/dependency.

Monday, February 27, 12

Page 22: Best practices   seeqnce - 2324-02-2012

What School Did not Teach You

• Deliver often, get user feedback in a continuous regular and intense flow

• Don't try to be too much smarter than your customer, just enough

• Do only whats needed to deliver the functionality expected in each step in the best possible way

• Make sure you love and care about your work, code, user and customer

Monday, February 27, 12

Page 23: Best practices   seeqnce - 2324-02-2012

Questions?Comments?Concerns?

Monday, February 27, 12

Page 24: Best practices   seeqnce - 2324-02-2012

“Motivational products don’t

work.But our

Demotivators® products don’t

work even better.”

Monday, February 27, 12

Page 25: Best practices   seeqnce - 2324-02-2012

TDDTest Driven Development

Monday, February 27, 12

Page 26: Best practices   seeqnce - 2324-02-2012

Write TestsLet them fail

Monday, February 27, 12

Page 27: Best practices   seeqnce - 2324-02-2012

Write the minimal code that will make

your tests pass

Monday, February 27, 12

Page 28: Best practices   seeqnce - 2324-02-2012

Write More Tests

Monday, February 27, 12

Page 29: Best practices   seeqnce - 2324-02-2012

rinse lather repeat

Monday, February 27, 12

Page 30: Best practices   seeqnce - 2324-02-2012

source: http://www.agiledata.org/essays/tdd.html

Monday, February 27, 12

Page 31: Best practices   seeqnce - 2324-02-2012

= TFDTest First Development

Monday, February 27, 12

Page 32: Best practices   seeqnce - 2324-02-2012

TDD = x + TFD

any guesses to what x is?

Monday, February 27, 12

Page 33: Best practices   seeqnce - 2324-02-2012

Refactor

Monday, February 27, 12

Page 34: Best practices   seeqnce - 2324-02-2012

source: http://www.agiledata.org/essays/tdd.htmlMonday, February 27, 12

Page 35: Best practices   seeqnce - 2324-02-2012

source: http://www.despair.com/overconfidence.htmlMonday, February 27, 12

Page 36: Best practices   seeqnce - 2324-02-2012

Monday, February 27, 12

Page 37: Best practices   seeqnce - 2324-02-2012

TDD ||\/

less fluff, more stuff

Monday, February 27, 12

Page 38: Best practices   seeqnce - 2324-02-2012

Frameworks RSpecxUnit

for more: http://en.wikipedia.org/wiki/List_of_unit_testing_frameworksMonday, February 27, 12

Page 39: Best practices   seeqnce - 2324-02-2012

Monday, February 27, 12

Page 40: Best practices   seeqnce - 2324-02-2012

Monday, February 27, 12

Page 41: Best practices   seeqnce - 2324-02-2012

bash-3.2$ bundle exec rake spec

..................................................................................*.....................................................................................................

.......................................................

Pending: GroupVenue add some examples to (or delete) /Users/ychaker/Dev/jogabo/spec/models/group_venue_spec.rb # No reason given # ./spec/models/group_venue_spec.rb:4

Finished in 3 minutes 43.24 seconds239 examples, 0 failures, 1 pending

.................................................................................................................................................................

.............................................................................

Finished in 3 minutes 49.69 seconds238 examples, 0 failures

Monday, February 27, 12

Page 42: Best practices   seeqnce - 2324-02-2012

Break15 minutes

Monday, February 27, 12

Page 43: Best practices   seeqnce - 2324-02-2012

and we’re back...

Monday, February 27, 12

Page 44: Best practices   seeqnce - 2324-02-2012

Question:

Why are you writing code?What’s the purpose of your code?

Monday, February 27, 12

Page 45: Best practices   seeqnce - 2324-02-2012

Answer:

solve Business problems

produce a certain Behavior

Monday, February 27, 12

Page 46: Best practices   seeqnce - 2324-02-2012

Then maybe we should do Behavior Driven

Development!

Monday, February 27, 12

Page 47: Best practices   seeqnce - 2324-02-2012

D’oh!

Monday, February 27, 12

Page 48: Best practices   seeqnce - 2324-02-2012

source: http://www.agiledata.org/essays/tdd.htmlMonday, February 27, 12

Page 49: Best practices   seeqnce - 2324-02-2012

Disclaimer:The RSpec example was actually a BDD

example

Monday, February 27, 12

Page 50: Best practices   seeqnce - 2324-02-2012

User Stories

Monday, February 27, 12

Page 51: Best practices   seeqnce - 2324-02-2012

Features

Monday, February 27, 12

Page 52: Best practices   seeqnce - 2324-02-2012

Scenarios

Monday, February 27, 12

Page 53: Best practices   seeqnce - 2324-02-2012

Monday, February 27, 12

Page 54: Best practices   seeqnce - 2324-02-2012

Integration Testing

Monday, February 27, 12

Page 55: Best practices   seeqnce - 2324-02-2012

cucumber demo

Monday, February 27, 12

Page 56: Best practices   seeqnce - 2324-02-2012

Continuous Integration (CI)

Monday, February 27, 12

Page 57: Best practices   seeqnce - 2324-02-2012

Hudson

Monday, February 27, 12

Page 58: Best practices   seeqnce - 2324-02-2012

Monday, February 27, 12

Page 59: Best practices   seeqnce - 2324-02-2012

Monday, February 27, 12

Page 60: Best practices   seeqnce - 2324-02-2012

standup, stretch your legs

Monday, February 27, 12

Page 61: Best practices   seeqnce - 2324-02-2012

if there’s anything I want you to take away from today is this last

part

Monday, February 27, 12

Page 63: Best practices   seeqnce - 2324-02-2012

Distributed model(examples)

• Fossil

• git

• Mercurial

Monday, February 27, 12

Page 64: Best practices   seeqnce - 2324-02-2012

delete, don’t comment out

Monday, February 27, 12

Page 65: Best practices   seeqnce - 2324-02-2012

Always use source control system even if the project has only

one developer

Monday, February 27, 12

Page 66: Best practices   seeqnce - 2324-02-2012

git demo

Monday, February 27, 12

Page 67: Best practices   seeqnce - 2324-02-2012

Questions?Comments?Concerns?

Monday, February 27, 12

Page 68: Best practices   seeqnce - 2324-02-2012

Monday, February 27, 12

Page 69: Best practices   seeqnce - 2324-02-2012

Day 2

Go Beyond

Monday, February 27, 12

Page 70: Best practices   seeqnce - 2324-02-2012

Activity

Monday, February 27, 12

Page 71: Best practices   seeqnce - 2324-02-2012

Be Agile, Be Happy

Monday, February 27, 12

Page 72: Best practices   seeqnce - 2324-02-2012

Agile ManifestoWe are uncovering better ways of developingsoftware by doing it and helping others do it.Through this work we have come to value:

Individuals and interactions over processes & toolsWorking software over comprehensive documentation

Customer collaboration over contract negotiationResponding to change over following a plan

That is, while there is value in the items onthe right, we value the items on the left more.

Monday, February 27, 12

Page 73: Best practices   seeqnce - 2324-02-2012

Let’s go closer

Monday, February 27, 12

Page 74: Best practices   seeqnce - 2324-02-2012

Agile ModelingAgile Unified Process (AUP)

Dynamic Systems Development Method (DSDM)Essential Unified Process (EssUP)

Extreme Programming (XP)Feature Driven Development (FDD)

Open Unified Process (OpenUP)Scrum

Velocity tracking

Monday, February 27, 12

Page 75: Best practices   seeqnce - 2324-02-2012

Scrum

Monday, February 27, 12

Page 76: Best practices   seeqnce - 2324-02-2012

Monday, February 27, 12

Page 77: Best practices   seeqnce - 2324-02-2012

iterative, incremental framework for project management and agile software development.

Monday, February 27, 12

Page 78: Best practices   seeqnce - 2324-02-2012

Monday, February 27, 12

Page 79: Best practices   seeqnce - 2324-02-2012

2-4 week sprints

Monday, February 27, 12

Page 80: Best practices   seeqnce - 2324-02-2012

“ScrumMaster”, who maintains the processes

(typically in lieu of a project manager)

Monday, February 27, 12

Page 81: Best practices   seeqnce - 2324-02-2012

“Product Owner”, who represents the

stakeholders, represents the business

Monday, February 27, 12

Page 82: Best practices   seeqnce - 2324-02-2012

“Team”, a cross-functional group of about 7 people who do the actual

analysis, design, implementation, testing,

etc.

Monday, February 27, 12

Page 83: Best practices   seeqnce - 2324-02-2012

Pigs & ChickensA pig and a chicken are walking down a road. The chicken

looks at the pig and says, “Hey, why don’t we open a restaurant?”

The pig looks back at the chicken and says, “Good idea, what do you want to call it?”

The chicken thinks about it and says, “Why don’t we call it ‘Ham and Eggs’?”

“I don’t think so,” says the pig, “I’d be committed, but you’d only be involved.”

Monday, February 27, 12

Page 84: Best practices   seeqnce - 2324-02-2012

Key Notions

• (Sprint) Planning

• Backlog*

• (Sprint) Burn down

• Daily Standups

• + more...

*Backlog: Product/Sprint backlog or any list of tasksMonday, February 27, 12

Page 85: Best practices   seeqnce - 2324-02-2012

Scrum for Kids

Monday, February 27, 12

Page 86: Best practices   seeqnce - 2324-02-2012

YES! I’m serious

Monday, February 27, 12

Page 87: Best practices   seeqnce - 2324-02-2012

The Meads

Monday, February 27, 12

Page 88: Best practices   seeqnce - 2324-02-2012

Introducing the Scrum Board

Monday, February 27, 12

Page 89: Best practices   seeqnce - 2324-02-2012

The Pughs

Monday, February 27, 12

Page 90: Best practices   seeqnce - 2324-02-2012

The Board (again)

Monday, February 27, 12

Page 91: Best practices   seeqnce - 2324-02-2012

The Toyota way

Monday, February 27, 12

Page 92: Best practices   seeqnce - 2324-02-2012

The Right Process Will Produce the Right Results

1. Create continuous process flow to bring problems to the surface.

2. Use the "pull" system to avoid overproduction.

3. Level out the workload (heijunka). (Work like the tortoise, not the hare.)

4. Build a culture of stopping to fix problems, to get quality right from the [start].

5. Standardized tasks are the foundation for continuous improvement and employee empowerment.

6. Use visual control so no problems are hidden.

7. Use only reliable, thoroughly tested technology that serves your people and processes.

Monday, February 27, 12

Page 93: Best practices   seeqnce - 2324-02-2012

Add Value to the Organization by Developing Your People and Partners

1. Grow leaders who thoroughly understand the work, live the philosophy, and teach it to others.

2. Develop exceptional people and teams who follow your company's philosophy.

3. Respect your extended network of partners and suppliers by challenging them and helping them improve.

Monday, February 27, 12

Page 94: Best practices   seeqnce - 2324-02-2012

Continuously Solving Root Problems Drives Organizational Learning

1. Go and see for yourself to thoroughly understand the situation (Genchi Genbutsu, 現地現物);

2. Make decisions slowly by consensus, thoroughly considering all options (Nemawashi, 根回し);

implement decisions rapidly;

3. Become a learning organization through relentless reflection (Hansei, 反省) and continuous

improvement (Kaizen, 改善).Monday, February 27, 12

Page 95: Best practices   seeqnce - 2324-02-2012

Break15 minutes

Monday, February 27, 12

Page 96: Best practices   seeqnce - 2324-02-2012

and we’re back...

Monday, February 27, 12

Page 97: Best practices   seeqnce - 2324-02-2012

Monday, February 27, 12

Page 98: Best practices   seeqnce - 2324-02-2012

Activity

Monday, February 27, 12

Page 99: Best practices   seeqnce - 2324-02-2012

Sprint Planning + Scrum Poker

Monday, February 27, 12

Page 100: Best practices   seeqnce - 2324-02-2012

Daily Standups

Short: less than 15 minutes

What did I do yesterday?What am I doing today?What are my obstacles?

Monday, February 27, 12

Page 101: Best practices   seeqnce - 2324-02-2012

Stay FlexibleStay Lean

Monday, February 27, 12

Page 102: Best practices   seeqnce - 2324-02-2012

Retrospectives

Monday, February 27, 12

Page 103: Best practices   seeqnce - 2324-02-2012

Monday, February 27, 12

Page 104: Best practices   seeqnce - 2324-02-2012

Monday, February 27, 12

Page 105: Best practices   seeqnce - 2324-02-2012

Pair Programming

Monday, February 27, 12

Page 106: Best practices   seeqnce - 2324-02-2012

Monday, February 27, 12

Page 107: Best practices   seeqnce - 2324-02-2012

Questions?Comments?Concerns?

Monday, February 27, 12

Page 108: Best practices   seeqnce - 2324-02-2012

Bonus

Monday, February 27, 12

Page 109: Best practices   seeqnce - 2324-02-2012

Lean Startup

Monday, February 27, 12

Page 110: Best practices   seeqnce - 2324-02-2012

Screen

Monday, February 27, 12

Page 111: Best practices   seeqnce - 2324-02-2012

You have now learnt the basic of software

craftsmanship

Monday, February 27, 12

Page 112: Best practices   seeqnce - 2324-02-2012

References• Fowler, Martin. The New Methodology: http://martinfowler.com/articles/newMethodology.html

• Wikipedia. Agile Software Development: http://en.wikipedia.org/wiki/Agile_software_development

• Manifesto for Agile Software Development: http://agilemanifesto.org/

• Wikipedia. Scrum (development): http://en.wikipedia.org/wiki/Scrum_(development)

• Wikipedia. Ariane 5 Flight 501: http://en.wikipedia.org/wiki/Ariane_5_Flight_501

• Ariane 5 Failure, Full Report: http://sunnyday.mit.edu/accidents/Ariane5accidentreport.html

• Wikipedia. Tehrac-25: http://en.wikipedia.org/wiki/Therac-25

• Wikipedia. List of software bugs: http://en.wikipedia.org/wiki/List_of_software_bugs

• Rails Maturity Models: http://railsmaturitymodels.com/practices

• Scrum For Kids http://scrumforkids.com/

• Toyota Production System http://en.wikipedia.org/wiki/Toyota_Production_System

• The Toyota Way http://en.wikipedia.org/wiki/The_Toyota_Way

• Manifesto for Software Craftsmanship http://manifesto.softwarecraftsmanship.org/

• The Lean Startup http://theleanstartup.com/

• Cucumber-Rails https://github.com/cucumber/cucumber-rails

• Gherkin https://github.com/cucumber/cucumber/wiki/Gherkin

Monday, February 27, 12

Page 113: Best practices   seeqnce - 2324-02-2012

Contact

@ychaker

http://youhoo.im

http://linked.com/in/ychaker

Monday, February 27, 12