Tuesday, 11 October 2022

What is Reintroduce ?

 A derived class uses the reintroduce directive to hide the name of a virtual or dynamic method was declared in a base class.

Example:-

 type

  TBooks = class

    public

      procedure Add(Item: Integer); virtual;

  end;

  TMathBook = class

    public

      // The TMathBook.Add method hides TBooks.Add, so that compiler warn you about this.

      procedure Add(Item: Single);reintroduce;

  end;

Thursday, 29 September 2022

What is difference between Virtual and Dynamic ?

 virtual and dynamic methods are semantically equivalent. However, they differ in the implementation of method-call dispatching at run time: 

virtual methods optimize for speed, while dynamic methods optimize for code size.

About the design patterns and its Type

In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design. A design pattern isn't a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations.

Object oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved.

  • Singleton :- A class of which only a single instance can exit.
  • Abstract Factory :- Create an instance of several families of classes.
  • Factory Method :- Create an instance of several derived classes.
  • Builder :- Separates object construction from its representation.
  • Prototype :- A fully initialized instance to be copied or cloned.
  • Object Pool :- Avoid expensive acquisition and release of resources by recycling objects that are no longer use.