自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(28)
  • 收藏
  • 关注

原创 DB2 学习笔记

因为只能用自己公司的数据库产品,所以理所应当的学习DB2...现在用数据库会想当然的用MySQL的处理方式,发现不妥,DB2整个就是另外的产品,看来要系统的学习下。 找了一本教材,非常非常厚,有点找不着北的感觉,不过还是和以前一样,一边记录一边读好了。...

2010-08-24 12:35:28 71

原创 Work@IBM

从八月初离开薄荷,加入了蓝色巨人。可以说是非常艰辛,刚刚入职的这三周,第一周肠胃出了点问题,在医院躺了2天,不过还好,问题不大,以后真的要注意饮食了。 IBM的工作很充实,项目也很有挑战性,这个确实是我的dream  work很多细节可以看出IBM的包容和胸怀里面很大的问题就是我的英语貌似还是不够用,开始进去开会是完全听不懂,法国人的英语说的确实比较怪慢慢的...

2009-08-24 21:30:42 76

原创 how RoR scales

转载自DHH的blog http://www.loudthinking.com/arc/000479.html I've said it before, but it bears repeating: There's nothing interesting about how Ruby on Rails scales. We've gone the easy route and mer...

2009-07-21 22:58:10 150

Rails中实现分表(1)垂直分表

我们开发的时候遇到一种情况,业务量小的时候设计了一张表来存帖子:posts(id, topic_id, content, status, created_at, updated_at) 当数据量达到百万的量级后,发现此表查找非常慢,这时候想从数据库的角度来改进。比较常用的方法是,把posts表中的大块数据的字段拆分出来,作为一个子表: posts(id, topic_id,...

2009-07-15 16:29:15 239

原创 Layer Supertype

每个层比如Dao,都有一些通用的方法,这些方法可以放到一个BaseDaoImpl里面,然后所有Dao层的都继承这个类。这个在Rails也是这种机制:Controller都是基于ApplicationController < ActionController::BaseModel基于ActiveRecord::Base,其实可以自己添加一个model作为BaseRecord &lt...

2009-07-01 13:08:14 102

原创 Mapper

Mapper一般使用在连接两层模块。 常用于解耦模型和数据库Model <= Mapper => Database比如我有一个Person类,我们实现一个PersonMapper类用于获取Person以及完成DB交互转换。可以看作是将一些层与层之间复杂的转换都交给Mapper来处理。...

2009-07-01 13:00:15 125

原创 Gateway

Gateway模式最适用的场合就是当你需要和外部接口或者程序通信的时候,采用Gateway来隔离接口是非常通用的方式。我们前一阵子做的开放平台应用的时候这种接口就为我们提供了很多便利:定一个Gateway和开放平台进行验证,传输信息等操作,应用程序调用此Gateway来完成自己需要的功能。为了支持多个开放平台,可以定义一个Gateway接口,然后为每个开放平台都实现此接口Appli...

2009-06-24 21:06:06 101

Rails请求的生命周期

之前在csdn写了不少关于Rails的笔记,不过觉得一个文件一个文件来读不够有条理,现在可以从更加实用和课题式的角度来读Rails代码。 以WEBrick为例子,WEBrick的请求处理代码如下:  def service(req, res) #:nodoc: unless handle_file(req, res) # 如果不是处理文件请求 begin...

2009-06-21 21:26:41 212

继承和数据库设计

OOP中我们经常会遇到继承的问题,在面向对象的语言中表示继承是很简单的。比如Java、Ruby。但是如果我们需要每个类对应关系数据库的表结构也能够反映出继承关系呢? 假设有一个公司员工俱乐部系统,有足球俱乐部、篮球俱乐部、读书俱乐部,我们已经有如下类结构 class Club {   String name;   Time createTime;   } c...

2009-06-20 14:36:58 228

复杂输入分析系统设计

我们在开发中可能会遇到这样一类问题:1 你需要分步骤录入一个几页信息的大数据表2 系统会根据输入数据根据某种规则分析出结果报表3 结果需要持久化4 结果可以修改5 结果报表可以根据规则重新生成6 每个输入有唯一的一个对应的报表7 分析规则是容易测试的 我在解决这个问题的时候花了很多的时间,绕了个大弯,后来才发现是策略的问题,把最终设计的结果整理下: Pr...

2009-06-15 13:50:09 106

SNS网站feed的设计思考

SNS网站一般都有这么一个功能:feed或者叫做新鲜事之类的之前在我们自己的网站也做了类似的一个功能,当时让人最郁闷的就是数据量的问题,上网搜了下,大部分结构都是类似。 我当时设计了这么一种简单的机制,数据量相对较小,但是运算复杂,并且限制较多: 1)feed字典表:feeds(id, event_type: int, //事件类别:写日记,上传照片,成为好友等...

2009-06-14 14:19:08 112

原创 Design Patterns in Ruby [Digest 12] Builder

Imagine that you are create a computer machine, if you create a class named ComputerSo the initializer will be such a painful and tedious parameter monster, you will find that it is a mess.  S...

2009-06-11 21:00:39 80

原创 Design Patterns in Ruby [Digest 11] Factory

Factory is used to integrate the creation of some related object into one responsory class:class PondOrganismFactory def new_animal(name) Frog.new(name) end def new_plant(name) ...

2009-06-10 13:36:55 74

原创 算法小记(2) backtracking

回溯算法:就是搜索一棵状态树的过程,这个过程类似于DFS,但是在决定搜索下一步的时候先作一次判断。如果ok再继续下一步搜索,这里等于是进行一次启发式的剪枝。 一般会有这么一行: backtrack(current_state) {    // blalala    for next_state in next_states(current_state)    if ...

2009-06-09 08:53:51 104

原创 算法小记(1) Brute Force

以前业余的时候总喜欢去TopCoder上玩算法,之前做了不少题目,总结下,从里面的一些education文章整理下一些解题办法,重新学习学习。 brute force 就是穷举算法:按照问题定义来遍历所有情况,并且题目规模较小。 比如这道题 http://www.topcoder.com/stat?c=problem_statement&pm=3005&rd=585...

2009-06-09 08:53:17 65

原创 Rails tips (1) dependent 设置问题

 has_many has_one belongs_to都有设置dependent属性 has_many的文档里写的dependent是设置为:destroy将调用关联对象destroy方法,如果设置为:delete_all将调用class.delete_all而不调用destroy方法,:nullify就是直接将外键设为null. has_one的文档里写的dependent...

2009-06-08 11:47:59 193

原创 Design Patterns in Ruby [Digest 10] Singleton

Singleton is common for every coder. It provide only instance of class.  class SimpleLogger # Lots of code deleted... @@instance = SimpleLogger.new def self.instance return @@instance...

2009-06-07 22:33:38 68

原创 Design Patterns in Ruby [Digest 9] Decorator

The Decorator pattern is used when you need to add some feature to a class with wrapper rather than write a new method. Think about the writer support chechsum write, line number write:  cla...

2009-06-06 19:56:28 84

原创 Design Patterns in Ruby [Digest 8] Proxy

 When we meet these requirements:1) Controlling access to an object 2) providing a location-independent way of getting at the object3) delaying its creationall three actually have a common s...

2009-06-06 16:20:36 86

原创 Design Patterns in Ruby [Digest 8] Adapter

The Adapter is just like the power adapter such as from 220V to 120V. And when the pin does not fit the socket we need the adapter to fit it.In software system, we already have a Encrypter to encryp...

2009-06-06 12:34:53 84

原创 Design Patterns in Ruby [Digest 7] Command

 Command pattern command is an instruction to do something, something specific. It can be execute right now or later or specific time. In our GUI's do and undo actions it is wildly used.  If w...

2009-06-05 12:46:03 72

原创 Design Patterns in Ruby [Digest 6] Iterator

The Iterator pattern is a technique that allows an aggregate object to provide the outside world with a way to access its collection of subobjects.In Java we use java.util.Iterator interface to be i...

2009-06-03 22:31:29 79

原创 Design Patterns in Ruby [Digest 5] Composite

When we want to build up bigger objects from small sub-objects those build up on the sub-sub-objects then there is a Composite Pattern.The key point of the pattern is that complex objects and simple...

2009-06-01 15:39:38 59

原创 Engel

Engel是一个爬虫项目,昨天做了一天,弄了个简要版本,我放在了ruby forge上。工作了两三年了,其实一直以来的兴趣是互联网搜索和挖掘,以前主要在大学的实验室做这些事儿,用Java倒腾了不少事儿,由于一直心愿未了,决定从基础框架开始,用Ruby重新做一个。持续会有一系列的项目:  爬虫框架 分词 索引、搜索框架 Web分析和信息抽取 基于文本的研发:分类...

2009-05-31 09:12:37 61

原创 Design Patterns in Ruby [Digest 4] Observer

 The Observer Pattern is useful when you need to inform other objects whenever one original change of object occurs. Such as SNS feeds feature, cache clear and so on... Without this pattern the ...

2009-05-29 10:40:25 69

原创 Design Patterns in Ruby [Digest 3] Strategy

The Template method is build around inheritance, the inheritance has the nature born relationship.So the Strategy give a delegate solution. So we use the strategy implementation:  class Fo...

2009-05-28 11:55:57 56

原创 Design Patterns in Ruby [Digest 1] About Patterns

 The following tips are really essential the patterns for patterns:1) Seperate out the things that change from those stay the sameA key goal of software engineering is to builld a system ...

2009-05-27 13:02:54 84

原创 Design Patterns in Ruby [Digest 2] - Template

When we have a complex algorithm including several steps to build something, which would be vary in the middle.Now you need Template method.It comes up with an example:class Report def initialize...

2009-05-27 12:51:25 75

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除