english_bt — 2014-06-28T07:34:57-04:00 — #1
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.
fretburner — 2014-06-29T18:17:03-04:00 — #2
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?
jeff_mott — 2014-06-30T00:59:25-04:00 — #3
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?
english_bt — 2014-07-03T20:02:24-04:00 — #4
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.
jeff_mott — 2014-07-04T04:06:03-04:00 — #5
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.
oddz — 2014-07-04T10:28:13-04:00 — #6
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.
english_bt — 2014-07-04T20:05:35-04:00 — #7
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."