Re: How much oop is too much oop?
- From: "Eugene Gershnik" <gershnik@xxxxxxxxxxx>
- Date: Tue, 26 Apr 2005 13:41:37 -0700
Doug Harrison [MVP] wrote:
> That's kinda what I was getting at. :) When I think "invalid" in this
> context, I envision something like:
>
> struct X
> {
> int m_x;
> };
>
> X x;
> // Here, x is invalid, uninitialized, or whatever you want to call it.
[...]
> CWnd is not like X. Rather, its ctor puts it into a good state,
> albeit one with very limited capabilities. In particular, it passes
> the AssertValid test.
Not at all. Object x has a perfectly well defined state in which the only
method you can call on it is the destructor or assignment to field m_x. It
is no different from an "unhooked" CWnd were there are some mthods you can
call and some that you cannot. Both cases are evil. When an object has
multiple states one should either use some variation of state pattern or
decompose it in two (or more) classes.
> I'm not sure exactly what a two-class approach buys you over a single
> class with two-phase construction.
1) RAII
2) No special/singular/invalid ( pick your term ;-) ) states
--
Eugene
http://www.gershnik.com
.
- Follow-Ups:
- Re: How much oop is too much oop?
- From: Doug Harrison [MVP]
- Re: How much oop is too much oop?
- References:
- How much oop is too much oop?
- From: ben
- Re: How much oop is too much oop?
- From: David Webber
- Re: How much oop is too much oop?
- From: Eugene Gershnik
- Re: How much oop is too much oop?
- From: David Webber
- Re: How much oop is too much oop?
- From: Eugene Gershnik
- Re: How much oop is too much oop?
- From: David Webber
- Re: How much oop is too much oop?
- From: Eugene Gershnik
- Re: How much oop is too much oop?
- From: David Webber
- Re: How much oop is too much oop?
- From: Doug Harrison [MVP]
- Re: How much oop is too much oop?
- From: Eugene Gershnik
- Re: How much oop is too much oop?
- From: Doug Harrison [MVP]
- How much oop is too much oop?
- Prev by Date: Re: What is a union?
- Next by Date: Re: Is CALLBACK or WINAPI is necessary?
- Previous by thread: Re: How much oop is too much oop?
- Next by thread: Re: How much oop is too much oop?
- Index(es):
Relevant Pages
|