I am very new to this. I was wondering if this is the correct approach to OOP or not.
Any tips or suggestions would be highly appreciated.
That's a bit of a vague question. Are you asking if what you've got there is a good object oriented design for an MVC style framework? If that's the case, then I'd point you in the direction of a couple popular, well-designed frameworks such as Laravel or Symfony2. A lot can be learned from looking at the source code and seeing how they work.
If you're talking about actual application design (i.e your business/domain logic) then there really isn't enough in your example to go on, and we've discussed more concrete examples in your previous posts regarding the mailing list service.
Just looking over the classes/interfaces in your link raises a couple of questions:
- What is the responsibility of the HomeController class?
- What is the purpose of the MemberInterface interface?
Ditto what fretburner said. I think you need to clearly define what job a controller is supposed to do. In the Symfony framework, for example, a controller action is defined to be anything callable that accepts an HTTP request and returns an HTTP response. In your code, however, the MemberController doesn't yet do anything, and the HomeController's index action only returns the member controller. What kind of return value are you expecting from your controller actions?
I really over simplified this.
HomeController is the first controller the bootstrap file loads and it could do anything.
MemberInterface is an interface that any class that retrieves members information from the database should implement. In this example MembersController should have implemented it but it looks like I forgot to do it.
I am learning Laravel at the moment. It took 2 months to learn about composer, artisan, vagrant and the new things that come with Laravel.
It is massive. Really hard to get to know it well. But I decided to write and write code until I get there.
At this stage in Laravel department my challenge is understanding Facades.
In that case, your MembersController class isn't fulfilling a duty normally attributed to controllers. It sounds more like the duties of a model/repository/record/etc class. If you rename it to MembersRepository, then I think it'll make more sense.
I would suggest giving it a more clearly defined responsibility. Once we understand what you intend for it to do, it may turn out that this too is mis-labeled as a controller.
Once the syntax is understood to the point of being able to read code you will learn much more from using an existing tried and true MVC solution than rolling your own lower level framework. Not to mention the docs for both Symfony and Laravel are excellent. Additionally, many well known projects such as; Drupal is using Symfony components. In many cases the knowledge is transferable to other systems that might make use of the ecosystem.
Jeff Mott I am still reading on these replies and doing research meanwhile I wanted to write to you and tell you that your signature rocks. I will tattoo this on my arm
"First make it work. Then make it better."
This topic is now closed. New replies are no longer allowed.