I want to create a class hierarchy of the classes in an ontology using OWL API, similar to what you might see if you loaded an ontology in a tool such as Protege.
An example of how to do this may be found here: http://sourceforge.net/p/owlapi/mailman/message/27600103/.
As you can see, it seems difficult to reproduce the Protege hierarchy precisely using OWL API, and I am wondering if there is an example which will reproduce Protege's behaviour or if the fundamental reasons for not being able to do so may be clarified so an alternative approach may be found. I have had similar problems to the author of the post above, in that I can't seem to consistently reproduce the hierarchy shown by Protege by recursively going through the classes and subclasses, starting at owl:Thing, in order to create the full class hierarchy.
I need to:
Create not only the class hierarchy structure of the top level ontology being parsed, but also show the hierarchical relationships with classes in dependent ontologies, as Protege does. Protege shows the classes in the top level ('active') ontology in bold, with classes taken from dependent ontologies in normal print.
Create the hierarchy consistent with that shown by Protege for the same active ontology. I am assuming the hierarchy shown by Protege is correct?
I am happy to post code snippets and examples if desired, please do ask.
The Protégé hierarchy is not a plain hierarchy - Protégé does some reasoning to enrich it, at the behest of its users.
If you have code snippets you wish to refine, it would be useful to see the code, an ontology snippet and what you wish the result to look like - for example, a Protégé screenshot. Then it will be easier to refine the answer.
Related
I am trying to generate a Doxygen documentation for my Python project.
It seems like Doxygen does not provide an overall class diagram of the project including Association. It shows only inheritance for a single file.
Is there is a way I can generate an overall class diagram in doxygen?
Thanks a lot!
Doxygen does not generate class diagrams that contain "association" arrows.
These are the diagram types and my experience with them (stemming from C++):
CLASS_DIAGRAMS: Seems to be an old Doxygen option, superseded by CLASS_GRAPH, which contains more information. CLASS_DIAGRAMS often just show the class without anything else in my output, which is superfluous.
CLASS_GRAPH: This is actually an inheritance diagram, not a full class diagram (internally, it even goes by the name "inherit graph"). It doesn't show a diagram at all if a class is not a derived class or base class.
COLLABORATION_GRAPH: Shows base class, membership and template relations. Doesn't show "inherited by" or "used by" relationships. For a leaf class, the inheritance diagram (CLASS_GRAPH) is just a part of the COLLABORATION_GRAPH.
TEMPLATE_RELATIONS: Shows template relations in a similar style as inheritance, which is helpful for code using template specialization instead of inheritance, e.g. CRTP.
As you have a python project, did you try out Sphinx? sphinx.ext.inheritance_diagram comes included with the sphinx-doc distribution but also does not show other types of relations than inheritance.
A web search turned out https://pypi.org/project/sphinx-pyreverse/ which might be what you're looking for. I did not try it out myself.
Definitely not looking for anyone to do my homework, just having a little trouble understanding naming conventions in Eclipse as well as bracket placement.
I'm still getting pretty tripped up by not knowing exactly what to name my (not sure what the correct word is here) main class, the class I originally create in Eclipse after I create a Java Project and create a Package inside of my Java Project and then right-click my Package and select New/Class. Here is a link to the code and instructions the professor gave me by the way.
Right now I'm calling my "main class" Container in my Java Project/Package. I named it that because it was the first class declared in the code I have. Is this a bad idea, should I name it something else?
Also, is there anyone that can help me understand bracket placement a little better? I understand that brackets section off sections of code and that you can layer and nest sections of code within other code using brackets. What I don't get (for this current assignment especially) is how should I be nesting code inside other code using the brackets.
For instance, in the link I provided above my professor has structured the brackets so that the abstract class 'Container', as well as all the classes that extend 'Container' are completely cut-off and independent from each other as well as the rest of the code. The only part of the code which shares brackets with another is the class 'ContainerCollection' which nests the Main Method inside of it.
On all of my other assignments my code was structured so that I had a class declared at the top of my program which contained in its brackets all of the other classes, constructor, and methods including my Main Method. Here's an example
of what I'm used to seeing, structurally speaking.
Anyway, I feel like I'm missing something fundamental about how these brackets section off and nest code. For instance, I didn't think that you could have sections independent of all other sections in the code, I thought everything had to be within the brackets of the main class. I would really appreciate any insight into this at all.
Hi hi and welcome to programming :) It seems to me you have some problems understanding some fundamental stuff in coding itself. I'll try and answer some of the questions that you have outlined here (without getting too deep into the technicalities) as well as give an overview of some of the code that you've linked.
1) Naming your "Main" class.
The name of your 'main' class doesn't need to be anything special. Usually the class that holds the critical "main" method (that is, the public static void main(String[] args) { ... }) is just the class that "runs" your program. When I was doing assignments I often just named it CalculatorRunner.java or GameRunner.java or whatever.
2) Constructors, Classes, Methods, Brackets
From what I see in your questions, it seems like you also have a little trouble discerning the difference between Classes, Constructors, Methods. Do a little research and you'll learn to spot the subtle difference between the syntax and bracketing. :)
The code that your professor linked
The code that your professor linked is set out somewhat poorly. Several classes are defined in the single text file which can be confusing for a new programmer. "OMG WHY ARE THERE SO MANY CLASSES IN HERE?! WHAT'S GOING ON?!" LOL don't panic. It's probably because your professor's lazy and doesn't want to separate the classes out. It's acceptable to the Java VM but not so fun for a programmer. Spot where the classes are and put them into their own class files and things will be much clearer. The Fantasy football code is much clearer and doesn't have multiple classes embedded in one.
Anyways, the questions you've asked is pretty textbook... practice a bit more and it'll all slowly come together. Hope it helps.
I was self-studying various UML diagrams and I understood most of them except for Class Diagram and Object Diagram.
I can not get my head around how they wil be converted into code.
The trick that I learnt is this: all nouns become classes and verbs become methods of the classes.
All good till there but after that, how is the diagram converted into code?
Have a look at a diagram here that I got from the internet:
So, assuming that the language is Java, how will you code a software based on this?
A UML diagram solely describes the internal architecture of a given piece of software.
The information contained in your UML diagram is therefore:
What classes are contained
What methods and properties do they contain
How do they relate to each other
Each block with a header ("Train" for instance ) represents a class, listing its properties and methods.
As such the UML diagram does not state anything about a GUI or how the user interacts with the software. It is up to you or a UI/UX designer to create an interface you can implement, that uses the functionality outlined in this UML diagram.
You can think of a UML diagram as a description of the architecture of a piece of software, that is very shallow but is well suited for an overview of the project.
It is not a recipe.
I hope this was useful to you.
When you have a class diagram, you have a representation of the classes (and its members) that you should have in code.
So, your noun/verb analysis (what you were talking about), has already been done when you have a class diagram.
A class diagram is just a visual representation of your classes, converting them to code is just easy if you know the syntax of the language that you want to use.
Is there a tool that can generate diagrams (similar to Doxygen using Graphviz) but in the formats described by this paper: Lisp Looks Different
Program Style Distribution: Determine which programming style (Functional, OO, Imperative or Macro) dominates a software package, also to determine the size of complexity in each package.
Class Method Relation View: Visualizes the relationships between classes and methods (in Lisp, classes and methods are separated). The goal is to identify possible independent or loosely coupled components of the system.
Generic Concer View: Helps to identify and locate cross-cutting concerns associated with generic functions.
Class Type View: Helps to identify different types of classes, based on their structure, more precisely on the attributes to methods ratio.
tio
For the meaning of the colors and shapes, please refer to the document. It would be nice if there are equivalent tools for other languages as well.
Have you looked at Mondrian, which the paper cites was what was used to generate those diagrams?
More generally, have you looked at Moose, of which Mondrian is but a part?
I'm not sure I've seen one that produces diagrams exactly like those above, but there are quite a few more software visualization tools around.
Obvous first step: contact the paper's authors and ask what tools they used, and do they have any code they can share.
We seems to be abstracting a lot of logic way from web pages and creating "helper" classes. Sadly, these classes are all sounding the same, e.g
ADHelper, (Active Directory)
AuthenicationHelper,
SharePointHelper
Do other people have a large number of classes with this naming convention?
I would say that it qualifies as a code smell, but remember that a code smell doesn't necessarily spell trouble. It is something you should look into and then decide if it is okay.
Having said that I personally find that a name like that adds very little value and because it is so generic the type may easily become a bucket of non-related utility methods. I.e. a helper class may turn into a Large Class, which is one of the common code smells.
If possible I suggest finding a type name that more closely describes what the methods do. Of course this may prompt additional helper classes, but as long as their names are helpful I don't mind the numbers.
Some time ago I came across a class called XmlHelper during a code review. It had a number of methods that obviously all had to do with Xml. However, it wasn't clear from the type name what the methods had in common (aside from being Xml-related). It turned out that some of the methods were formatting Xml and others were parsing Xml. So IMO the class should have been split in two or more parts with more specific names.
As always, it depends on the context.
When you work with your own API I would definitely consider it a code smell, because FooHelper indicates that it operates on Foo, but the behavior would most likely belong directly on the Foo class.
However, when you work with existing APIs (such as types in the BCL), you can't change the implementation, so extension methods become one of the ways to address shortcomings in the original API. You could choose to names such classes FooHelper just as well as FooExtension. It's equally smelly (or not).
Depends on the actual content of the classes.
If a huge amount of actual business logic/business rules are in the helper classes, then I would say yes.
If the classes are really just helpers that can be used in other enterprise applications (re-use in the absolute sense of the word -- not copy then customize), then I would say the helpers aren't a code smell.
It is an interesting point, if a word becomes 'boilerplate' in names then its probably a bit whiffy - if not quite a real smell. Perhaps using a 'Helper' folder and then allowing it to appear in the namespace keeps its use without overusing the word?
Application.Helper.SharePoint
Application.Helper.Authentication
and so on
In many cases, I use classes ending with Helper for static classes containing extension methods. Doesn't seem smelly to me. You can't put them into a non-static class, and the class itself does not matter, so Helper is fine, I think. Users of such a class won't see the class name anyway.
The .NET Framework does this as well (for example in the LogicalTreeHelper class from WPF, which just has a few static (non-extension) methods).
Ask yourself if the code would be better if the code in your helper class would be refactored to "real" classes, i.e. objects that fit into your class hierarchy. Code has to be somewhere, and if you can't make out a class/object where it really belongs to, like simple helper functions (hence "Helper"), you should be fine.
I wouldn't say that it is a code smell. In ASP.NET MVC it is quite common.