The Active Record is ORM anti-pattern. We should avoid it.
It will be better if we see JTable replaced with Domain Driven Design patterns in Joomla 4.
It should be replaced with Entities, Repositories and Data Mappers.
The entities must depend on abstraction, not on concretions (database layers, services, etc.)
The architecture of Joomla 4 should follow
S.O.L.I.D and
DDD principles.
Nowadays, we are trying to do complex platforms using Joomla. We need better architecture to achieve our goals.
I am going to give you an example...
I was trying to do web services that send JSON data from Joomla website to a mobile application.
I was planning to do the web services via Laravel. I found that, I had to write the whole business logic and domain models. I had to reinvent the well.
It will be great if we see much more abstraction in Joomla 4.
For example, in my case, I would be really happy if I was able to download CMS library via Packager to my Laravel instance, just like other Joomla Framework classes.
So, I will only be able to do Laravel repository that will load the content from database. Then, I will use the Data Mapper from Joomla CMS libraries to create an object or collections. It will not be necessary to reinvent the well.
$dbAdapter = new Database();
// It should be possible to use any database layer. It should follow Dependency Inversion principle
$repository = new Cms\Content\Repository($dbAdapter);
// It will return Cms\Content\Article (
Entity )
.
// The repository will load the content form database and will create an object Cms\Content\Article, using Data Mapper.
$articleId = 1;
$article = $repository->findById($articleId);
// Save the article.
$article->setTitle("New Titile");
$repository->save($article);
// It will return Collection.
$userId = 2;
$articles = $repository->findUserArticles($userId);
As a result...
We will be able to use Joomla objects and data everywhere where we need - via Simfony, Laravel, Zend Framework, Lumen,.. Joomla CMS could be used as a website. The popular framework could be used for web services, micro services or other enterprise solutions using Joomla libraries.
Here you are more information.
ORM Is an Offensive Anti-PatternORM anti-pattern seriesAre there good reasons not to use an ORM?Domain-Driven Design in PHPDomain-Driven Design: The RepositoryDomain-Driven Design: Data Access StrategiesRich vs Anemic Domain ModelAnemic vs. Rich Domain Objects—Finding the Balance