Programming practises and project management for professionnal software development
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Programming practises and project management for professionnal software development

on

  • 251 views

par Sébastien Jodogne, 28 mai 2013

par Sébastien Jodogne, 28 mai 2013

Statistics

Views

Total Views
251
Views on SlideShare
251
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Programming practises and project management for professionnal software development Presentation Transcript

  • 1. Introduction Best Programming Practices Software Quality Project Management Summary Programming Practices and Project Management for Professional Software Development Sébastien Jodogne CHU of Liège Interfaces-Entreprises ULg, May 28th, 2013 1 / 34
  • 2. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 3. Introduction Best Programming Practices Software Quality Project Management Summary Who Am I? PhD in Computer Science, ULg. Domains of interest: Image Processing, Machine Learning, High-Performance Computing, Theoretical Computer Science. 5-year professional experience in private companies: CCTV – Closed Circuit Television (Secosys, Euresys), Machine Vision (Euresys), Broadcasting (EVS). Now: Medical imaging engineer in the Department of Medical Physics at the CHU of Liège. This talk: Industrial practices for compiled languages. 2 / 34
  • 4. Introduction Best Programming Practices Software Quality Project Management Summary Case Study Summary Lightweight, scriptable server for medical imaging. Open-source (GPLv3). Developed with an industrial methodology. Main languages: Core: C++. GUI: HTML5, JavaScript. 3 / 34
  • 5. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 6. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 7. Introduction Best Programming Practices Software Quality Project Management Summary Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations Put Your Code in Revision Control Software Advantages Keep track of all the changes to the code. Share across multiple computers, with multiple collaborators. Track the various versions of the software (“tagging”). Backup (recover deleted or modified files). Avoid the ZIP mess (which version is the latest one?). Candidates 1 Mercurial. 2 Git (more adapted to geeks). 3 Subversion (becomes legacy). 4 / 34
  • 8. Introduction Best Programming Practices Software Quality Project Management Summary Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations Questions When Starting a Project Choose a licensing model (cf. Jérémie Fays). GPLv3 is the de-facto choice. Choose a software forge: For closed-source (private): BitBucket, SourceForge. For open-source (public): GitHub, Google Code. For confidential code (medical data, spin-off): ??? 5 / 34
  • 9. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 10. Introduction Best Programming Practices Software Quality Project Management Summary Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations Choose (and Stick to) a Coding Style 6 / 34
  • 11. Introduction Best Programming Practices Software Quality Project Management Summary Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations Documentation Document functions and classes in the source code ⇒ Doxygen (C/C++), Javadoc (Java), XML (C#). Document architecture and algorithms elsewhere (separate files or Wiki). Don’t forget the User Manual (PDF or Wiki). Be verbose and use explicit names (possibly long) for variables, functions and methods. ⇒ “Self-Documented Code”. Do not reuse variables and introduce them only when they are needed (not at the top of a function as in C). 7 / 34
  • 12. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 13. Introduction Best Programming Practices Software Quality Project Management Summary Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations Don’t Reinvent the (Squared) Wheel Use third-party libraries. ⇒ Know your ecosystem (language, frameworks, StackOverflow). Recommended libraries for C++: STL, Boost, SQLite, Qt. . . Caveats: Minimize the number of dependencies! Avoid heavyweight, not supported or “exotic” libraries. Pay attention to portability (Windows, Mac OS). License compatibility. 8 / 34
  • 14. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 15. Introduction Best Programming Practices Software Quality Project Management Summary Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations Anti-Patterns (Don’ts!) Programs whose structure is barely comprehensible, especially because of misuse of code structures (especially GOTO). 9 / 34
  • 16. Introduction Best Programming Practices Software Quality Project Management Summary Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations Anti-Patterns (Don’ts!) Classes not properly encapsulated, thus permitting unrestricted access to their internals. 10 / 34
  • 17. Introduction Best Programming Practices Software Quality Project Management Summary Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations Anti-Patterns (Don’ts!) An object that knows too much or does too much. 11 / 34
  • 18. Introduction Best Programming Practices Software Quality Project Management Summary Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations Anti-Patterns (Don’ts!) Conclusions Learn and recognize bad software architectures. Inventories do exist! Lasagna code, Magic numbers, Poltergeists, Error hiding. . . [Antipatterns, Code smells, Fifth-System Effect] 12 / 34
  • 19. Introduction Best Programming Practices Software Quality Project Management Summary Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations Design Patterns (Do’s!) Recurring solutions to common problems in software design. 13 / 34
  • 20. Introduction Best Programming Practices Software Quality Project Management Summary Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations Design Patterns (Do’s!) Basic Philosophy Uncouple the software components by adding abstractions (“Java interfaces”), thanks to object-oriented programming. [Wikipedia, Head First Design Patterns] Some Common Patterns Singleton. Factory. Observer. Model-View-Controller (aka. separate GUI and core). 14 / 34
  • 21. Introduction Best Programming Practices Software Quality Project Management Summary Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations RAII — Resource Acquisition Is Initialization Most useful design pattern for C++. Automatic release of a resource on leaving scope or on exception ⇒ Never any leak! Applicable to memory allocation, I/O, multithreading. . . class FileWriter { private: FILE* fp_; public: FileWriter(const char* filename) { fp_ = fopen(filename, "w"); } ~FileWriter() { printf("Closing filen"); fclose(fp_); } }; void Demo1() { FileWriter w1("/tmp/hello.txt"); // Leaving scope => closing "w1.fp_" } void Demo2() { FileWriter w2("/tmp/hello.txt"); throw std::runtime_error("Sorry guy"); // Exception => closing "w2.fp_" } 15 / 34
  • 22. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 23. Introduction Best Programming Practices Software Quality Project Management Summary Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations Other Recommendations 1 KISS (“Keep it simple, stupid”) — A code is written once, but read many times by different people! 2 DRY (“Don’t repeat yourself”) — Implement some computation at a single place to ensure consistency. 3 “Premature optimization is the root of all evil” [D. Knuth]. 4 Use exceptions, never return error codes (except in C). 5 Use a build system (CMake, SCons or Visual Studio). 6 Windows-only: Do not create DLL and favor static linking, except if you know what you are doing (ABI, DLL hell)! Learn debugging tools: 7 Debuggers (Visual Studio, Eclipse, gdb. . . ). Linux-only: Valgrind (memory leaks, access violations. . . ). 16 / 34
  • 24. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 25. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 26. Introduction Best Programming Practices Software Quality Project Management Summary Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing What is Legacy Code? Legacy code is defined as code without tests. ⇓ Impossible to know when things get broken (i.e. to detect regressions). ⇓ Impossible to refactor. 17 / 34
  • 27. Introduction Best Programming Practices Software Quality Project Management Summary Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing “Testing is up to the Testers and the Users!” 18 / 34
  • 28. Introduction Best Programming Practices Software Quality Project Management Summary Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing “Testing is up to the Testers and the Users!” Really? Bugs detected at the code level are: Easier to understand, Easier to reproduce, Easier and cheaper to fix, More contained. ⇓ Software engineers are part of the testing process! 18 / 34
  • 29. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 30. Introduction Best Programming Practices Software Quality Project Management Summary Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing Assertion-Driven Testing (aka. Invariants/Preconditions) #include <assert.h> #include <stdio.h> int factorial(int value) { assert(value >= 0); if (value == 0) return 1; else return value * factorial(value - 1); } int main() { printf("%dn", factorial(-5)); /* => crash */ } 19 / 34
  • 31. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 32. Introduction Best Programming Practices Software Quality Project Management Summary Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing Unit Testing int main() { printf("%dn", printf("%dn", printf("%dn", printf("%dn", printf("%dn", printf("%dn", } factorial(0)); factorial(1)); factorial(2)); factorial(3)); factorial(4)); factorial(5)); /* /* /* /* /* /* 1 1 2 6 24 120 */ */ */ */ */ */ 20 / 34
  • 33. Introduction Best Programming Practices Software Quality Project Management Summary Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing Unit Testing int main() { printf("%dn", printf("%dn", printf("%dn", printf("%dn", printf("%dn", printf("%dn", } factorial(0)); factorial(1)); factorial(2)); factorial(3)); factorial(4)); factorial(5)); /* /* /* /* /* /* 1 1 2 6 24 120 */ */ */ */ */ */ ⇒ TEST(Example, Factorial) { ASSERT_EQ(1, factorial(0)); ASSERT_EQ(1, factorial(1)); ASSERT_EQ(2, factorial(2)); ASSERT_EQ(6, factorial(3)); ASSERT_EQ(24, factorial(4)); ASSERT_EQ(120, factorial(5)); } 20 / 34
  • 34. Introduction Best Programming Practices Software Quality Project Management Summary Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing Unit Testing int main() { printf("%dn", printf("%dn", printf("%dn", printf("%dn", printf("%dn", printf("%dn", } factorial(0)); factorial(1)); factorial(2)); factorial(3)); factorial(4)); factorial(5)); /* /* /* /* /* /* 1 1 2 6 24 120 */ */ */ */ */ */ ⇒ TEST(Example, Factorial) { ASSERT_EQ(1, factorial(0)); ASSERT_EQ(1, factorial(1)); ASSERT_EQ(2, factorial(2)); ASSERT_EQ(6, factorial(3)); ASSERT_EQ(24, factorial(4)); ASSERT_EQ(120, factorial(5)); } Basic Idea Accumulate a database of tests! 20 / 34
  • 35. Introduction Best Programming Practices Software Quality Project Management Summary Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing Unit Testing In Practice Use a unit testing framework (e.g. Google Test). Move your main() tests as unit tests. Keep your unit tests small and fast. Add unit tests each time a function or a class is added. Add an unit test for each solved bug. Execute the unit tests as a step of the build process! Even better: Write tests before writing the code (aka. TDD — Test-Driven Development). 21 / 34
  • 36. Introduction Best Programming Practices Software Quality Project Management Summary Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing Continuous Integration Server (Build + Unit tests) 22 / 34
  • 37. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 38. Introduction Best Programming Practices Software Quality Project Management Summary Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing Different Flavors of Quality Assurance System testing Integration testing Unit testing Hardware/OS Executable Classes Functions 23 / 34
  • 39. Introduction Best Programming Practices Software Quality Project Management Summary Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing Integration Tests “End-to-end” tests on the final binaries (black box). Typically less automated and much more lengthy than unit tests (white box). Possible approaches: 1 2 3 Inject stimuli, compare outputs with expected results. GUI automation testing. Challenge the API (cf. Orthanc). Run integration tests (at least) before each release, or even better as part of the nightly builds. System Tests At last, the testing team makes user-level tests. 24 / 34
  • 40. Introduction Best Programming Practices Software Quality Project Management Summary Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing Issue Tracker: Link between Engineers, Testers and Users Common Choices Bugzilla, JIRA, FogBugz, Redmine, Trac. Often integrated within the software forge. 25 / 34
  • 41. Introduction Best Programming Practices Software Quality Project Management Summary Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing The Software Quality Iceberg 26 / 34
  • 42. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 43. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 44. Introduction Best Programming Practices Software Quality Project Management Summary Agile Methodologies Scrum Extreme Programming A New Vision of Project Management The cathedral (monolithic) 27 / 34
  • 45. Introduction Best Programming Practices Software Quality Project Management Summary Agile Methodologies Scrum Extreme Programming A New Vision of Project Management ⇒ The cathedral (monolithic) The bazaar (agile) 27 / 34
  • 46. Introduction Best Programming Practices Software Quality Project Management Summary Agile Methodologies Scrum Extreme Programming Agility: Cut Down Release Cycles 28 / 34
  • 47. Introduction Best Programming Practices Software Quality Project Management Summary Agile Methodologies Scrum Extreme Programming Agility: Cut Down Release Cycles 28 / 34
  • 48. Introduction Best Programming Practices Software Quality Project Management Summary Agile Methodologies Scrum Extreme Programming Agility: Cut Down Release Cycles ⇒ Features are incrementally added. Software architecture is continuously refactored. 28 / 34
  • 49. Introduction Best Programming Practices Software Quality Project Management Summary Agile Methodologies Scrum Extreme Programming Continuous Testing is at the Center of Agile Development ⇒ The cathedral (monolithic) The bazaar (agile) 29 / 34
  • 50. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 51. Introduction Best Programming Practices Software Quality Project Management Summary Agile Methodologies Scrum Extreme Programming Scrum: Most Popular Agile Methodology 30 / 34
  • 52. Introduction Best Programming Practices Software Quality Project Management Summary Agile Methodologies Scrum Extreme Programming Scrum: The Product Backlog of Orthanc in Trello 31 / 34
  • 53. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 54. Introduction Best Programming Practices Software Quality Project Management Summary Agile Methodologies Scrum Extreme Programming Extreme Programming: Agile Engineering Practices 32 / 34
  • 55. Introduction Best Programming Practices Software Quality Project Management Summary Agile Methodologies Scrum Extreme Programming Extreme Programming: Agile Engineering Practices 32 / 34
  • 56. Introduction Best Programming Practices Software Quality Project Management Summary Agile Methodologies Scrum Extreme Programming Extreme Programming: Agile Engineering Practices 32 / 34
  • 57. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 58. 1 Introduction 2 Best Programming Practices Put Your Code in Revision Control Software Coding Style and Documentation Don’t Reinvent the (Squared) Wheel Design Patterns Other Recommendations 3 Software Quality Software Engineers are Part of the Testing Assertion-Driven Testing Unit Testing Integration and System Testing 4 Project Management Agile Methodologies Scrum Extreme Programming 5 Summary Score Your Project!
  • 59. Introduction Best Programming Practices Software Quality Project Management Summary Score Your Project! Score Your Project! 33 / 34
  • 60. Introduction Best Programming Practices Software Quality Project Management Summary Score Your Project! Any Question? 34 / 34