jlaky's profileJLaky's Open MindPhotosBlogLists Tools Help

JLaky Qiu

Occupation

JLaky's Open Mind

May 31

转移blog

改到JavaEye了,原因是这个编辑器不支持code
May 26

Design Patterns in Ruby [Digest 1]

1 About Patterns
 
the patterns for patterns:
1) Seperate out the things that change from those stay the same
A key goal of software engineering is to builld a system that allow us to contain the damage.
To make all changes local rather than change them everywhere.
It requires to identify and modulize the parts those most likely to change.
Hmmm... Seperate the changes parts from the stable parts. but how to do?
 
2) Program to an interface, not a implementation
It does not mean to program to the "interface" itself but to program to most general type you can.
Abstract important methods from class is a good idea, but it not enough
Ruby (a language that lacks interfaces in the built-in syntax sense)
actually encourages you to program to your interfaces in the sense of rogramming to the most general types.
 
3) Prefer composition over inheritance
Inheritancewill bind two classes with common implementation core.
The superclass changes will effect the subclasses behavior.
The interior of superclass will be exposed to subclasses, which might be forgotten.
If our goal is to build systems that are not tightly coupled together, to build systems
"where a single change does not ripple through the code like a sonic boom, breaking the glassware as it goes, then probably we should not rely on inheritance as much as we do."
 
Take the Vehicle and Car example: (It is not every vehicle need start and stop engine)
class Vehicle
# All sorts of vehicle-related code...
   def start_engine
   # Start the engine
   end
   def stop_engine
   # Stop the engine
   end
end

class Car < Vehicle
  def sunday_drive
     start_engine
     # Cruise out into the country and return
     stop_engine
  end
end
 
So it goes to:
class Engine
  # All sorts of engine-related code...
  def start
  # Start the engine
  end
  def stop
  # Stop the engine
  end
end
 
class Car
  def initialize
  @engine = Engine.new
  end
  def sunday_drive
    @engine.start
    # Cruise out into the country and return...
    @engine.stop
  end
end
4) Delegate
class Car
  # same as above
  def start_engine
    @engine.start
  end
 
  def stop_engine
    @engine.stop
  end
end
The composition and delegate gracefully replace the inheritance.
But it bring in some dull methods, and some minor performance cost.
In ruby the built-in lib support delegate to remove dull mothods.
 
Last rule is wrote by the writer:
 
You aint gonna need it
"This design principle comes out of the Extreme Programming world and is elegantly summed up by the phrase You Ain’t Gonna Need It (YAGNI for short). The YAGNI principle says simply that you should not implement features,
or design in flexibility, that you don’t need right now. Why? Because chances are, you ain’t gonna need it later, either."
 
"If you are not sure that you need it right now, postpone implementing the functionality until you really do need it."
 
The principle of the rule is that is the simple realization that we tend to be wrong when we try to anticipate exactly what we will need in the future
 
In the end , the last paragraph I love the most:
 
"The proper use of design patterns is the art of making your system just flexible enough to deal with the problems you have today, but no more. Patterns are useful techniques, rather than ends in themselves. They can help you construct a working system, but your system will not work better because you used all 23 of the GoF design patterns in every possible combination. Your code will work better only if it focuses on the job it needs to do right now."
May 25

流水帐

周五晚上继成跟他老婆回来了,
狗子喊着0210上海小聚会,
但是自己磨蹭了好长时间,
才晃晃悠悠过来,
Zhangc同学9点20到了,
南京过来的人差点赶在狗子之前,
我们在KFC呆了两个多小时,
消灭了若干汉堡和薯条。
最重要的是聊得很开心~
 
本来周五晚临时抱佛脚计划报销了,
硬着头皮考吧~
上周六考了个试,一整天。
结果题目很简单,很多不用看书可以按常识做,
所以比较顺利。
 
第二天陪老婆去一个非常非常偏远的地方去考试,
又是起了一个大早,
今天去看了李艳和小廖夫妇,
两个月前怀上宝宝了,
恭喜~
吃了一顿非常丰盛的大餐~
 
回家发现最近吃太多,
肚子肉多了不少,
确实得好好减减了~
 
May 22

2009 RubyConf China

昨天参加完这个会,
感觉很不错,
见了不少大牛,
最主要的是见到了Ruby之父Matz,
据说他原来的slides有100多页,
要讲2个小时,加上日语翻译,可能要4个小时,
后来删了很多,变成1个小时不到,
Matz看上去很年轻,很随和,有点腼腆,讲话挺风趣的,
中间去合影了一张,hoho
他讲的题目是《Why Ruby?》
影响最深的就是他slide最后所说的一句话 Enjoy Programming,
对于我们Programming是for money,
但是如果能把Programming变成很享受的事情,
why not?
Ruby 最早是 for fun 被创造的,
Ruby哲学就是简单,自然,易记,易学还有一点特别明显就是free,
这个free不仅是money free,而且是没有限制,自由的含义。
了解到Ruby现在support的Giant有三个:Microsoft,Apple,SUN Microsystem
微软貌似想搞一个咚咚叫做IM Ruby, Apple在iPhone里已经支持Ruby程序了,SUN是在支持JRuby,据说是Tim Bray 带头搞得,
Ruby社区和Java社区曾经发生过很大的冲突,因为用Java开发网站的人感觉被嘲笑了~ 大笑
 
之前一哥们上去讲了用Ruby实现Design Pattern的主题,讲的不错,就是感觉太少了,不够用啊~
因为我之前也想到过这个主题,中间休息我跟他交换了名片,周末联系联系他,哪天有空我一个个整理出来。
 
之后是JavaEye的老大Robin 范凯演讲,题目是JavaEye的架构解密,非常实在的演讲,我们联想到自己开发的网站也遇到很多类似的问题。
我们流量也跟JavaEye接近啦~ 估计遇到很多同样的问题
后来交换了名片,以后可以多联系~
 
下午第一个是Robin Lu做了一个演讲,讲Ruby On Rails Pitfall,都是经验之谈,hoho 做了笔记,稍后贴上。
他们的团队貌似非常干练,我喜欢这种风格~
 
后面出来讲的是ThoughtWorks的郑晔,讲企业级的Ruby开发,
主要提到了他们项目管理工具就是用RoR开发的,
还提到他们帮助客户新开发的一个项目用了JRuby,
看起来JRuby挺有前途,
07年也参加过一个会议,那时候刚开始用RoR,
里面提到了JRuby,还有国内一帮人自己搞的XRuby,
我已经把JRuby作为我个人知识库的一个Tag,
有时间好好研究研究
 
之间有个国外的哥们跑上去宣扬了下OpenSource
美国OpenSource项目貌似比国内高了3倍多
其实整体来说国内大部分人都是在忙于手头的工作,
虽然大部分人是支持开源,
但是行动不多,
比如像我,
不过最近我也正打算小试下,
搞个Crawler和HTML分析工具先放到RubyForge上去。
 
然后是一个来自北京的Tony讲了他们用RoR开发的政府项目,
感觉他们挺不容易的,20多人的RoR团队,
要普及这种技术需要克服很多困难,
在RoR团队建设上需要更多的精力,
比如协作和质量控制这些和一般的企业级项目会有不少区别。
 
然后是Koz讲在日本政府和社区使用Ruby,
感觉日本还是投入很多的资源的。
据说Ruby World Conf会在岛根县举行,
9月份,貌似有不少重量级的人都去
 
后来还有很长的提问时间,挺有意思的。
 
开完会已经六点了,
感觉一天很累也非常充实,
感觉对Ruby更有信心,感觉自己要投入更多时间和精力才行。
首先做的一点就是Open Mind
May 10

胡言乱语

从春节回来德最近几个月感觉天天都很累,
发生了好几件大事,
感觉自己身上担子很沉重。
不过都扛过来了,希望接下来能顺利。
 
最近两个月几乎每天回家都在看书,
主要还是技术方面的,
5月份发现自己之前报名了一个感觉挺sb的认证考试,
发现还有两周就考了,
几乎没看书,
nnd 书加起来800多页,
只能再拿起突击的本事了~
 
在当当上买了本存储相关的书,
写的比较细,
有点意思。
January 05

你好,2009

08年终于过去鸟,辉常不容易,
先祝老爸老妈同学同事新年快乐,
 
0210的老男银们,
都老了一岁,
很多同学马上就要到上海,
一个宿舍华仔和江舟已经来上海了,
开始了新的生活,
以后聚会一桌子就不够了
 
最后,做个简单的个人总结,
08年俺的心态而言可算是低开高走~
太多回忆 太多感慨 太多收获
今年可以算是真正慢慢走向成熟自信的一年,
其中经历了各种心态的起起伏伏,
在各种影响下才迫使自己走向了正轨,
学会了解、激励并解放自己,
学会去理解他人,
学会如何去承担压力和责任
...
但是今年最重要的是 
老婆跳槽到上海,并且终于通过资格考试,安定下来了。
对她来说很不容易~
从银行到证券,她付出了太多
...
 
工作方面
06 07 08 两年多的播种耕耘
希望09年是收获的一年