- 浏览: 67125 次
- 性别:
- 来自: 深圳
-
文章分类
最新评论
-
wosxiaoyacongsd:
呵 多谢!!!
在JAVA中获得当前时间 -
heavilyarmed:
谢谢了 呵呵
在JAVA中获得当前时间 -
vii779:
very good
hibernate的各种保存方式的区别 (save,persist,update,saveOrUpd -
vii779:
好好好
hibernate的各种保存方式的区别 (save,persist,update,saveOrUpd -
heshencao:
feigofigo3 写道
路在脚下,切忌浮躁
谢谢,这会平 ...
回成都感言
//////////////////////////////////////////////////////////////////// 创建模式 //////////////////////////////////////////////////////////////////// //FactoryMethod模式的例子 package pattern.a.factoryMethod; interface Product { void operation(); } class ConProduct1 implements Product { //不同的实现可以有不同的产品操作 public void operation() {} } class ConProduct2 implements Product { //不同的实现可以有不同的产品操作 public void operation() {} } interface Factory { Product CreateProduct(); void operation1(); } class ConFactory1 implements Factory { //不同的实体场类 在创建产品是可以有不能的创建方法 public Product CreateProduct() { Product product = new ConProduct1(); operation1(); return product; } public void operation1() {} public static Factory getFactory() { return new ConFactory1(); } } class ConFactory2 implements Factory { //不同的实体场类 在创建产品是可以有不能的创建方法 public Product CreateProduct() { Product product = new ConProduct2(); operation1(); return product; } public void operation1() {} // public static Factory getFactory() { return new ConFactory2(); } } public class FactoryMethod { public static void main(String[] args) { Factory factory = ConFactory1.getFactory(); Product product = factory.CreateProduct(); product.operation(); } } *********************************************************************** //AbstractoryFactory模式的例子 //我觉得这个模式与FactoryMethod 就是创建产品的数量上有区别 package pattern.a.abstractfactory; //产品A的接口和实现 interface ProductA {} class ProductA1 implements ProductA {} class PorductA2 implements ProductA {} //产品B的接口和实现 interface ProductB {} class ProductB1 implements ProductB {} class ProductB2 implements ProductB {} //工程和工厂的实现 interface Factory { ProductA CreateA(); ProductB CreateB(); } //1工厂产生1系列产品 class ConFactory1 implements Factory { public ProductA CreateA() { return new ProductA1(); } public ProductB CreateB() { return new ProductB1(); } } //2工厂产生2系列产品 class ConFactory2 implements Factory { public ProductA CreateA() { return new PorductA2(); } public ProductB CreateB() { return new ProductB2(); } } class ConFactory {} public class AbstractFactory { public static void main(String[] args) { //1工厂产生1类产品 Factory factory1 = new ConFactory1(); ProductA a1 = factory1.CreateA(); ProductB b1 = factory1.CreateB(); //2工厂产生2类产品 Factory factory2 = new ConFactory1(); ProductA a2 = factory2.CreateA(); ProductB b2 = factory2.CreateB(); } } *********************************************************************** //Builder模式的例子 // 模式的宗旨是 将部件创建的细节 和部件的组装方法分离!!! 考兄弟悟性要高 package pattern.a.builder; class director { //construct 中存放着组装部件的逻辑 注意 逻辑的分离 public Product construct(Builder builder) { builder.buildPart1(); builder.buildPart2(); operation(); Product product = builder.retrieveProduct(); return product; } public void operation() {} } class Product {} interface Builder { void buildPart1(); void buildPart2(); Product retrieveProduct(); } class ConBuilder1 implements Builder { public void buildPart1() {} public void buildPart2() {} public Product retrieveProduct() { return null; } } class ConBuilder2 implements Builder { public void buildPart1() {} public void buildPart2() {} public Product retrieveProduct() { return null; } } public class BuilderPattern { public static void main(String[] args) { } } *********************************************************************** //Singleton模式例子 package pattern.a.singleton; // 一种简单的形式 class SingletonExample { private static SingletonExample instance; private SingletonExample() {} public static SingletonExample getInstance() { if (instance == null) { instance = new SingletonExample(); } return instance; } synchronized public static SingletonExample getInstance1() { if (instance == null) { instance = new SingletonExample(); } return instance; } public static SingletonExample getInstance2() { synchronized(SingletonExample.class) { if (instance == null) { instance = new SingletonExample(); } } return instance; } } //利用类加载时 初始化只产生一次 class SingletonExample2 { private static SingletonExample2 instance = new SingletonExample2(); private SingletonExample2() {} public static SingletonExample2 getInstance() { return instance; } } public class SingletonPattern { public static void main(String[] args) { } } *********************************************************************** //Prototype模式例子 package pattern.a.prototype; interface Prototype { Prototype myclone(); } class ConPrototype1 implements Prototype{ private String a; public ConPrototype1(String a) { this.a = a; } public Prototype myclone() { return new ConPrototype1(a); } } class ConPrototype2 implements Prototype{ private int b; public ConPrototype2(int b) { this.b = b; } public Prototype myclone() { return new ConPrototype2(b); } } public class PrototypePattern { public static void main(String[] args) { Prototype inst1 = new ConPrototype1("testStr1"); Prototype inst2 = null; inst2 = inst1.myclone(); } } *********************************************************************** //////////////////////////////////////////////////////////////////// 结构模式 //////////////////////////////////////////////////////////////////// //Adapter模式的例子 package pattern.b.Adapter; // 类适配 interface Target1 { void request(); } class Adaptee1 { public void specRequest() {} } class Adapter1 extends Adaptee1 implements Target1 { public void request() { super.specRequest(); } } //对象适配 interface Target2 { void request(); } class Adaptee2 { public void specRequest() {} } class Adapter2 implements Target2 { private Adaptee2 adaptee; public Adapter2(Adaptee2 adaptee) { this.adaptee = adaptee; } public void request() { adaptee.specRequest(); } } public class AdapterPattern { public static void main(String[] args) { } } *********************************************************************** //Proxy模式例子 package pattern.b.proxy; interface Subject { void request(); } //真正处理请求的地方 class RealSubject implements Subject { public void request() { System.out.println("real access"); } } //ProxySubject是与用户交互的类 他是REalSubject的代理 //在处理功能之上的一层 这里可以做前操作 后操作 例如可以验证是否处理请求。 class ProxySubject implements Subject { private RealSubject real; public ProxySubject(RealSubject real) { this.real = real; } // public void request() { preRequest(); real.request(); afterRequest(); } private void preRequest() {} private void afterRequest() {} } //java自身提供代理类使用反射机制 public class ProxyPattern { public static void main(String[] args) { } } *********************************************************************** //Composite 模式例子 //在用户的角度 并不知道 不见是单独的还是符合的 只要调用接口级方法 operation package pattern.b.composite; import java.util.ArrayList; import java.util.Iterator; import java.util.List; // 安全模式 在接口级只提供部分功能 leaf 和 composite 有不同的功能 interface Component1 { public void operation(); } class leaf1 implements Component1 { public void operation() { System.out.println("this is the leaf1"); } } class Composite1 implements Component1 { private List components; public Composite1() { components = new ArrayList(); } public void operation() { Iterator it = components.iterator(); Component1 com = null; while (it.hasNext()) { com = (Component1) it.next(); com.operation(); } } public void addComponent(Component1 com) { components.add(com); } public void removeComponent(int index) { components.remove(index); } } // 透明模式 接口定义全部功能 leaf中可能使用空方法或抛出异常 活着写一层 抽象类 写上默认实现方法(极端情况下 是空或异常) interface Component2 { public void operation(); public void addComponent(Component2 com); public void removeComponent(int index); } class leaf2 implements Component2 { public void operation() { System.out.println("this is the leaf1"); } //这个使用空方法 public void addComponent(Component2 com) {} //这个使用不支持异常 public void removeComponent(int index){ throw new UnsupportedOperationException(); } } class Composite2 implements Component2 { private List components; public Composite2() { components = new ArrayList(); } public void operation() { Iterator it = components.iterator(); Component2 com = null; while (it.hasNext()) { com = (Component2) it.next(); com.operation(); } } public void addComponent(Component2 com) { components.add(com); } public void removeComponent(int index) { components.remove(index); } } //也可以用一个抽象类 abstract class AbstractComponent implements Component2{ public void operation() {} public void addComponent(Component2 com) {} abstract public void removeComponent(int index); } public class CompositePattern { public static void main(String[] args) { } } *********************************************************************** //Flywight 模式例子 // 将共同的跟不同的属性分离 共享共同属性 而不同属性由外部传入 进行特定操作 package pattern.b.flyweight; import java.util.HashMap; import java.util.Map; // 1没有办法通过obj.value方式 2没有改变属性的方法 3不能通过继承重置属性 所以这个对象是 immutable 不可变的 final class State { private String value = null; public State(String value) { this.value = value; } public String getValue() { return value; } } interface Flyweight { void operation(String extrinsicState); } class ConFlyweight1 implements Flyweight { //state 表示享元的内部状态 //或者用构造函数传入 private State state = new State("state1"); //out 为外部传给享元的 外部状态 public void operation(String out) { //使用外部状态和内部状态来执行 operation操作 System.out.println("ConFlyweight1: " + out + state.getValue()); } } // 充数的 class ConFlyweight2 implements Flyweight { private State state = new State("state2"); public void operation(String out) { System.out.println("ConFlyweight2: " + state.getValue() + out ); } } class FlyweightFactory { Map flyweights = new HashMap(); public Flyweight getFlyweight(String key) { if (flyweights.containsKey(key)) { return (Flyweight) flyweights.get(key); } else { // 这里就随便写的 Flyweight flyweight = null; if (key.charAt(key.length() - 1) == '1') { flyweight = new ConFlyweight1(); flyweights.put(key, flyweight); } else { flyweight = new ConFlyweight2(); flyweights.put(key, flyweight); } return flyweight; } } } public class FlyweightPattern { public static void main(String[] args) { FlyweightFactory factory = new FlyweightFactory(); Flyweight flyweight1a = factory.getFlyweight("flytest1"); flyweight1a.operation("outparam1"); } } *********************************************************************** // Bridge 模式例子 //对一处的操作 改成引用一个对象 具体操作再另一个对象中进行 这样便于功能扩展 package pattern.b.bridge; interface Implementor { void realOperation(); } class ConImplementor1 implements Implementor { public void realOperation() { System.out.println("do the real operation1"); } } class ConImplementor2 implements Implementor { public void realOperation() { System.out.println("do the real operation2"); } } abstract class Abstraction { protected Implementor imp; public Abstraction(Implementor imp) { this.imp = imp; } protected void med0() {} abstract public void operation(); } class ConAbstraction extends Abstraction{ public ConAbstraction(Implementor imp) { super(imp); } public void operation() { med0(); imp.realOperation(); } } public class BridgePattern { public static void main(String[] args) { Implementor imp = new ConImplementor1(); Abstraction abs = new ConAbstraction(imp); abs.operation(); } } *********************************************************************** //Decorator 模式例子 package pattern.b.decorator; //源部件和修饰类的共同接口 interface Component { void operation(); } class ConComponent implements Component { public void operation() { System.out.println("the begin operation"); } } //没有提供给component赋值的方法 所以声明这个类为抽象的 这里并没有抽象的方法就是不像让这个类有实例 abstract class Decotor implements Component{ private Component component; public void operation() { component.operation(); } } class ConDecotor1 extends Decotor { private Component component; public ConDecotor1(Component component) { this.component = component; } public void operation() { super.operation(); //!!注意这里 这里提供了功能的添加 // 这里就是Decorator的核心部分 不是修改功能而是添加功能 将一个component传入装饰类调用对象的接口 //方法 在此过程添加功能 重新实现接口方法的功能 med0(); } private void med0() { System.out.println("1"); } } class ConDecotor2 extends Decotor { private Component component; public ConDecotor2(Component component) { this.component = component; } public void operation() { super.operation(); med0(); } private void med0() { System.out.println("2"); } } //class public class DecoratorPattern { public static void main(String[] args) { //注意 起点位置是从一个ConComponent开始的!! Component component = new ConDecotor2(new ConDecotor1(new ConComponent())); component.operation(); } } *********************************************************************** //Facade 的例子 //在子系统上建立了一层 对外使用感觉比较简单 Facade的方法中封装与子系统交互的逻辑 package pattern.b.facade; class Exa1 { public void med0() {} } class Exa2 { public void themed() {} } //这就是一个简单的Facade的方法的例子 class Facade { public void facdeMed() { Exa1 exa1 = new Exa1(); exa1.med0(); Exa2 exa2 = new Exa2(); exa2.themed(); } } public class FacadePattern { public static void main(String[] args) { } } *********************************************************************** //////////////////////////////////////////////////////////////////// 行为模式 //////////////////////////////////////////////////////////////////// //Command 模式例子 //感觉将一个类的方法 分散开了 抽象成了接口方法 注意 参数和返回值要一致 //每个Command封装一个命令 也就是一种操作 package pattern.c.command; //这个是逻辑真正实现的位置 class Receiver { public void med1() {} public void med2() {} } interface Command { // 要抽象成统一接口方法 是有局限性的 void execute(); } class ConCommand1 implements Command{ private Receiver receiver; public ConCommand1(Receiver receiver) { this.receiver = receiver; } public void execute() { receiver.med1(); } } class ConCommand2 implements Command{ private Receiver receiver; public ConCommand2(Receiver receiver) { this.receiver = receiver; } public void execute() { receiver.med2(); } } class Invoker { private Command command; public Invoker(Command command) { this.command = command; } public void action() { command.execute(); } } public class CommandPattern { public static void main(String[] args) { Receiver receiver = new Receiver(); // 生成一个命令 Command command = new ConCommand1(receiver); Invoker invoker = new Invoker(command); invoker.action(); } } *********************************************************************** //Strategy 模式例子 //Strategy中封装了算法 package pattern.c.strategy; interface Strategy { void stMed(); } class Constrategy1 implements Strategy { public void stMed() {} } class constrategy2 implements Strategy { public void stMed() {} } class Context { private Strategy strategy; public Context (Strategy strategy) { this.strategy = strategy; } public void ContextInterface() { strategy.stMed(); } } public class StrategyPattern { public static void main(String[] args) { } } *********************************************************************** //State模式例子 //将一种状态和状态的助理封装倒state中 package pattern.c.state; class Context { private State state = new CloseState(); public void changeState(State state) { this.state = state; } public void ruquest() { state.handle(this); } } interface State { void handle(Context context); } //表示打开状态 class OpenState implements State{ public void handle(Context context) { System.out.println("do something for open"); context.changeState(new CloseState()); } } //表示关闭状态 class CloseState implements State{ public void handle(Context context) { System.out.println("do something for open"); context.changeState(new OpenState()); } } public class StatePattern { public static void main(String[] args) { } } *********************************************************************** //Visitor模式例子 //双向传入 package pattern.c.visitor; import java.util.*; interface Visitor { void visitConElementA(ConElementA conElementA); void visitConElementB(ConElementB conElementB); } class ConVisitor1 implements Visitor{ public void visitConElementA(ConElementA conElementA) { String value = conElementA.value; conElementA.operation(); //do something } public void visitConElementB(ConElementB conElementB) { String value = conElementB.value; conElementB.operation(); //do something } } class ConVisitor2 implements Visitor{ public void visitConElementA(ConElementA conElementA) { String value = conElementA.value; conElementA.operation(); //do something } public void visitConElementB(ConElementB conElementB) { String value = conElementB.value; conElementB.operation(); //do something } } interface Element { void accept(Visitor visitor); } class ConElementA implements Element { String value = "aa"; public void operation() {} public void accept(Visitor visitor) { visitor.visitConElementA(this); } } class ConElementB implements Element { String value = "bb"; public void operation() {} public void accept(Visitor visitor) { visitor.visitConElementB(this); } } class ObjectStructure { private List Elements = new ArrayList(); public void action(Visitor visitor) { Iterator it = Elements.iterator(); Element element = null; while (it.hasNext()) { element = (Element) it.next(); element.accept(visitor); } } public void add(Element element) { Elements.add(element); } } public class VisitorPattern { public static void main(String[] args) { ObjectStructure objs = new ObjectStructure(); objs.add(new ConElementA()); objs.add(new ConElementA()); objs.add(new ConElementB()); objs.action(new ConVisitor1()); } } *********************************************************************** //Observer模式例子 package pattern.c.observable; import java.util.*; class State {} interface Subject { void attach(Observer observer); void detach(Observer observer); void myNotify(); State getState(); void setState(State state); } class ConSubject implements Subject { List observers = new ArrayList(); State state = new State(); public void attach(Observer observer) { observers.add(observer); } public void detach(Observer observer) { observers.remove(observer); } public void myNotify() { Iterator it = observers.iterator(); Observer observer = null; while (it.hasNext()) { observer = (Observer) it.next(); observer.update(); } } public State getState() { return state; } public void setState(State state) { this.state = state; } } interface Observer { void update(); } class ConObserver1 implements Observer{ private Subject subject; public ConObserver1(Subject subject) { this.subject = subject; } public void update() { State state = subject.getState(); // do something with state } } class ConObserver2 implements Observer{ private Subject subject; public ConObserver2(Subject subject) { this.subject = subject; } public void update() { State state = subject.getState(); // do something with state } } public class ObservablePattern { public static void main(String[] args) { } } *********************************************************************** //Mediator模式例子 package pattern.c.mediator; public interface Colleague { void setState(String state); String getState(); void change(); void action(); } package pattern.c.mediator; public class ConColleague1 implements Colleague { private String state = null; private Mediator mediator; public void change() { mediator.changeCol1(); } public ConColleague1 (Mediator mediator) { this.mediator = mediator; } public void setState(String state) { this.state = state; } public String getState() { return state; } public void action() { System.out.println("this 2 and the state is " + state); } } package pattern.c.mediator; public class ConColleague2 implements Colleague { private String state = null; private Mediator mediator; public ConColleague2 (Mediator mediator) { this.mediator = mediator; } public void change() { mediator.changeCol2(); } public void setState(String state) { this.state = state; } public String getState() { return state; } public void action() { System.out.println("this 1 and the state is " + state); } } package pattern.c.mediator; public class ConMediator implements Mediator { private ConColleague1 con1; private ConColleague2 con2; public void setCon1(ConColleague1 con1) { this.con1 = con1; } public void setCon2(ConColleague2 con2) { this.con2 = con2; } public void changeCol1() { String state = con1.getState(); con2.setState(state); con2.action(); } public void changeCol2() { String state = con2.getState(); con1.setState(state); con1.action(); } } package pattern.c.mediator; public interface Mediator { void setCon1(ConColleague1 con1); void setCon2(ConColleague2 con2); void changeCol1(); void changeCol2(); } package pattern.c.mediator; public class MediatorTest { public static void main(String[] args) { Mediator mediator = new ConMediator(); ConColleague1 col1 = new ConColleague1(mediator); col1.setState("lq test in the MediatorTest main 18"); ConColleague2 col2 = new ConColleague2(mediator); mediator.setCon1(col1); mediator.setCon2(col2); col1.change(); } } *********************************************************************** //Iterator模式例子 package pattern.c.iterator; interface Aggregate { MyIterator Iterator(); } class ConAggregate { public MyIterator Iterator() { return new ConMyIterator(); } } interface MyIterator { Object First(); Object Last(); boolean hasNext(); Object Next(); } class ConMyIterator implements MyIterator{ Object[] objs = new Object[100]; int index = 0; public Object First() { index = 0; return objs[index]; } public Object Last() { index = objs.length - 1; return objs[index]; } public boolean hasNext() { return index < objs.length; } public Object Next() { if (index == objs.length - 1) { return null; } else { return objs[++index]; } } } public class IteratorPattern { public static void main(String[] args) { } } *********************************************************************** // Template Method 模式例子 package pattern.c.template_method; abstract class father { abstract void med0(); abstract void med1(); //operation为一个模板方法 public void operation() { med0(); med1(); // and other logic } } class child extends father { public void med0() { System.out.println("the med0 method"); } public void med1() { System.out.println("the med1 method"); } } public class TemplateMethodPattern { public static void main(String[] args) { } } *********************************************************************** //Chain of Responsiblity模式例子 //将请求在链上传递 //如果是当前节点的请求就结束传递处理请求否则向下传递请求 //每个节点有另一个节点的引用 实现链状结构 package pattern.c.chain_of_responsiblity; interface Handler{ void handleRequest(int key); } class ConHandler1 implements Handler { private Handler handler; public ConHandler1(Handler handler) { this.handler = handler; } public void handleRequest(int key) { if (key == 1) { System.out.println("handle in 1"); //handle something } else { handler.handleRequest(key); } } } class ConHandler2 implements Handler { private Handler handler; public ConHandler2(Handler handler) { this.handler = handler; } public void handleRequest(int key) { if (key == 2) { System.out.println("handle in 2"); //handle something } else { handler.handleRequest(key); } } } class ConHandler3 implements Handler { private Handler handler; public ConHandler3(Handler handler) { this.handler = handler; } public void handleRequest(int key) { if (key == 3) { System.out.println("handle in 3"); //handle something } else { handler.handleRequest(key); } } } public class ChainOfResponsiblityPattern { public static void main(String[] args) { Handler handler = new ConHandler2(new ConHandler1(new ConHandler3(null))); handler.handleRequest(3); } } *********************************************************************** //Interpreter模式例子 /* * Variable 表示变量 存储在上下文中 * Constant 终结表达式 * And 与的关系 双目 * Not 反的关系 单目 */ package pattern.c.interpreter; import java.util.*; class Context { private Map variables = new HashMap(); public boolean lookUp(Variable name) { Boolean value = (Boolean) variables.get(name); if (value == null) { return false; } return value.booleanValue(); } public void bind(Variable name, boolean value) { variables.put(name, new Boolean(value)); } } interface Expression { boolean interpret(Context cont); } class Constant implements Expression { private boolean value; public Constant(boolean value) { this.value = value; } public boolean interpret(Context cont) { return value; } } class Variable implements Expression{ private String name; public Variable(String name) { this.name = name; } public boolean interpret(Context cont) { return cont.lookUp(this); } } class And implements Expression { private Expression left; private Expression right; public And(Expression left, Expression right) { this.left = left; this.right = right; } public boolean interpret(Context cont) { return left.interpret(cont) && right.interpret(cont); } } class Not implements Expression { private Expression expression; public Not(Expression expression) { this.expression = expression; } public boolean interpret(Context cont) { return ! expression.interpret(cont); } } public class InterpreterPattern { public static void main(String[] args) { Context cont = new Context(); Variable variable = new Variable("parameter1"); cont.bind(variable, true); Expression and = new And(new Not(new Constant(true)), new And(new Constant(false), new Variable("parameter1"))); // (!(true)) && ((false)&&(true)) and.interpret(cont); } } *********************************************************************** //Memento模式例子 package pattern.c.memento; class Memento { String value1; int value2; public Memento(String value1, int value2) { this.value1 = value1; this.value2 = value2; } } class Originator { private String value1; private int value2; public Originator(String value1, int value2) { this.value1 = value1; this.value2 = value2; } public void setMemento(Memento memento) { value1 = memento.value1; value2 = memento.value2; } public Memento createMemento() { Memento memento = new Memento(value1, value2); return memento; } public void setValue1(String value1) { this.value1 = value1; } public void setValue2(int value2) { this.value2 = value2; } } class CareTaker { private Memento memento; public Memento retrieveMemento() { return memento; } public void saveMemento(Memento memento) { this.memento = memento; } } public class MementoPattern { public static void main(String[] args) { Originator originator = new Originator("test1", 1); CareTaker careTaker = new CareTaker(); //保存状态 careTaker.saveMemento(originator.createMemento()); originator.setValue1("test2"); originator.setValue2(2); //恢复状态 originator.setMemento(careTaker.retrieveMemento()); } }
发表评论
-
测试可视化编辑器
2012-05-13 17:37 0function createMap(Id,zPoin ... -
Java5泛型的用法,T.class的获取和为擦拭法站台(江南白衣)
2009-04-24 23:15 2005Java 5的泛型语法已经有太多书讲了,这里不再打字贴书。G ... -
搞懂java中的synchronized关键字
2009-02-26 09:49 1249synchronized关键字的作用域有二种: 1)是某个对 ... -
java.lang.reflect.Field
2008-09-05 13:28 2049package java.lang.reflect; imp ... -
java.lang.reflect.Constructor
2008-09-05 13:26 2397package java.lang.reflect; imp ... -
java.lang.reflect.Method
2008-09-05 13:24 2455package java.lang.reflect; imp ... -
常用正则表达式
2008-08-20 21:18 866正则表达式用于字符串 ... -
如何使用Log4j
2008-08-11 21:46 9341、 Log4j是什么? Log4j ... -
java的30个学习目标
2008-07-28 11:50 819你需要精通面向对象分 ... -
动态代理类
2008-07-23 21:59 1018Java动态代理类位于Java.lang.ref ... -
一个小的WEB项目中的实现方法讨论(转载JDON)
2008-05-09 12:31 1036最近对一个别人的WEB项目进行维护,看到这样的实现方法: 1. ... -
java数组
2008-03-06 17:15 792这两天写了一个小的JAVA游戏.当然做游戏一般都会用到数组.遇 ... -
在JAVA中获得当前时间
2008-03-02 10:38 9689Date currentTime = new Date(); ... -
mysql乱码
2008-03-02 10:36 1027JSP的request 默认为ISO8859_1,所以在处理中 ... -
ServletContext与ServletConfig的深度分析<网上收集>
2007-12-20 15:46 1115对于web容器来说,ServletContext接口定义了一个 ... -
对synchronized的一点认识
2007-11-30 16:02 1439今天看了一下多线程。 对synchronized这个东东是研究 ...
相关推荐
总结来说,"MVC设计模式例子程序"是一个演示了如何在C#的Windows Forms环境下实现MVC模式的应用。通过模型、视图和控制器的分离,这个程序实现了业务逻辑、用户界面和数据管理的清晰划分,增强了代码的可读性和可...
设计模式例子设计模式例子设计模式例子
这份名为"设计模式例子文档,简单易学"的资源,显然是为了帮助开发者更直观、更快速地理解和应用设计模式。设计模式并非具体的代码或库,而是一种通用的解决方案模板,可以在不同的软件开发过程中复用,以提高代码的...
在这个“设计模式例子和PPT”压缩包中,包含的内容主要是关于设计模式的基本原则、UML类图以及一些实际的应用示例。 设计模式分为三大类:创建型模式、结构型模式和行为型模式。每种模式都有其特定的目标和适用场景...
标题中的“文档编辑器,设计模式例子Jexi”指的是一个使用Java编程语言实现的软件项目,该项目旨在模仿名为Lexi的文档编辑器,并且它巧妙地应用了设计模式来构建其架构。设计模式是在软件工程中经过验证的解决常见...
标题中的"常用设计模式例子.zip"表明这个压缩包包含了一些常见的设计模式的实际示例代码。让我们逐一探讨这些模式: 1. **工厂模式**:工厂模式是创建型设计模式,它提供了一种创建对象的最佳方式。在工厂模式中,...
在给定的压缩包文件中,"设计模式例子,观察者模式,建造者模式" 提到了两种重要的设计模式:观察者模式(Observer Pattern)和建造者模式(Builder Pattern)。下面我们将深入探讨这两种设计模式的概念、应用场景、...
"patternDesign设计模式例子源码"这个压缩包很可能是包含了一些常见设计模式的实际应用示例,如单例模式、工厂模式、观察者模式等。下面我们将深入探讨这些设计模式及其重要性。 1. **单例模式**:单例模式确保一个...
java 设计模式 例子 , 整理了网上的源码,实践了23 种设计模式。
在"Java设计模式例子"的压缩包中,`src`目录很可能包含了上述各种设计模式的实现代码,你可以通过查看这些代码来深入理解每种模式的工作原理和使用场景。实践中,灵活运用设计模式可以提高代码的可读性、可维护性和...
标题"设计模式例子(高手可以不看)"可能暗示这是一份面向初学者或中级开发者的学习资料,包含了设计模式的实际应用示例。描述中的“对设计模式的一个练习”进一步确认了这是一个学习和实践设计模式的项目。 设计模式...
"c++所有常用设计模式例子代码Source.zip"这个压缩包包含了C++实现的各种设计模式的实例代码,对于学习和理解设计模式有着极大的帮助。 设计模式通常分为三大类:创建型、结构型和行为型。下面,我们将详细讨论这些...
以JAVA为例,汇总了十几种常用的设计模式,包括了:单例模式、工厂模式、建造者模式、适配器模式、装饰器模式、外观模式、命令模式、观察者模式、状态模式、策略模式、模板方法模式等。仅供学习使用。 相关文章请看...
自己看书时写的例子程序,简单明了,供大家学习参考。 如有不对之处,请多谅解。 AbstractFactory Adapter Bridge chainResponsibility Command Composite Facade Factory Iterator Prototype Proxy
最近在看head first 设计模式,书上的例子是用java编写的.因为工作上C用的比较多,所以决定编看书,边用C++也编写书上的例子.既可以加深对设计模式的理解,也顺便练习下c++. 希望这写代码也能帮助别人学习c++和设计模式...
最近在看head first 设计模式,书上的例子是用java编写的.因为工作上C用的比较多,所以决定编看书,边用C++也编写书上的例子.既可以加深对设计模式的理解,也顺便练习下c++. 希望这些代码也能帮助别人学习c++和设计模式...
设计模式是软件开发中的一种重要概念,它是经过时间验证并被广泛接受的解决方案模板,用于解决常见的编程问题。设计模式的出现源于建筑学家Christopher Alexander的工作,他在建筑领域提出了模式的概念,即针对特定...
**WPF MVVM设计模式详解** MVVM(Model-View-ViewModel)设计模式在Windows Presentation Foundation(WPF)中被广泛使用,它是一种用于构建用户界面的架构模式,旨在提高代码的可测试性和可维护性。这个模式由...
这个压缩包文件名为“23种设计模式示例源码”,暗示其中包含了解决23种经典设计模式的具体实现代码,这对于初学者或者希望深入理解设计模式的开发者来说是一份宝贵的资源。下面将对这23种设计模式进行详细解释。 1....