SCJD: Result Breakdown

January 20, 2010 grwilliamson 1 comment

I’d forgotten to log in and get my assessor comments from the cert database after passing.

Here is the feedback…

This report shows the total points that could have been awarded in each section, and the actual number of points you were awarded. This is provided to give you per-section feedback on your strengths.
The maximum possible score is 400; the minimum to pass is 320.

General Considerations (maximum = 100): 100
Documentation (maximum = 70): 70
O-O Design (maximum = 30): 30
GUI (maximum = 40): 31
Locking (maximum = 80): 80
Data store (maximum = 40): 40
Network server (maximum = 40): 40

David T, you were clearly right in your assessment of the GUI… Still had a few rough edges! :-)

Categories: Java Tags: , ,

Beware: Your API is more public than you may think

October 29, 2009 grwilliamson Comments off

Well, I made a classic school boy error today in my SOA service pubic API.

I somehow convinced myself that wrapping an “internal” exception in a public/”external” API service-level exception would ensure that client would only be dependent on the external exception. Wrong!

Certainly not when I did the sensible (?) thing of preserving the cause of the exception – that being the internal exception:

try {
   doSomethingThatMightThrowAnInternalException();
} catch (InternalException e) {
   throw new ExternalException("A useful message.",e);
}

The “,e);” is the culprit in the above code snippet.

My SOA service is offered as an RMI service as well as a web service. I provide a client jar containing all the public API classes (interfaces and exceptions) but no internal implementation classes. If the internal exception occurs though, then a ClassNotFoundException will occur when unmarshalling the external exception, because it has-a(n) internal exception.

java.lang.ClassNotFoundException: com.my.InternalException
(no security manager: RMI class loader disabled)

Now this wouldn’t happen if dynamic class loading were in use, but in this instance, it isn’t.

Three solutions are open now:

  • Add the internal exception to the client interface jar.
  • Don’t wrap the internal exception, but instead throw a new external exception without a cause.
  • Turn on dynamic class loading by enabling the RMI class loader.

Like I say, school boy error. We live and learn (or at least remember).

SCEA: Books

October 19, 2009 grwilliamson Comments off

Books: Want One – Practical API Design

October 19, 2009 grwilliamson 1 comment

I’ve got to get this book: “Practical API Design: Confessions of a Java Framework Architect“.

Practical API Design

Practical API Design

I seem to spend so much time developing extensible frameworks and APIs these days, it would great to see/read another opinion.

There’s a review of the book here, and it sounds promising.

Interesting Mapper/Builder Strategy

October 14, 2009 grwilliamson Comments off

Jakub has an interesting slant on the problem of mapping objects from one representation into another, without XML.

This is something I’ve come up against many times on my most recent project.

http://www.jakubkorab.net/2009/10/a-better-builder.html

My thoughts:

I like this approach. It provides a very elegant mechanism for mocking, for sure.

On my recent project I opted for individual mapper classes due to their reusability across different scenarios – for example the mapping of a particular type that is a member of many different, and quite independent, objects.

In addition, the mapping classes were really pretty big and to have all of this logic in a single class would create a massive class. Not quite a monolithic block of code in a single method, but it would still have the feel of a retro procedural programming treat.

I guess for me I felt that the individual mapper classes were better aligned with the principles of single responsibility, separation of concerns, increased cohesion and reduced coupling, albeit for the cost of class explosion! Each mapper only knew about the input object, the resulting output object, and any child or member objects. It’s also simple to test – something which I did actually do.

Like everything though, it depends on the situation and it’s interesting to have another tool in the bat belt for this. I’ll definitely take this into consideration next time around.

Further Thoughts:

Couldn’t much the same be achieved by simply extending the Builder and then overriding the methods that you don’t want to test? I.e. mock the builder methods that are irrelevant during the test scenario.

Intellij & Parallels – Error Highlighting Broken

September 30, 2009 grwilliamson Comments off

If you are using Intellij on a mac via Parallels and Windows, beware the evil problems caused by sharing your home directory between Parallels and Mac OS X.

Sharing your home directory will break your error highlighting within Intellij. Your code will build/make so long as you have configured your JDK (JSDK) correctly, but will fail to find core Java language types such as String within the editor.

Save yourself many hours and uncheck the option in Parallels to share your home directory.

See the final comment in this chain for further details: Error highlighting is flagging my Java types “cannot resolve symbol” even tho compile & run works.

Categories: Java, Macs, Technical Tags: , ,

SCJD: The Result

September 27, 2009 grwilliamson 1 comment

Finally, after more than 6 weeks of waiting, I logged into the Sun assignment web site to find my result for the Sun Certified Java Developer assignment:

Sun Certified Developer for the Java 2 Platform (310-027)             Sep 26 2009       P        391

391/400, which is about 98%. Phew!

I was beginning to worry I would fail for over-engineering the solution, but it looks like my (and most developers’ I should think) usual design paid off.

Categories: Java Tags: , ,

Walkies in the Three Counties

September 12, 2009 grwilliamson Comments off

This post is for Arkala, Madge, Bean and I to note our recent doggie-holiday walking achievements…

  • Friday:
    • Walk: Short one around the farm land until we reached an impassable field of crazy  cows.
    • Nosh: The Plume of Feathers, Castlemorton. Great food, sitting in the bar area. Exceptional puddings (chocolate and pear fondant).
  • Saturday:
    • Walk: Tewkesbury > 6 miles. Weren’t so keen on the town, and the walk mainly circled developed areas. Never really left the town. All flat. Not much view of the river.
    • Nosh: The Nags Head, Malvern.
  • Sunday:
    • Walk: British Camp via the Obo > 7 miles. Great walk, but hard work. Muddy.
    • Nosh: The Plume of Feathers, Castlemorton. Great food (roast), sitting in the bar area.
  • Thursday:
    • Walk: Barn to Greggs in Ledbury and back via the Obo > 16 miles. A bit of everything – a great walk across the common, up past the Quarry to the Obelisk and through the Deer Park to Ledbury, and back.
    • Nosh: The Plume of Feathers, Castlemorton. Great food, sitting in the bar area. Exceptional puddings (chocolate and pear fondant).

Glorious Gotchas

September 3, 2009 grwilliamson Comments off

Two nice gotchas that helped me waste time tonight…

EXCEPTION_ACCESS_VIOLATION

If you get the following, kill all of your JVMs and try again. Simple as. Grrrr… Big red hearing when you’ve just changed a load of code.

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at

Thanks to http://www.java-forums.org/eclipse/312-exception_access_violation-0xc0000005.html for this.

OSGi Bundles and Native Code

Be warned, configuring native code within an OSGi bundle manifest isn’t obvious or intuitive.

This looks like it works, but it doesn’t … and it fails silently, even though if I added some nonsense entry, it would complain.

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: My Cool Plug-in
Bundle-SymbolicName: com.figmentweb.cool;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: com.figmentweb.cool.Activator
Bundle-Vendor: DKIB
SpringContext: OSGI-INF/importexport.xml,
 spring/cool/application-context.xml,
 spring/client/cool/cool-beans.xml
Require-Bundle: org.eclipse.core.runtime,
 org.eclipse.ui;bundle-version="3.4.1"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-NativeCode: dll/a.dll,
 dll/b.dll,
 dll/c.dll,
 dll/d.dll,
 dll/e.dll,
 dll/f.dll,
 dll/g.dll,
 dll/h.dll
Bundle-ClassPath: ...

This is what it should be:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: My Cool Plug-in
Bundle-SymbolicName: com.figmentweb.cool;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: com.figmentweb.cool.Activator
Bundle-Vendor: DKIB
SpringContext: OSGI-INF/importexport.xml,
 spring/cool/application-context.xml,
 spring/client/cool/cool-beans.xml
Require-Bundle: org.eclipse.core.runtime,
 org.eclipse.ui;bundle-version="3.4.1"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-NativeCode: dll/a.dll;
 dll/b.dll;
 dll/c.dll;
 dll/d.dll;
 dll/e.dll;
 dll/f.dll;
 dll/g.dll;
 dll/h.dll
Bundle-ClassPath: ...

That is, even though every other multi-entry/list of configurations is split across lines by ‘,’ – within the Bundle-NativeCode we should use ‘;’. Using ‘,’ won’t cause an error, it just means that only the first DLL is loaded.

The ability to bundle DLLs/SOs into a bundle jar is awesome though.

Thanks to: http://www.eclipse.org/newsportal/article.php?id=12052&group=eclipse.platform.rcp#12052

Categories: Java Tags: , ,

SCJD: Sun Certified Java Developer… the Book!

September 1, 2009 grwilliamson Comments off

When studying for the Sun Certified Java Developer assignment exam I used the book: SCJD Exam with J2SE 5 by Andrew Monkhouse and Terry Camerlengo from APress. I found it to be an invaluable resource when preparing for the assignment.

SCJD Exam with J2SE 5 Book from APress

SCJD Exam with J2SE 5 Book from APress

I must admit, I was thoroughly impressed with this book. It assumes a fair amount of Java knowledge and programming savvy, and as a result reads well for the more experienced developer looking to fill holes in their skill set, rather than learn OO from scratch (as most programming books begin). Its broad subject matter is really ideal for this task specifically, by illustrating how the many APIs in Java can be used to develop an enterprise solution with no more than core Java. Whilst this design in itself might not be the most sensible in a production environment, it does afford the opportunity to learn how things work “under the bonnet” in an enterprise container, and in fact roll your own.