Skip to content

Commit 05f7391

Browse files
committed
WIP
1 parent 2770b73 commit 05f7391

14 files changed

Lines changed: 250 additions & 76 deletions

assets/colophon.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
<div style="padding-top: 110mm; position: relative; color: #222;">
1+
2+
3+
<div style="padding-top: 5mm; position: relative; color: #222; font-style: oblique; line-height: 1;">
4+
<p style="margin-bottom: 0;margin-top: 0">УДК 004.415</p>
5+
<p style="margin-bottom: 0;margin-top: 0.5em">ББК 32.973.201</p>
6+
<p style="margin-bottom: 0;margin-top: 0.5em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ч49</p>
7+
</div>
8+
9+
<div style="padding-top: 90mm; position: relative; color: #222;">
210
<div style="text-align: center; max-width: 280px; margin: 0 auto; line-height: 1.3;">
311
<p style="margin: 0; font-weight: 700; font-size: 14pt; letter-spacing: 0.05em;">ДЕНДИ-КОД</p>
412
<p style="margin: 0; font-weight: 600; font-size: 12pt; margin-top: 0.15em;">Черняев Александр</p>
5-
<p style="margin: 0; font-size: 10pt; margin-top: 0.5em;">Версия 1.0, издание первое</p>
6-
<p style="margin: 0; font-size: 10pt; margin-top: 0.3em;">ISBN 000-0-00000-000-0</p>
13+
<p style="margin: 0; font-size: 10pt; margin-top: 0.3em;">ISBN 978-5-6051372-3-8</p>
714
<p style="margin: 0; font-size: 10pt; margin-top: 0.3em;">Коммит [commit]</p>
815
<p style="margin: 0; font-weight: 700; font-size: 12pt; margin-top: 1em;">Липецк [year]</p>
916
</div>

assets/cover-back.jpg

58 Bytes
Loading

assets/cover.jpg

-2.7 KB
Loading

assets/hightlight.css

Lines changed: 115 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,59 @@
1+
/*
12
pre, code {
2-
color: #1f2328;
3+
background-color: #f4f4f4;
4+
color: #1a1a1a;
35
}
46
7+
58
.hl-keyword {
6-
color: #cf222e;
9+
color: #b22222;
710
}
811
12+
913
.hl-property {
10-
color: #8250df;
14+
color: #6a0dad;
1115
}
1216
17+
1318
.hl-attribute {
19+
color: #795548;
1420
font-style: italic;
1521
}
1622
23+
1724
.hl-type {
18-
color: #EA4334;
25+
color: #d93025;
1926
}
2027
21-
.hl-generic {
22-
color: #9d3af6;
23-
}
2428
25-
.hl-value {
26-
color: #0a3069;
29+
.hl-generic {
30+
color: #9c27b0;
2731
}
2832
29-
.hl-literal {
30-
color: #0a3069;
31-
}
3233
34+
.hl-value,
35+
.hl-literal,
3336
.hl-number {
34-
color: #0a3069;
37+
color: #0645ad;
3538
}
3639
40+
3741
.hl-variable {
38-
color: #953800;
42+
color: #c16000;
3943
}
4044
45+
4146
.hl-comment {
42-
color: #6e7781;
47+
color: #4b5258;
48+
font-weight: 500;
4349
}
4450
51+
4552
.hl-blur {
4653
filter: blur(2px);
4754
}
4855
56+
/ выделения /
4957
.hl-strong {
5058
font-weight: bold;
5159
}
@@ -69,7 +77,7 @@ pre, code {
6977
.hl-gutter {
7078
display: inline-block;
7179
font-size: 0.9em;
72-
color: #555;
80+
color: #333;
7381
padding: 0 1ch;
7482
margin-right: 1ch;
7583
user-select: none;
@@ -83,4 +91,94 @@ pre, code {
8391
.hl-gutter-deletion {
8492
background-color: #EA4334;
8593
color: #fff;
86-
}
94+
}
95+
*/
96+
97+
pre, code {
98+
background-color: #dfdfdf;
99+
color: #000;
100+
}
101+
102+
.hl-keyword {
103+
color: #000;
104+
}
105+
106+
.hl-property {
107+
color: #222;
108+
}
109+
110+
.hl-attribute {
111+
color: #333;
112+
}
113+
114+
.hl-type {
115+
color: #444;
116+
}
117+
118+
.hl-generic {
119+
color: #444;
120+
}
121+
122+
.hl-value,
123+
.hl-literal,
124+
.hl-number {
125+
color: #555;
126+
}
127+
128+
.hl-variable {
129+
color: #111;
130+
}
131+
132+
.hl-comment {
133+
color: #666;
134+
font-weight: 400;
135+
font-style: oblique;
136+
}
137+
138+
.hl-blur {
139+
filter: blur(2px);
140+
}
141+
142+
.hl-strong {
143+
color: #000;
144+
text-decoration: underline;
145+
}
146+
147+
.hl-em {
148+
color: #666;
149+
}
150+
151+
.hl-addition {
152+
display: inline-block;
153+
min-width: 100%;
154+
border-left: 3px solid #000;
155+
background-color: transparent;
156+
}
157+
158+
.hl-deletion {
159+
display: inline-block;
160+
min-width: 100%;
161+
border-left: 3px dashed #000;
162+
background-color: transparent;
163+
}
164+
165+
.hl-gutter {
166+
display: inline-block;
167+
font-size: 0.9em;
168+
color: #222;
169+
padding: 0 1ch;
170+
margin-right: 1ch;
171+
user-select: none;
172+
}
173+
174+
.hl-gutter-addition {
175+
border-left: 3px solid #000;
176+
color: #000;
177+
background: none;
178+
}
179+
180+
.hl-gutter-deletion {
181+
border-left: 3px dashed #000;
182+
color: #000;
183+
background: none;
184+
}

assets/img/phone-format.jpg

17.6 KB
Loading

assets/theme.html

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<header>
2-
<link rel="stylesheet"
3-
href="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/github.min.css">
42
<style>
53
body {
64
font-family: "EB Garamond", Georgia, Calibri, sans-serif;
@@ -99,27 +97,17 @@
9997
text-wrap: balance;
10098
}
10199

102-
ul,
103-
ol {
104-
/*margin-bottom: 20px;*/
105-
}
106-
107100
p {
108101
text-indent: 1.4em;
109-
/*
110-
padding: 0;
111-
margin: 0;
112-
*/
113102
}
114103

115104
pre {
116105
page-break-inside: avoid;
117106
break-inside: avoid;
118-
background-color: #fafafa;
119107
padding: 12pt 12pt;
120108
margin-bottom: 4mm;
121109
overflow-x: auto;
122-
border-radius: 4pt;
110+
//border-radius: 4pt;
123111
font-family: "JetBrains Mono", Consolas, Monaco, 'Courier New', monospace;
124112
font-size: 8pt;
125113
line-height: 1.5;
@@ -130,7 +118,6 @@
130118
background: none;
131119
font-size: 8pt;
132120
line-height: 1.5;
133-
color: #2d2d2d;
134121
text-align: left;
135122
font-family: "JetBrains Mono", Consolas, Monaco, 'Courier New', monospace;
136123
letter-spacing: 0.02em;
@@ -140,8 +127,10 @@
140127
}
141128

142129
code {
143-
color: #A5215D;
144-
background-color: #faf7f7;
130+
//color: #A5215D;
131+
//background-color: #f4f4f4;
132+
color: #000;
133+
background-color: #dedede;
145134
border-radius: .2rem;
146135
padding: .12rem .2rem;
147136
font-size: 100%;
@@ -200,7 +189,8 @@
200189
margin-bottom: 3mm;
201190
margin-left: 0;
202191
page-break-inside: avoid;
203-
background: #f5f2ef;
192+
background-color: #dedede;
193+
//background: #f5f2ef;
204194
padding: 20px;
205195
font-style: italic;
206196
}
@@ -221,7 +211,8 @@
221211
}
222212

223213
blockquote.notice {
224-
background-color: #f0f5ff;
214+
//background-color: #f0f5ff;
215+
background-color: #dedede;
225216
border-left: solid 5px #5b87dd;
226217
padding: 20px;
227218
}
@@ -231,7 +222,8 @@
231222
}
232223

233224
blockquote.warning {
234-
background-color: #ffeced;
225+
//background-color: #ffeced;
226+
background-color: #dedede;
235227
border-left: solid 5px #dd787d;
236228
padding: 20px;
237229
}
@@ -299,12 +291,6 @@
299291
page-break-inside: avoid;
300292
}
301293

302-
.quote-icon {
303-
display: block;
304-
font-size: 16pt;
305-
color: red;
306-
}
307-
308294
p:has(+ pre) {
309295
break-after: avoid;
310296
page-break-after: avoid;

content/001-preface.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242

4343
- [ ] Я имею базовые знания программирования.
4444
- [ ] Я участвовал в создании хотя бы одного коммерческого, личного или учебного проекта.
45-
- [ ] Я хочу улучшить свой код и работать в команде более эффективно.
45+
- [ ] Я хочу улучшить свой код и работать в команде более
46+
эффективно.
4647

4748
</div>
4849

content/009-size.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ $document = Document::find(1);
9696
$content = $document->export(Excel::class);
9797

9898
$user->notify(ExportNotification::class, [
99-
'content' => $content->toString(),
99+
'content' => $content->toString(),
100100
]);
101101
```
102102

content/010-no-nonsense.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,64 @@ $city = $user->address->city();
207207
> которые
208208
> не должны выполнять никаких действий.
209209
210+
211+
212+
Даже для простых типов данных — строк и чисел — стоит использовать объекты.
213+
Мы уже ранее рассматривали пример класса `Temperature`, который скрывает от нас работу с единицами измерения.
214+
Теперь рассмотрим аналогичный подход на примере строк.
215+
216+
Часто обработку строки записывают через вложенные вызовы:
217+
```php
218+
// Плохо [✗]
219+
echo strtoupper(trim(substr($input, 0, 10)));
220+
```
221+
222+
Код работает, но превращается в «матрёшку» из-за их чрезмерного количества вложенных функций.
223+
Читать его приходится справа налево, что совсем не свойственно латинице, на которой мы пишем код.
224+
Это увеличивает когнитивную нагрузку и скрывает намерение.
225+
226+
Для чтения удобнее сделать класс:
227+
228+
```php
229+
// Хорошо [✓]
230+
class Text implements Stringable {
231+
public function __construct(private string $value) {}
232+
233+
public function cut(int $length): static
234+
{
235+
return new static(substr($this->value, 0, $length));
236+
}
237+
238+
public function trim(): static
239+
{
240+
return new static(trim($this->value));
241+
}
242+
243+
public function value(): string
244+
{
245+
return $this->value;
246+
}
247+
248+
// ...
249+
}
250+
```
251+
252+
С таким классом обработка становится читаемой и выразительной:
253+
254+
```php
255+
echo (new Text($input))
256+
->cut(10)
257+
->trim()
258+
->upper()
259+
->value();
260+
```
261+
262+
Теперь мы читаем цепочку шагов, а не пытаемся расшифровать вложенные функции.
263+
264+
> **Обратите внимание на иммутабельность.**
265+
> Каждый шаг возвращает новый объект при котором не будет скрытых побочных эффектов.
266+
267+
210268
### Ссылки делают код хрупким
211269

212270
Передавать переменную по ссылке кажется удобным: функция сразу меняет её — меньше кода, меньше присваиваний.
@@ -304,7 +362,7 @@ class NewsGrouperBySoundex extends NewsGrouper
304362

305363
На первый взгляд — разумно. Но через месяц таких потомков будет уже пять, потом десять.
306364
Затем понадобится изменить в части наследников нормализацию имен для городов. Кто-то добавит изменения в
307-
родительский класс, чтобы «не трогать потомков», — и структура начинает шататься.
365+
родительский класс, чтобы «не трогать потомков» — и структура начинает шататься.
308366

309367
Вы смотрите на этот зоопарк и задаётесь вопросом: где живёт нужная логика? В родителе? В потомке? В обоих? В каком из
310368
пятнадцати классов?

0 commit comments

Comments
 (0)