1

I'm developing my first component and I'm not sure how to best handle models that use other models from a design and implementation standpoint. For instance, I have a contact model (person or business). Then I have a model for address. In the database I have these joined by a junction table. How would I design and implement the MVC for this? I need to be able to perform CRUD operations on a contact that includes the address(s) for that contact. How do I handle the junction table from a design standpoint? I doubt it would be a model itself. Should I implement it in a helper file?

2

There are many software design / architecture patterns and the is a good overview at https://en.wikipedia.org/wiki/Architectural_pattern

From your description, it sounds like having a single joomla component with a model, view(s) and control will work ok. It is hard to say what is best, but perhaps your might have the following...

  • Models
    • actor (person or business)
    • address
  • Views
    • list actors
    • edit actor
    • edit address
  • controls
    • get list of actors
    • display actor details
    • save actor edit
    • display address details
    • save address details

Or something similar, though this is just an idea based on an interpretation of what you described.

You may find that you can quickly create this component, or something similar enough to it, using https://www.component-creator.com.

  • Thank you for the answer. Unfortunately I still have questions. How does the many-to-many (junction table) relationship get modeled and implemented? And, my actor model has its own table and logic. Perhaps I should have a (super) model that handles the logic of putting actors, addresses, phone numbers, etc. together? I prefer not to use a code generator because I need to understand and debug the component. – nimble May 18 '16 at 14:41
  • 1
    Yes, it may be your way out of your situation. Also take a look on how you can use JTables and JTableObservers – Alexandr May 24 '16 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.