Dedian |
|
|||
-- 關(guān)注搜索引擎的開發(fā) |
日歷
統(tǒng)計
導(dǎo)航常用鏈接留言簿(8)隨筆分類(45)
隨筆檔案(82)
文章檔案(2)Java Spaces搜索積分與排名
最新評論
閱讀排行榜評論排行榜 |
GData, Google data API, provides a simple standard protocol for reading and writing data on the web, which supports two common XML-based syndication formats (Atom and RSS).
Briefly browse the documents and javadoc of GData, I found that it is very similiar to my thought on my current clustering searching engine system, designing an interface of data structure for all the request to searching engine servers, and employing an other interface to handle external/internal requests and fill up the data structure. Although my first version of searching engine has been deployed on LiveDigital, I am still working on the new version?with clustering?design. source code has been packaged and implementation document is almost done,?I still hope I can learn something from GData, more professional and structrual design.?
To control access to an object, provide a surrogate or placeholder (proxy) for it. As a mostly used strategy, Proxy can defer the creation and initialization of the object until it is on demand. Structure: Similar to adapter, client includes an object of proxy to access, and proxy includes a real object that proxy represents. Difference from Adapter: Adapter provides a different interface to the object it adapts. In contrast, Proxy provides the same interface as its subject. As a protection of real object, Proxy can refuse to perform an operation that the subject will perform. Example: http://www.javaworld.com/javaworld/jw-02-2002/jw-0222-designpatterns.html Reference: Book: (GoF)Design Patterns http://en.wikipedia.org/wiki/Proxy_design_pattern http://www.inf.bme.hu/ooret/1999osz/DesignPatterns/Proxy4/ http://alumni.media.mit.edu/~tpminka/patterns/Proxy.html Encapsulate a set of objects which interact with each other. The benefit to do this is keeping objects from communicating with each other directly. All the messages between objects should be sent to mediator at first and then mediator will control and coordinate those interaction. Also, mediator can handle external interaction request and decide which object to response the external request. Structure: star topology: Mediator class is as a hub which connects to a set of classes (colleague classes). Difference from Facade Pattern: Facade differs from Mediator in that it abstracts a subsystem of objects to provide a more convenient interface. Its protocol is unidirectional. That is, Facade objects make requests of the subsystem classes but not vice versa. In contrast, Mediator enables cooperative behavior that colleague objects don't or can't provide, and the protocol is multidirectional. reference: Gamma, E., R. Helm, R. Johnson, J. Vlissides (1995). Design Patterns. Addison Wesley. ISBN 0.201-63361-2 http://sern.ucalgary.ca/courses/seng/443/W02/assignments/Mediator/ http://my.execpc.com/~gopalan/design/behavioral/mediator/mediator.html http://reviews.cnet.com/4520-7610_7-5084364-3.html and also I have some interests in ViewSonic type http://www.viewsonic.com/products/desktopdisplays/lcddisplays/valueseries/va902b/ but i am not sure if it is best deal :(. coz PRINCETON also has a not bad deal which is cheaper and with DVI connector... still thinking and hunting, should be settled down by this week. 都是撞車而死,J2EE程序員與.Net程序員有什么區(qū)別? 答: J2EE程序員死前有剎車的痕跡----一種打破常規(guī)的操作。
虛無主義者是這樣一種人,對于如其所是地存在的世界,他斷定它不應(yīng)當存在;對于如其應(yīng)是地存在的世界,他斷定它并不實存。
--摘自朋友的Blog 這個說的比較抽象,俺翻譯如下,不知是否達意: if exists(A)
{
?????Assert(!A.bExisting);
}
else if(A != null && A.bExisting)
{
???? Assert(!exists(A));
}
? 2. extend Exception class for your throwable error-handled classes 3. Throw your defined exception classes in your code block in necessary 4. Embed error information in your defined exception 5. if you develop with new Java, be noticed that Exception implements serializable interface, you need define a static final variable for serial version UID, otherwise, warn message will be given by new compiler. here is a good article to talk about this issue. 2. generate .Jar file including thoes packages. 3. write script files (*.sh) to run certain test java classes in .Jar in same folder as my .Jar file and set CLASSPATH in my script files ex: export CLASSPATH=$CLASSPATH:com.mycompany.util-1.0.0.jar java com.mycompany.util.TestClass 4. then run the script file... or, we can use command line like this: java -classpath *.jar ..TestClass Note: be sure to use complete path for testing classes, otherwise famours NoClassDefFound error will be thrown out. InputStream convertToInputStream(String str) { ??? ??? ByteArrayInputStream is = new ByteArrayInputStream(str.getBytes()); ??????? return is; } 2. InputStream --> String ???? String convertToString(InputStream is) { ??? ?? ?????? BufferedReader in = new BufferedReader(new InputStreamReader(is)); ??? ??? StringBuffer buffer = new StringBuffer(); ??? ??? String line = ""; ??? ??? while ((line = in.readLine()) != null) ??? ??? { ???? ??? ??? buffer.append(line); ???? ??? } ???? ??? return buffer.toString(); ??? ??? ??? } When I do the socket programming, I always need to deal with inputstream and string, above are the basic ways to so that, but I am not sure if there are any simpler ways to do that... To configure a persistent CLASSPATH under Windows XP:
1. int --> String ??? a. apply "+" operation with an empty string ??? ?? ?? ex: ??? ?? ?? int index = 20; ??? ?? ?? String indexStr = "" + index; ??? b. use String function ??? ?? ?? ex: ??? ?? ?? int index = 20; ??? ?? ?? String indexStr = String.valueOf(index); ??? c. convert to Integer class firstly ??? ?? ?? ex: ??? ?? ?? int index = 20; ??? ?? ?? Integer Index = new Integer(index); ??? ?? ?? String indexStr = Index.toString(); ??? ?? ?? or ??? ?? ?? String indexStr = Integer.toString(index); 2. String --> int ??? a. use class Integer parse funtion ??? ?? ex: ??? ?? String indexStr = "20"; ??? ?? int index = Integer.parseInt(indexStr); ??? ?? or ??? ?? int index = (new Integer(indexStr)).intValue(); note: above convertion methods can be applied to other number types, such as float, long, double... P.S. for 1.a method, should be noticed that following two expression are different: int i = 7; int j = 8; String str1 = i + j + ""; //(str1 == "15") String str2 = "" + i + j; //(str2 == "78") ? Make your code robust and protect your code from invalid data, events or other unexpectable impact. good habits: -- Handle for invalid inputs (data from external sources, routine input parameters) ??? a. garbage in, nothing out ??? b. garbage in, error message out ??? c. no garbage allowed in -- Build your own assert machanism (for debugging purpose) ??? a. avoid putting executable code into assertion (otherwise will miss some execution code when releasing) ??? -- Error-Handling Techniques ??? a. return a neutral/closest value ??? b. skip to next valid data ??? c. return last valid data ??? d. Log a warning message to a file (Log file) ??? e. Return a defined error code (Throw an exception) ??? f. call an error-processing routine/object ??? g. display an error message (System.out.print) ??? h. shut down -- tips for Exception mechanism ??? a. avoid throwing exceptions in constructors and destrictors unless you catch them in the same place. ??? b. throw exceptions at the right level of abstraction ??? c. avoid empty catch blocks ??? d. consider creating your own project-specific exception class, which can serve as the base class for all exceptions thrown on your project. This supports centralizing and standardizing logging, error reporting and so on. -- Damage-containment strategy: Barricade your program (add a firewall layer for your code which maybe contains Assertions and Error-handlers) -- Debugging Aids ??? a. use offensive programming to notify yourself the potential errors ??? b. handle exception cases in a way that makes them obvious during development and recoverable when production code is running. ??? c. use version-control tools and build tools like ant and make |
![]() |
|
Copyright © Dedian | Powered by: 博客園 模板提供:滬江博客 |