Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Style a programs language gives you a lot of freedom how to write a program – too much? but some programming style is good goal: it must be.

Similar presentations


Presentation on theme: "Programming Style a programs language gives you a lot of freedom how to write a program – too much? but some programming style is good goal: it must be."— Presentation transcript:

1 Programming Style a programs language gives you a lot of freedom how to write a program – too much? but some programming style is good goal: it must be easy to understand the program there are standards – deviate from a standard only if there is a very good justification 3 legs of style: – program structure – naming of program elements – comments (documentation) you can define formatting in Eclipse

2 Structure indentation – nesting – blocks – Eclipse does it for us packages classes, methods – order of parameters – order of operands in an expression order of declarations line wrapping white space – spaces, no tabs

3 Naming name must clearly denote the element's purpose – no abbreviations, unless it's a standard – no one letter names, unless it's a standard – variables are as important as methods expressive, but terse – not aVariable (not expressive) – not undecidedStudentWithoutMajor (not terse) – not aMethodIWroteYesterday (who cares) camel notation – class names start with uppercase – methods, variables start with lowercase – all other words start with uppercase – except packages all lowercase, underscores self-documenting names

4 Comments, Documentation on all levels at detail – line comments // within method body – block comments /* */ main comments documenting declarations – classes, methods, parameters – Javadoc /** */ standard for declarations can be extracted into a web page – no body, formatted – separate manuals you must document – every non-obvious code line – every logical block introduced – every class, its purpose – every instance variable, its purpose – every method, its purpose, pre- and post-conditions – every parameter, its purpose, permissible values expressive, but terse

5 ICS 111 Standard http://www2.hawaii.edu/~walbritt/ics111/intro/standard.htm


Download ppt "Programming Style a programs language gives you a lot of freedom how to write a program – too much? but some programming style is good goal: it must be."

Similar presentations


Ads by Google