Here is classical object model:
class ViewBase
{
void DoSomethingForView() { } //May be virtual
}
class View1 : ViewBase //(derived class from ViewBase)
{
void DoSomethingForView() { }
void DoSomethingForView1Special() { }
}
class View2: ViewBase //(another derived class from ViewBase)
{
void DoSomethingForView2Special() { }
}
class Application
{
void Print() { }
void DoSomething() { }
//Do some magic to create a view object (View1 or View2) and return
//Something which I don't know to describe. Its like dynamically
//returning object of View1 or View2 at runtime
}
I want to convert this to Perl Moose class model.
So that,
I will call the view methods like
void Main()
{
App = new Application();
App->View1->DoSomethingForView();
App->View1->DoSomethingForView1Special();
App->View2->DoSomethingForView();
App->View2->DoSomethingForView2Special();
}
I will not know which View to be called. But at runtime, View1/View2 instance must be created & DoSomethingForView() must be called.
The above code is not exactly Perl. How to translate & achieve this in Perl.
An Application object shall have View object, but we will not know the type of the view at compile time. We have a test application, development in Perl.
You can imagine Application is a GUI application, and View is what you are seeing in the application window. User can select any view.
I am sorry about my English. Please let me know If I need to provide more text.