Skip to content

Commit e5fb7e0

Browse files
committed
feat: update articles
1 parent 5beac21 commit e5fb7e0

File tree

11 files changed

+112
-10
lines changed

11 files changed

+112
-10
lines changed
File renamed without changes.
File renamed without changes.

java/oop/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Java Concurrency Snippets
2+
3+
参考 []() 获取完整的并发编程与代码说明。

java/oop/pom.xml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>wx</groupId>
5+
<artifactId>design-pattern</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<properties>
8+
<maven.compiler.source>1.8</maven.compiler.source>
9+
<maven.compiler.target>1.8</maven.compiler.target>
10+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
11+
</properties>
12+
<dependencies>
13+
<dependency>
14+
<groupId>junit</groupId>
15+
<artifactId>junit</artifactId>
16+
<version>4.12</version>
17+
</dependency>
18+
<dependency>
19+
<groupId>org.hamcrest</groupId>
20+
<artifactId>hamcrest-all</artifactId>
21+
<version>1.3</version>
22+
</dependency>
23+
</dependencies>
24+
<build>
25+
<sourceDirectory>.</sourceDirectory>
26+
<pluginManagement>
27+
<plugins>
28+
<plugin>
29+
<groupId>org.apache.maven.plugins</groupId>
30+
<artifactId>maven-checkstyle-plugin</artifactId>
31+
<version>3.0.0</version>
32+
<dependencies>
33+
<dependency>
34+
<groupId>com.puppycrawl.tools</groupId>
35+
<artifactId>checkstyle</artifactId>
36+
<version>8.10</version>
37+
</dependency>
38+
<dependency>
39+
<groupId>com.github.ngeor</groupId>
40+
<artifactId>checkstyle-rules</artifactId>
41+
<version>1.1.0</version>
42+
</dependency>
43+
</dependencies>
44+
<configuration>
45+
<configLocation>com/github/ngeor/checkstyle.xml</configLocation>
46+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
47+
</configuration>
48+
</plugin>
49+
</plugins>
50+
</pluginManagement>
51+
<plugins>
52+
<plugin>
53+
<groupId>org.apache.maven.plugins</groupId>
54+
<artifactId>maven-checkstyle-plugin</artifactId>
55+
</plugin>
56+
57+
<!--
58+
You can run jacoco in the default profile with:
59+
mvn jacoco:prepare-agent test jacoco:report
60+
-->
61+
<plugin>
62+
<groupId>org.jacoco</groupId>
63+
<artifactId>jacoco-maven-plugin</artifactId>
64+
<version>0.8.1</version>
65+
</plugin>
66+
</plugins>
67+
</build>
68+
<reporting>
69+
<plugins>
70+
<plugin>
71+
<groupId>org.apache.maven.plugins</groupId>
72+
<artifactId>maven-javadoc-plugin</artifactId>
73+
<version>3.0.0</version>
74+
</plugin>
75+
<plugin>
76+
<groupId>org.apache.maven.plugins</groupId>
77+
<artifactId>maven-checkstyle-plugin</artifactId>
78+
<configuration>
79+
<configLocation>com/github/ngeor/checkstyle.xml</configLocation>
80+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
81+
</configuration>
82+
</plugin>
83+
</plugins>
84+
</reporting>
85+
86+
</project>

java/oop/rm-misc.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
find . -name '*.project' -exec rm -rf {} \;
4+
find . -name '*.idea' -exec rm -rf {} \;
5+
find . -name '*.iml' -exec rm -rf {} \;
6+
find . -name 'bin' -exec rm -rf {} \;
7+
find . -name 'target' -exec rm -rf {} \;

ts/oop/src/facade/demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Facade } from './facade';
1+
import { Facade } from '.';
22

33
const facade: Facade = new Facade();
44

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import ConnectionInterface from './ConnectionInterface';
22

33
export default class PasswordReminder {
4-
private db;
4+
private db: ConnectionInterface;
5+
56
constructor(db: ConnectionInterface) {
67
this.db = db;
78
}
89
reminder(): string {
910
return this.db.connect() + ' ...reminding password';
1011
}
11-
}
12+
}

ts/oop/src/solid/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const report = new SalesReporter(new SalesRepository());
2525
const htmlReport = report.between<string>(1, 2, new HtmlOutput());
2626
const jsonReport = report.between<object>(3, 5, new JsonOutput());
2727
console.group('reports', htmlReport, jsonReport);
28+
console.groupEnd();
2829

2930
const checkout = new Checkout();
3031
const cash = checkout.begin(12, new CashPaymentMethod());
@@ -38,15 +39,19 @@ const areas = calculateArea.calculate([
3839
new Square(10, 10),
3940
]);
4041
console.group('areas', areas);
42+
console.groupEnd();
4143

4244
const dbLessons = getAll(new DbLessonRepository());
4345
const fileLessons = getAll(new FilesLessonRepository());
4446
console.group('lessons', dbLessons, fileLessons);
47+
console.groupEnd();
4548

4649
const captain = new Captain();
4750
const manageAndroid = captain.manage(new AndroidWorker());
4851
const manageHuman = captain.manage(new HumanWorker());
4952
console.group('manage', manageAndroid, manageHuman);
53+
console.groupEnd();
5054

5155
const passwordRemainder = new PasswordReminder(new MySqlConnection());
5256
console.group('passwordRemainder', passwordRemainder.reminder());
57+
console.groupEnd();

ts/oop/src/solid/ocp/Circle.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import ShapeI from './ShapeI';
22

33
class Circle implements ShapeI {
4-
private radius;
4+
private radius: number;
55
constructor(radius: number) {
66
this.radius = radius;
77
}
8-
area() : number {
8+
area(): number {
99
return this.radius * this.radius * Math.PI;
1010
}
1111
}
1212

13-
export default Circle;
13+
export default Circle;

ts/oop/src/solid/ocp/Square.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import ShapeI from './ShapeI';
22

33
class Square implements ShapeI {
4-
private height;
5-
private width;
4+
private height: number;
5+
private width: number;
66

77
constructor(height: number, width: number) {
88
this.height = height;
@@ -14,4 +14,4 @@ class Square implements ShapeI {
1414
}
1515
}
1616

17-
export default Square;
17+
export default Square;

0 commit comments

Comments
 (0)