RE: UML for a Role

[email protected] (Jeff Hallock)
Newsgroups perl.moose
Message-ID <5995603F96DF2B4E80C77ED3E77AE2D05FDD546D@CH1PRD0811MB408.namprd08.prod.outlook.com>
Well, there are traits –  which if you are not familiar, is just a role than can be applied to an instance instead of a class.

And then you still have your abstract classes. I don’t use them that often myself, but sometimes it is appropriate to use instead of a role.

Here as an example of how I use all three, extrapolated from a real project.

Let’s say you have a GUI app with multiple “browsers”. An employee browser, a schedule browser, and a project browser – I would create the following classes and roles.

App::Browser – Abstract browser class – all browsers descend from this class, set up initialization necessary for all browsers

Our browser classes
App::EmployeeBrowser
App::ScheduleBrowser
App::ProjectBrowsser

And then some roles to be used with our browsers – each browser class can pick and choose which ones to use. These roles don’t necessarily need to applied to a browser even. Maybe they work with  App::Window too. That’s what I think about when deciding between an abstract class and  role.

App::Role::HasToolbar
App::Role::HasStatusBar
App::Role::HasListView
App::Role::HasIconView
App::Role::HasCrudButtons


And maybe we could add some traits that can be applied:

App::Trait::ExitOnDelete – This trait could be applied to any App::Browser or App::Window to tell the application to exit if the window is closed
App::Trait::UpdateOnShow – This trait could tell the browser refresh itself when it is displayed on the screen



Hopefully this gave you some helpful insight. This is just my approach and I’m sure others have different qualifications for what should be a Role and what should be an Abstract class.



-          Jeffrey


P.S. For anyone who is reading this and is curious about my referencing GUI programming with Moose objects, I recommend checking out my module Gapp (http://search.cpan.org/~jhallock/Gapp/) which is Moose layer over Gtk2.  It allows for adding roles and traits to GUI objects among other things and overall makes Gtk+ programming in perl feel more perlish. I have had plans to announce it’s existence to this list soon, but I figured it was appropriate to plug here because of the examples I provided.






From: [email protected] [mailto:[email protected]]
Sent: Thursday, January 10, 2013 1:32 PM
To: [email protected]
Subject: RE: UML for a Role


Thanks Jeff.

Besides a Role does Moose have other thing near an abstract class? (I know roles are not abstract classes)
I'm writing a doc about rational methodology and Moose, that is why I'm asking.

[Inactive hide details for Jeff Hallock ---10/01/2013 16:00:25---I represent it using  an interface. -----Original Message-----]Jeff Hallock ---10/01/2013 16:00:25---I represent it using  an interface. -----Original Message-----

De: Jeff Hallock <[email protected]<mailto:[email protected]>>
Para: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>, "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
Data: 10/01/2013 16:00
Assunto: RE: UML for a Role

________________________________



I represent it using  an interface.

-----Original Message-----
From: [email protected]<mailto:[email protected]> [mailto:[email protected]]
Sent: Thursday, January 10, 2013 12:50 PM
To: [email protected]<mailto:[email protected]>
Subject: UML for a Role


Hi there.
I'm new at [email protected]<mailto:[email protected]> and just like to know how you use to represent a Moose::Role in a UML diagram? Just like an ordinary class and <<type>>?
________________________________________
Thiago Glauco Sanchez
Tec. Telecom. Pl. - Petrobras SA
ITIL, MCSO, ECS ( Routing, Wireless, Switching )
tel: 55 11 3523-9756
rota: http://ltp.petrobras.com.br

"Blaming the network is easy. The network touches everything. Businesses assume that the network will work perfectly and make decisions accordingly.
A user can’t open that 900MB Excel spreadsheet on the file server on another continent from his 20th-century PC? Network problem. A website in Farawayistan is slow? Network problem. A user can’t get a faster response over a 33.6Kbps modem? Network problem."
"O emitente desta mensagem é responsável por seu conteúdo e endereçamento. Cabe ao destinatário cuidar quanto ao tratamento adequado. Sem a devida autorização, a divulgação, a reprodução, a distribuição ou qualquer outra ação em desconformidade com as normas internas do Sistema Petrobras são proibidas e passíveis de sanção disciplinar, cível e criminal."

"The sender of this message is responsible for its content and addressing. The receiver shall take proper care of it. Without due authorization, the publication, reproduction, distribution or the performance of  any other action not conforming to Petrobras System internal policies and procedures is forbidden and liable to disciplinary, civil or criminal sanctions."

"El emisor de este mensaje es responsable por su contenido y direccionamiento. Cabe al destinatario darle el tratamiento adecuado. Sin la debida autorización, su divulgación, reproducción, distribución o cualquier otra acción no conforme a las normas internas del Sistema Petrobras están prohibidas y serán pasibles de sanción disciplinaria, civil y penal."


"O emitente desta mensagem é responsável por seu conteúdo e endereçamento. Cabe ao destinatário cuidar quanto ao tratamento adequado. Sem a devida autorização, a divulgação, a reprodução, a distribuição ou qualquer outra ação em desconformidade com as normas internas do Sistema Petrobras são proibidas e passíveis de sanção disciplinar, cível e criminal."

"The sender of this message is responsible for its content and addressing. The receiver shall take proper care of it. Without due authorization, the publication, reproduction, distribution or the performance of any other action not conforming to Petrobras System internal policies and procedures is forbidden and liable to disciplinary, civil or criminal sanctions."

"El emisor de este mensaje es responsable por su contenido y direccionamiento. Cabe al destinatario darle el tratamiento adecuado. Sin la debida autorización, su divulgación, reproducción, distribución o cualquier otra acción no conforme a las normas internas del Sistema Petrobras están prohibidas y serán pasibles de sanción disciplinaria, civil y penal."
image001.gif (image/gif, 105 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.