Содержание
- 2. Packages Package system - way of hierarchical organization of the project code In Java packages map
- 3. Package visibility package ru.innopolis.bootcamp2; public class PublicClass { } package ru.innopolis.bootcamp2; class DefaultClass { }
- 4. Package naming conventions A name for a Java package must be a sequence of one or
- 5. Packages in file system
- 6. Build in packages We build and run with respect of the package One class javac ru/innopolis/bootcamp2/BootCampSpecificClass.java
- 7. Referencing the package
- 8. Stating coding standards Coding standards - usually internal corporate document helping to organize the code Start
- 9. Stating coding standards
- 10. Common rules Each Java source file (.java file) has the following structure: Introductory comments Declaration of
- 11. What is comment Comment - is a piece of text that do not affect compilation Single
- 12. Special comments Use “//XXX” in a comment to flag something that is bogus but works Use
- 13. Special comments
- 14. Introductory comment (javadoc) /** * @deprecated if you recommend not to use a class * to
- 15. Introductory comment (javadoc)
- 16. Introductory comment /* * @(#)Blah.java 1.82 99/03/18 * * Copyright (c) 1994-1999 Sun Microsystems, Inc. *
- 17. Class/Interface arrangement Instance variables Constructors Methods http://developer.alexanderklimov.ru/android/java/constructor.php
- 18. Class/Interface arrangement
- 19. Naming conventions Divided into Conventions about how to give meaningful names Conventions about how names must
- 20. Class Names (same for interfaces) Should be singular nouns, referring to the object they represent First
- 21. Method names Verbs or verbal forms in mixed cases Starting with lower letter and each internal
- 22. Method names Methods returning void should be named with imperative verbs describing what they must do
- 23. Variables Variables should be named for the objects they represent Usually named with a singular noun
- 25. Parameter and constant names Name parameters in such a way that the method call is readable
- 27. Code readability conventions These conventions are often very close to design guidelines, since code readability is
- 28. Formatting conventions Very important to ease code readability and to make quicker code inspections The specific
- 29. Formatting conventions One statement per line Use indents to highlight structured programming constructs Do not indent
- 30. Putting brackets Open brace “{” appears at the end of the same line as the class,
- 32. Lines and wrapping When an expression will not fit on a single line, break it according
- 34. Variables declaration There should be usually only one declaration per line to promote comments of the
- 35. Example of good style http://www.docjar.net/html/api/java/util/Collections.java.html
- 37. Скачать презентацию