But on top of MySQL is a built-in layer of abstraction that makes it possible to take advantage of Object-oriented patterns and principles. Here are just a few of the most prominent examples:
Inheritance
- You can easily designate one "Class" or "Interface" to inherit from another. Under the hood, tables and columns are uniquely created so that in essense the one table "extends" or "inherits from" the other. Take the example of a model that has a "Dog" class that inherits from an "Animal" class. Assuming the "Animal" class has a "color" property, the "Dog" class would inherit the "color" property as well. What this means is that when you query instances of the "Dog" class, you can fetch or filter on the "color" column along with any other "Dog" specific properties.
Multiple Inheritance
- That's right, Schematize allows multiple-inheritance and handles appropriate table/column creation allowing your "Dog" class to "extend" from "Quadruped" abstract class as well as the "Animal" class.
Abstraction
You can achieve abstraction in Schematize by defining your model in terms of "Interfaces" or "Abstract Classes". Keeping our same example, we may want to define an interface called "Omnivorous" that defines a few required properties and methods. If "Dog" implements the "Omnivorous" interface, it would be defined with the same properties/columns necessary to make it truly "Omnivorous".
Polymorphism
Schematize support polymorphism in a few forms. First, let's introduce a "Lion" class which inherits from "Animal". If we also create an association from "Animal" to "Habitat" through "Habitat"s list property "inhabitants", both "Dog" and "Lion" can now be used as instances in the "inhabitants" list. Second, if the "Animal" class requires a method "eat()", both "Dog" and "Lion" have the opportunity to "override" the default "eat()" method. At this time, we have not implemented method "overloading" yet, but again have the capacity to do so because of our reliance on UML as a base.
Encapsulation
Schematize in its current form doesn't allow for any private members...yet. however, being built on top of UML, Schematize can easily accomodate encapsulation.
Associations/References
Although not part of the "4 pillars" of OOP, references are integral to how object-oriented programming works. Schematize recognizes this and makes enabling associations and navigating bi-directional references easy.
Operations/Methods
Yes, Schematize even supports methods! UML calls these "Operations". The implementation of this feature is still in its infancy, but yes, you can define instance methods in the langauges available and they become available to use in the libraries that are automatically assembled.