SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
An Introduction To Software
Development Using Python
Spring Semester, 2015
Class #23:
Implementation
So What’s The Goal?
• The goal of any software development effort is to deliver
working software.
• “Implementation” happens when we transform a detailed
design into a valid program.
• This has to do with more than just writing code:
– Tested
– Debugged
– Compiled
– Built into a complete executable product
Image Credit: www.fotosearch.com
What Makes A Good
Implementation?
• Readability – can be easily read an understood by other programmers
• Maintainability – code can be easily modified and maintained
• Performance – the code should run as fast as possible
• Traceability – all code needs to be able to be traced back to a user story
• Correctness – the code needs to do what it is supposed to do
• Completeness – all system requirements must be met
Note that each of these requires a trade off. Performance optimization may
decrease the code’s readability and maintainability…
Image Credit: www.dreamstime.com
Programming Style &
Coding Guidelines
• Pretty much every software organization will have its own
coding guidelines.
• Guidelines cover such topics as naming, indentation, and
commenting styles. Many development tools can be
programmed to implement these styles.
• Most of these are not very important – it’s just a matter of
getting used to a given style. The goal is to be consistent in
order to help others later on avoid confusion when debugging
or maintaining the code.
Image Credit: www.dreamstime.com
Programming Style &
Coding Guidelines
• Guidelines should cover error messages. You want your error
messages to be clear to users but to also contain information
that programmers can use while debugging to find out where
the error message came from.
• Banning parts of a language that have been found to cause
lots of problems is also common (e.g. multiple inheritance).
Depreciated language features are also banned. Code must
compile with no warnings.
• Your goals for maintaining a good coding style are to be
consistent and to try to highlight the meaning of your code.
Image Credit: www.clipartpanda.com
Coding Style Recommendations
• Naming: one of the most important issues in
improving readability and maintainability.
– Bad names will require additional comments and may
mislead the reader
– Good names == good understanding
– Use long names for global variables and short names for
local variables
– Consistency is king: use the same word for a given concept
(“patient” not “customer”)
– Multicultural / multi-language teams may have special
challenges
Image Credit: www.clipartpanda.com
Coding Style Recommendations
• Separating Words & Capitalization: since
spaces can’t be used to separate words that
make up a variable name, different
programming languages have different
conventions
– C: lowercase with underscores: patient_name
– Java: no separation with capitalization:
patientName
Image Credit: www.clipartpanda.com
Coding Style Recommendations
• Indentation & Spacing: adding horizontal space
before a line in order to better reflect the structure
of the code
– Indentation affects both readability and maintainability
– A common style should be defined and all programmers
should follow it.
– The most important issue is consistency
– Most languages have a defacto indentation style that is
defined in the primary language reference
Image Credit: www.clipartpanda.com
Coding Style Recommendations
• Function Size: studies have shown that larger
functions are more error prone than smaller
functions
– Being able to look at an entire function at one
time helps with readability and maintainability
– Limit the size of a function to around 50 lines of
code
– This helps a function fit onto a single page
Image Credit: www.clipartbest.com
Coding Style Recommendations
• Unique Language Features: Different
languages support different features which
can be misused and need special precautions.
– Example: GOTO and multiple inheritance
– In Python, exceptions handling using TRY
EXCEPTION and FINALLY might be one such
situation.
Image Credit: www.clipartbest.com
Comments
• Comments are important
• Comments can help or hurt program readability and
maintainability.
• Two main problem with comments:
– They may distract from the code and make a section more difficult to
read
– They may be wrong
• Comments may become outdated as the code changes.
• Comments may be wrong from the start because they are
never executed/tested.
Image Credit: www.clipartpanda.com
6 Different Types Of Comments
• Repeat of the code – done by new programmers and should be avoided.
These comments waste effort and distract the user
(e.g. “increment index by 1”)
• Explanation of the code – explain what complex code does in human
language. Code that is this complex should probably be rewritten.
• Marker in the code – markers in the code indicate incomplete items,
opportunities for improvement, etc. Must be removed before production.
• Summary of the code – Comments that summarize what the code does
are helpful, but they need to be kept up-to-date
• Description of the code intent – most valuable. They describe what the
code should do, not what it does.
• External references – link code to external entities Image Credit: www.liveattherock.com
Comments Are A Trade-Off
• We need to recognize the trade-off that comments represent.
• Comments can help to clarify code and relate it to other
sources.
• They also represent some level of duplication of the code.
• It takes time to both create them and then to maintain them.
• Comment errors can be very hard to both find and correct.
Image Credit: www.fotosearch.com
Comment Dangers!
• Comments can be used to justify bad coding practices
• Programmers may be tempted to create code that is too
complicated or too hard to maintain and then add comments
to it instead of rewriting it to better coding standards.
• An alternative: code that is so well written that it documents
itself (“self documenting code”).
• Good goal, but comments still have a place in capturing the
programmer’s intent.
Image Credit: www.clipartof.com
Debugging
• Debugging is all about locating and fixing
errors in the code.
• Generally errors are found by testing, but they
can also be reported by users or code
inspections.
• Debugging is a highly iterative process.
Image Credit: www.clker.com
4 Phases In The Debugging Process
• Reproduction: Be able to reproduce the error
in a given configuration. Find out the
conditions that lead to the error by
constructing a minimal test case. Don’t care
about the code.
• May find some cases where code works
correctly.
• Always try to write simpler tests that still fail.
Image Credit: www.clker.com
4 Phases In The Debugging Process
• Localization: Finding the sections of the code
that lead to the error.
• Generally, this is the hardest part to do.
• If the reproduction phase shows a very simple
test case, then this may easier to do.
Image Credit: driverlayer.com
4 Phases In The Debugging Process
• Correction: Changing the code to fix the error.
• If you truly understand what is causing the
error, you have a good chance of being able to
fix it.
• Common mistake – trying to fix the problem
when you don’t know what it is or where it is.
– Leads to random changes
– Results in more errors
Image Credit: www.iconseeker.com
4 Phases In The Debugging Process
• Verification: Making sure that the error is
fixed.
• Make sure that no new errors were introduced
into the code.
• All too often the fix does not fix the problem,
but does cause other problems.
Image Credit: tech-kid.com
Two Types Of Errors In Programs
• Syntax Errors
– Found by the complier
– Compiler tells you what their source is
• Logic Errors
– Harder to find
– Need to understand what the code is both trying
to do and is actually doing
Image Credit: www.clker.com
Debugging Tools
• Source code comparators – show you what changed
• Extended checkers – find errors with syntax, logic, or
style
• Interactive debuggers – let you step through code
and inspect variables
• Specialty Libraries – provide extra safeguards to
detect and prevent errors
• Profiler Tools - describe pre and post conditions
Image Credit: www.clipartsfree.net
Assertions &
Defensive Programming
• Precondition – something that your code
needs in order to create correct results
• Postcondition – a condition that should hold
true after executing your code
• Assertions - statements that check a condition
and product an error if the condition is not
met (e.g. a checking account balance)
Image Credit: www.easyvectors.com
Performance Optimization
• Performance for any program is important, but…
• Optimizing for performance almost always affects code maintainability
and readability for the worse.
• Real-time systems are the exception – they are all about performance.
• Programmers often make the mistake of worrying about performance too
early in the development cycle.
– Get the code to work first and make it easy to maintain
– If the performance is unsatisfactory, then you can optimize performance – most times
this won’t be an issue.
– Most code is only executed a few times and does not impact performance
– Only a few pieces of code will have to be optimized for performance
Image Credit: www.istockphoto.com
How To Optimize Performance
• Start with a profiler tool
– Runs the program and calculates how much time is spent in each part.
– Helps you to find bottlenecks and to determine what code needs to be
optimized
• Now review and optimize only those modules that will have
an impact on performance
• After making changes, run the profiler again to determine
impact and to ensure changes actually boosted performance.
Image Credit: www.dreamstime.com
The Cost Of Optimization
• A cost / benefit analysis should be done before
performing any performance optimization.
• A programmer’s time is more expensive than
computer time – it may be cheaper to just buy faster
hardware.
• You need to weigh the increase in performance
against the decrease in maintainability and the
possibility of introducing errors.
Image Credit: www.clipartpanda.com
Refactoring
• Just like a novel can be made better by rewriting parts, so to
can your code be made better by refactoring parts of it.
• Refactoring refers to improving your code style without
altering its behavior.
• Refactoring is one of the most powerful techniques for
producing good code.
• Reasons to refactor:
– Duplicated code
– Excessively large or long functions
– Etc.
Image Credit: publicdomainvectors.org
What Do You Do When You
Refactor?
• Turn a code fragment in to a standalone function
with its own name and calls to it.
• Replace the body of a function with a new algorithm
that is clearer and which returns the same results.
• Move an algorithm from one function to another
where it makes more sense
• Divide a function into two functions.
Image Credit: publicdomainvectors.org
What We Covered Today
1. Programming style &
coding guidelines
2. Comments
3. Debugging
4. Optimization
5. Refactoring
Image Credit: http://www.tswdj.com/blog/2011/05/17/the-grooms-checklist/
What We’ll Be Covering Next Time
1. Software Support and
Maintenance
Image Credit: http://merchantblog.thefind.com/2011/01/merchant-newsletter/resolve-to-take-advantage-of-these-5-e-commerce-trends/attachment/crystal-ball-fullsize/

Weitere ähnliche Inhalte

Was ist angesagt?

Lotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 CommandmentsLotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 CommandmentsBill Buchan
 
Software development slides
Software development slidesSoftware development slides
Software development slidesiarthur
 
Software coding & testing, software engineering
Software coding & testing, software engineeringSoftware coding & testing, software engineering
Software coding & testing, software engineeringRupesh Vaishnav
 
xTreme Programming by Sejo Ćesić and Enis Zeherović
xTreme Programming by Sejo Ćesić and Enis ZeherovićxTreme Programming by Sejo Ćesić and Enis Zeherović
xTreme Programming by Sejo Ćesić and Enis ZeherovićBosnia Agile
 
Importance of the quality of code
Importance of the quality of codeImportance of the quality of code
Importance of the quality of codeShwe Yee
 
Cqrs and Event Sourcing Intro For Developers
Cqrs and Event Sourcing Intro For DevelopersCqrs and Event Sourcing Intro For Developers
Cqrs and Event Sourcing Intro For Developerswojtek_s
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and developmentAli Raza
 
Introduction to compiler interpreter
Introduction to compiler interpreterIntroduction to compiler interpreter
Introduction to compiler interpreterpoojapainter
 
An Evaluation of Pair Programming Practice
An Evaluation of Pair Programming PracticeAn Evaluation of Pair Programming Practice
An Evaluation of Pair Programming PracticeKranthi Lakum
 
Language-Oriented Business Applications
Language-Oriented Business ApplicationsLanguage-Oriented Business Applications
Language-Oriented Business ApplicationsMarkus Voelter
 
Generic Tools - Specific Languages (PhD Defense Slides)
Generic Tools - Specific Languages (PhD Defense Slides)Generic Tools - Specific Languages (PhD Defense Slides)
Generic Tools - Specific Languages (PhD Defense Slides)Markus Voelter
 
Extreme programming - a quick and agile overview !
Extreme programming - a quick and agile overview !Extreme programming - a quick and agile overview !
Extreme programming - a quick and agile overview !Vinit Kumar Singh
 
Test-driven development with Node.js
Test-driven development with Node.jsTest-driven development with Node.js
Test-driven development with Node.jsMirko Kiefer
 
Professionalism and Industry Expectations related to IT industry
Professionalism and Industry Expectations related to IT industry  Professionalism and Industry Expectations related to IT industry
Professionalism and Industry Expectations related to IT industry Tharindu Weerasinghe
 

Was ist angesagt? (20)

Lotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 CommandmentsLotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 Commandments
 
Xp Slideshow
Xp SlideshowXp Slideshow
Xp Slideshow
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
 
Software development slides
Software development slidesSoftware development slides
Software development slides
 
SitFRA - No Comment?
SitFRA - No Comment?SitFRA - No Comment?
SitFRA - No Comment?
 
Introduction
IntroductionIntroduction
Introduction
 
Software coding & testing, software engineering
Software coding & testing, software engineeringSoftware coding & testing, software engineering
Software coding & testing, software engineering
 
xTreme Programming by Sejo Ćesić and Enis Zeherović
xTreme Programming by Sejo Ćesić and Enis ZeherovićxTreme Programming by Sejo Ćesić and Enis Zeherović
xTreme Programming by Sejo Ćesić and Enis Zeherović
 
Importance of the quality of code
Importance of the quality of codeImportance of the quality of code
Importance of the quality of code
 
Cqrs and Event Sourcing Intro For Developers
Cqrs and Event Sourcing Intro For DevelopersCqrs and Event Sourcing Intro For Developers
Cqrs and Event Sourcing Intro For Developers
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and development
 
Introduction to compiler interpreter
Introduction to compiler interpreterIntroduction to compiler interpreter
Introduction to compiler interpreter
 
An Evaluation of Pair Programming Practice
An Evaluation of Pair Programming PracticeAn Evaluation of Pair Programming Practice
An Evaluation of Pair Programming Practice
 
Language-Oriented Business Applications
Language-Oriented Business ApplicationsLanguage-Oriented Business Applications
Language-Oriented Business Applications
 
Generic Tools - Specific Languages (PhD Defense Slides)
Generic Tools - Specific Languages (PhD Defense Slides)Generic Tools - Specific Languages (PhD Defense Slides)
Generic Tools - Specific Languages (PhD Defense Slides)
 
Extreme programming - a quick and agile overview !
Extreme programming - a quick and agile overview !Extreme programming - a quick and agile overview !
Extreme programming - a quick and agile overview !
 
Code Inspection
Code InspectionCode Inspection
Code Inspection
 
Test-driven development with Node.js
Test-driven development with Node.jsTest-driven development with Node.js
Test-driven development with Node.js
 
Professionalism and Industry Expectations related to IT industry
Professionalism and Industry Expectations related to IT industry  Professionalism and Industry Expectations related to IT industry
Professionalism and Industry Expectations related to IT industry
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 

Andere mochten auch

An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()Blue Elephant Consulting
 
An Introduction To Python - Tables, List Algorithms
An Introduction To Python - Tables, List AlgorithmsAn Introduction To Python - Tables, List Algorithms
An Introduction To Python - Tables, List AlgorithmsBlue Elephant Consulting
 
An Introduction To Python - Nested Branches, Multiple Alternatives
An Introduction To Python - Nested Branches, Multiple AlternativesAn Introduction To Python - Nested Branches, Multiple Alternatives
An Introduction To Python - Nested Branches, Multiple AlternativesBlue Elephant Consulting
 
An Introduction To Python - Python Midterm Review
An Introduction To Python - Python Midterm ReviewAn Introduction To Python - Python Midterm Review
An Introduction To Python - Python Midterm ReviewBlue Elephant Consulting
 
An Introduction To Software Development - Software Support and Maintenance
An Introduction To Software Development - Software Support and MaintenanceAn Introduction To Software Development - Software Support and Maintenance
An Introduction To Software Development - Software Support and MaintenanceBlue Elephant Consulting
 
An Introduction To Software Development - Architecture & Detailed Design
An Introduction To Software Development - Architecture & Detailed DesignAn Introduction To Software Development - Architecture & Detailed Design
An Introduction To Software Development - Architecture & Detailed DesignBlue Elephant Consulting
 
An Introduction To Python - Variables, Math
An Introduction To Python - Variables, MathAn Introduction To Python - Variables, Math
An Introduction To Python - Variables, MathBlue Elephant Consulting
 
An Introduction To Python - Functions, Part 2
An Introduction To Python - Functions, Part 2An Introduction To Python - Functions, Part 2
An Introduction To Python - Functions, Part 2Blue Elephant Consulting
 
An Introduction To Python - Working With Data
An Introduction To Python - Working With DataAn Introduction To Python - Working With Data
An Introduction To Python - Working With DataBlue Elephant Consulting
 

Andere mochten auch (16)

An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()
 
An Introduction To Python - Tables, List Algorithms
An Introduction To Python - Tables, List AlgorithmsAn Introduction To Python - Tables, List Algorithms
An Introduction To Python - Tables, List Algorithms
 
An Introduction To Python - Dictionaries
An Introduction To Python - DictionariesAn Introduction To Python - Dictionaries
An Introduction To Python - Dictionaries
 
An Introduction To Python - Nested Branches, Multiple Alternatives
An Introduction To Python - Nested Branches, Multiple AlternativesAn Introduction To Python - Nested Branches, Multiple Alternatives
An Introduction To Python - Nested Branches, Multiple Alternatives
 
An Introduction To Python - Python Midterm Review
An Introduction To Python - Python Midterm ReviewAn Introduction To Python - Python Midterm Review
An Introduction To Python - Python Midterm Review
 
An Introduction To Software Development - Software Support and Maintenance
An Introduction To Software Development - Software Support and MaintenanceAn Introduction To Software Development - Software Support and Maintenance
An Introduction To Software Development - Software Support and Maintenance
 
An Introduction To Python - Lists, Part 1
An Introduction To Python - Lists, Part 1An Introduction To Python - Lists, Part 1
An Introduction To Python - Lists, Part 1
 
An Introduction To Python - FOR Loop
An Introduction To Python - FOR LoopAn Introduction To Python - FOR Loop
An Introduction To Python - FOR Loop
 
An Introduction To Python - Lists, Part 2
An Introduction To Python - Lists, Part 2An Introduction To Python - Lists, Part 2
An Introduction To Python - Lists, Part 2
 
An Introduction To Python - WHILE Loop
An Introduction To  Python - WHILE LoopAn Introduction To  Python - WHILE Loop
An Introduction To Python - WHILE Loop
 
An Introduction To Software Development - Architecture & Detailed Design
An Introduction To Software Development - Architecture & Detailed DesignAn Introduction To Software Development - Architecture & Detailed Design
An Introduction To Software Development - Architecture & Detailed Design
 
An Introduction To Python - Variables, Math
An Introduction To Python - Variables, MathAn Introduction To Python - Variables, Math
An Introduction To Python - Variables, Math
 
An Introduction To Python - Functions, Part 2
An Introduction To Python - Functions, Part 2An Introduction To Python - Functions, Part 2
An Introduction To Python - Functions, Part 2
 
An Introduction To Python - Graphics
An Introduction To Python - GraphicsAn Introduction To Python - Graphics
An Introduction To Python - Graphics
 
An Introduction To Python - Files, Part 1
An Introduction To Python - Files, Part 1An Introduction To Python - Files, Part 1
An Introduction To Python - Files, Part 1
 
An Introduction To Python - Working With Data
An Introduction To Python - Working With DataAn Introduction To Python - Working With Data
An Introduction To Python - Working With Data
 

Ähnlich wie An Introduction To Software Development - Implementation

An Introduction To Software Development - Final Review
An Introduction To Software Development - Final ReviewAn Introduction To Software Development - Final Review
An Introduction To Software Development - Final ReviewBlue Elephant Consulting
 
Introducing systems analysis, design & development Concepts
Introducing systems analysis, design & development ConceptsIntroducing systems analysis, design & development Concepts
Introducing systems analysis, design & development ConceptsShafiul Azam Chowdhury
 
Topic production code
Topic production codeTopic production code
Topic production codeKavi Kumar
 
Expert Code Review best practices
Expert Code Review best practicesExpert Code Review best practices
Expert Code Review best practicesjeetendra mandal
 
Introducing Systems Analysis Design Development
Introducing Systems Analysis Design DevelopmentIntroducing Systems Analysis Design Development
Introducing Systems Analysis Design Developmentbsadd
 
Best Practices in Software Development
Best Practices in Software DevelopmentBest Practices in Software Development
Best Practices in Software DevelopmentAndré Pitombeira
 
Agile Software Development
Agile Software DevelopmentAgile Software Development
Agile Software DevelopmentAhmet Bulut
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware ProgrammingPostSharp Technologies
 
Amanda Cinnamon - Treat Your Code Like the Valuable Software It Is
Amanda Cinnamon - Treat Your Code Like the Valuable Software It IsAmanda Cinnamon - Treat Your Code Like the Valuable Software It Is
Amanda Cinnamon - Treat Your Code Like the Valuable Software It IsRehgan Avon
 
Unit_5 and Unit 6.pptx
Unit_5 and Unit 6.pptxUnit_5 and Unit 6.pptx
Unit_5 and Unit 6.pptxtaxegap762
 
Code Review
Code ReviewCode Review
Code ReviewRavi Raj
 
Twelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btechTwelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btechIIITA
 
Indy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleIndy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleikram_ahamed
 
Python: Object-oriented Testing
Python: Object-oriented TestingPython: Object-oriented Testing
Python: Object-oriented TestingDamian T. Gordon
 
Lecture3.se.pptx
Lecture3.se.pptxLecture3.se.pptx
Lecture3.se.pptxAmna Ch
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesInductive Automation
 

Ähnlich wie An Introduction To Software Development - Implementation (20)

An Introduction To Software Development - Final Review
An Introduction To Software Development - Final ReviewAn Introduction To Software Development - Final Review
An Introduction To Software Development - Final Review
 
Introducing systems analysis, design & development Concepts
Introducing systems analysis, design & development ConceptsIntroducing systems analysis, design & development Concepts
Introducing systems analysis, design & development Concepts
 
Topic production code
Topic production codeTopic production code
Topic production code
 
Expert Code Review best practices
Expert Code Review best practicesExpert Code Review best practices
Expert Code Review best practices
 
Introducing Systems Analysis Design Development
Introducing Systems Analysis Design DevelopmentIntroducing Systems Analysis Design Development
Introducing Systems Analysis Design Development
 
Best Practices in Software Development
Best Practices in Software DevelopmentBest Practices in Software Development
Best Practices in Software Development
 
Unit iv
Unit ivUnit iv
Unit iv
 
Agile Software Development
Agile Software DevelopmentAgile Software Development
Agile Software Development
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming
 
Amanda Cinnamon - Treat Your Code Like the Valuable Software It Is
Amanda Cinnamon - Treat Your Code Like the Valuable Software It IsAmanda Cinnamon - Treat Your Code Like the Valuable Software It Is
Amanda Cinnamon - Treat Your Code Like the Valuable Software It Is
 
Coding
CodingCoding
Coding
 
Unit_5 and Unit 6.pptx
Unit_5 and Unit 6.pptxUnit_5 and Unit 6.pptx
Unit_5 and Unit 6.pptx
 
Code Review
Code ReviewCode Review
Code Review
 
Java Code Quality Tools
Java Code Quality ToolsJava Code Quality Tools
Java Code Quality Tools
 
Twelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btechTwelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btech
 
Coding - SDLC Model
Coding - SDLC ModelCoding - SDLC Model
Coding - SDLC Model
 
Indy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleIndy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-mule
 
Python: Object-oriented Testing
Python: Object-oriented TestingPython: Object-oriented Testing
Python: Object-oriented Testing
 
Lecture3.se.pptx
Lecture3.se.pptxLecture3.se.pptx
Lecture3.se.pptx
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 

Kürzlich hochgeladen

Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationMJDuyan
 
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfMaximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfTechSoup
 
Latin American Revolutions, c. 1789-1830
Latin American Revolutions, c. 1789-1830Latin American Revolutions, c. 1789-1830
Latin American Revolutions, c. 1789-1830Dave Phillips
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17Celine George
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptxraviapr7
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17Celine George
 
Human-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesHuman-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesMohammad Hassany
 
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxPractical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxKatherine Villaluna
 
The Singapore Teaching Practice document
The Singapore Teaching Practice documentThe Singapore Teaching Practice document
The Singapore Teaching Practice documentXsasf Sfdfasd
 
NOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdf
NOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdfNOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdf
NOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdfSumit Tiwari
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapitolTechU
 
The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsEugene Lysak
 
Presentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphPresentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphNetziValdelomar1
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and stepobaje godwin sunday
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxDr. Santhosh Kumar. N
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxKatherine Villaluna
 

Kürzlich hochgeladen (20)

Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive Education
 
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfMaximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
 
Latin American Revolutions, c. 1789-1830
Latin American Revolutions, c. 1789-1830Latin American Revolutions, c. 1789-1830
Latin American Revolutions, c. 1789-1830
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17
 
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdfPersonal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17
 
Human-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesHuman-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming Classes
 
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxPractical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
 
The Singapore Teaching Practice document
The Singapore Teaching Practice documentThe Singapore Teaching Practice document
The Singapore Teaching Practice document
 
NOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdf
NOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdfNOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdf
NOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdf
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptx
 
The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George Wells
 
Presentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphPresentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a Paragraph
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and step
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 
M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptx
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptx
 

An Introduction To Software Development - Implementation

  • 1. An Introduction To Software Development Using Python Spring Semester, 2015 Class #23: Implementation
  • 2. So What’s The Goal? • The goal of any software development effort is to deliver working software. • “Implementation” happens when we transform a detailed design into a valid program. • This has to do with more than just writing code: – Tested – Debugged – Compiled – Built into a complete executable product Image Credit: www.fotosearch.com
  • 3. What Makes A Good Implementation? • Readability – can be easily read an understood by other programmers • Maintainability – code can be easily modified and maintained • Performance – the code should run as fast as possible • Traceability – all code needs to be able to be traced back to a user story • Correctness – the code needs to do what it is supposed to do • Completeness – all system requirements must be met Note that each of these requires a trade off. Performance optimization may decrease the code’s readability and maintainability… Image Credit: www.dreamstime.com
  • 4. Programming Style & Coding Guidelines • Pretty much every software organization will have its own coding guidelines. • Guidelines cover such topics as naming, indentation, and commenting styles. Many development tools can be programmed to implement these styles. • Most of these are not very important – it’s just a matter of getting used to a given style. The goal is to be consistent in order to help others later on avoid confusion when debugging or maintaining the code. Image Credit: www.dreamstime.com
  • 5. Programming Style & Coding Guidelines • Guidelines should cover error messages. You want your error messages to be clear to users but to also contain information that programmers can use while debugging to find out where the error message came from. • Banning parts of a language that have been found to cause lots of problems is also common (e.g. multiple inheritance). Depreciated language features are also banned. Code must compile with no warnings. • Your goals for maintaining a good coding style are to be consistent and to try to highlight the meaning of your code. Image Credit: www.clipartpanda.com
  • 6. Coding Style Recommendations • Naming: one of the most important issues in improving readability and maintainability. – Bad names will require additional comments and may mislead the reader – Good names == good understanding – Use long names for global variables and short names for local variables – Consistency is king: use the same word for a given concept (“patient” not “customer”) – Multicultural / multi-language teams may have special challenges Image Credit: www.clipartpanda.com
  • 7. Coding Style Recommendations • Separating Words & Capitalization: since spaces can’t be used to separate words that make up a variable name, different programming languages have different conventions – C: lowercase with underscores: patient_name – Java: no separation with capitalization: patientName Image Credit: www.clipartpanda.com
  • 8. Coding Style Recommendations • Indentation & Spacing: adding horizontal space before a line in order to better reflect the structure of the code – Indentation affects both readability and maintainability – A common style should be defined and all programmers should follow it. – The most important issue is consistency – Most languages have a defacto indentation style that is defined in the primary language reference Image Credit: www.clipartpanda.com
  • 9. Coding Style Recommendations • Function Size: studies have shown that larger functions are more error prone than smaller functions – Being able to look at an entire function at one time helps with readability and maintainability – Limit the size of a function to around 50 lines of code – This helps a function fit onto a single page Image Credit: www.clipartbest.com
  • 10. Coding Style Recommendations • Unique Language Features: Different languages support different features which can be misused and need special precautions. – Example: GOTO and multiple inheritance – In Python, exceptions handling using TRY EXCEPTION and FINALLY might be one such situation. Image Credit: www.clipartbest.com
  • 11. Comments • Comments are important • Comments can help or hurt program readability and maintainability. • Two main problem with comments: – They may distract from the code and make a section more difficult to read – They may be wrong • Comments may become outdated as the code changes. • Comments may be wrong from the start because they are never executed/tested. Image Credit: www.clipartpanda.com
  • 12. 6 Different Types Of Comments • Repeat of the code – done by new programmers and should be avoided. These comments waste effort and distract the user (e.g. “increment index by 1”) • Explanation of the code – explain what complex code does in human language. Code that is this complex should probably be rewritten. • Marker in the code – markers in the code indicate incomplete items, opportunities for improvement, etc. Must be removed before production. • Summary of the code – Comments that summarize what the code does are helpful, but they need to be kept up-to-date • Description of the code intent – most valuable. They describe what the code should do, not what it does. • External references – link code to external entities Image Credit: www.liveattherock.com
  • 13. Comments Are A Trade-Off • We need to recognize the trade-off that comments represent. • Comments can help to clarify code and relate it to other sources. • They also represent some level of duplication of the code. • It takes time to both create them and then to maintain them. • Comment errors can be very hard to both find and correct. Image Credit: www.fotosearch.com
  • 14. Comment Dangers! • Comments can be used to justify bad coding practices • Programmers may be tempted to create code that is too complicated or too hard to maintain and then add comments to it instead of rewriting it to better coding standards. • An alternative: code that is so well written that it documents itself (“self documenting code”). • Good goal, but comments still have a place in capturing the programmer’s intent. Image Credit: www.clipartof.com
  • 15. Debugging • Debugging is all about locating and fixing errors in the code. • Generally errors are found by testing, but they can also be reported by users or code inspections. • Debugging is a highly iterative process. Image Credit: www.clker.com
  • 16. 4 Phases In The Debugging Process • Reproduction: Be able to reproduce the error in a given configuration. Find out the conditions that lead to the error by constructing a minimal test case. Don’t care about the code. • May find some cases where code works correctly. • Always try to write simpler tests that still fail. Image Credit: www.clker.com
  • 17. 4 Phases In The Debugging Process • Localization: Finding the sections of the code that lead to the error. • Generally, this is the hardest part to do. • If the reproduction phase shows a very simple test case, then this may easier to do. Image Credit: driverlayer.com
  • 18. 4 Phases In The Debugging Process • Correction: Changing the code to fix the error. • If you truly understand what is causing the error, you have a good chance of being able to fix it. • Common mistake – trying to fix the problem when you don’t know what it is or where it is. – Leads to random changes – Results in more errors Image Credit: www.iconseeker.com
  • 19. 4 Phases In The Debugging Process • Verification: Making sure that the error is fixed. • Make sure that no new errors were introduced into the code. • All too often the fix does not fix the problem, but does cause other problems. Image Credit: tech-kid.com
  • 20. Two Types Of Errors In Programs • Syntax Errors – Found by the complier – Compiler tells you what their source is • Logic Errors – Harder to find – Need to understand what the code is both trying to do and is actually doing Image Credit: www.clker.com
  • 21. Debugging Tools • Source code comparators – show you what changed • Extended checkers – find errors with syntax, logic, or style • Interactive debuggers – let you step through code and inspect variables • Specialty Libraries – provide extra safeguards to detect and prevent errors • Profiler Tools - describe pre and post conditions Image Credit: www.clipartsfree.net
  • 22. Assertions & Defensive Programming • Precondition – something that your code needs in order to create correct results • Postcondition – a condition that should hold true after executing your code • Assertions - statements that check a condition and product an error if the condition is not met (e.g. a checking account balance) Image Credit: www.easyvectors.com
  • 23. Performance Optimization • Performance for any program is important, but… • Optimizing for performance almost always affects code maintainability and readability for the worse. • Real-time systems are the exception – they are all about performance. • Programmers often make the mistake of worrying about performance too early in the development cycle. – Get the code to work first and make it easy to maintain – If the performance is unsatisfactory, then you can optimize performance – most times this won’t be an issue. – Most code is only executed a few times and does not impact performance – Only a few pieces of code will have to be optimized for performance Image Credit: www.istockphoto.com
  • 24. How To Optimize Performance • Start with a profiler tool – Runs the program and calculates how much time is spent in each part. – Helps you to find bottlenecks and to determine what code needs to be optimized • Now review and optimize only those modules that will have an impact on performance • After making changes, run the profiler again to determine impact and to ensure changes actually boosted performance. Image Credit: www.dreamstime.com
  • 25. The Cost Of Optimization • A cost / benefit analysis should be done before performing any performance optimization. • A programmer’s time is more expensive than computer time – it may be cheaper to just buy faster hardware. • You need to weigh the increase in performance against the decrease in maintainability and the possibility of introducing errors. Image Credit: www.clipartpanda.com
  • 26. Refactoring • Just like a novel can be made better by rewriting parts, so to can your code be made better by refactoring parts of it. • Refactoring refers to improving your code style without altering its behavior. • Refactoring is one of the most powerful techniques for producing good code. • Reasons to refactor: – Duplicated code – Excessively large or long functions – Etc. Image Credit: publicdomainvectors.org
  • 27. What Do You Do When You Refactor? • Turn a code fragment in to a standalone function with its own name and calls to it. • Replace the body of a function with a new algorithm that is clearer and which returns the same results. • Move an algorithm from one function to another where it makes more sense • Divide a function into two functions. Image Credit: publicdomainvectors.org
  • 28. What We Covered Today 1. Programming style & coding guidelines 2. Comments 3. Debugging 4. Optimization 5. Refactoring Image Credit: http://www.tswdj.com/blog/2011/05/17/the-grooms-checklist/
  • 29. What We’ll Be Covering Next Time 1. Software Support and Maintenance Image Credit: http://merchantblog.thefind.com/2011/01/merchant-newsletter/resolve-to-take-advantage-of-these-5-e-commerce-trends/attachment/crystal-ball-fullsize/

Hinweis der Redaktion

  1. New name for the class I know what this means Technical professionals are who get hired This means much more than just having a narrow vertical knowledge of some subject area. It means that you know how to produce an outcome that I value. I’m willing to pay you to do that.