Re: Class design question



In article <1146045782.921174.194370@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"sundeep" <sundeeps@xxxxxxxxx> wrote:

Hi,

Let me first describe the requirement. I have to design a small system
that should be able to manage websites on a hosting environments. The
tasks that i need to do are
- CreateWebSIte
- DeleteWebSite
- ModifyWebSite
- ChangeIPAdress

Now, I have two options to design the Biz functionlity.

You have a lot more than the two options you specified...

What i want to know is the difference in two options i mentioned,
merits and demerits, recomended approach as per OO design principles.

An ideal OO program works like a termite colony where each object is
like a termite. No object is ever told what to do, they just react to
their environment. That's not to say that it's wrong to demand objects
enter certain states, just know that it's not "OO" to do so (IE your
working in the procedural realm at that point.)

Now there are two ways of setting up such a system. One is to simply
notify objects when a change in their environment occurs and let them
inspect the environment and decide what to do about it. This method is
characterized by very few "mutator" methods and lots of "getter"
methods. For example, when a new IP address has been entered by the
user, the WebSite object is given a "environChanged" message, the
WebSite object at this point should already have a reference to its
environment, so it would ask the appropriate environment what the new IP
address is and change itself.

The second method is to inform objects directly what has changed, this
is characterized by lots of mutator methods and few getter methods. An
example here would be sending a "newIPAddressAvailable" message with the
new IP address attached. The WebSite object can then choose to accept
the new address or not at its will.

In either case, the mutator methods are requests or notifications, *not*
demands. Your not telling the WebSite object to change its IP address,
you are simply letting it know it can if it wants to.


As far as your specified options. The second one looks like a Command
pattern. I wouldn't use it unless I needed to be able to back out a
series of requests, or needed to queue up requests to be executed later,
or send requests over a network, or log a series of requests that would
need to be resent later. In C++ such a system is also used to create
callbacks (called "functors" among C++ people.) Other languages usually
have some sort of method/block/lambda object and therefore don't need
functors.

The reason I wouldn't use it unless I had to, is because it's much more
complex than simply sending requests to objects.
.



Relevant Pages

  • Re: Deep Freeze
    ... environment and it offers some unique capabilities. ... Audit your website security with Acunetix Web Vulnerability Scanner: ... Cross site scripting and other web attacks before hackers do! ...
    (Pen-Test)
  • Re: CSS drop-down menus
    ... poor design of the website in the first place. ... An Apple one eh! ... OSs we are talking a very controlled environment. ... In the case of the dropdowns put in by a website ...
    (comp.infosystems.www.authoring.stylesheets)
  • RE: Active Directory user enumeration
    ... > environment and I could not find a way to anonymously ... Audit your website security with Acunetix Web Vulnerability Scanner: ... Cross site scripting and other web attacks before hackers do! ...
    (Pen-Test)
  • Re: Hello Again , ABPO ?
    ... I do not think any website is going to be the same as USENET. ... order than is possible in the wild wild west. ... being able to maintain a record of culture practices and results would ... allow us to learn what works best in a given environment. ...
    (rec.gardens.orchids)
  • Re: should space shuttle be cancelled?
    ... So it was the environment of the cold ocean is ... And had an aircraft wing suffered the same damage, ... solved in the design. ... NASA is just being crazy. ...
    (sci.space.policy)