role pattern lib for ruby

S

shasckaw

Hello there,
Im' searching for a ruby lib that provides a role pattern framework.
Does anyone know about such a lib?

If there aren't any, I'll probably try to create my own, does anyone
have any ideas on how to proceed?

Lio
 
S

shasckaw

Thansk for the link, it looks interesting but it is perhaps too complex
for what I intend to do. But I can give it a try... well, I'd be happy
to try it but there isn't any files in the package, and project activity
is near to death. I'll try to get more info about it, but I haven't much
hope.

If anyone has another solution, please help me!

Lio
 
R

Robert Klemme

shasckaw said:
Thansk for the link, it looks interesting but it is perhaps too complex
for what I intend to do. But I can give it a try... well, I'd be happy
to try it but there isn't any files in the package, and project activity
is near to death. I'll try to get more info about it, but I haven't much
hope.

If anyone has another solution, please help me!

Depending on what you need to do it might even be built into the language
already. If you only need to add roles over time you could define some
modules for the roles and add them as needed:

irb(main):001:0> class Foo;end
=> nil
irb(main):002:0> f=Foo.new
=> #<Foo:0x1019dfe0>
irb(main):003:0> f.respond_to? :inject
=> false
irb(main):004:0> f.extend Enumerable
=> #<Foo:0x1019dfe0>
irb(main):005:0> f.respond_to? :inject
=> true

Other than that SimpleDelegator might help you as well:
http://www.rubycentral.com/book/lib_patterns.html

robert
 
S

shasckaw

Robert said:
Depending on what you need to do it might even be built into the language
already. If you only need to add roles over time you could define some
modules for the roles and add them as needed:

irb(main):001:0> class Foo;end
=> nil
irb(main):002:0> f=Foo.new
=> #<Foo:0x1019dfe0>
irb(main):003:0> f.respond_to? :inject
=> false
irb(main):004:0> f.extend Enumerable
=> #<Foo:0x1019dfe0>
irb(main):005:0> f.respond_to? :inject
=> true

Other than that SimpleDelegator might help you as well:
http://www.rubycentral.com/book/lib_patterns.html

robert
I'll try that way,
thanks for the advices,
Lio
 
S

shasckaw

shasckaw said:
Thansk for the link, it looks interesting but it is perhaps too complex
for what I intend to do. But I can give it a try... well, I'd be happy
to try it but there isn't any files in the package, and project activity
is near to death. I'll try to get more info about it, but I haven't much
hope.

Now, I know the truth, I had a bug with my archive manager that's why I
couldn't look into the package. I didn't think it could be my archive
manager because I never had such problems before. I must tell the
package is a little weird, with the extension "tgz.gz" or "tgz.tar".
Well, no matter all this, now I can use it and that's a good new. BTW
the develloper of robjectteams told me he doesn't use the CVS, so it's
normal that it is empty.

Lio
 
P

Pit Capitain

Sam Roberts wrote about Object Teams:
Is there a description of it somewhere?
(...)
Can anybody help me out?

On the Ruby Object Teams page on sourceforge there's a link called "Home Page",
which leads you to http://objectteams.org

My first impression is that Object Teams is a very useful paradigm. It "allows
the programmer to encapsulate the interaction of a set of objects (roles) into a
compound object (the team)". I've never been convinced to really start using
AOP, but I'll definitely give the Object Teams concept a try.

Regards,
Pit
 
P

Pit Capitain

Pit said:
Sam Roberts wrote about Object Teams:


(... Object Teams stuff ...)

Sorry, I didn't notice you were talking about Aspect Oriented Programming in
general. Ignore my previous post for the moment, but look at it again when you
come to a point where you say "well, AOP is nice, but how can I use it?"

Object Teams, which I was talking about, uses AOP under the hood to offer a very
nice way to build components out of objects that don't have to know each other.

Regards,
Pit
 
S

shasckaw

Hello!

Pit said:
Pit Capitain wrote:

Sorry, I didn't notice you were talking about Aspect Oriented
Programming in general. Ignore my previous post for the moment, but look
at it again when you come to a point where you say "well, AOP is nice,
but how can I use it?"
We were talking about AOP? No, it seems you made a mistake somewhere, we
weren't talking about that, I just wanted some lights about role
pattern. And someone pointed out that I could use an AOP framework for
ruby and designed with roles.
In fact, I'm already at the point "how can I use it?". I don't even
bother to read exhaustively the ObjectTeams site, it's too academic for
me: most docs are in fact german academic thesis.
Object Teams, which I was talking about, uses AOP under the hood to
offer a very nice way to build components out of objects that don't have
to know each other.
I will give it a try. I don't want to do something complex, I'll
probably use only few features of robjetcteams. If robjectteams is too
complex for me to understand, I'll seek another way (perhaps delegation
will be enough?). Nevertheless I think robjectteams is worth the
experience (and a shorter name ;) ).

Lio
 
T

T. Onoma

I think I can give a reasonable overall picture of AOP.

Think about it from a top-down view-point, as a form of weaving code together,
as opposed to the traditional manner of building one block on top of another.
So lets say you want to monitor employees. So you create a model of an
employee, then you create a logging mechinism, and say a visualizer. AOP
allows you to weave these components together describing how they interact,
without requiring you to specifically modify any of the code within them.
Traditionally you would have built the logging mechinism on top of, or
integrated into, the employee model, and likewise with the visualizer. AOP
allows you to have much cleaner Seperations Of Concerns --and that's the real
point of AOP.

So an *aspect* then, is one of these concerns, and is said to be orthogonal to
the other concerns. The weaving is accompished by describing where code is to
be "interwoven" into other code. The code that gets "inserted" is called
*advice* (in practice it is defined much like one does a method). This is
accomplished by selecting join-points. *Join-points* are specific places in
code that can have other advice code inserted into it, and are selectable by
some descriptive syntax. This syntax will select a set of joint-points; a set
of join-points so selected is reffered to as a *point-cut*.

HTH,
T.
 
A

Ara.T.Howard

Date: Thu, 5 Feb 2004 11:16:42 +0900
From: T. Onoma <[email protected]>
Newsgroups: comp.lang.ruby
Subject: Re: what is aspect-oriented s/w? (was Re: role pattern lib for
ru by)

I think I can give a reasonable overall picture of AOP.

Think about it from a top-down view-point, as a form of weaving code
together, as opposed to the traditional manner of building one block on top
of another. So lets say you want to monitor employees. So you create a
model of an employee, then you create a logging mechinism, and say a
visualizer. AOP allows you to weave these components together describing how
they interact, without requiring you to specifically modify any of the code
within them. Traditionally you would have built the logging mechinism on
top of, or integrated into, the employee model, and likewise with the
visualizer. AOP allows you to have much cleaner Seperations Of Concerns
--and that's the real point of AOP.

So an *aspect* then, is one of these concerns, and is said to be orthogonal
to the other concerns. The weaving is accompished by describing where code
is to be "interwoven" into other code. The code that gets "inserted" is
called *advice* (in practice it is defined much like one does a method).
This is accomplished by selecting join-points. *Join-points* are specific
places in code that can have other advice code inserted into it, and are
selectable by some descriptive syntax. This syntax will select a set of
joint-points; a set of join-points so selected is reffered to as a
*point-cut*.

HTH,
T.

thanks for that - interesting.

-a
--

ATTN: please update your address books with address below!

===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| STP :: http://www.ngdc.noaa.gov/stp/
| NGDC :: http://www.ngdc.noaa.gov/
| NESDIS :: http://www.nesdis.noaa.gov/
| NOAA :: http://www.noaa.gov/
| US DOC :: http://www.commerce.gov/
|
| The difference between art and science is that science is what we
| understand well enough to explain to a computer.
| Art is everything else.
| -- Donald Knuth, "Discover"
|
| /bin/sh -c 'for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done'
===============================================================================
 
S

shasckaw

T. Onoma said:
I think I can give a reasonable overall picture of AOP.

[short AOP description]
HTH,
T.

I have already tried to understand AOP. The stuff I've already read
about it explained aproximatively the same things as you did. But I must
tell it doesn't help me much to understand. Those concepts Join-Points,
Point-Cuts, advices, aspect and concerns are too blurred for me.

Someone has already proposed AOP for python and Guido Van Rossum himself
said him it was not its intention to do that as it is possible to do AOP
with the use of meta-classes.

Then I suppose it is possible to do that in ruby either. If some fair
people could give some simple examples of practical AOP in ruby, it
would probably help everybody to grasp the concepts.

Meanwhile I'll try to get something from robjectteams. :)

Cheers,
Lio
 
A

Alfio Astanti

shasckaw said:
Hello there,
Im' searching for a ruby lib that provides a role pattern framework.
Does anyone know about such a lib?

Is there a "role pattern" definition somewhere? Is it a design
pattern? Or an analysis pattern? Or ...

Just curious.

AA
 
S

shasckaw

Alfio said:
Thanks a lot!! I have searched c2 indeed, but for some obscure reasons
I skip that specific page ... :)

AA
What is explained on that page is rather different from the academic
papers I've found all over the web about role pattern.
For example, robjectteams which is in fact a kind of role designing
framework doesn't work with the same axioms. BTW robjectteams is really
simple to understand, I really advice anybody to read its samples. Here
is the site if you want more info:
http://sourceforge.net/projects/robjectteam/

Cheers,
Lio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top