caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* OO design
@ 2006-05-05  9:35 David Baelde
  2006-05-05 10:47 ` [Caml-list] " Gerd Stolpmann
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: David Baelde @ 2006-05-05  9:35 UTC (permalink / raw)
  To: Ocaml

Hi,

I'm no OO guru, so my question may be irrelevant, or there just might
not be an answer, which wouldn't hurt..

Let's say that I have a base class, with some kind of activation
procedure: anybody wanting to use the class must call #enter before,
and then call #leave for releasing. Internally, the methods #do_enter
and #do_leave are called respectively at the first #enter and last
#leave.

Nobody should call the #do_* directly, and I'd also like to make sure
the #enter and #leave are never overriden, since their behaviour is
important and actually much more complex than what I said.

I could just rely on the user who derives my base class, but let's see
what we can do. First the #do_* should be made private, so they can be
defined in the derived classes, but never called from the outside. To
avoid the overriding of #enter and #leave the only solution seems to
make them normal functions instead of methods. But then how could
#enter call #do_enter ? I tried to first define the class with public
#enter and make that method private in the interface, but OCaml told
me that was impossible.

I'm just curious if anybody has an opinion/idea about that.
--
David


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2006-05-11 15:49 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-05  9:35 OO design David Baelde
2006-05-05 10:47 ` [Caml-list] " Gerd Stolpmann
2006-05-05 13:00 ` Remi Vanicat
2006-05-05 19:32   ` Andrej Bauer
2006-05-08  3:17 ` Jacques Garrigue
2006-05-08 21:29   ` David Teller
2006-05-08 21:36     ` Dan Grossman
2006-05-10  2:41       ` Geoffrey Alan Washburn
2006-05-10 16:17         ` [Caml-list] " Dan Grossman
2006-05-10 18:15           ` Geoffrey Alan Washburn
2006-05-10 18:44             ` [Caml-list] " Dan Grossman
2006-05-10 18:35           ` Shawn
2006-05-10 18:47             ` Till Varoquaux
2006-05-10 19:01               ` Shawn
2006-05-10 18:43           ` brogoff
2006-05-11  0:08             ` Geoffrey Alan Washburn
2006-05-11  5:45               ` [Caml-list] " Till Varoquaux
2006-05-11  6:21               ` Jacques Garrigue
2006-05-11 15:48                 ` Geoffrey Alan Washburn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).