大师说的这些话,今天还记得吗?

我在设计C++的时候,思考了一系列的设计元素,  无论它是不是面向对象的,我认为他们都是最基本和实用的.

1. 抽象: 是用程序直接表现一个概念的能力, 将次要的细节隐藏在精心定义的接口后面. 这是任何一个无论规模大小的灵活的系统的设计关键.

2. 封装: 是保证”抽象”仅仅是根据其规格定义而使用的能力, 这是防止”抽象”被损坏的关键.

3. 多态: 是为接口提供不同实现方法的能力, 这是用抽象来简化代码的关键.

4. 继承: 是从已有的抽象去建造新的抽象的能力, 这是组建有用的抽象的最强大的方法之一.

5. 通用: 为类型和功能付以参数的能力, 这是表达安全类型和通用算法的强有力工具

6. 和其他语言和系统共存 – 重要性在于建造在客观世界的执行环境

7. 运行时的简洁和速度 – 对经典系统编程尤其重要

8. 静态类型的安全性 – 一个语言的完整性, 保证设计的属性和运行时的效率

上面所提及的这些能力是不是面向对象的呢? 哪一个是呢? 用哪一个面向对象的定义去解释呢?

在大多数的情形下, 我认为这些问题都不对. 真正有意义的是你怎样表达你的思想, 怎么样可以更好和其他软件资源结合, 怎么样能有效的维护程序. 也就是说, 你如何可以更好的支持程序编码和设计要比用什么词语去描述它有意义的多.

最基本的思想就是用抽象去提高设计和编码. 你想隐藏细节, 你想开发系统的通用性. 你想让你的程序实现这些想法.

我想建议你不要把面向对象作为一个无用的词语去理解, “面向对象” 太多的时候被误解了,比如

-与”好”划等号

-与”一种语言”划等号

-认为什么都是”面向对象”的

我这里的论点是一定有超出”面向对象”的编程和设计…

Advertisements
Posted in Uncategorized | Leave a comment

How to make a python script scale on Cloud?

I was often asked by bioinformaticians in the research group (Oxford MMM) how to make a python script ready for scaling in the cloud. That is not rocket science but it is not trivial either. It not only needs some software development discipline but also needs a different way of thinking.

I am going to walk through a little bioinformatic project to explain what I meant in terms of discipline and thinking behind the coding. 

The requirement

A python script is needed to parse input VCF files and to create new VCF files that only contain SNVs. The VCF file used in our tests are in size of 1G. A file contains about 4.4 million of rows of data. We aim to process 25,000 files of this kind. Make a solution and evaluate the compute and related cost of this task.

Continue reading
Posted in 信息科技 | 4 Comments

彼岸

周末组织了”彼岸”本年度的最后一次活动,和出版人,代理人,媒体人见面,促进华人作家在英国闯入主流的文化市场,在英国出版自己的作品。这对于像我这样的第一代华人移民,或许永远是一个梦。不过生命还在,希望就在吧。

请来的业界四个嘉宾都给我们讲了好多实际的,真诚的建议。摘录几条和大家共勉:

Continue reading
Posted in Uncategorized | 1 Comment

nextflow with Azure Kubernetes Service (AKS)

One week ago, I was googling a lot looking for a working example running a nextflow pipeline on a Kubenetes cluster, specially in Azure Kubernetes Service (AKS), I could not find any.  Luckily, I got a lot of support from nextflow gitter,  specially from Paolo Di Tommaso.  Finally, I made it work and now it is time to share this with you all.

Before start, I assume you have read the following to get familiar with the nextflow way of running a pipeline in Kubernetes cluster.

latest nextflow with Kubenetes

In summary, this new feature provided by nextflow (version 0.31.1 in this post) with Kubenetes has following three benefits:

Continue reading
Posted in 信息科技 | Leave a comment

Teaching Chinese

I am just back from a Chinese teacher training workshop. It was an inspiring and enjoyable experience. The instructor, Chris Webster, is a passionate Chinese trainer who developed a learning toolkit for students aged 11 to 16.

His toolkit is well thought and can be used straight way for Chinese teachers. As a native speaker, although I am confident to teach my students about everything about Chinese, the toolkit and his way of teaching is still fascinating to me.

The workshop starts with discussion on the challenges of learning and teaching Chinese in UK schools. We all agree it’s pretty difficult to teach Chinese. There are at least five aspects identified, Attitude, Behaviour, Support, Slow progress and Time Constraint. Most of us think that attitude is the biggest challenge as self-motivation is such important for learning anything. However, we do know most of our students are sent to school by parents, I guess no kids like to learn this language deep from their heart at that young age. It reminded my fear when I started to learn English in Year 7. I was so afraid to learn a new language. It is all for the tests, for the opportunity to go to a good university. My learning has never been self-motivated, deep in heart. So can motivation be built easily?

Chris showed us a good discipline for Teacher’s Talk, the 5Cs: Consistent, Concise, Checks Understanding, Creative and Communicative. And he is so good at those disciplines. Be consistent about speaking target language for teaching, this has been challenging for me for a while, I have never been consistent to use Chinese, English or both; Using simple and clear phrase to get students involved in the activities; Constantly checking and communicate with students about their understanding. And most important, he is so creative about the learning material, learning activity, such as using banter, rap with Dr Dre and all possible visual and art forms to teach. You can imagine how enjoyable the students are learning Chinese with him.

A few techniques from Chris that worth to explore:

  • Give your student an authentic Chinese Name, they love it
  • Use Think – Pair – Share for practice
  • Use 5,4,3,2,1,0 counting down to get student attention
  • Let the students to read aloud, explain the activities and correcting mistakes
  • And lots of 3 version of visual (with English, with Pinyin and without)

OK, learning never ends,even for teachers … the most important thing is the attitude. If we love Chinese training from heart, we are half way there.

Posted in 中文 | Leave a comment

Radcliffe Camera

I am reading Shakespeare’s poem (my homework from Coursera) in Radcliffe Camera, a 270 years old library in Central Oxford. Only the university students and staff can come in. This is such a privilege! I like to come here to remind myself how lucky I am working at this best learning environment in the world.

While reading, I cannot help looking at the splendid dome, the beautiful carvings on every corner of the building and the statue of John Radcliffe, the notable doctor to the King. He funded this library, together with University College and JR hospital, where my office is.

I sit here right in front of John Radcliffe statue, admiring the heritage, the elite of the scholars whose work have been collected here and the well reserved artefacts. It is the human civilization we should all be proud of. And sitting here seem to be part of it and got inspired and encouraged.

At this place this moment, I am satisfied, contented and also feel humble from heart. There is no excuse to complain, to blame or to find any excuses for not being good enough.

Posted in 人生感悟 | Leave a comment

2018@上海

老同学为我们的上海聚会选了一家在上海南京路上的川菜馆,就在地铁口的旁边,特别棒的选择。除了地点,还因为我也特别喜欢川菜,在腐国有限的黑暗料理中,川菜算是最解馋开胃的了。当然,聚会,聚餐不是只为饱腹,能一下子见到那么多老同学,是件不容易的事。

从外滩到南京路,走在上海的街头,正是下班时间,和匆匆的路人擦肩而过,我想起拜伦说的关于去东方旅行的那句话 “去东方,看看那里的人们,而不只是在书本上读到他们”。用今天的话说,应该是,”去看看朋友,而不只是在朋友圈里读到他们”。

十五年前,也是怀着这样的好奇,一张维真航空的单程票,把我带到遥远的英格兰,那时候,就是想看看那里的人们,想知道他们的生活真的像书本里写的那样吗? 转眼间,十五年过去了,回到东方,这里倒变得陌生起来,时空的交错,给我一种幻觉的感受,在上海的街头,我被魔都迷住了。这是我人生中第四次来上海。1986年,1998年,2008年,2018年,大约每十年,我都和这个城市有个约会。来这里,感受她的变化,体会她的底蕴,尝试着理解她,爱上她。这座承载着近代中国历史的城市,次次来都有令人难忘的发现。

最近的十年这个国家进入了史上空前繁荣的时代,”中国梦” 让所有人心醉神迷。在追梦的路上,这个城市展现了这个阶段特有的风景: 街道上奔跑着豪华的私家车,路边有随处可见的共享单车,还有那些无畏风雨的,机敏穿梭在狭窄弄堂里的电动摩托车。在外滩,精美的西式糕点店和清晨炸油条的拐角小屋只有几步之遥。南京路上,豪华的哈根达斯冰淇淋店里热闹非凡,新华书店在一个无人问津的角落里冷冷清清。浦东的摩天高楼,气派的机场,先进的高铁,十八条地铁线;科技馆里的中英文讲解,妙趣横生的机器人展览;免费向公众开放的上海博物馆和中华文化宫都无疑的向世人展示这是一个超级现代化,国际化的大都市。一位爱聊天的出租车司机跟我说,上海是一座二十四小时不停歇的城市,有朝九晚五的上班族,也有晚九朝五的服务族,还有全天候的网路一族。在追梦的路上,大家都不能停歇。仅仅用一个游客的眼睛去观察这个城市肯定是不够的。遗憾的是,我从没有在这里工作,生活过。这是一个令我仰慕的城市,似乎自己配不上她,只能偶尔来看看,短暂的拥抱她,然后可以愉悦的回忆十年。

是的,这场聚会也可以让我愉悦的回忆十年,昔日的老同学,个个都是时代的缩影。他们不仅在事业上的打拼,对老一辈,下一代的一丝不苟,也是这个时代特别的印记。饭桌上,大家只能简短的说说自己这些年的经历,幽默诙谐间,我们知道,每个人的这些年都不简单。在毕业二十多年以后,我们都努力成为了想成为的自己。

那个晚上,回到外滩,久久不能入睡,我的耳边一遍遍的回荡李宗盛的那首歌:

       为你我用了半年的积蓄,
       漂洋过海来看你
       为了这次相聚,
       就连见面时的呼吸
       我都反复练习
       言语从来没有将我的情意
       表达千万分之一
       为了这个遗憾
       我在夜里想了又想
       不肯睡去 … …

毕淑敏有一篇散文叫”旅行使我们谦虚”,说的特别好。旅行帮我们打开尘封的记忆,唤起我们对世界的好奇。每一次旅程都是一次奇妙的体验,在一个陌生的城市,在一个新的时空,在慢慢感受她的不同的时候,也慢慢看到一个不同的自己。感谢各位老同学的到来,我们相约十年后再见!

Posted in Uncategorized | Leave a comment