Re: Constructor as a "Reset" Button



Sanders Kaufman wrote:
Michael Fesser wrote:
.oO(Sanders Kaufman)

That's ONE use for the constructor.

It's the only use. As it's name suggests - it's used to create an object
(and a destructor is called while cleaning up, respectively). In PHP the
constructor is more or less just for initialization, in other languages
it's also used to allocate memory for the new object.

That was funny.
It took just two sentences for you to contradict yourself.


There was no contradiction in what he said.

You're somewhat correct when you say that it's "more or less just for initialization". It is indeed useful for MORE than just initializing the object. In fact, it's also pretty good at re-initializing the object.


As he said - it is the ONLY use.


If clsGrandKid has a constructor, then clsKid's and clsMama's constructors don't get called - not until I manually call them from within clsGrandKid.

In PHP, yes. But this doesn't mean that you're supposed to call the
parent constructor multiple times or not at all! In PHP you might get
the result you expect, other compilers might kill you for doing that.

Yeah - that's why I said in my OP that I'm not concerned, in this particular case, with how "good" programmers do it. I just need to know if, in doing so, I'm exposing myself to a threat from something like Zombie processes.


It's how ANY programmer should be doing it.

When you use a system function incorrectly, you run into all kinds of potential problems.


It's a
quite useful pattern for database objects or - as in my framwork - for
having a global application object. Firstly, it would be fatal if there
would be a second one, secondly, using the Singleton pattern allows
kinda "superglobal" access to the application object from everywhere.

One of my core design principles at this stage is to avoid having a global application object. This foundation/framework that I'm building is to be used to *create* such objects... but not to be one in and of itself. Also, I maximize its value if I can keep the features atomic enough to be implemented independent of the framework as a whole.


There is nothing wrong with a global application object. It's not the same as global variables. Singletons are quite common for things like this.

So building it around a global application object would be a mistake for this particular project.


Or not building it around a global application object could be a mistake. It depends on what you're doing.

I am, however, simultaneously developing a reference model for this foundation/framework and it IS a global application object.

btw - this project I'm working on is a HIPPA thing. If any of you guys out there are looking for work - go to the local hospital's IT department. There's some HUGE ka-ching out there!

But don't do it in Dallas. This is MY turf. ;)

And you have to be HIPPA certified to do it. And HIPPA certification is not easy - nor is it cheap.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: Constructor as a "Reset" Button
    ... constructor is more or less just for initialization, ... You're somewhat correct when you say that it's "more or less just for initialization". ... In PHP you might get ... I am, however, simultaneously developing a reference model for this foundation/framework and it IS a global application object. ...
    (comp.lang.php)
  • Re: Constructor as a "Reset" Button
    ... In PHP the ... constructor is more or less just for initialization, in other languages ...
    (comp.lang.php)
  • Re: Message Builder vs. a Build Method?
    ... Builder class would encapsulate all the complex algorithms for making ... OTOH, as Daniel T. suggests, sometimes the initialization requires unique processing for initialization that is clearly intrinsic to the object itself. ... Constructors tend to be fragile and it is difficult to manage errors when they occur in a constructor scope, so it is usually a good idea to keep the processing in constructors as simple as possible. ... When the initialization of attribute data requires complex processing AND it seems like is intrinsic ot the object, that justifies having a separate initialization method that is invoked immediately after the constructor. ...
    (comp.object)
  • Re: Localization Service
    ... these assets are contents to be edited by the users. ... problem with a validatorFactory. ... I was filling the dictionary on the constructor. ... beware of too much deferred initialization. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: simple question
    ... I mean it will be just the same if I remove the c-tor and change this row ... member field initializers are in fact handled differently from initialization in the constructor. ... Rather, a more explicit initialization is constructed from your declarations, that looks something like the following. ...
    (microsoft.public.dotnet.languages.csharp)