🗊 Презентация Few words about how to write [disputably] nice code

Нажмите для полного просмотра!
Few words about how to write [disputably] nice code, слайд №1 Few words about how to write [disputably] nice code, слайд №2 Few words about how to write [disputably] nice code, слайд №3 Few words about how to write [disputably] nice code, слайд №4 Few words about how to write [disputably] nice code, слайд №5 Few words about how to write [disputably] nice code, слайд №6 Few words about how to write [disputably] nice code, слайд №7 Few words about how to write [disputably] nice code, слайд №8 Few words about how to write [disputably] nice code, слайд №9 Few words about how to write [disputably] nice code, слайд №10 Few words about how to write [disputably] nice code, слайд №11 Few words about how to write [disputably] nice code, слайд №12 Few words about how to write [disputably] nice code, слайд №13 Few words about how to write [disputably] nice code, слайд №14 Few words about how to write [disputably] nice code, слайд №15 Few words about how to write [disputably] nice code, слайд №16 Few words about how to write [disputably] nice code, слайд №17 Few words about how to write [disputably] nice code, слайд №18 Few words about how to write [disputably] nice code, слайд №19 Few words about how to write [disputably] nice code, слайд №20 Few words about how to write [disputably] nice code, слайд №21 Few words about how to write [disputably] nice code, слайд №22 Few words about how to write [disputably] nice code, слайд №23 Few words about how to write [disputably] nice code, слайд №24 Few words about how to write [disputably] nice code, слайд №25 Few words about how to write [disputably] nice code, слайд №26 Few words about how to write [disputably] nice code, слайд №27 Few words about how to write [disputably] nice code, слайд №28 Few words about how to write [disputably] nice code, слайд №29 Few words about how to write [disputably] nice code, слайд №30 Few words about how to write [disputably] nice code, слайд №31 Few words about how to write [disputably] nice code, слайд №32 Few words about how to write [disputably] nice code, слайд №33 Few words about how to write [disputably] nice code, слайд №34 Few words about how to write [disputably] nice code, слайд №35 Few words about how to write [disputably] nice code, слайд №36

Вы можете ознакомиться и скачать презентацию на тему Few words about how to write [disputably] nice code. Доклад-сообщение содержит 36 слайдов. Презентации для любого класса можно скачать бесплатно. Если материал и наш сайт презентаций Mypresentation Вам понравились – поделитесь им с друзьями с помощью социальных кнопок и добавьте в закладки в своем браузере.

Слайды и текст этой презентации


Слайд 1


Few words about how to write [disputably] nice code Kamill Gusmanov
Описание слайда:
Few words about how to write [disputably] nice code Kamill Gusmanov

Слайд 2


Packages Package system - way of hierarchical organization of the project code In Java packages map to file system. Each file belonging to a package...
Описание слайда:
Packages Package system - way of hierarchical organization of the project code In Java packages map to file system. Each file belonging to a package X.Y.Z: Should be placed in a folder PROJECT/X/Y/Z Should have explicit declaration package X.Y.Z;

Слайд 3


Package visibility package ru.innopolis.bootcamp2; public class PublicClass { } package ru.innopolis.bootcamp2; class DefaultClass { }
Описание слайда:
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 more valid Java identifiers separated by dots (“.”) package...
Описание слайда:
Package naming conventions A name for a Java package must be a sequence of one or more valid Java identifiers separated by dots (“.”) package java.lang; package java.io; package java.awt; package ru.innopolis.iis.mlkr; Usually, the letters in the name of a package are all lowercase If a package is to be widely distributed, it is a common convention to prefix its name with the reverse Internet domain name of the producing or distributing organization, with slashes substituted by dots.

Слайд 5


Packages in file system
Описание слайда:
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 cd...
Описание слайда:
Build in packages We build and run with respect of the package One class javac ru/innopolis/bootcamp2/BootCampSpecificClass.java cd ru/innopolis/bootcamp2 javac BootCampSpecificClass.java java ru/innopolis/bootcamp2/BootCampSpecificClass java DefaultClass All classes in package javac ru/innopolis/bootcamp2/*.java All classes recursively (build tree) Ant, Maven

Слайд 7


Referencing the package
Описание слайда:
Referencing the package

Слайд 8


Stating coding standards Coding standards - usually internal corporate document helping to organize the code Start from Java Code Conventions Keep it...
Описание слайда:
Stating coding standards Coding standards - usually internal corporate document helping to organize the code Start from Java Code Conventions Keep it simple (less than 20 rules) Better if developed by the team Be not too specific Avoid bad standards Evolve it over time

Слайд 9


Stating coding standards
Описание слайда:
Stating coding standards

Слайд 10


Common rules Each Java source file (.java file) has the following structure: Introductory comments Declaration of package (if needed) Import...
Описание слайда:
Common rules Each Java source file (.java file) has the following structure: Introductory comments Declaration of package (if needed) Import instruction (if needed) Definition of classes and interfaces (in Java you can store single class* in a file)

Слайд 11


What is comment Comment - is a piece of text that do not affect compilation Single line: // something will happen here int x = 4; //TODO: implement...
Описание слайда:
What is comment Comment - is a piece of text that do not affect compilation Single line: // something will happen here int x = 4; //TODO: implement calculation of x! Multiple lines (inline): obj.callSomeMethod(a /* very important param */, b, c); /* this is Very long Multiline Comment */

Слайд 12


Special comments Use “//XXX” in a comment to flag something that is bogus but works Use “//FIXME” to flag something that is bogus and broken Use...
Описание слайда:
Special comments Use “//XXX” in a comment to flag something that is bogus but works Use “//FIXME” to flag something that is bogus and broken Use “//TODO” to flag something that should be implemented

Слайд 13


Special comments
Описание слайда:
Special comments

Слайд 14


Introductory comment (javadoc) /** * @deprecated if you recommend not to use a class * to preserve backward compatibility * * @see OtherClass * *...
Описание слайда:
Introductory comment (javadoc) /** * @deprecated if you recommend not to use a class * to preserve backward compatibility * * @see OtherClass * * @serial SERIAL_NUMBER * * @since WHICH.VERSION.OF.THE.PROJECT/LIBRARY * * @version 1.0.0.1 * * @author Stanislav Protasov */ *Javadoc support html

Слайд 15


Introductory comment (javadoc)
Описание слайда:
Introductory comment (javadoc)

Слайд 16


Introductory comment /* * @(#)Blah.java 1.82 99/03/18 * * Copyright (c) 1994-1999 Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto,...
Описание слайда:
Introductory comment /* * @(#)Blah.java 1.82 99/03/18 * * Copyright (c) 1994-1999 Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, California, * 94303, U.S.A. All rights reserved. * * This software is the confidential and * proprietary information of Sun Microsystems, * Inc. ("Confidential Information"). You shall * not disclose such Confidential Information and * shall use it only in accordance with the terms * of the license agreement you entered into * with Sun. */

Слайд 17


Class/Interface arrangement Instance variables Constructors Methods
Описание слайда:
Class/Interface arrangement Instance variables Constructors Methods

Слайд 18


Class/Interface arrangement
Описание слайда:
Class/Interface arrangement

Слайд 19


Naming conventions Divided into Conventions about how to give meaningful names Conventions about how names must be written All of the names in your...
Описание слайда:
Naming conventions Divided into Conventions about how to give meaningful names Conventions about how names must be written All of the names in your program should convey information about the purpose of the item they refer Use not abbreviations for your names (only if they are in common use in normal speech) Use descriptively named variables Avoid ambiguous words

Слайд 20


Class Names (same for interfaces) Should be singular nouns, referring to the object they represent First letter and each internal word of class or...
Описание слайда:
Class Names (same for interfaces) Should be singular nouns, referring to the object they represent First letter and each internal word of class or interface names is capitalized (UpperCamelCase) Train, Event, Station Do not put hierarchy information in class names, unless real-world names bear this information EmployeePerson, SecretaryEmployeePerson

Слайд 21


Method names Verbs or verbal forms in mixed cases Starting with lower letter and each internal word should be capitalized (lowerCamelCase) Methods...
Описание слайда:
Method names Verbs or verbal forms in mixed cases Starting with lower letter and each internal word should be capitalized (lowerCamelCase) Methods returning a boolean usually named with verb phrases expressing the question isRed() Methods assigning boolean variable can be named with verb phrases beginning with "set"/"be" beOff(), setStateOffline()

Слайд 22


Method names Methods returning void should be named with imperative verbs describing what they must do openDBLink() Methods converting a value into...
Описание слайда:
Method names Methods returning void should be named with imperative verbs describing what they must do openDBLink() Methods converting a value into another should be named with verb phrases starting with "as"/"to" and denoting the converted type asDecimal(), toString() Other methods should describe what they return previousSignal() Accessor methods may report the variable’s name prefixed with “get” or “set”

Слайд 23


Variables Variables should be named for the objects they represent Usually named with a singular noun If it represent a collection of objects, its...
Описание слайда:
Variables Variables should be named for the objects they represent Usually named with a singular noun If it represent a collection of objects, its name should be plural The name should not include typing information lowerCamelCase One lowercase letter variable names are OK only for temporary variables, indexes, etc.

Слайд 24


Few words about how to write [disputably] nice code, слайд №24
Описание слайда:

Слайд 25


Parameter and constant names Name parameters in such a way that the method call is readable public static double power(double base, double exponent)...
Описание слайда:
Parameter and constant names Name parameters in such a way that the method call is readable public static double power(double base, double exponent) { // } Use named constants and not literal values, wherever a specific value is needed In order to differentiate the names of constants from the other names, constants are often completely capitalized and compound names are separated by an underscore

Слайд 26


Few words about how to write [disputably] nice code, слайд №26
Описание слайда:

Слайд 27


Code readability conventions These conventions are often very close to design guidelines, since code readability is obtained with cohesive classes...
Описание слайда:
Code readability conventions These conventions are often very close to design guidelines, since code readability is obtained with cohesive classes and methods Classes and methods focused on performing a single task Methods must be short In Java standard less than 10 statements Every method performs just one task, and Every full method must fit on one screen

Слайд 28


Formatting conventions Very important to ease code readability and to make quicker code inspections The specific code convention adopted is less...
Описание слайда:
Formatting conventions Very important to ease code readability and to make quicker code inspections The specific code convention adopted is less important than sticking to the same convention throughout the code NetBeans: Alt + Shift + F Eclipse: Ctrl/Cmd + Shift + F

Слайд 29


Formatting conventions One statement per line Use indents to highlight structured programming constructs Do not indent too much…do not waste...
Описание слайда:
Formatting conventions One statement per line Use indents to highlight structured programming constructs Do not indent too much…do not waste horizontal space! Do not indent too little…make the structure evident!

Слайд 30


Putting brackets Open brace “{” appears at the end of the same line as the class, interface, or method declaration Closing brace “}” starts a line by...
Описание слайда:
Putting brackets Open brace “{” appears at the end of the same line as the class, interface, or method declaration Closing brace “}” starts a line by itself aligned with the opening statement, except null block “{}” No space between a method name and the parenthesis “(” starting its parameter list Methods are separated by a blank line When a nested statements occur within blocks Use the 4 spaces rule, in general

Слайд 31


Few words about how to write [disputably] nice code, слайд №31
Описание слайда:

Слайд 32


Lines and wrapping When an expression will not fit on a single line, break it according to these general principles: Break after a comma. Break...
Описание слайда:
Lines and wrapping When an expression will not fit on a single line, break it according to these general principles: Break after a comma. Break before an operator. Prefer higher-level breaks to lower-level breaks. Align the new line with the beginning of the expression at the same level on the previous line. If the above rules lead to confusing code or to code that's squished up against the right margin, just indent 8 spaces instead.

Слайд 33


Few words about how to write [disputably] nice code, слайд №33
Описание слайда:

Слайд 34


Variables declaration There should be usually only one declaration per line to promote comments of the variables Variables should be initialized...
Описание слайда:
Variables declaration There should be usually only one declaration per line to promote comments of the variables Variables should be initialized where they are declared… Unless the value of the variable depends on some computations to be performed later Declarations should be placed at the beginning of the outermost block where a variable is used Avoid declarations in inner blocks of variables with the same name as variable in outer blocks

Слайд 35


Example of good style
Описание слайда:
Example of good style

Слайд 36


Extra task Given a system of linear equations, solve it using Cramer’s rule reusing created code.
Описание слайда:
Extra task Given a system of linear equations, solve it using Cramer’s rule reusing created code.



Похожие презентации
Mypresentation.ru
Загрузить презентацию