Document 15075212

advertisement
Mata kuliah
Tahun
: T0144 – Advanced Topics in Software Engineering
: 2010
Pertemuan 2
Software Construction Best Practices
Learning Outcomes
Pada akhir pertemuan ini, diharapkan:
– Mahasiswa dapat menerapkan Best Practices dalam
melakukan Programming / Software Construction
3
Outline Material
•
•
•
•
What is “Best Practice” ?
Objectives of applying a “Best Practice”
Software Construction Fundamentals
How to improve your code
4
What is a “Best Practice” ?
• A best practice is a technique, method, process, activity,
incentive, or reward that is believed to be more effective at
delivering a particular outcome than any other technique,
method, process, etc. when applied to a particular condition or
circumstance.
• The idea is that with proper processes, checks, and testing, a
desired outcome can be delivered with fewer problems and
unforeseen complications.
What is a “Best Practice” ?(cont’d)
• Best practices can also be defined as the most efficient (least
amount of effort) and effective (best results) way of
accomplishing a task, based on repeatable procedures that have
proven themselves over time for large numbers of people.
Why apply “Best practice”?
• Mostly similar to the goal of Software Engineering itself
–
–
–
–
–
Reliability
Quality
Maintainability
Reusability
Speed of Development
• Lessons learned from other projects
• Can be adapted or modified
Software Construction
#1 Minimizing Complexity
• Applies to all aspect of Software Construction
• Managing Complexity is one of the biggest challenge of
Software Construction
• Practical Considerations:
–
–
–
–
Better Requirement Gatherings
Domain Expert
Modularization
Write simple and readable code instead of “clever” code
#2 Anticipating Change
• Fact of Life: most software WILL change over time.
• Internal vs External influences
– Hardware Migration
– Operating System upgrades
– Business Process changes
• Practical Considerations:
–
–
–
–
Standardized Communication Methods (i.e. Document Formats)
Better Tools (i.e. IDE Support for Refactoring, UML Diagrams)
Coding Standard
Self-documenting code & good commenting techniques
#3 Constructing for Verification
• How do I know that my program is “correct” ?
• Enables us to detect bugs / errors earlier.
– The later we find them, the more expensive it is to fix.
• Practical Considerations:
– Coding standard & Code Reviews
• Although might not be practical in smaller projects
• Ego issues (not fun getting criticized publicly)
– Better error handling
• Assertions vs exceptions
– Unit Testing & Test Driven Development
– Automated Testing & Regression Testing
#4 Standards in Construction
• Any internal & external standards used in the process.
• Practical Considerations:
– Coding Standard
– Design Patterns
– UML
“Bad” vs “Good” Code
•
Discussion
–
–
–
–
What makes a “Good” code?
What makes a “Bad” code?
How did “Bad” code get written?
How to prevent this in the first place?
How to improve *your* code?
Discussion
How to improve *your* code?
• First steps
–
–
–
–
Good Commenting Techniques: Explains “why”
Good Naming Practice: Explains “what”
Coding Standard / Coding Convention
Simplify, simplify, simplify
• After the code is written
– Testing
– Refactoring
References
• Software Engineering Body of Knowledge – Chapter 4: Software Construction
http://www.computer.org/portal/web/swebok/html/ch4
• Code Complete 2: A Practical Handbook of Software Construction –
Steve McConnell - Microsoft Press; 2nd edition (June 9, 2004)
• How to write unmaintainable Code – Roedy Green
http://freeworld.thc.org/root/phun/unmaintain.html
• The fine art of commenting – Bernhard Spuida
http://www.icsharpcode.net/TechNotes/Commenting20020413.pdf
16
Download