[ruby]ruby on rails学习笔记1

摘要: 准备:ruby(windows): http://rubyforge.org/frs/?group_id=167gem: http://rubyforge.org/frs/?group_id=126gem install rails创建应用项目: rails new blog配置数据库:sqlite3: development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000mysq1: development: adapter: mysql2 encoding: utf8... 阅读全文
posted @ 2011-02-15 21:57 bluefrog 阅读(377) 评论(0) 推荐(0) 编辑

[php]php设计模式 Interpreter(解释器模式)

摘要: <?php/** * 解释器 示例 * * @create_date: 2010-01-04 */class Expression{ function interpreter($str) { return $str; }}class ExpressionNum extends Expression{ function interpreter($str) { switch($str) { case "0": return "零"; case "1": return "一"; ... 阅读全文
posted @ 2011-01-04 23:23 bluefrog 阅读(3464) 评论(0) 推荐(0) 编辑

[php]php设计模式 Factory(工厂模式)

摘要: 1 <?php 2 /** 3 * 工厂方法模式 4 * 5 * 定义一个用于创建对象的接口,让子类决定将哪一个类实例化,使用一个类的实例化延迟到其子类 6 */ 7 8 /* 9 class DBFactory10 {11 public static function create($type)12 {13 swtich($type)14 {15 case "Mysql":16 return new MysqlDB(); break;17 case "Po... 阅读全文
posted @ 2011-01-04 23:22 bluefrog 阅读(3475) 评论(0) 推荐(0) 编辑

[php]php设计模式 Facade(外观模式)

摘要: 1 <?php 2 /** 3 * 外观模式 示例 4 * 5 * 为子系统中的一组接口提供一个一致的界面,定义一个高层接口,使得这一子系统更加的容易使用 6 */ 7 class SubSytem1 8 { 9 publicfunction Method1()10 {11 echo"subsystem1 method1<br/>";12 }13 }14 15 class SubSytem216 {17 publicfunction Method2()18 {19 echo"subsystem2 method2<br/>"; 阅读全文
posted @ 2011-01-04 23:20 bluefrog 阅读(2536) 评论(0) 推荐(1) 编辑

[php]php设计模式 Delegation(委托模式)

摘要: <?php/** * 委托模式 示例 * * @create_date: 2010-01-04 */class PlayList{ var $_songs = array(); var $_object = null; function PlayList($type) { $object = $type."PlayListDelegation"; $this->_object = new $object(); } function addSong($location,$title) { $this->_song... 阅读全文
posted @ 2011-01-04 23:19 bluefrog 阅读(2076) 评论(1) 推荐(0) 编辑

[php]php设计模式 Decorator(装饰模式)

摘要: 1 <?php 2 /** 3 * 装饰模式 4 * 5 * 动态的给一个对象添加一些额外的职责,就扩展功能而言比生成子类方式更为灵活 6 */ 7 header("Content-type:text/html;charset=utf-8"); 8 abstractclass MessageBoardHandler 9 {10 publicfunction __construct(){}11 abstractpublicfunction filter($msg);12 }13 14 class MessageBoard extends MessageBoardHand 阅读全文
posted @ 2011-01-04 23:18 bluefrog 阅读(1656) 评论(0) 推荐(0) 编辑

[php]php设计模式 DAO(数据访问对象模式)

摘要: <?php/** * 数据访问对象(Data Access Object) 示例 * * @create_date: 2010-01-04 */class BaseDAO{ var $_db = null; var $_table = null; function BaseDAO($config) { $this->_db = new MysqlDB(); // 这里的不能进行操作 } /** * 获取处理 * * @param array $filter // 过滤条件 * @param string $f... 阅读全文
posted @ 2011-01-04 23:15 bluefrog 阅读(3485) 评论(0) 推荐(0) 编辑

[php]php设计模式 Builder(建造者模式)

摘要: 1 <?php 2 /** 3 * 建造者模式 4 * 5 * 将一个复杂对象的构建与它的表示分离,使用同样的构建过程可以创建不同的表示 6 */ 7 class Product 8 { 9 public$_type=null;10 public$_size=null;11 public$_color=null;12 13 publicfunctionsetType($type)14 {15 echo"set product type<br/>";16 $this->_type =$type;17 }18 19 publicfunction setS 阅读全文
posted @ 2011-01-04 23:14 bluefrog 阅读(1710) 评论(0) 推荐(1) 编辑

[php]php设计模式 Adapter(适配器模式)

摘要: 1 <?php 2 /** 3 * 适配器模式 4 * 5 * 将一个类的接口转换成客户希望的另外一个接口,使用原本不兼容的而不能在一起工作的那些类可以在一起工作 6 */ 7 8 // 这个是原有的类型 9 class OldCache10 {11 publicfunction __construct()12 {13 echo"OldCache construct<br/>";14 }15 16 publicfunction store($key,$value)17 {18 echo"OldCache store<br/>" 阅读全文
posted @ 2011-01-04 23:12 bluefrog 阅读(2401) 评论(1) 推荐(0) 编辑

[python]django学习笔记 二

摘要: 视图HelloworldCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->from django.http import HttpResponsedef hello(request): return HttpResponse("Hello world")路由文件urls.pyCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.C 阅读全文
posted @ 2010-12-31 06:03 bluefrog 阅读(313) 评论(0) 推荐(0) 编辑