?
Solved

Overriding a class

Posted on 2012-09-13
6
Medium Priority
?
349 Views
Last Modified: 2012-09-13
When overriding a class such as:

       public override void OnCreate()
        {
            base.OnCreate();
            Global.Initialize(this);                                        
         }

Open in new window


Is it best to call the base method BEFORE or AFTER your code? And reasons why please.

Thanks :)
0
Comment
Question by:zattz
6 Comments
 
LVL 45

Assisted Solution

by:AndyAinscow
AndyAinscow earned 400 total points
ID: 38394339
>>Is it best to call the base method BEFORE or AFTER your code?

Depends on what you do.  Sometimes before, sometimes after, sometimes makes no difference.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 1200 total points
ID: 38394370
Well typically the base implementation is what actually raises the event. The decision you have to make is whether not you want the client to see the event before your code runs or after your code runs, or to never see it all. ( more or less what Andy said. )
0
 
LVL 10

Assisted Solution

by:John Claes
John Claes earned 400 total points
ID: 38395100
Example :

For Constructor you mostly set it first : you are then sure that it's constructed
For destruction set is as last : you want it to be destructed after you've destructed all the addon's

For the other methods, it's all about what the others said, just trying to clear it out a little more with the 2 examples
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 45

Expert Comment

by:AndyAinscow
ID: 38395479
@poor_beggar

Very good point, re c'tor and d'tor
0
 

Author Comment

by:zattz
ID: 38396995
I guess I'll have to try it out and see what works best. I'm developing for Android, so I'm in the dark mostly :) Thanks for the help
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38397256
Not to discredit my fellow experts, but you might try posting your question in the Android TA. (Myself, I have only dabbled in Android development.)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month17 days, 8 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question