摘要:
using System; // Strategy Pattern by Judith Bishop Oct 2007 // Shows two strategies and a random switch between them // The Context class Context { // Context state public const int start = 5; public int Counter = 5; // Strategy aggregation IStrategy strategy = new Strategy1(); // Algorithm invo... 阅读全文
posted @ 2012-05-17 21:04
ChaunceyHao
阅读(169)
评论(0)
推荐(0)
摘要:
using System;using System.IO;using System.Runtime.Serialization;using System.Runtime.Serialization.Formatters.Binary;using System.Collections;// Memento Pattern Judith Bishop September 2007// Simulates TicTacToe, where the game can roll back any// specified number of moves. Mementos are kept at each 阅读全文
posted @ 2012-05-17 20:31
ChaunceyHao
阅读(186)
评论(0)
推荐(0)
摘要:
using System; using System.Collections.Generic; // State Pattern Judith Bishop Oct 2007 // Simple game where the context changes the state based on user input // Has four states, each with 6 operations interface IState { int MoveUp(Context context); int MoveDown(Context context); } // State 1 cla... 阅读全文
posted @ 2012-05-17 19:59
ChaunceyHao
阅读(143)
评论(0)
推荐(0)
摘要:
using System; using System.Collections.Generic; namespace StatePattern { // State Pattern D-J Miller and Judith Bishop Sept 2007 // Simple game where the context changes the state based on user input // Has four states, each with 6 operations abstract class IState { public virtual string Move(Con... 阅读全文
posted @ 2012-05-17 19:57
ChaunceyHao
阅读(194)
评论(0)
推荐(0)
摘要:
using System; using System.Collections.Generic; // Builder Pattern judith Bishop November 2007 // Simple theory code with one director and two builders class Director { // Builder uses a complex series of steps public void Construct(IBuilder builder) { builder.BuildPartA(); builder.BuildPartB(); bu. 阅读全文
posted @ 2012-05-17 19:53
ChaunceyHao
阅读(157)
评论(0)
推荐(0)
摘要:
using System; using System.Diagnostics; using System.IO; using System.Threading; namespace BuilderPattern { // Builder Pattern D-J Miller and Judith Bishop Sept 2007 // Abstract Factory : Builder Implementation interface IBuilder<Brand> where Brand : IBrand { IBag CreateBag(); } // Abstract Fa 阅读全文
posted @ 2012-05-17 19:52
ChaunceyHao
阅读(179)
评论(0)
推荐(0)
摘要:
DECLARE @dt datetimeSET @dt=GETDATE()--1.短日期格式:yyyy-m-dSELECT REPLACE(CONVERT(varchar(10),@dt,120),N'-0','-')--2.长日期格式:yyyy年mm月dd日 --A. 方法1 SELECT STUFF(STUFF(CONVERT(char(8),@dt,112),5,0,N'年'),8,0,N'月')+N'日'--B. 方法2 SELECT DATENAME(Year,@dt)+N'年'+DATE 阅读全文
posted @ 2012-05-17 17:05
ChaunceyHao
阅读(183)
评论(0)
推荐(0)
摘要:
--交叉表,根据优先级取数据,日期处理create table tb(qid int,rid nvarchar(4),tagname nvarchar(10),starttime smalldatetime,endtime smalldatetime,startweekday int,endweekday int,startdate smalldatetime,enddate smalldatetime,d int)insert tb select 1,'A1','未订','08:00','09:00',1 ,5 ,null ,n 阅读全文
posted @ 2012-05-17 17:02
ChaunceyHao
阅读(194)
评论(0)
推荐(0)
摘要:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[f_weekdaycount]') and xtype in (N'FN', N'IF', N'TF'))drop function [dbo].[f_weekdaycount]GO/*--计算任意两个时间之间的星期几的次数(纵向显示) 本方法直接判断 @@datefirst 做对应处理 不受 sp_language 及 set datefirst 的影响 --邹建 2004.08(引用请保留 阅读全文
posted @ 2012-05-17 17:01
ChaunceyHao
阅读(195)
评论(0)
推荐(0)
摘要:
--示例--示例数据create table tb(ID int,Time datetime)insert tb select 1,'2005/01/24 16:20'union all select 2,'2005/01/23 22:45'union all select 3,'2005/01/23 0:30'union all select 4,'2005/01/21 4:28'union all select 5,'2005/01/20 13:22'union all select 6,'2005/0 阅读全文
posted @ 2012-05-17 16:59
ChaunceyHao
阅读(132)
评论(0)
推荐(0)
摘要:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[f_weekdaycount]') and xtype in (N'FN', N'IF', N'TF'))drop function [dbo].[f_weekdaycount]GO/*--计算任意两个时间之间的星期几的次数(横向显示) 本方法直接判断 @@datefirst 做对应处理 不受 sp_language 及 set datefirst 的影响 --邹建 2004.08(引用请保留 阅读全文
posted @ 2012-05-17 16:59
ChaunceyHao
阅读(193)
评论(0)
推荐(0)
摘要:
--定义基本数字表declare @T1 table(代码 int,名称 varchar(10),参加时间 datetime,终止时间 datetime)insert into @T1 select 12,'单位1','2003/04/01','2004/05/01' union all select 22,'单位2','2001/02/01','2003/02/01' union all select 42,'单位3','2000/04/01','2003/ 阅读全文
posted @ 2012-05-17 16:58
ChaunceyHao
阅读(150)
评论(0)
推荐(0)
摘要:
原代码: DECLARE @E_ID VARCHAR(20) DECLARE @AFFECT INT SELECT @E_ID=TB_USER.E_ID FROM TB_EMPLOYEE INNER JOIN TB_USER ON TB_USER.E_ID=TB_EMPLOYEE.E_ID WHERE U_USERNAME='LL' UPDATE TB_EMPLOYEE SET E_NAME='张三',E_MAIL='zhangsan163@163.COM',E_TEL='12345667' WHERE E_ID=@E_ID IF 阅读全文
posted @ 2012-05-17 16:57
ChaunceyHao
阅读(109)
评论(0)
推荐(0)
摘要:
using System;using Wrox.ProCSharp;using Wrox.ProCSharp.VenusBank;using Wrox.ProCSharp.JupiterBank;namespace Wrox.ProCSharp{ class MainEntryPoint { static void Main() { IBankAccount venusAccount = new SaverAccount(); ITransferBankAccount jupiterAccount = new CurrentAccount(); venusAccount.PayIn... 阅读全文
posted @ 2012-05-17 15:47
ChaunceyHao
阅读(148)
评论(0)
推荐(0)
摘要:
美国计算机科学家,LaTex的作者Leslie Lamport说:“分布式系统就是这样一个系统,系统中一个你甚至都不知道的计算机出了故障,却可能导致你自己的计算机不可用。”一语道破了开发分布式 系统的玄机,那就是它的复杂与不可控。所以Martin Fowler强调:分布式调用的第一原则就是不要分布式。这句话看似颇具哲理,然而就企业应用系统而言,只要整个系统在不停地演化,并有多个子系统共同存 在时,这条原则就会被迫打破。盖因为在当今的企业应用系统中,很难寻找到完全不需要分布式调用的场景。Martin Fowler提出的这条原则,一方面是希望设计者能够审慎地对待分布式调用,另一方面却也是分布... 阅读全文
posted @ 2012-05-17 09:25
ChaunceyHao
阅读(513)
评论(0)
推荐(0)
摘要:
Mobile Shell,或简称为MoSH,在GitHub上发布,是移动设备上SSH的替代品。阐释MoSh背后的原则的技术论文将在下月召开的2012 USENIX年度技术会议上发布。 下述两个重要特性是MoSH有别于其它类似产品的: 第一,连接的IP地址不可知;而不是采用TCP/IP连接,数据通过UDP/IP发送。好处是,如果移动设备无信号或设备的IP地址改变(因为移动设备可以在WiFi网络和蜂窝网络间漫游),那么在传输层保持有状态连接就不那么可靠。第二,MoSH没有在客户端与服务器之间提供一个透明的加密字节流,让服务器通过重绘屏幕来响应的机制;MoSH客户端提供了一个本地 echo的变体。这 阅读全文
posted @ 2012-05-17 09:23
ChaunceyHao
阅读(334)
评论(0)
推荐(0)
浙公网安备 33010602011771号