1

I'm new to Jena, but when I look at the vocabularies defined with the Jena source (i.e. in directory: jena-2.10.0-Source\jena-core\src\main\java\com\hp\hpl\jena\vocabulary) I see some of the vocabularies create properties and resources using 'ResourceFactory.createProperty()' (e.g. OWL2.java, RDF.java, RDFS.java), whereas others in the same directory use 'ModelFactory.createDefaultModel().createProperty()' (e.g. DC_11.java, VCARD.java, DCTerms.java).

I understand that ResourceFactory is used to create resources and properties without reference to a 'model', but I just want to understand why some of these vocabs choose to create and use a 'model' instance while others choose not to.

Is it just personal style, or is one approach generally recommended over the other (maybe one style is an 'old approach', as I understand Jena has been around a long time)?

I'd like to use both the RDFS and DC_11 vocabs with my code, and obviously define my own app-specific resources and properties, so I'm just trying to understand which approach I should adopt for my own stuff.

durron597
  • 31,968
  • 17
  • 99
  • 158

1 Answers1

1

That both styles are used is just historical accident. I think these days, I'd probably suggest using the ResourceFactory approach, simply because it avoids the (small) overhead of allocating a model, and the model gives you no real advantages. At some point, we'll probably go back and do some refactoring to just use a single approach in the Jena codebase.

Ian Dickinson
  • 12,875
  • 11
  • 40
  • 67
  • Cool - thanks Ian, that was exactly what I was looking for! I guessed the reason might be historical, and I was leaning towards the 'ResourceFactory' approach myself anyway, so thanks a million for taking the time to verify that for me :) – Pat McBennett Jul 18 '13 at 09:48
  • If you feel your question is answered, you can notify future SO readers with the same enquiry of that fact by ticking the check-mark next to your preferred answer. – Ian Dickinson Jul 18 '13 at 10:05
  • Yeah, I know Ian, but my reputation is only '6'(!), and you need 15 to Up-Vote - sorry! – Pat McBennett Jul 23 '13 at 16:15
  • No, you misunderstand. You can accept an answer by ticking the checkmark next to the question so that it goes green. It's different from up-voting, and will increase your reputation too! – Ian Dickinson Jul 23 '13 at 22:25
  • @PatMcBennett You should [accept this answer](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work), and now that you've got enough reputation, you could upvote it too. – Joshua Taylor Sep 06 '13 at 16:40