面朝大海,春暖花开

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  12 Posts :: 1 Stories :: 3 Comments :: 0 Trackbacks

2006年4月27日 #

马上要做新项目了,项目不大,准备用ajax来练练手,HOHO!
posted @ 2006-06-05 22:09 面朝大海 阅读(151) | 评论 (0)编辑 收藏

今天在网上闲逛,发现了一本好书,关于JAVA和TDD的,内容介绍如下:

Master Java 5.0 and TDD Together: Build More Robust, Professional Software

Master Java 5.0, object-oriented design, and Test-Driven Development (TDD) by learning them together. Agile Java weaves all three into a single coherent approach to building professional, robust software systems. Jeff Langr shows exactly how Java and TDD integrate throughout the entire development lifecycle, helping you leverage today's fastest, most efficient development techniques from the very outset.

Langr writes for every programmer, even those with little or no experience with Java, object-oriented development, or agile methods. He shows how to translate oral requirements into practical tests, and then how to use those tests to create reliable, high-performance Java code that solves real problems. Agile Java doesn't just teach the core features of the Java language: it presents coded test examples for each of them. This TDD-centered approach doesn't just lead to better code: it provides powerful feedback that will help you learn Java far more rapidly. The use of TDD as a learning mechanism is a landmark departure from conventional teaching techniques.

  • Presents an expert overview of TDD and agile programming techniques from the Java developer's perspective

  • Brings together practical best practices for Java, TDD, and OO design

  • Walks through setting up Java 5.0 and writing your first program

  • Covers all the basics, including strings, packages, and more

  • Simplifies object-oriented concepts, including classes, interfaces, polymorphism, and inheritance

  • Contains detailed chapters on exceptions and logging, math, I/O, reflection, multithreading, and Swing

  • Offers seamlessly-integrated explanations of Java 5.0's key innovations, from generics to annotations

  • Shows how TDD impacts system design, and vice versa

  • Complements any agile or traditional methodology, including Extreme Programming (XP)


E文不算太难,一般都应该可以看懂,为什么好书都是老外写的呢?
我想把书传上来,但是.Text对文件的大小好象是有限制,书的名字叫
Agile Java Crafting Code with Test-Driven Development,想要的同学可以留下EMAIL

posted @ 2006-05-12 19:17 面朝大海 阅读(408) | 评论 (2)编辑 收藏

很早就听说过Castle的大名了,但是一直没有时间去研究。一方面也是自己的惰性,另一方面也关于Castle的分析文章太少了。但是不管怎么说,面对这这么优秀的项目没有一睹芳容,真是。现在好了,在博客园找到了一个关于Castle的系列文章,先收藏个连接,51在休息的空隙,还可以抽出点时间好好研究好东东,
http://www.cnblogs.com/Terrylee/archive/2006/04/28/387503.html
posted @ 2006-04-28 22:04 面朝大海 阅读(252) | 评论 (0)编辑 收藏

近来很忙,一直没写 blog 了,今天晚上有点时间,听了节 MSDN 上面的一节 webCast ,讲的就是 Proxy 模式,本就就是这节课的笔记。

学习设计模式也有段时间了,很早也见过 Proxy 模式的,记得最开始接触 Proxy 模式还是在著名的 JIVE 论坛( JIVE 中用 Proxy 来做权限控制)。今天算是一遍复习吧。

对复杂的软件系统,人们常常用的一种处理手法是在系统增加一层间接层,得到对系统灵活的、满足特殊要求的解决方案。

使用 Proxy 模式的动机:在 OO 的开发过程中,某些对象的开销很大(如: new 的开销大、某些对象因为安全的原因不能被客户直接的调用等),如果直接操作这些对象会破坏系统结构。那么,我们就用代理对象来控制对象的访问。

例子,   一个常见的 HR 系统:

using  System;

class  Employee
{
    
public   double  GetSalary()
    
{
        ..
    }

    
public   void  Report()
    
{
        .
    }

    
public   void  ApplyVacation()
    
{
        
    }

}


class  HrSys
{
    
public   void  ProcessEmployee
        (Employee employee
/* 该对象和HR系统在同一个地址空间中 */ )
    
{
        employee.Report();
        ..
        employee.ApplyVacation();
    }

}

现在要求把 Employee 做成 webService HR 系统通过 webService 来调用 Employee 对象,代码修改如下:

using  System;

interface  IEmployee
{
    
public   double  GetSalary();
    
public   void  Report();
    
public   void  ApplyVacation();
}

// 运行在internet上面的某台机器
class  Employee : IEmployee
{
    
public   double  GetSalary()
    
{
        ..
    }

    
public   void  Report()
    
{
        .
    }

    
public   void  ApplyVacation()
    
{
        
    }

}

// 运行在本地的程序中
class  EmployeeProxy : IEmployee
{
    
public   double  GetSalary()
    
{
        
// 对对象创建/访问的SOAP封装
    
     
// 发送SOAP数据
    
     
// 如果有返回值,就对SOAP分析,得到C#数据
    }

    
    
public   void  Report()
    
{
        
// 对对象创建/访问的SOAP封装
    
     
// 发送SOAP数据
    
     
// 如果有返回值,就对SOAP分析,得到C#数据
    }

    
    
public   void  ApplyVacation()
    
{
        
// 对对象创建/访问的SOAP封装
    
     
// 发送SOAP数据
    
     
// 如果有返回值,就对SOAP分析,得到C#数据
    }

}

class  HrSys
{
    
public   void  ProcessEmployee(IEmployee employeeProxy)
    
{
        employeeProxy.Report();
        ..
        employeeProxy.ApplyVacation();
    }

}

Proxy 使用的要点:

1 、“增加一层间接层”,是软件系统中常用的手段之一。

2 、具体的实现中, Proxy 有很大差别,有的是简单的“ copy-on-write ”,有的是对组件模块的抽象代理。在 JAVA 中常见的 SSH 架构模式中( struts+spring+hibernate )中,我们可以把 spring 所在的服务层看成对 hiberate 的代理。

具体的实现可以参考 .NET 中的 WebService 的实现。

Copy-on-write 技术

class  App
{
    
// 系统在内存中其实是指向同一块内存
     string  s1  =   " Hello " // 不可在修改
     string  s2  =   " Hello " // 不可在修改

    
// s1.ToUpper();  // s1不会产生任何改变

    stringBulider sb1 
=   new  stringBulider( " Hello " );
    stringBulider sb2 
=   new  stringBulider( " Hello " );
    
    sb1.replace(
" H " , " L " );  // 可以修改成功
}

sb1.replace("H","L"); 系统做的动作是, sb1 的代理对象先拷贝 ”Hello” 字符串,然后用“ L ”替换“ H ”, sb1 的代理对象重新指向新的对象。

posted @ 2006-04-27 20:33 面朝大海 阅读(291) | 评论 (0)编辑 收藏