Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Currently I have some code like this:

OntologyGenerator generator = new OntologyGenerator();
generator.AddOntologyHeader("Testing");
generator.AddClassDeclaration(owlBuilder);
generator.AddSubClass(owlBuilder);
generator.AddAnnotationAssertions(owlBuilder);

where that OwlBuilder param you see being passed has collections of objects like this:

public class OwlLBuilder: IOwlLBuilder
{
       private ICollection<IOwlClass> owlClasses = new Collection<IOwlClass>();
       private ICollection<IOwlRelation>  owlRelations = new Collection<IOwlRelation> ();
}

so for example when I say generator.AddClassDeclaration(owlBuilder); it will be looping through owlClasses collection of that owlBuilder param and do some stuff to it...

I feel it is an ugly design. Do you have any other better design suggestions, well with some code sample so I can have the big picture of what I should do in my head!

share|improve this question
    
Are the same set of ontonoly properties going to be added every time? Also, if this is a markup-type piece of code (in that it will generate something like a document) perhaps something like XLINQ would be worth consideration? –  JohnL Aug 21 '12 at 0:25
    
not sure if I understood your question correctly but I always call those methods (Add* method) in the same order...first create their classes, then subclasses,etc... –  BDotA Aug 21 '12 at 0:31
    
That was my question - they should really be in the constructor if you always call the same ones in the same way, as you could forget to call one somewhere or swap the ordering by accident. –  JohnL Aug 21 '12 at 6:27
    
BTW, I mean all those calls should probably be in the OntologyGenerator constructor –  JohnL Aug 21 '12 at 6:31
add comment

1 Answer 1

up vote 3 down vote accepted

I have 2 opposing ideas:

Get rid of the IOwlBuilder completly and pass collection themselves.

OntologyGenerator generator = new OntologyGenerator();
generator.AddOntologyHeader("Testing");
generator.AddClassDeclaration(classes);
generator.AddSubClass(relations); // ??
generator.AddAnnotationAssertions(??);

Create an interface that will provide all data needed for creation.

public interface IOntologySource 
{
     public string GetHeader {get; }
     public ICollection<IOwlClass> Classes {get; }
     public ICollection<IOwlRelation> Relations {get; }   
}

And then use it as parameter in constructor.

OntologyGenerator generator = new OntologyGenerator(ontologySource);

But it seems like you are not telling us everything and there is much more going on with your code. You should add more details if you want better answer.

share|improve this answer
    
+1 for the last sentence, I have highlighted the important parts. –  Doc Brown Aug 21 '12 at 7:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.