Can someone give me an example of an example of a class hierarchy relevant to computer science? - class-design

Can someone give me an example of an example of a class hierarchy relevant to computer science?
In my lectures I've seen some simple examples like:
Vehicle
Construction
Heavy
Machinery
Crane
Grader
Back-hoe
Haulage
Semi-trailer
Flatbed
Passenger
Commercial
Bus
Fire-truck
Limousine
Police-motorcycle
Personal
Car
SUV
Motorcycle

Here's a class hierarchy from a content management system I work on:
Node
User
Active Directory User
Database User
Folder
Site
Template Gallery
Image Gallery
Template
Page
File

A decent example from the .NET world (and I believe Java has something very similar) might be:
Exception
ArgumentException
ArgumentNullException
ArgumentOutOfRangeException
ArithmeticException
DivideByZeroException
NotFiniteNumberException
OverflowException
IOException
DirectoryNotFoundException
FileNotFoundException
PathTooLongException
...etc., etc.
(The hierarchy is actually much bigger than that; those are just some popular examples.)

Related

Unity3D trying to understand Monoscript

I am trying to understand what does Monoscript do, according to Unity tutorial
It is important to understand that a MonoBehaviour has a reference to
a MonoScript, and MonoScripts simply contain the information needed to
locate a specific script class. Neither type of Object contains the
executable code of script class.
A MonoScript contains three strings: an assembly name, a class name,
and a namespace.
Does that mean, during build, for example, every c# classes inherited from MonoBehaviour will have a MonoScript pointing to a corresponding position in Assembly-CSharp.dll ?
It appears so. Note that it applies to ScriptableObjects as well: https://docs.unity3d.com/ScriptReference/MonoScript.html?_ga=2.112551556.1460905390.1600095105-379318471.1582836001
Remember there are some other assemblies than just the one you mentioned, for example the "first pass" and "Editor" varieties. Also from Unity's documentation:
"A MonoBehaviour provides a wrapper that links to a MonoScript. A MonoScript is an internal data type that Unity uses to hold a reference to a specific scripting class within a specific assembly and namespace. The MonoScript does not contain any actual executable code."
This sounds very much like what you said. This excerpt may be found here: https://learn.unity.com/tutorial/assets-resources-and-assetbundles#5c7f8528edbc2a002053b5a6. You likely will need an account to access it.

Understanding the output of ClearNLP

I am using ClearNLP as a semantic labeler but I have some questions:
Can I change the output to a tree view that shows the semantic dependencies?
What does Sheads="2:A0=PAG" mean? I could not understand the semantic output in a sentence such: I have a new employee. He has studied computer science and has developed a lot of programs; he is qualified to be manager. add him in the appropriate table.
You can copy the output of the clearnlp suite and paste it in this online visualization tool that will draw it: http://www.mathcs.emory.edu/~choi/clearnlp/demo/demo.html
About your second question, A0 refers to the first slot in the SRL of the verb.

Scalatra file organisation

How should I manage my files in Scalatra . After encountering the following error my fundamental understanding of "code separation" in Scala has been destroyed .
Working in Scalatra I defined an class in one file and received an in an error after attempting to define a class with the same name in another file . I was somewhat confused about the error because I was working under the impression that there was some degree of isolation afforded to each file ( Node JS inspired assumption).
I cam currently working on an application that requires : Actors, Routes, Classes, etc . How should I organize these things ?
Classes of the same name need to be in different packages. You can use imports to avoid having to type the full path (packagename.ClassName), but if you don't create separate packages there is no way to unambiguously refer to the class you mean. That quickly grows unworkable in code bases of more than moderate size.
So, no, separate files are not enough.

Converting UML class diagram to C++ code(VS 2012)

I am using VS2012 for a course project that we started from scratch, We are to use C++ to create something like this (I think the aggregation part is reversed):
https://www.dropbox.com/s/w2zh7yltbups6cm/class.png
Well , we had that on paper , wrote the code for each class with no problems, except we can't test because each class depends on another that was not finished at the time.
Long story short : each class has its own untested code and VS does not detect any errors whatsoever and based on our previous experience we know that the code is correct, no syntax errors anyway.
When I start compiling some 500 errors come out of nowhere , some of them it says in "time.h" , I thought it was something wrong with the compiler , tried switching to C::B and see if it work but i needed a different compiler and I don't have the time to download any large files ,seriously , deadline in 2 days and internet speed sucks.
doing some research here (and googling around) I narrowed it down to cyclic dependencies and I learned that I can draw the diagram in VS and get code files , unfortunately it does it in C# while I have a C++ code (it has to be C++) .
How can I realize this diagram in C++ ? Which class should include which headers ?
How can I avoid this in the future ?
EDIT:
Solved it by removing all dependencies and disabling pre-compiled headers (Don't really know if I had to) , then I included each .h in its corresponding .cpp , then I included in each .h every header it needs to use.
All that did not really solve my problem , it was the declarations !!!
I did #ifndef myclass , #define myclass to each header and declared the used classes , I think it's what's called "Forward Declaration" (correct me if I'm wrong)
Anyway it finally compiled and I will start testing .
If you have any remarks then by all means , you can add them.
Cyclic "dependency" can be. Why not? Because they are not dependencies, but associations with visible navigability. But you have some problems here.
Reservation should better have navigation to Member. Backward it could be, too. But Reservation should have Member instance as attribute. It is more simple way.
Also Rental is a class representation of association between DVD and Customer. And should have their instances as attributes. Again, back navigation IS possible, but do you need it? Maybe.
Another problem:
Title-DVD aggregation has correct direction, but it should be Composite, for there are no DVD without Title.
Testing: You can do unit tests, isolating classes from other ones by mocking first. After debugging that start to replace mocks with real classes. After that try unit tests without mocking, then normal auto tests, with automatic input/output/comparing.
As for code engineering, download VP UML enterprise "for testing version" and/or Enterprise Architect of Sparx, eval professional version. They both can do code engineering in C++.

Silverlight 4, MEF, Export/Import errors, Mefx doesn't want to work

Out of frustration and more than 3 days googling up this issue... i have no choice but to bother you guys with my question.
i am creating a Silverlight application. I am using MEF. When i try to run my application i get the following error.
The invocation of the constructor on
type
'IFG.Silverlight.Client.Views.MenuView'
that matches the specified binding
constraints threw an exception. [Line:
25 Position: 47]
and its Inner exception is as follow...
The composition remains unchanged. The
changes were rejected because of the
following error(s): The composition
produced a single composition error.
The root cause is provided below.
Review the CompositionException.Errors
property for more detailed
information.
1) No valid exports were found that
match the constraint
'((exportDefinition.ContractName ==
"MenuViewModel") AndAlso
(exportDefinition.Metadata.ContainsKey("ExportTypeIdentity")
AndAlso
"IFG.Silverlight.Client.ViewModel.MenuViewModel".Equals(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))',
invalid exports may have been
rejected.
Resulting in: Cannot set import
'IFG.Silverlight.Client.Views.MenuView.ViewModel
(ContractName="MenuViewModel")' on
part
'IFG.Silverlight.Client.Views.MenuView'.
Element:
IFG.Silverlight.Client.Views.MenuView.ViewModel
(ContractName="MenuViewModel") -->
IFG.Silverlight.Client.Views.MenuView
Ok. my code is very simple since it's a test application.
i have an Interface IRetailModel
namespace IFG.Silverlight.Client.Common
{
public interface IRetailModel
{ ............
then i have a class that implements this interface
namespace IFG.Silverlight.Client.Model
{
[Export(typeof(IRetailModel))]
public class RetailModel : IRetailModel
{ .................
Then I have my ViewModel for the View
namespace IFG.Silverlight.Client.ViewModel
{
[PartCreationPolicy(CreationPolicy.NonShared)]
[Export(ViewModelTypes.MenuViewModel)]
public class MenuViewModel : IFGViewModelBase
{
IRetailModel _model;
[ImportingConstructor]
public MenuViewModel(IRetailModel model)
{
Well, i found that there is a magical tool called MefX that it's supposed to debug deep to the bone your code and tells you what's going on... I havent been able to get this to work.
I followed directions from this article http://blogs.msdn.com/b/nblumhardt/archive/2009/09/24/debug-composition-from-within-visual-studio.aspx
When i try to run it says
Error: Unable to load one or more of
the requested types. Retrieve the
LoaderExceptions property for more
information.
Then went back to Google and i found this Visual MefX (which is the same but with a GUI) and i can load the .xap but basically it gives me the same info that i get from Visual Studio. I can't find the darn [BECAUSE]...
I am really, HONESTLY AND DEEPLY, frustrated with this situation. Can anyone explain to me where am i failing to get MefX to do its job? I know the risk of dealing with these Overnight Frameworks (lack of documentation, buggy, etc etc) that MEF seems to be, but Prism is not a option to me (i feel like buying a M16 to kill a fly when i can use my finger).
Thank you
For future reference, an updated version of Visual Mefx is attached to this blog post: How to Debug and Diagnose MEF Failures. It is also part of MEFContrib, although I'm not sure if the MEFContrib version has all the changes from the version in the blog post.