当前位置:首页 » 软件开发
开发技术指南» 文章正文
    引言: The Strategy, Template Metho
 

 

    摘要:the last ten years of software development have seen the rise of the internet and open standards, most prominently html. to most non-technical people, web pages (just html over a tcp/ip connection) ......
    摘要:this time of year, theres plenty of leftover wrapping paper sitting around. why not put it to good use? if you create interfaces, you may have heard of paper prototyping. its a technique that lets......


Principles, Patterns, and Practices: The Strategy, Template Method, and Bridge Patterns

the strategy, template method, and bridge patterns

to illustrate the strategy pattern lets assume that we are working on a debug logger. debug loggers are often very useful devices. programmers can send messages to these loggers at strategic places within the code. if the system misbehaves in some way, the debug log can provide clues about what the system was doing internally at the time of the failure. 【程序编程相关:谨慎使用Date和Time类

one of the great benefits of object-oriented programming is polymorphism; i.e., the ability to send a message to an object without knowing the true type of the object. perhaps no pattern illustrates this better than the strategy pattern. 【推荐阅读:使用Properties类带来的好处

logger.log("my message");

on the other hand, what we want to see in the log is quite a bit more complex. at very least we are going to want to see the time and date of the message. well also probably want to see the thread id. indeed, there may be a whole laundry list of system states that we want to log along with the message. so the logger needs to gather all of this peripheral information together, format it into a log message, and then add it to the growing list of logged messages. 【扩展信息:Jar clone的版本冲突

in order to be effective, loggers need to be simple for programmers to use. programmers arent going to frequently use something that is inconvenient. you should be able to emit a log message with something no more complicated than:


...   下一页
    摘要:whether it is a word-processing application that saves documents to a disk, a utility that remembers its configuration for subsequent use, or a game that allows players to assume world domination and ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE