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.
- Google Blog - googleblog.blogspot.com
- Google Talkabout - googletalk.blogspot.com
- Google Base Blog - googlebase.blogspot.com
- Google Video - googlevideo.blogspot.com
- Inside Google Desktop - googledesktop.blogspot.com
- Google Code - code.google.com
- Inside AdWords - adwords.blogspot.com
- Inside AdSense - adsense.blogspot.com
- Google Reader Blog - googlereader.blogspot.com
- Blogger Buzz - buzz.blogger.com
- AdWords API Blog - adwordsapi.blogspot.com
- Google Enterprise Blog - googleenterprise.blogspot.com
- Google Research - googleresearch.blogspot.com
- Google Maps API Blog - googlemapsapi.blogspot.com
- Google Writely - writely.blogspot.com
- Inside Google Book Search - booksearch.blogspot.com
Purpose:
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
Purpose:
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
Just wanna add an additional screen for better working, LCD monitor is my favorite thought, here is good article for purchase guide:
http://reviews.cnet.com/4520-7610_7-5084364-3.htmland 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.
http://www.metanotes.com/
Just installed on my xp machine today, updated with Callisto Discovery
Site, seems lots of plugins have been integrated. I'd like to see c++,
TPTP, WST and UML plugin tools in it. But still don't know
how to play Visual Editor ...can't get rid of crutch
thought from Microsoft kits..
问:
都是撞车而死,J2EE程序员与.Net程序员有什么区别?
答:
J2EE程序员死前有刹车的痕迹----一种打破常规的操作。
虚无主义者是这样一种人,对于如其所是地存在的世界,他断定它不应当存在;对于如其应是地存在的世界,他断定它并不实存。
--摘自朋友的Blog
这个说的比较抽象,俺翻译如下,不知是否达意:
if exists(A)
{
Assert(!A.bExisting);
}
else if(A != null && A.bExisting)
{
Assert(!exists(A));
}
1. Design your own Exception hierarchy to handle all categories of potential errors in your system
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.
1. put every class in certain packages, including those test classes, not like to use Default package
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.
1. String --> InputStream
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:
- Click the Start Button
- Select the Control Panel
- Click Switch to Classic View
- Click the System button
- Select the Advanced tab
- Click the Environment Variables button
- Click the New button to create a CLASSPATH or the Edit button to edit an existing CLASSPATH
- Enter CLASSPATH as the variable name
- Enter the list of directories or jar files in your CLASSPATH
as the variable value, using a semicolon to separate entries in your
list
- Click OK
- Click OK
- Click OK
It is common problem of convertion between int & string for certian
computer language. Well, in Java, following are some easy ways I
usually apply:
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")
purpose:
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