-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
743 lines (498 loc) · 34.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
<link rel="mask-icon" href="/images/logo.svg" color="#222">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
<script id="hexo-configurations">
var NexT = window.NexT || {};
var CONFIG = {"hostname":"shouge.me","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
</script>
<meta name="description" content="我在黑夜敲击明天">
<meta property="og:type" content="website">
<meta property="og:title" content="shou ge| Blog">
<meta property="og:url" content="https://shouge.me/index.html">
<meta property="og:site_name" content="shou ge| Blog">
<meta property="og:description" content="我在黑夜敲击明天">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="shou ge">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="https://shouge.me/">
<script id="page-configurations">
// https://hexo.io/docs/variables.html
CONFIG.page = {
sidebar: "",
isHome : true,
isPost : false,
lang : 'en'
};
</script>
<title>shou ge| Blog</title>
<noscript>
<style>
.use-motion .brand,
.use-motion .menu-item,
.sidebar-inner,
.use-motion .post-block,
.use-motion .pagination,
.use-motion .comments,
.use-motion .post-header,
.use-motion .post-body,
.use-motion .collection-header { opacity: initial; }
.use-motion .site-title,
.use-motion .site-subtitle {
opacity: initial;
top: initial;
}
.use-motion .logo-line-before i { left: initial; }
.use-motion .logo-line-after i { right: initial; }
</style>
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage">
<div class="container use-motion">
<div class="headband"></div>
<header class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-container">
<div class="site-nav-toggle">
<div class="toggle" aria-label="Toggle navigation bar">
<span class="toggle-line toggle-line-first"></span>
<span class="toggle-line toggle-line-middle"></span>
<span class="toggle-line toggle-line-last"></span>
</div>
</div>
<div class="site-meta">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<h1 class="site-title">shou ge| Blog</h1>
<span class="logo-line-after"><i></i></span>
</a>
<p class="site-subtitle" itemprop="description">作为一只禽兽我感觉鸭梨很大</p>
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger">
</div>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="main-menu menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>Tags</a>
</li>
<li class="menu-item menu-item-categories">
<a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>Categories</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>Archives</a>
</li>
</ul>
</nav>
</div>
</header>
<div class="back-to-top">
<i class="fa fa-arrow-up"></i>
<span>0%</span>
</div>
<div class="reading-progress-bar"></div>
<main class="main">
<div class="main-inner">
<div class="content-wrap">
<div class="content index posts-expand">
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
<link itemprop="mainEntityOfPage" href="https://shouge.me/2021/04/11/40b026b41836/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://avatars2.githubusercontent.com/u/17906190">
<meta itemprop="name" content="shou ge">
<meta itemprop="description" content="我在黑夜敲击明天">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="shou ge| Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2021/04/11/40b026b41836/" class="post-title-link" itemprop="url">sql判断记录是否存在</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2021-04-11 17:02:33 / Modified: 17:12:50" itemprop="dateCreated datePublished" datetime="2021-04-11T17:02:33+08:00">2021-04-11</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">In</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/mysql/" itemprop="url" rel="index"><span itemprop="name">mysql</span></a>
</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p><img src="https://picsum.photos/1000/400?random=1618131525351" alt="插图"></p>
<p>根据条件从数据库表中查询 [存在] 与 [不存在]两种状态。</p>
<p>在业务代码中,需要根据一个或多个条件,查询是否存在记录,不关心有多少条记录。普遍写法如下:</p>
<h3 id="SQL"><a href="#SQL" class="headerlink" title="SQL"></a>SQL</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> <span class="built_in">COUNT</span>(<span class="operator">*</span>) <span class="keyword">FROM</span> tableName <span class="keyword">WHERE</span> xxx <span class="operator">=</span> <span class="number">123</span> <span class="keyword">AND</span> is_deleted <span class="operator">=</span> <span class="number">0</span>;</span><br></pre></td></tr></table></figure>
<h3 id="JAVA"><a href="#JAVA" class="headerlink" title="JAVA"></a>JAVA</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">int</span> count = xxDao.countxxByxx(params);</span><br><span class="line"><span class="keyword">if</span> (count > <span class="number">0</span>) {</span><br><span class="line"> <span class="keyword">return</span> <span class="keyword">true</span>;</span><br><span class="line">}</span><br><span class="line"><span class="keyword">return</span> <span class="keyword">false</span>;</span><br></pre></td></tr></table></figure>
<h2 id="推荐写法"><a href="#推荐写法" class="headerlink" title="推荐写法"></a>推荐写法</h2><p>推荐优化方案如下:</p>
<h3 id="SQL-1"><a href="#SQL-1" class="headerlink" title="SQL"></a>SQL</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> <span class="number">1</span> <span class="keyword">FROM</span> tableName <span class="keyword">WHERE</span> xxx <span class="operator">=</span> <span class="number">123</span> <span class="keyword">AND</span> is_deleted <span class="operator">=</span> <span class="number">0</span> LIMIT <span class="number">1</span>;</span><br></pre></td></tr></table></figure>
<h3 id="XML"><a href="#XML" class="headerlink" title="XML"></a>XML</h3><p>采用的ORM以mybatis 为例: </p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><-- 注意:resultType--> </span><br><span class="line"><span class="tag"><<span class="name">select</span> <span class="attr">id</span>=<span class="string">"existXxxxByXxx"</span> <span class="attr">resultType</span>=<span class="string">"integer"</span>></span></span><br><span class="line"> SELECT </span><br><span class="line"> 1</span><br><span class="line"> FROM tableName</span><br><span class="line"> WHERE</span><br><span class="line"> xxx = 123</span><br><span class="line"> AND </span><br><span class="line"> is_deleted = 0</span><br><span class="line"> LIMIT 1</span><br><span class="line"> <span class="tag"></<span class="name">select</span>></span></span><br></pre></td></tr></table></figure>
<h3 id="JAVA-1"><a href="#JAVA-1" class="headerlink" title="JAVA"></a>JAVA</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">Integer exist = xxDao.existXxxxByXxx(params);</span><br><span class="line"><span class="comment">// return exist != null;</span></span><br><span class="line"><span class="keyword">return</span> Objects.nonNull(exist);</span><br></pre></td></tr></table></figure>
<p>注意: 此处推荐采用包装类型来进行接收 , 直接通过判空来判断是否存在, SQL不在继续使用COUNT, 在SQL语句后面添加 LIMIT 1, 让数据库查询时遇到一条数据就返回, 不用再继续往下查找。</p>
<blockquote>
<p>在查询或者更新的时候 推荐尽量加上LIMIT ,养成良好的编码习惯。</p>
</blockquote>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
<link itemprop="mainEntityOfPage" href="https://shouge.me/2021/04/10/52956a7eae9c/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://avatars2.githubusercontent.com/u/17906190">
<meta itemprop="name" content="shou ge">
<meta itemprop="description" content="我在黑夜敲击明天">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="shou ge| Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2021/04/10/52956a7eae9c/" class="post-title-link" itemprop="url">factory method</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2021-04-10 00:02:19" itemprop="dateCreated datePublished" datetime="2021-04-10T00:02:19+08:00">2021-04-10</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Modified: 2021-04-11 16:59:40" itemprop="dateModified" datetime="2021-04-11T16:59:40+08:00">2021-04-11</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">In</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/design-pattrns/" itemprop="url" rel="index"><span itemprop="name">design-pattrns</span></a>
</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p><img src="https://picsum.photos/1000/400?random=1618131569883" alt="插图"></p>
<p><strong>工厂方法模式</strong>是一种创建型设计模式,其在父类中提供一个创建对象的方法,允许子类决定实例化对象的类型。</p>
<blockquote>
<p>工厂分为简单工厂模式(SimpleFactory), 工厂方法模式(FactoryMethod), 抽象工厂模式(AbstractFactory)。三种模式可以理解为同一种编程思想的三个版本。</p>
</blockquote>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
<link itemprop="mainEntityOfPage" href="https://shouge.me/2021/04/01/fd4fdd97d439/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://avatars2.githubusercontent.com/u/17906190">
<meta itemprop="name" content="shou ge">
<meta itemprop="description" content="我在黑夜敲击明天">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="shou ge| Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2021/04/01/fd4fdd97d439/" class="post-title-link" itemprop="url">Java Nameing Conventions</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2021-04-01 01:10:27" itemprop="dateCreated datePublished" datetime="2021-04-01T01:10:27+08:00">2021-04-01</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Modified: 2021-04-10 01:15:24" itemprop="dateModified" datetime="2021-04-10T01:15:24+08:00">2021-04-10</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">In</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/java/" itemprop="url" rel="index"><span itemprop="name">java</span></a>
</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p><img src="https://picsum.photos/1000/400?random=1617988035368" alt="插图"></p>
<p>前网景通讯公司(Netscape)知名工程师 Phil Karlton 也说过:</p>
<blockquote>
<p>There are only two hard things in Computer Science: cache invalidation and naming things.</p>
</blockquote>
<p> 命名非常能体现一个工程师的基本编码素养, 命名的好坏,对于代码的可读性非常重要,甚至起到决定性作用。混乱的命名不仅让我们对代码难以理解,更为糟糕的是会误导我们的思维,导致对代码理解完全错误,相反良好的命名,则可以让我们的代码非常容易正确表达事物以及逻辑。大到项目名,包名,模块,对外暴露的接口,小至类名,函数, 变量,参数都难以避免”命名”这个困扰。取一个良好的名字是一件非常困难的事情,即便是母语是英语的程序员而已,想要取一个能准确表达含义的名字,也是一件非常困难的事情,如上所示。对于天朝这些母语非英语的程序员来说,更是难上加难(比如我这种英语学渣)。</p>
<p>在日常编码工作中,实在想不到好名字的时候,可以采用变量名命名神器(CODELF) 来辅助我们进行变量命名,注: 本人有幸在项目中通过它来辅助自己的命名,个人感觉帮助并不是很大,只能作为参考。</p>
<h3 id="多长才是最合适的"><a href="#多长才是最合适的" class="headerlink" title="多长才是最合适的?"></a>多长才是最合适的?</h3><p>我们在进行命名的时候,是应该写一个很长的命名,还是一个简短的命名,这是一个非常有争议的问题,有时感觉命名一定要准确表达含义,长一点也没关系,还有另外一类代表派系则主张简短的命名方式。能缩写就尽量缩写。如果是你你是喜欢长一点还是短一点?</p>
<p>尽管长的命名可以包含更多的信息 ,更能准确直观的表达意图,但如果变量的命名很长,那它们共同组成的代码语句就会很长,甚至超出编辑器代码长度限制,就会被编辑器换行切割成多行的情况,这会影响代码的可读性。在命名能足够表达其含义的情况下,命名其实越短越好。当然短的命名没有长的命名那么更能达意。对于那些比较常见的词,推荐使用缩写的方式,既能让命名短一些,又能不影响阅读理解。比如: VO (View Object), DTO (Data Transfer Object ), DO (Domain Object), str (String), num (Number), 除此之外对于作用于比较小的变量,我们可以使用相对较短的命名方式。比如一些函数内的零时变量,循环迭代的下标索引等。相反, 对于类名这样作用域比较大的, 更推荐用长的命名方式。对于代码的作者而言,自己对代码的逻辑非常清楚,总感觉采用什么样的命名都能达意,对于需要接手你代码的同事来讲, 可能就不这么认为,在编写代码的时候,我们一定要学会换位思考,假设自己不熟悉这块代码,从代码阅读者的角度去 思考命名是否足够直观。</p>
<h3 id="利用上下文简化命名"><a href="#利用上下文简化命名" class="headerlink" title="利用上下文简化命名"></a>利用上下文简化命名</h3> <figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">User</span> </span>{</span><br><span class="line"> <span class="keyword">private</span> String userName;</span><br><span class="line"> <span class="keyword">private</span> String userPassword;</span><br><span class="line"> <span class="keyword">private</span> String userAvatarUrl;</span><br><span class="line"> <span class="comment">// 省略Geeter Seeter </span></span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>在上述类上下文中,我们没有必要在成员属性的命名添加user作为命名前置,而是直接命名为 name, password, avatarUrl。在使用属性的时候,我们可以很友好的借助对象上下文,表达也足够明确,如下 :</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">User user = <span class="keyword">new</span> User();</span><br><span class="line">String name = user.getName();</span><br></pre></td></tr></table></figure>
<p>函数的参数也可以借助这个上下文来进行简化命名, 如下:</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// Bad</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">uploadUserPic2Oss</span><span class="params">(String userPicImageUri)</span></span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">// Good</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">uploadUserPic2Oss</span><span class="params">(String ImageUri)</span></span>;</span><br></pre></td></tr></table></figure>
<h3 id="如何命名一些特殊的类"><a href="#如何命名一些特殊的类" class="headerlink" title="如何命名一些特殊的类"></a>如何命名一些特殊的类</h3><p>接口类 在阿里巴巴编程规范手册中推荐的方式 , 在接口类命名前面加前缀 “I”, 表示这是一个接口(Interface),如 IUserService ,已至对应的实现类添加Impl后缀,如 UserServiceImpl。对于接口的命名我个人更加倾向于不添加“I”前缀的方式, 如 UserService, 对于的实现类可以添加Impl后缀。但是如果在团队中大家约定了方式,那么一定要跟Team 保持Match。</p>
<p>抽象类 跟接口类一样,两种方式,通过添加统一的前缀 这里为 “Abstract”, 如 AbstractChannelHandlerDelegate (dubbo 服务消费者发送消息服务提供者接受消息) ,另外一种不带前缀 “Abstract” 。无论使用那种命名方式都是可以的,项目能够统一就ok。</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
<link itemprop="mainEntityOfPage" href="https://shouge.me/2021/01/24/d2a0055bc73b/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://avatars2.githubusercontent.com/u/17906190">
<meta itemprop="name" content="shou ge">
<meta itemprop="description" content="我在黑夜敲击明天">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="shou ge| Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2021/01/24/d2a0055bc73b/" class="post-title-link" itemprop="url">Hello World</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2021-01-24 21:17:33" itemprop="dateCreated datePublished" datetime="2021-01-24T21:17:33+08:00">2021-01-24</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Modified: 2021-04-10 01:08:16" itemprop="dateModified" datetime="2021-04-10T01:08:16+08:00">2021-04-10</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">In</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/Testing/" itemprop="url" rel="index"><span itemprop="name">Testing</span></a>
</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>Welcome to <a target="_blank" rel="noopener" href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a target="_blank" rel="noopener" href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a target="_blank" rel="noopener" href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a target="_blank" rel="noopener" href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>
<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<script>
window.addEventListener('tabs:register', () => {
let { activeClass } = CONFIG.comments;
if (CONFIG.comments.storage) {
activeClass = localStorage.getItem('comments_active') || activeClass;
}
if (activeClass) {
let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
if (activeTab) {
activeTab.click();
}
}
});
if (CONFIG.comments.storage) {
window.addEventListener('tabs:click', event => {
if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
let commentClass = event.target.classList[1];
localStorage.setItem('comments_active', commentClass);
});
}
</script>
</div>
<div class="toggle sidebar-toggle">
<span class="toggle-line toggle-line-first"></span>
<span class="toggle-line toggle-line-middle"></span>
<span class="toggle-line toggle-line-last"></span>
</div>
<aside class="sidebar">
<div class="sidebar-inner">
<ul class="sidebar-nav motion-element">
<li class="sidebar-nav-toc">
Table of Contents
</li>
<li class="sidebar-nav-overview">
Overview
</li>
</ul>
<!--noindex-->
<div class="post-toc-wrap sidebar-panel">
</div>
<!--/noindex-->
<div class="site-overview-wrap sidebar-panel">
<div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
<img class="site-author-image" itemprop="image" alt="shou ge"
src="https://avatars2.githubusercontent.com/u/17906190">
<p class="site-author-name" itemprop="name">shou ge</p>
<div class="site-description" itemprop="description">我在黑夜敲击明天</div>
</div>
<div class="site-state-wrap motion-element">
<nav class="site-state">
<div class="site-state-item site-state-posts">
<a href="/archives/">
<span class="site-state-item-count">4</span>
<span class="site-state-item-name">posts</span>
</a>
</div>
<div class="site-state-item site-state-categories">
<a href="/categories/">
<span class="site-state-item-count">4</span>
<span class="site-state-item-name">categories</span></a>
</div>
<div class="site-state-item site-state-tags">
<a href="/tags/">
<span class="site-state-item-count">4</span>
<span class="site-state-item-name">tags</span></a>
</div>
</nav>
</div>
<div class="links-of-author motion-element">
<span class="links-of-author-item">
<a href="https://github.com/shouge" title="GitHub → https://github.com/shouge" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
</span>
<span class="links-of-author-item">
<a href="mailto:[email protected]" title="E-Mail → mailto:[email protected]" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
</span>
</div>
</div>
</div>
</aside>
<div id="sidebar-dimmer"></div>
</div>
</main>
<footer class="footer">
<div class="footer-inner">
<div class="copyright">
© 2015 –
<span itemprop="copyrightYear">2021</span>
<span class="with-love">
<i class="fa fa-heart"></i>
</span>
<span class="author" itemprop="copyrightHolder">shou ge</span>
</div>
<div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a>
</div><script color="0,0,255" opacity="0.5" zIndex="-1" count="99" src="https://cdn.jsdelivr.net/npm/canvas-nest.js@1/dist/canvas-nest.js"></script>
</div>
</footer>
</div>
<script src="/lib/anime.min.js"></script>
<script src="/lib/pjax/pjax.min.js"></script>
<script src="/lib/velocity/velocity.min.js"></script>
<script src="/lib/velocity/velocity.ui.min.js"></script>
<script src="/js/utils.js"></script>
<script src="/js/motion.js"></script>
<script src="/js/schemes/pisces.js"></script>
<script src="/js/next-boot.js"></script>
<script>
var pjax = new Pjax({
selectors: [
'head title',
'#page-configurations',
'.content-wrap',
'.post-toc-wrap',
'.languages',
'#pjax'
],
switches: {
'.post-toc-wrap': Pjax.switches.innerHTML
},
analytics: false,
cacheBust: false,
scrollTo : !CONFIG.bookmark.enable
});
window.addEventListener('pjax:success', () => {
document.querySelectorAll('script[data-pjax], script#page-configurations, #pjax script').forEach(element => {
var code = element.text || element.textContent || element.innerHTML || '';
var parent = element.parentNode;
parent.removeChild(element);
var script = document.createElement('script');
if (element.id) {
script.id = element.id;
}
if (element.className) {
script.className = element.className;
}
if (element.type) {
script.type = element.type;
}
if (element.src) {
script.src = element.src;
// Force synchronous loading of peripheral JS.
script.async = false;
}
if (element.dataset.pjax !== undefined) {
script.dataset.pjax = '';
}
if (code !== '') {
script.appendChild(document.createTextNode(code));
}
parent.appendChild(script);
});
NexT.boot.refresh();
// Define Motion Sequence & Bootstrap Motion.
if (CONFIG.motion.enable) {
NexT.motion.integrator
.init()
.add(NexT.motion.middleWares.subMenu)
.add(NexT.motion.middleWares.postList)
.bootstrap();
}
NexT.utils.updateSidebarPosition();
});
</script>
<div id="pjax">
</div>
</body>
</html>