Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
编写高质量Java代码的7个建议
Search
uictechparty
July 08, 2012
Programming
200
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
编写高质量Java代码的7个建议
By Zelong Liang, 2nd TechParty@UIC
uictechparty
July 08, 2012
More Decks by uictechparty
See All by uictechparty
产品经理是做什么的呢?
uictechparty
1
250
找人
uictechparty
3
490
香港研究生申请经验分享
uictechparty
0
420
css.pdf
uictechparty
1
220
Introduction to Design Patterns
uictechparty
2
190
视觉障碍出行辅助仪 -The Third Eye
uictechparty
1
170
jQuery 快速入门
uictechparty
1
160
Introduction to NodeJS
uictechparty
1
240
Introduction to Hadoop
uictechparty
3
240
Other Decks in Programming
See All in Programming
『寄り添うラジオ』をAIで作る 体験価値から逆算した、会話しないUXと品質設計
theoriatec2024
3
180
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
570
Agents on Rails - Rails at Scale 2026
irinanazarova
0
190
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
390
AHC070解法紹介
eijirou
0
130
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
240
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
270
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
4
3.6k
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
160
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.1k
一人だけ、Kiroが静止する日
hideg
0
130
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
310
Featured
See All Featured
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
580
Design in an AI World
tapps
1
330
Thoughts on Productivity
jonyablonski
76
5.4k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
390
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
310
Mind Mapping
helmedeiros
1
370
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
ラッコキーワード サービス紹介資料
rakko
1
5M
Product Roadmaps are Hard
iamctodd
55
13k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.1k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
300
Transcript
编写高质量 Java 代码的 7 个 建议
Who I am ? • @ 龙 mol_ 才不是小 眼睛
建议 1 :不要在变量和常量中出现 容易混淆的字母 • 包名,全小写 test • 类名,首字母全大写 Client
• 常量,全部大写并用下划线分隔 NUM_1 • 变量,采用驼峰命名方法 • KillDragon1
• l -> L • o/O( 增加注释 )
建议 2 :少用静态导入 • 从 Java5 开始引入了静态导入方法 ( import static
) • 减少字符输入量 • 提高代码可读性 • KillDragon2
建议 3 :提倡异常封装 • Java 异常处理机制确保程序健壮性 • 但不易看懂 • 开发人员
• 用户 • 异常封装
优点 • 1. 提高系统的友好性 • 2. 提高系统的可维护性 • KillDragon3
建议 4 :使用线程异常处理器提升 系统可靠性 • 数据交互时要监听指定端口,实现数据包 的接收和发送逻辑 • 避免线程阻塞 •
借口稳定性和可靠性问题 • KillDragon4
建议 5 :提升 Java 性能基本方 法 • 1. 不要再循环条件中计算 •
2. 尽量把变量、方法声明为 final static • 3. 频繁字符串操作使用 StringBulider 或 SreingBuffer • KillDragon5
建议 6 :让注释正确、清晰、简洁 • 1. 废话式注释 • 2. 故事式注释 •
3. 不必要的注释 • 4. 过时的注释 • 5. 大块注释的代码 • 1. 警示式注释 • 2.TODO 注释 • 注释是美化剂,不是催化剂,或为优秀加分,或为拙劣减 分
建议 7 :增强类的可替换性 • 多态,一个接口可以有多个实现方式,一 个父类可以有多个子类,并且可以把不同 的实现或子类赋给不同的借口和父类。 • 好处:替换性 •
1. 子类必须完全实现父类方法 • 2. 前置条件可以被放大 • KillDragon6
Q&A