CSEB 233 Fundamentals of Software Engineering Software Construction
CSEB 233: Fundamentals of Software Engineering Software Construction
Objectives m Explain what is software construction and why it is important m Describe good programming principles/practices m Explain the concept of ‘defensive programming’ m Describe software inspection as a static method to discover defects, errors or problems m Explain the concepts, benefits and problems of software reuse
Software Implementation & Coding Software Construction & Its Importance
What is Software Construction? m ‘Construction’ refers to the hands-on part of creating something m Include implementation/coding and debugging; and verification and validation m Generally focus at coding, debugging, some detailed design and some testing (esp. unit testing) m Quality of construction substantially affects the quality of the software
What is Software Construction? m According to Mc. Connell (1993), construction may involve: Verifying that the groundwork has been laid so that construction can proceed successfully u Designing and writing routines and modules u Selecting and creating data types and naming identifiers u Selecting control structures and organizing blocks of statements u Finding and fixing errors u
What is Software Construction? m According involve: to Mc. Connell (1993), construction may Reviewing other team members’ design and code and having them review yours u Polishing the code – formatting and writing comments (i. e. internal documentation) u Integrating software components (if built separately) u Tuning the code – make it more efficient, smaller and faster u
Why is Software Construction Important? m Depending on the size of project, construction may take 30% - 80% of the total project time u The larger the time spent, the bigger the work affect the success of the project Construction is the pivotal activity in software development m With a focus on construction, there is a great potential for the average programmer’s productivity to improve (Mc. Connel, 1993) m
Why is Software Construction Important? Requirements document and design documents can go out of date, but construction’s by product, the source code, is always up to date m Ideally software project goes through requirements engineering and modeling activities before construction begins m u Construction is the only activity that’s guaranteed to be done! (Mc. Connel, 1993)
Software Implementation & Coding Good Programming Principles
Coding Principles m Coding principles and concepts are closely aligned programming style, programming languages, and programming methods m Before you write one line of code, be sure you: Understand of the problem you’re trying to solve u Understand basic design principles and concepts u
Coding Principles m Before you write one line of code, be sure you: Pick a programming language that meets the needs of the software to be built and the environment in which it will operate u Select a programming environment that provides tools that will make your work easier u Create a set of unit tests that will be applied once the component you code is completed u
Coding Principles m As you begin writing code, be sure you: Constrain your algorithms by following structured programming practice u Consider the use of pair programming u Select data structures that will meet the needs of the design u Understand the software architecture and create interfaces that are consistent with it u Keep conditional logic as simple as possible u
Coding Principles m As you begin writing code, be sure you: Create nested loops in a way that makes them easily testable u Select meaningful variable names and follow other local coding standards u Write code that is self-documenting u Create a visual layout (e. g. , indentation and blank lines) that aids understanding u
Coding Principles m After you’ve completed your first coding pass, be sure to: Conduct a code walkthrough when appropriate u Perform unit tests and correct errors you’ve uncovered u Refactor the code u ■ reorganization technique that simplifies the code without changing its function or behaviour
Good Programming Practices m Start with a good design. Update the design documents regularly u Create additional design documents before adding new major features or functionality u m The program under development should be functioning at all times u m The development process consists of adding new functionality without breaking existing functionality Work has to be divided into small incremental steps that can be typically accomplished and code-reviewed in one day. u Even large-scale rewrites should be made incremental
Good Programming Practices m Every line of code written or modified undergoes peer review u m The smallest team must contain at least two programmers so that they can code-review each other's changes Always attempt to work top-down in: Design—start with high level objects u Implementation—create top-level objects using low-level stubs u Modification—change the top-level objects and the overall flow of control first. If necessary, use stubs, or fake new functionality using old implementation (Source: http: //relisoft. com/practice. html) u
Good Programming Practices m Be consistent with formatting m Be consistent with naming conventions m Use global [identifiers] sparingly m Don’t assume output formats m Add comment to your code – explain what and why (Source: Kim Moser at http: //relisoft. com/practice. html )
Good Programming Practices m Provide useful error messages m Recover (or fail) gracefully m Push interface up and implementation down m Know what you don't know – prepare for changes (Source: Kim Moser at http: //relisoft. com/practice. html )
Software Implementation & Coding Defensive Programming Concepts
Defensive Progamming m Defensive programming is when the programmer makes necessary assumptions and creates code that anticipates potential problems and specification changes m A good defensive programmer is sufficiently confident in his/her abilities to ignore the traditional belief that “If it isn’t broke, don’t fix it. ”
Defensive Progamming m Defensive programming involves: finding problems in the existing code by identifying code inconsistencies and understanding typical uses of the software u anticipating – and preempting – both potential problems with the existing specifications as well as likely changes in user behavior and design specifications, and u streamlining the code to aid readability and simplify maintainability (Mehta, 2009) u
Software Implementation & Coding Software Inspection
Software Inspections m An ‘old school’ approach m A process to review, analyze and check static system representations such as requirements document, design document, and program source code to look for errors and problems u Static – need not run the software on a computer m Generally, focus at source code
Software Inspections m Sometime also known as peer reviews or program /code inspections m Inspections can check conformance with a specification but not conformance with the customer’s real requirements m But, inspections cannot check non-functional characteristics such as performance, usability, etc.
Program/Code Inspection Process m Focus at detecting defects - logical errors and anomalies in the code m Program inspections are very effective in discovering defects m A formal process that involve team of several members u Fagan originally developed this method at IBM in the 1970 s with four suggested roles – author, reader, tester and moderator
Advantages of Inspection over Testing m. A single inspection session can discover many errors u During program testing, errors can mask (hide) other errors m Incomplete versions of a software can be inspected without additional costs u To test an incomplete program, specialized test is needed to test the parts that are available (Sommerville, 2004)
Advantages of Inspection over Testing m Inspections can search for program defects and other quality attributes of a program u e. g. , compliance to standard, maintainability, portability, efficiency, etc. (Sommerville, 2004)
Drawbacks/Issues related to Inspections Difficult to introduce formal inspections into software development organizations m Software engineers (programmers) with experience are sometimes reluctant to accept that inspections can be more effective for detecting defects (errors) than testing m Managers may be sceptical as inspections require extra costs during modelling and construction m Inspections may take time to arrange and appear to slow down the development process m
Software Implementation & Coding Software Reuse
Software Reuse In most engineering disciplines, systems are designed by composing existing components that have been used in other systems m Software engineering has been more focused on original development m It is now recognised that to achieve better software quickly at lower cost, we need to adopt a design process that is based on systematic reuse rather than ad-hoc reuse m (Sommerville, 2004)
Reuse-based Software Engineering m Application system reuse u m Component reuse u m The whole of an application system may be reused either by incorporating it without change into other systems (COTS reuse) or by developing application families Components of an application from sub-systems to single objects may be reused Object and function reuse u Software components that implement a single well-defined function may be reused
Requirements for Reuse m It must be possible to find appropriate reusable components m The reuser of the component must be confident that the components will be reliable and will behave as specified m The components must be documented so that they can be understood and, where appropriate, modified.
Benefits of Reuse m Increased dependability Software/components/functions have been tried and tested in working systems u They should be more dependable than new software u m Reduced process risk u m Less uncertainty in development costs especially if large software components are reused Effective use of specialists Reuse components instead of people u The specialist can create reusable components u
Benefits of Reuse m Standards u compliance Standards such as UI standard (e. g. , drop-down menu) can be implemented as reusable components to improve dependability as users are less likely to make mistake m Accelerated u development Avoid original development, speed-up production and hence able to market product early
Reuse Problems m Increased costs in understanding whether the application/component/ function is suitable for reuse u in testing it to ensure its dependability and in maintaining the reused item u m Lack of CASE tool support m Maintaining a component library can be expensive
Reuse Problems m Not-invented-here u syndrome Some software engineers may think that writing original software is seen as more challenging than reusing other people’s software. m Finding and adapting reusable components
Summary m You have been introduced to: good programming principles/practices u the concept of ‘defensive programming’ u software inspection as a static method to discover defects, errors or problems u the concepts, benefits and problems of software reuse u
THE END Copyright © 2014 College of Information Technology
- Slides: 38