Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Жернов Андрей, 396, Storeable and Parallel #592

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,30 @@
## Семинары
В папке [tasks](tasks) находятся описания заданий на
семинары. Для написания программ необходимо руководствоваться [соглашениями
по оформлению кода](http://www.oracle.com/technetwork/java/codeconv-138413.html)
по оформлению кода](http://www.oracle.com/technetwork/java/codeconvtoc-136057.html)
от Oracle (Code Conventions).

В документе [github-workflow](github-workflow.md) описаны
общие правила по ведению задач на github, а также упрощение жизни с помощью утилиты
[checkstyle](http://checkstyle.sourceforge.net/), которая проверяет код на соответствие
Code Conventions.

## Лекции
1. [Java, JVM, примитивные типы](https://yadi.sk/d/_ZgbGf9NbXraZ)
2. [Object, String, исключения](https://yadi.sk/d/MCu6krbtbXrgZ)
3. [IO Stream, инициализация объектов, enum](https://yadi.sk/d/MinWJhG0bteEr)
4. [Лямбды, аннотации, обобщения, коллекции](https://yadi.sk/d/hxkoP81rbteTp)
5. [Reflection, Proxy, JUnit](https://yadi.sk/i/Ku-C6VYOc4icJ)
6. [Сериализация, XML, JSON](https://yadi.sk/d/8upuEG2ecRknU)
7. [Многопоточность](https://yadi.sk/i/FsBB-AXVcRkoH)
8. [Многопоточность](https://yadi.sk/i/IY2kKLoacgaBr)

## Список литературы
* Брюс Эккель — Философия Java (Thinking in Java)
* Brian Goetz — Java Concurrency in Practive (продвинутая книжка
по многопоточности в Java)
* [Спецификации по JVM и JLS](http://docs.oracle.com/javase/specs/index.html)
* [Code Conventions](http://www.oracle.com/technetwork/java/codeconv-138413.html)

## Успеваемость
[Таблица на Google Docs](https://docs.google.com/spreadsheet/ccc?key=0Ag7dwrMmZBKedGk1Q1RfSXh1RzZyeEJhaE94dW1CaGc&usp=sharing)
12 changes: 8 additions & 4 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<project name="fizteh-java-2013" default="compile">
<project name="fizteh-java-2014" default="compile">

<property name="out" location="${basedir}/out"/>
<property name="jars" location="${basedir}/jars"/>
Expand All @@ -18,7 +18,7 @@
</path>

<target name="compile" depends="init">
<javac destdir="${out}" encoding="UTF-8" debug="true" source="1.7" target="1.7" includeAntRuntime="false" nowarn="on" deprecation="off">
<javac destdir="${out}" encoding="UTF-8" debug="true" source="1.8" target="1.8" includeAntRuntime="false" nowarn="on" deprecation="off">
<classpath refid="fizteh.classpath"/>
<src refid="fizteh.sourcepath"/>
<include name="**/*.java"/>
Expand All @@ -29,18 +29,22 @@
<jar jarfile="${jars}/fizteh.jar" basedir="${out}"/>
</target>

<target name="junit" depends="run.checkstyle">
<fail if="run.checkstyle.failure"/>
</target>
<target name="checkstyle" depends="dist, run.checkstyle">
<fail if="run.checkstyle.failure"/>
</target>

<target name="run.checkstyle" description="Checkstyle utility (code conventions)">
<taskdef resource="checkstyletask.properties" classpath="bin/checkstyle-5.6-all.jar"/>
<taskdef resource="checkstyletask.properties" classpath="lib/checkstyle-5.9-SNAPSHOT-all.jar"/>

<checkstyle
config="bin/checkstyle-rules.xml"
config="lib/checkstyle-rules.xml"
failureProperty="run.checkstyle.failure"
failOnViolation="false"
>
<formatter type="plain"/>
<formatter type="xml" tofile="${out}/checkstyle-report.xml"/>
<classpath>
<path refid="fizteh.classpath"/>
Expand Down
2 changes: 1 addition & 1 deletion github-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@

Чтобы сократить количество итераций на проверку задания, полезно самостоятельно удостовериться, что Code Conventions
соблюдены. Для этого нужно запустить сборку проекта с помощью ```ant checkstyle```. Вместо этого можно поставить
соответствующий плагин в IDE и настроить этот плагин на конфигурационный файл ```bin/checkstyle-rules.xml```.
соответствующий плагин в IDE и настроить этот плагин на конфигурационный файл ```lib/checkstyle-rules.xml```.
157 changes: 157 additions & 0 deletions lib/checkstyle-rules.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">

<property name="charset" value="UTF-8"/>

<module name="SuppressionFilter">
<property name="file" value="${basedir}/lib/checkstyle-suppress.xml"/>
</module>

<!-- Checks that a package-info.java file exists for each package. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
<!-- <module name="JavadocPackage"/> --> <!-- We don't write javadoc -->

<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="FileLength"/>

<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="FileTabCharacter"/>

<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="NewlineAtEndOfFile"/>
<module name="Translation"/>

<module name="TreeWalker">
<module name="FileContentsHolder"/>

<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<!-- Yes, we don't write comments -->
<!--
<module name="JavadocMethod"/>
<module name="JavadocType"/>
<module name="JavadocVariable"/>
<module name="JavadocStyle"/>
-->

<!-- Annotations -->
<!-- See http://checkstyle.sourceforge.net/config_annotation.html -->
<module name="MissingOverride"/>

<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>


<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<!--<module name="AvoidStarImport"/>-->
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>


<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="LineLength">
<property name="max" value="120"/>
<property name="ignorePattern" value="^ *\* *.+$"/>
</module>
<module name="MethodLength">
<property name="max" value="200"/>
<property name="countEmpty" value="false"/>
</module>
<module name="ParameterNumber"/>


<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="EmptyForInitializerPad"/>
<module name="EmptyForIteratorPad">
<property name="option" value="space"/>
</module>
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore">
<property name="tokens" value="DOT"/>
<property name="allowLineBreaks" value="true"/>
</module>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround">
<property name="tokens" value="
ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON,
DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO,
LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED,
LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN,
TYPE_EXTENSION_AND"/>
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
</module>


<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>


<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
<!-- <module name="AvoidNestedBlocks"/> --> <!-- Sometimes nested blocks are useful -->
<module name="EmptyBlock">
<!-- At least comment should be in empty block -->
<property name="option" value="text"/>
</module>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>


<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_coding.html -->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="IllegalInstantiation"/>
<module name="MissingSwitchDefault"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="DefaultComesLast"/>
<module name="FallThrough"/>
<module name="MultipleVariableDeclarations"/>
<module name="CovariantEquals"/>
<module name="StringLiteralEquality"/>
<module name="OneStatementPerLine"/>

<!-- Checks for class design -->
<!-- See http://checkstyle.sf.net/config_design.html -->
<!--<module name="FinalClass"/>-->
<module name="MutableException"/>


<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
<module name="UpperEll"/>
<module name="OuterTypeFilename"/>
</module>

</module>
7 changes: 7 additions & 0 deletions lib/checkstyle-suppress.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN" "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>

<suppress checks="IllegalImportCheck" files=".*UnsafeExample\.java$"/>

</suppressions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ru.fizteh.fivt.students.andrewzhernov.database;

/**
* Бросается при попытке извлечь из колонки {@link Storeable} значение не соответствующего типа,
* либо подставить в колонку значение несоответствующего типа.
*/
public class ColumnFormatException extends IllegalArgumentException {

private static final long serialVersionUID = 1L;

public ColumnFormatException() {
}

public ColumnFormatException(String s) {
super(s);
}

public ColumnFormatException(String message, Throwable cause) {
super(message, cause);
}

public ColumnFormatException(Throwable cause) {
super(cause);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package ru.fizteh.fivt.students.andrewzhernov.junit;
package ru.fizteh.fivt.students.andrewzhernov.database;

public class Command {
private String name;
private int numArgs;
private HandlerInterface processor;
private Handler processor;

public Command(String name, int numArgs, HandlerInterface processor) {
public Command(String name, int numArgs, Handler processor) {
this.name = name;
this.numArgs = numArgs;
this.processor = processor;
Expand All @@ -17,10 +17,10 @@ public String getName() {

public void execute(TableProvider database, String[] params) throws Exception {
if (params.length != numArgs) {
throw new Exception(String.format("Invalid number of arguments: %d expected, %d found.",
throw new IllegalArgumentException(String.format(name + ": invalid number of arguments: %d expected, %d found.",
numArgs, params.length));
} else {
processor.handle(processor.execute(database, params));
processor.handle(database, processor.execute(database, params));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package ru.fizteh.fivt.students.andrewzhernov.database;

public interface Handler {
Object execute(TableProvider database, String[] args) throws Exception;
void handle(TableProvider database, Object object) throws Exception;
}
Loading