My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
WorkingWithRocket  

Featured, Phase-Design
Updated Feb 4, 2010 by miroslav...@gmail.com

#Getting started and understanding how, why and where things are like they are...

Motivation

Developers new to GWT or rocket need a better understanding of how, why and where things are in the rocket project. It also includes coding standards used as a guide to better understand how things are put together.

Details

All classes follow a number of simple rules.

Using

To use anything thats bundled with the rocket library.

  • Add rocket.jar to your project's classpath (before gwt-user.jar).
  • Add rocket-stacktrace.jar (before gwt-user.jar) to include support for web mode stacktraces.
  • Inherit rocket.User
  • <inherits name="rocket.User" />

Packaging

  • client Contains classes that ultimately are translated to javascript.
  • rebind Contains any generators that assist client counterparts. These are typically accessed using deferred binding with an appropriate class literal.
  • server Contains the server side counterpart that work in tandem with a client.
  • test contains the corresponding tests for the component. To find tests for a client class navigate to the corresponding test subpackage. Tests are named to match the client component.

Classes

  • If a component consists of more than a single (a few) classes move them into their own sub package.
  • Many components are templates that require the developer to override and fill in the gaps.
  • Never try and do too much in a single class.
  • Keep classes small with a single purpose so they can be assembled into larger artefacts.

Constants

  • Never define constants in interfaces or classse.
  • All constants that should not be visible outside a package are placed in a class called Constants.
  • If some constants should be visible outside the package name the class XXXConstants where XXX is the module name.
  • Always provide a toString() that dumps important fields.
  • If possible try and make helpers package private.

Constructors

  • Classes typically have no arguments constructors.

Fields

  • Fields are always private.
  • Never directly access fields, use the getter or setter.
  • Initialize fields via a factory.
  • Use interface references whereever possible.

Methods

  • Always test incoming parameters - aka defensive programming -> use rocket.client.util.XXX.check
  • Avoid code duplication, move reusable code into a helper or super class.
  • Methods are categorised into two parts, methods that manipulate values and objects and other methods that coordinate a process.
  • Never group unrelated manipulations in a single method. Break up them into multiple independent methods. This makes it easy to sub class to change behaviour.
  • Always use factories whereever possible rather than new XXX.
  • Always try and make minimum number of methods public.
  • Make method names descriptive.
  • Name asserting methods checkXXX.
  • Methods should never be more than a screen full in length.
  • Make all jsni (javascript native interface) methods private with a corresponding regular java method to check parameters etc. Never hit the jsni method go via its java guard.

References

  • Always try and make variable and parameter references final.
  • Always try and use interface references rather than concrete types.

Tests

Components

  • When starting out look at the corresponding test for the component.

Feedback

Comment by rced...@gmail.com, Sep 30, 2008

Hi!

I have the next errors compiling:

Loading module 'com.mycompany.MyApplication5?'

Loading inherited module 'rocket.User'
ERROR? Unable to find 'rocket/User.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
ERROR? Line 3: Unexpected exception while processing element 'inherits'
com.google.gwt.core.ext.UnableToCompleteException?: (see previous log entries)
at com.google.gwt.dev.cfg.ModuleDefLoader?.nestedLoad(ModuleDefLoader?.java:225) at com.google.gwt.dev.cfg.ModuleDefSchema?$BodySchema?.inherits_begin(ModuleDefSchema?.java:194) at sun.reflect.NativeMethodAccessorImpl?.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl?.invoke(NativeMethodAccessorImpl?.java:39) at sun.reflect.DelegatingMethodAccessorImpl?.invoke(DelegatingMethodAccessorImpl?.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.google.gwt.dev.util.xml.HandlerMethod?.invokeBegin(HandlerMethod?.java:223) at com.google.gwt.dev.util.xml.ReflectiveParser?$Impl.startElement(ReflectiveParser?.java:257) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533) at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:220) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:872) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher?.dispatch(XMLDocumentFragmentScannerImpl.java:1693) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242) at com.google.gwt.dev.util.xml.ReflectiveParser?$Impl.parse(ReflectiveParser?.java:310) at com.google.gwt.dev.util.xml.ReflectiveParser?$Impl.access$100(ReflectiveParser?.java:48) at com.google.gwt.dev.util.xml.ReflectiveParser?.parse(ReflectiveParser?.java:381) at com.google.gwt.dev.cfg.ModuleDefLoader?.nestedLoad(ModuleDefLoader?.java:243) at com.google.gwt.dev.cfg.ModuleDefLoader?$1.load(ModuleDefLoader?.java:155) at com.google.gwt.dev.cfg.ModuleDefLoader?.doLoadModule(ModuleDefLoader?.java:269) at com.google.gwt.dev.cfg.ModuleDefLoader?.loadFromClassPath(ModuleDefLoader?.java:127) at com.google.gwt.dev.cfg.ModuleDefLoader?.loadFromClassPath(ModuleDefLoader?.java:108) at com.google.gwt.dev.GWTCompiler.run(GWTCompiler.java:562) at com.google.gwt.dev.GWTCompiler.run(GWTCompiler.java:554) at com.google.gwt.dev.GWTCompiler.main(GWTCompiler.java:214)
ERROR? Failure while parsing XML
com.google.gwt.core.ext.UnableToCompleteException?: (see previous log entries)
at com.google.gwt.dev.util.xml.DefaultSchema?.onHandlerException(DefaultSchema?.java:56) at com.google.gwt.dev.util.xml.Schema.onHandlerException(Schema.java:65) at com.google.gwt.dev.util.xml.Schema.onHandlerException(Schema.java:65) at com.google.gwt.dev.util.xml.HandlerMethod?.invokeBegin(HandlerMethod?.java:233) at com.google.gwt.dev.util.xml.ReflectiveParser?$Impl.startElement(ReflectiveParser?.java:257) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533) at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:220) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:872) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher?.dispatch(XMLDocumentFragmentScannerImpl.java:1693) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242) at com.google.gwt.dev.util.xml.ReflectiveParser?$Impl.parse(ReflectiveParser?.java:310) at com.google.gwt.dev.util.xml.ReflectiveParser?$Impl.access$100(ReflectiveParser?.java:48) at com.google.gwt.dev.util.xml.ReflectiveParser?.parse(ReflectiveParser?.java:381) at com.google.gwt.dev.cfg.ModuleDefLoader?.nestedLoad(ModuleDefLoader?.java:243) at com.google.gwt.dev.cfg.ModuleDefLoader?$1.load(ModuleDefLoader?.java:155) at com.google.gwt.dev.cfg.ModuleDefLoader?.doLoadModule(ModuleDefLoader?.java:269) at com.google.gwt.dev.cfg.ModuleDefLoader?.loadFromClassPath(ModuleDefLoader?.java:127) at com.google.gwt.dev.cfg.ModuleDefLoader?.loadFromClassPath(ModuleDefLoader?.java:108) at com.google.gwt.dev.GWTCompiler.run(GWTCompiler.java:562) at com.google.gwt.dev.GWTCompiler.run(GWTCompiler.java:554) at com.google.gwt.dev.GWTCompiler.main(GWTCompiler.java:214)
ERROR? Build failed

Now I have the GWT 1.5.2 and Rocket 0.56. When I had the GWT 1.4.60 and an old Rocket, the compilation was successful. Could someone help me? I have tested everything!

And the most strange is that if I launch the application in Hosted Mode, it works correctly.

Thank you in advance!

Regards, Raquel


Sign in to add a comment
Powered by Google Project Hosting