Se Module 2
Se Module 2
Standards
Contents
• Programming Style Guides and Coding Standards
• Literate Programming and Software Documentation
• Document Generators
• Javadoc
• phpDocumentor
Programming Style Guides
• Programming Style/ Code Style
• Set of rules or guidelines used when writing the source
code for a computer program
• A style guide helps everyone to write code in a consistent
way, and consistent code is easier to read and faster to
update
• The goal of good programming style is to provide
understandable, straightforward, elegant code
Programming Style - General Guidlines
• Clarity and simplicity of Expression
• The programs should be designed in such a manner so that the objectives of
the program is clear
• Naming
• In a program, it is required to name the module, processes, variable and so
on. The naming style should not be cryptic and non-representative
Ex. a = 3.14 * r * r
area of circle = 3.14 * radius * radius;
• Control Constructs
• It is desirable that as much as a possible single entry and single exit constructs
used
Programming Style - General Guidelines
• Information hiding
• The information stored in the data structures should be hidden from the rest
of the system where possible. Information hiding can decrease the coupling
between modules and make the system more maintainable
• Nesting
• It is desirable to avoid deep nesting of loops and conditions. Deep nesting
harm the static and dynamic behavior of a program. It also becomes difficult
to understand the program logic
• User-defined types
• Make heavy use of user-defined data types like enum, class, structure, and
union. These data types make the program code easy to write and easy to
understand
Programming Style - General Guidelines
• Module size
• The module size should be uniform. The size of the module should
not be too big or too small. If the module size is too large, it is not
generally functionally cohesive. If the module size is too small, it
leads to unnecessary overheads.
• Module Interface
• A module with a complex interface should be carefully examined
• Side-effects
• When a module is invoked, it sometimes has a side effect of
modifying the program state. Such side-effect should be avoided
• Widely accepted style guides
• Google’s Style Guides
• JavaScript Standard Style
• GitHub’s Ruby Style Guide
• Python Foundation’s Style Guide
• Airbnb’s JavaScript Style Guide
• Angular’s Style Guide
Coding Standards
• Increase Efficiency
• By following coding standards, developers can save time by
avoiding common mistakes and implementing proven solutions
• Ensure compatibility
• Ensures that code is compatible with different platforms, browsers,
and OS-device combinations
• Reduce Maintenance Costs
• By following established standards, developers can avoid
introducing new bugs and make changes to code more quickly and
easily
Coding Standards - General Guidelines
• Technical Documentation
• User Documentation
Advantages of Documentation
• Keeps track of all parts of a software or program
• Maintenance is easier
• Programmers other than the developer can understand all aspects of
software
• Improves overall quality of the software
• Assists in user training
• Ensures knowledge de-centralization, cutting costs and effort if people
leave the system abruptly
Documentation Generators
• A documentation generator is a programming tool that generates
software documentation intended for programmers or end users or
both, from a set of source code files, and in some cases, binary files
• Types of generation
• Batch generation (generic technique)
• Text block correspondence (documents created based on pre-defined text
blocks)
• Forms (forms for websites)
• Documentation synthesis:
• Documentation can be inferred from code
• Documentation can be inferred from execution traces
Javadoc & phpDocumentor
• Javadoc
• Is a documentation generator created by Sun Microsystems for the
Java language (now owned by Oracle Corporation) for generating
API documentation in HTML format from Java source code
• The HTML format is used for adding the convenience of being able
to hyperlink related documents together
• phpDocumentor
• Is the de-facto documentation application for PHP projects
• The phpDocumentor package provides automatic documenting of
php api directly from the source