Copy, inherit or use?

Source: Internet
Author: User
Copy, inherit or use?

Code reusability saves us time and effort, increasing our productivity. object-oriented programming has something to do with that, and in the case of Delphi we can reuse forms and even entire projects. for example if we have a form with a table, a DBGrid, a navigator and several buttons, we can save it like a model in the object repository to reuse it in several parts of our application or other applications. the same for a standard form of the type "Save, don't save, cancel ". to add a form to the repository you have to right-click it and select "add to repository... "In the context menu. to save a project in the repository choose "add to repository... "From the project menu.

To use a form of the repository in our application, In the File menu we chose new and in the new items dialog we click the forms tab to see the forms available in the repository. then we select the form we want, the method of use (copy, inherit, or use) and click the OK button. the dferences between these hree methods of use are described briefly here:

Copy: Creates a form that is copy of the form that is in repository. the changes you make to the copy won't affect the form in the repository (nor other projects that use it ), and changes made to the form in the repository won't affect forms previously copied from it. this option is used when the form in the repository is just a base to work, with a very low level of standardization. full-adaptation is possible.

Inherit: It creates a form that derives from the form in the repository. changes made to this derived form (inherited) won't affect the form in the repository, but the inverse is not true. this option is used when the form in the repository is well standardized but it is desired to allow some adaptation. it's the most powerful way to use a form.

Use: It adds the form of the repository to your project. it's not a copy, but the form of the Repository itself, and thus any modification that you make to it will apply to other projects that use or inherit. this option is used when the form of the repository is a standard and is defined in itself (it doesn't require particle adaptations for each case/application ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.