Day 1 — The best tool

Today, I started writing issues for a new project with a friend, based on use cases and a primary DB schema we had made. The project consists of a web application, my friend had an appealing idea, and we are trying to make it work, to -hopefully- make some money out of it.

After debating on high level ideas, we got to architecture and tools. We both had some bad experience with the Repository pattern when used with Active Record (we were using Laravel framework) and decided it is a no-no. In fact, we had felt that using Repository Pattern along with Active Record to decouple the Data Access Layer from the Business Layer is quite impossible unless you reimplement every Eloquent(Laravel’s ORM) method, so we discarded it. I had found out later that some people shared our concerns, you can check them here.

That bad experience had pushed me to question my usual tools, I’m a PHP developer and I use Laravel, I thought maybe PHP isn’t the best thing before this time, but now I was thinking about this project. Don’t worry this isn’t going to be another rant about why PHP is bad, I actually enjoy coding in PHP and would use anything as long as it does the job. I’m not very loyal I guess. To sum it up, we didn’t switch to another language because: PHP7.

Not just PHP, I started thinking about Laravel defects, and went looking at what people are saying about its cons, I had adopted Laravel 3 years ago and switched from CodeIgniter framework, which was a good decision in my opinion since CodeIgniter is now “deprecated” by the community. However, I hadn’t looked much at other alternatives except Yii framework. And frankly, I don’t really remember why I didn’t like it. Laravel was very easy to learn and had the stuff I was missing with CodeIgniter.

After some research, I decided not to abandon Laravel because most of the criticism was about “how Laravel promotes bad practices”. And some of the criticism seemed very biased. I can avoid bad practices, so this wasn’t a killer. I do agree on one thing though, using Laravel Facades can be a bad practice but I personnally always inject my dependencies, that’s the cool thing about Laravel, it lets you choose. You can check this article for PHP frameworks comparison, it’s really well done.

I watched a lot of talks and read a lot of articles of some great developers, and I was leaning to adopt a Data Mapper ORM(i.e: Doctrine) instead of Laravel’s Active Record ORM (Eloquent), that’s because I think Data Mapper plays very well with the repository pattern and makes it easier to use Domain Driven Development.

At that point, I almost decided to ditch Eloquent in the bad practices hole. But in the end, decided to stick with it for two reasons: 1- It is still in debate whether Data Mapper is any better than Active Record 2- Switching will cause us to loose many packages that depend on Eloquent (there are non-official packages that fill the gap) Since we’re not sure if this adventure of ours is going to lead somewhere, I think I should invest the bare minimum to launch it. For now we’ll just go with our usual tools, and try to use their best practices. If we succeed, than we’ll think about this again deeply.

After this thought process, I realised that most people don’t really choose their tools, and ban whoever disagrees; just like most people don’t choose their religion or their philosophical system. The environment they’re in chooses for them. Some people though reaccess their choices, weigh the pros and cons, and use not the best tool, but the best tool for the job.

How about you? ever had such a day?

Show your support

Clapping shows how much you appreciated Yazid HANIFI’s story.