PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Friend functions or classes
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Friend functions or classes

Réponse
 
LinkBack Outils de la discussion
Vieux 02/12/2007, 10h02   #1
SunRaySon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Friend functions or classes

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

Hi,

I would like to simulate something like friend class or method in Ruby; From
the pickaxe documentation I could not figure out if there is one directly
available or not.

I do understand that having friend classes and functions is not good
practice.

Regards,
Kiran.

  Réponse avec citation
Vieux 02/12/2007, 17h32   #2
Dejan Dimic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Friend functions or classes

On Dec 2, 11:02 am, SunRaySon <sunray...@gmail.com> wrote:
> Note: parts of this message were removed by the gateway to make it a legal Usenet post.
>
> Hi,
>
> I would like to simulate something like friend class or method in Ruby; From
> the pickaxe documentation I could not figure out if there is one directly
> available or not.
>
> I do understand that having friend classes and functions is not good
> practice.
>
> Regards,
> Kiran.


Friend Functions and Friend Classes are often useful for one class to
see the private variables of another class, even though these
variables should probably not be made part of the public interface
that the class supports.

Friend function or friend classes are one of most dangerous
construction. From my experience mostly because programmers tend to
misuse it. I do not want to make this an academic issue so to make
this short: my advice is do not use friend class as a construction in
you code especially if you try to port some C++ algorithm even if that
seams to look like an easy thing to do.

Depending on particular reason, why do you think you have to use the
friend class, I will most probably consider using observer and/or
visitor pattern in stand.
  Réponse avec citation
Vieux 02/12/2007, 17h49   #3
Steckly, Ron
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Scripting Outlook

Hi All,

I'm new to Ruby and I'm trying to script Microsoft Outlook to save
attachments that exceed half a megabyte. I am using WIN32OLE, and
trying to reference Outlook as a COM object. I also downloaded the OLE
browser and am examining the different things I can call. My really
rough, and inexperienced code,=20
is:
require 'win32ole'

outlook=3DWIN32OLE.new('Outlook.Application')

mapi =3Doutlook.GetNameSpace('MAPI')

inbox=3Dmapi.GetDefaultFolder(6)

indox.Items.each do |message|
if message.Attachment.Size > 500,000
message.Attachment.SaveAsFile('path to
remote drive')
end

Any thoughts on this?

Ron

-----Original Message-----
From: Dejan Dimic [mailto:dejan.dimic@gmail.com]=20
Sent: Sunday, December 02, 2007 12:35 PM
To: ruby-talk ML
Subject: Re: Friend functions or classes

On Dec 2, 11:02 am, SunRaySon <sunray...@gmail.com> wrote:
> Note: parts of this message were removed by the gateway to make it a

legal Usenet post.
>
> Hi,
>
> I would like to simulate something like friend class or method in

Ruby; From
> the pickaxe documentation I could not figure out if there is one

directly
> available or not.
>
> I do understand that having friend classes and functions is not good
> practice.
>
> Regards,
> Kiran.


Friend Functions and Friend Classes are often useful for one class to
see the private variables of another class, even though these
variables should probably not be made part of the public interface
that the class supports.

Friend function or friend classes are one of most dangerous
construction. From my experience mostly because programmers tend to
misuse it. I do not want to make this an academic issue so to make
this short: my advice is do not use friend class as a construction in
you code especially if you try to port some C++ algorithm even if that
seams to look like an easy thing to do.

Depending on particular reason, why do you think you have to use the
friend class, I will most probably consider using observer and/or
visitor pattern in stand.


  Réponse avec citation
Vieux 03/12/2007, 05h01   #4
SunRaySon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Friend functions or classes

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

Thanks Dejan. I will try it out.

Kiran.


On Dec 2, 2007 11:05 PM, Dejan Dimic <dejan.dimic@gmail.com> wrote:

> On Dec 2, 11:02 am, SunRaySon <sunray...@gmail.com> wrote:
> > Note: parts of this message were removed by the gateway to make it a

> legal Usenet post.
> >
> > Hi,
> >
> > I would like to simulate something like friend class or method in Ruby;

> From
> > the pickaxe documentation I could not figure out if there is one

> directly
> > available or not.
> >
> > I do understand that having friend classes and functions is not good
> > practice.
> >
> > Regards,
> > Kiran.

>
> Friend Functions and Friend Classes are often useful for one class to
> see the private variables of another class, even though these
> variables should probably not be made part of the public interface
> that the class supports.
>
> Friend function or friend classes are one of most dangerous
> construction. From my experience mostly because programmers tend to
> misuse it. I do not want to make this an academic issue so to make
> this short: my advice is do not use friend class as a construction in
> you code especially if you try to port some C++ algorithm even if that
> seams to look like an easy thing to do.
>
> Depending on particular reason, why do you think you have to use the
> friend class, I will most probably consider using observer and/or
> visitor pattern in stand.
>
>


  Réponse avec citation
Vieux 03/12/2007, 14h56   #5
Ilan Berci
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Friend functions or classes


>
> Depending on particular reason, why do you think you have to use the
> friend class, I will most probably consider using observer and/or
> visitor pattern in stand.


irb(main):001:0> class Foo
irb(main):002:1> private
irb(main):003:1> def cant_see_me
irb(main):004:2> "ouch! found me"
irb(main):005:2> end
irb(main):006:1> end
=> nil
irb(main):007:0> Foo.new.send('cant_see_me')
=> "ouch! found me"

Walking down this path leads to the dark side, the power of the dark
side is strong, you will have powers beyond your wildest imagination.
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h27.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14877 seconds with 13 queries