Object-Oriented Features
DBL supports both structured and object-oriented programming styles. Object-oriented programming (OOP) offers a way to organize data based on the concept of objects, which are the fundamental components of programs. OOP enables developers to model entities and relationships in a structured, intuitive way. This chapter explains how taking advantage of OOP concepts will help you to design maintainable, reusable, and extensible code.
Classes and objects are the basic elements of OOP. A class is like a blueprint that specifies the attributes and behaviors (aka methods) common to a specific type of object. An object is member of a class, representing a specific instance with defined properties and functionality.
One pillar of OOP is inheritance, which allows a class (called a derived class or a subclass) to acquire attributes and methods from another class (called a base class or superclass). Inheritance encourages code reuse and creates a natural hierarchy between general and specific concepts, making code more modular and easier to maintain.
Interfaces and delegates are more advanced constructs of OOP that improve code flexibility and reusability. An interface is like a contract that a class must comply with. It defines the properties, methods, and events that a class must use, which guarantees consistent behavior across different implementations. A delegate provides a way to pass methods as parameters, enabling event-driven programming and more dynamic interaction between components.