Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Class and Instance Logic
Message
De
02/08/2001 07:36:36
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00538248
Message ID:
00538744
Vues:
12
>>Is the following an example of a sound practice, or is there a better approach?
>>
>>Command button class named: cmd_ClassNew
>>
>>First instance: ThisForm.PageFrame.Page1.cmd_New1
>>Second instance: ThisForm.PageFrame.Page2.cmd_New2
>>
>>In cmd_ClassNew.Click there is code to run ThisForm.AddProc().
>>
>>In both cmd_New1.Click and cmd_New2.Click is code to store the current view as ThisForm.CurrentView. Then I issue DoDefault() and perform things like PageFrame.ActivePage and Object.SetFocus relevant to the particular instance.
>>
>>The ThisForm.AddProc() method contains code to add a new record based on the ThisForm.CurrentView. I use a case statement to handle the logic.
>>
>>Any opinions? I apply this logic to other objects as well, but command buttons were the easiest to describe. Seems I've read somewhere that objects should only know about themselves (or something like that) and wondered what the best way to handle class/instance logic was. Just trying to make sure I'm doing the best by my apps. Thanks!
>>
>>Renoir
>
>
>I think, I would agree with Dan, but you should explain, what you're trying to achieve in more details. Say, recently I subclassed our baseform class into my nAdditions library, added couple of new methods and properties and coded several methods. I re-pointed few of my applications to this new form and doing this, considerably shorten their code (since I put some common logic in this subclass). So, it depends, how often you would use this button, etc.

Nadya and Dan,

Thanks for your responses; I was beginning to wonder if anyone thought this was worth replying to... I guess using my example through everyone off a bit. I was interested primarily in knowing whether the logical relationship between the class and the instances was such that the class should contain behaviour/code that was shared and the instances only what was relevant to it's particular environment. I was really trying to draw a line in the sand regarding what to code in an instance as opposed to in the class. Dan mentioned that I should put the AddProc in both buttons as this was only relative to the form. I think I agree, but where is the line drawn? Does that mean that it would be ok to put it in the class if my classed forms always contained that proc? Or would it never be ok? Again, that's just an example; looking for concepts really. I'm trying to develop apps with the mindset of relatively easy mainenance as well as solid functionality. It gets a bit fuzzy in reality as to where to put what sometimes...

Renoir
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform