标签 博客 下的文章

你提供默认选项了吗

五一期间到姥姥家串门儿,自然午饭要在那吃,可中午做饭时听姥姥抱怨新买的电饭煲做饭时间太长而且还夹生,我好奇的走了过去想看看究竟,电饭煲的确是新买不久的,而且是美的的,我心想大牌厂商应该不会有这样的质量问题呀,一定是姥姥使用上的问题。仔细看了看控制板,果然不出所料,电饭煲的’功能选择’键停在了功能档的中央,既不是左边的’煮饭’也不是右边的’煲粥’,遂告诉姥姥以后煮饭要把功能选择调到’煮饭’档。

吃完午饭,闲来无事,便又想起这件事来,联系到Keso写过的一篇叫’默认的力量‘的文章,自己又有了些新想法。当Keso那篇文章说的是IE用’默认的力量’打败了’Netscape’,其中总结的一个潜规则就是’用户都是无知者’,’无知者’一方面可能没有能力去挖掘你的工具提供的诸多强大的功能,另一方面则是少有人愿意为挖掘出那些强大的功能而付出劳动,能用就好,最理想的就是’拿来即用’。这也好比一台理想的电视机,从商店买回家里,插上电源,按下电源开关,全国各个电视台就都能在电视上看到,而无需去人工搜索设定电视频道。这样的情形在很多场合都能见到,在软件开发中也不例外。

自己曾经在一个项目中提供了这样一组宏,其目的就是为了利用编译开关来选择程序输出的调试日志级别,比如level 1级别的日志只是输出某些最重要的调试信息,level 3级别的则是输出所有调试信息。当时没有多想就在一个头文件中写下了如下的代码:
/*
 * 代码片断1
 */
#ifdef _DEBUG_LEVEL1

#define MY_TRACE_L1(name, stat) TRACE(name, stat)
#define MY_TRACE_L2(name, stat) {}
#define MY_TRACE_L3(name, stat) {}

#endif /* _DEBUG_LEVEL1 */

#ifdef _DEBUG_LEVEL2

#define MY_TRACE_L1(name, stat) TRACE(name, stat)
#define MY_TRACE_L2(name, stat) TRACE(name, stat)
#define MY_TRACE_L3(name, stat) {}

#ifdef _DEBUG_LEVEL3

#define MY_TRACE_L1(name, stat) TRACE(name, stat)
#define MY_TRACE_L2(name, stat) TRACE(name, stat)
#define MY_TRACE_L3(name, stat) TRACE(name, stat)

不久一同项目组的哥们发来mail说程序编译不过去了,我迅速查了一下,发现在Makefile中没有定义任何DEBUG LEVEL宏,再看一下上面的代码你就会知道如果没有定义任何DEBUG LEVEL宏,那么用在程序代码中的MY_TRACE_Ln就是’undefined symbols’,程序自然不能编译通过。解决的方法很简单:添加一个DEBUG LEVEL宏,不过这样并不是一劳永逸的做法。正如我们上面所言,’用户都是无知的’,使用该程序的人最愿意看到的就是敲入’make’,马上得到可执行程序,而不是先添加一个宏定义后再make。最后我提供了一个默认的DEBUG LEVEL,解决方法如下:
/*
 * 代码片断2
 */
#if !defined(_DEBUG_LEVEL1) && !defined(_DEBUG_LEVEL2) && !defined(_DEBUG_LEVEL3)
#define _DEBUG_LEVEL1
#endif
把’代码片断2′放到’代码片断1′的前面,这样即使用户没有定义任何DEBUG LEVEL宏,程序仍然可以顺利通过编译。这段小插曲提醒我们时刻想着提供一个’默认的选项’,有些时候它事关重大,不能小觑它的力量。

仅仅提供一个’默认选项’就够了么?我们再回到前面的那个’美的’电饭煲的设计上。从功能上该电饭煲提供了两种功能’煮饭’和’煲粥’,但是它好像并未提供默认的选项,而是将’功能选择’键放在了功能档的中央。也许有些人会说这可能就是电饭煲提供的默认的选项呢,也许这个中间档是出于安全考虑呢。但是我要说即使它是默认选项,它也有误导的作用,不了解它的人会认为这样就可以煮饭了,我姥姥就是这么想的。没错儿,这里我要说的就是’谨慎选择默认项,不要误导使用者’。这里我没有很好的软件开发中的例子来说明,似乎少了些说服力,不过通过这个电饭煲的例子你也可以悟到一些东西。其实如果我是电饭煲的设计者,我是不会允许将’功能选择’键放在了功能档的中央的,要么放在’煮饭’档要么放在’煲粥’档。^_^

你在开发中提供默认选项了么,如果还没有的话,那就该好好想想是否是时候添加一个没有误导作用的默认选项了。

口语学习笔记之'随意的谈话'

平时闲聊,想必大家都会^_^。今天我们看看如何用英语’闲聊’,下面是’口语8000句’中的’随意谈话’一课的听写记录。

[征求意见]
Do you understand?
Understood?
Is that clear?
Get the picture? 了解情况么
Do you know what I mean?
Are you listening to me?
Are you blind? 你不知道么
You know what I am talking about.
I said that, didn’t I?
Do you know that?
Do you happen to know …? 说不定你知道…吧
I can’t tell the difference.
Can you hear me?
Did you hear me?

[同意]
I understand.
See?
I understand very well.
I think I understand.
I see what you mean.
I know that too well.
I see your point. = I see what you mean.
I get it. 终于明白对方所说的事情
I got it. 这样啊,原来是这么回事,随意的说法
I know that much. 这点事儿我还是知道的
That solves it. 原来是这样呀。
All right, all right. I understand.
I know that person.
I know him by sight. 知道、见过面
Yeah, I heard about it.
I am following you.
Make sense. 言之有理

[不明白、不知道]
I don’t (really) understand.
That’s not clear.
I can’t see your point.
I can’t understand what you mean.
I’m not sure what you mean.
I don’t know what’s what. 根本不知道是怎么回事
It’s over my head.
Your guess is as good as mine.
The more I think about it, the less I understand it.
I don’t know what he is driving at. = I don’t know what he is trying to do.
What’s she after? = what is she trying to do?
I’ve no idea.
I don’t know for sure.
No one knows for sure.
How should I know? 我怎么会知道
Who knows?

[反问]
Yes?
What for?
Pardon me? = I beg your pardon
How about now?
Excuse me?
What?
Did you say anything?
I’m sorry, what did you say?
So what? 那又能怎么样呢
What does it mean?
Are you saying that …
Then what? 后来怎么样了
What’s he driving at?
Would you repeat that please?
You’re speaking too quickly.
Please say it more slowly.
I can’t keep up.
Please speak a little louder.
I can’t hear you.
I couldn’t catch what you said.
What’re you talking about?

[感想]
Just like me.
Was it good?
Did you have fun?
How do you like it?
Did you like it?
What do you think of it?

[询问、叙述情况]
How did things turn out?
To make a long story short. 长话短说
Just tell me the story in a nutshell.
Let me know the circumstances/situation.
A piece of cake. 轻而易举
So far, so good. 到现在为止还好
so-so. 马马虎虎
That’s about it. 就是这样
It was nothing.
There is nothing to it.
It worked.
It needs work.
Going from bad to worse.
He made it big. 一举成名
We are set. 我们准备好了 or 问题解决了

[随声附和]
I see.
Uh-huh. 啊哈(表示肯定答复的惊叹词)
You have?
Is that right?
That’s right.
Exactly!
Oh, yeah? = Is that so? 是吗
And?
Me, too.
Neither do I.
Don’t be silly.
That’s too bad.
Are you sure?
What a shame!
What a surprise!
I hope not.
I hope so.
Great!
Unbelievable! 难以置信
No kidding! 开玩笑吧
You bet = sure, OK = No problem

[一时语塞]
Well… 嗯…
Let me see.
I mean…
It’s on the tip of my tongue. 话在嘴边
What should I say? 难以启齿的话
I don’t know quite how to put this. 我真不知道该说什么好
What do you call it?
You’ve got me 让你问住了

[催促别人说]
Say something.
Tell me more about it.
How was your trip?
I’m all ears. = I’m listening carefully.
How was the meeting?
I like to hear the story.
We had small talk.
Did you enjoy the play?
I want to talk about it now.
Shoot = Go ahead 说吧
Let’s talk in English.
Let’s have a chat.
To the point, please. 抓重点地说
How was your day?

[转换话题]
Let’s change the subject.
Let’s get back to the subject. 言归正传
I don’t want to talk about it now.
Let’s talk about it later.
To change the subject.
Well, all joking aside, …  好了,玩笑就到此为止…
By the way,…
You were saying?
That reminds me. = I remember it.
Let’s stop talking.
I’ve heard the story before.
Let’s drop the subject.
Don’t say it so loud.

[下决心]
I’ve decided it.
It is up to you. = you decide = It depends on you.
This is the important point.
This is my person problem.
It is a matter of life and death. 生死攸关的大事
You are free to go or stay.
There is no turning back. 已经无可挽回
Let’s play it by ear. 走一步看一步,顺其自然
I’m sure I can do it.
I’m still unable to decide what to do.
I’ll follow her.
Let’s all get together and act as one.
I have to do it anyhow. = I must do it anyway.
It’s now or never. 机不可失,失不再来
The sooner, the better.
I’ll take a chance.
Have more guts. 再拿出点勇气来
Let’s finish it somehow.
It is worth a try.
We must function as one mind and one body. 同心同德
You just wait. 等着瞧吧
It’s all or nothing. 豁出去了,孤注一掷

[New Words To Me]
in a nutshell — summed up briefly.
gut — courage; fortitude.

如发现本站页面被黑,比如:挂载广告、挖矿等恶意代码,请朋友们及时联系我。十分感谢! Go语言第一课 Go语言精进之路1 Go语言精进之路2 Go语言编程指南
商务合作请联系bigwhite.cn AT aliyun.com

欢迎使用邮件订阅我的博客

输入邮箱订阅本站,只要有新文章发布,就会第一时间发送邮件通知你哦!

这里是 Tony Bai的个人Blog,欢迎访问、订阅和留言! 订阅Feed请点击上面图片

如果您觉得这里的文章对您有帮助,请扫描上方二维码进行捐赠 ,加油后的Tony Bai将会为您呈现更多精彩的文章,谢谢!

如果您希望通过微信捐赠,请用微信客户端扫描下方赞赏码:

如果您希望通过比特币或以太币捐赠,可以扫描下方二维码:

比特币:

以太币:

如果您喜欢通过微信浏览本站内容,可以扫描下方二维码,订阅本站官方微信订阅号“iamtonybai”;点击二维码,可直达本人官方微博主页^_^:
本站Powered by Digital Ocean VPS。
选择Digital Ocean VPS主机,即可获得10美元现金充值,可 免费使用两个月哟! 著名主机提供商Linode 10$优惠码:linode10,在 这里注册即可免费获 得。阿里云推荐码: 1WFZ0V立享9折!


View Tony Bai's profile on LinkedIn
DigitalOcean Referral Badge

文章

评论

  • 正在加载...

分类

标签

归档



View My Stats