Make a controller a superclass in MVC design pattern

Posted by Nikola on Programmers See other posts from Programmers or by Nikola
Published on 2013-06-01T22:11:05Z Indexed on 2013/07/03 11:17 UTC
Read the original article Hit count: 359

Filed under:
|
|

I am really confused how to handle this.

I have:

  • model.Outsider
  • model.SubContractor (which extends Outsider)

Basically, Outsider would mean Supplier, but SubContractor is not a Supplier itself so I had to divide it somehow.

I used to have

  • model.Outsider (super class of the two bellow)
  • model.Supplier
  • model.SubContractor

But Supplier didn't have any unique fields so I have removed it (Was this correct?)

So, continuing, I have db layer which has:

  • db.DBOutsider
  • db.DBSubContractor (which again extends the top one)

And I have no place to put my Supplier methods. I can do that in DBOutsider, but then DBSubContractor (which extends DBOutsider) would get unnecessary methods. Do I create a DBSupplier even though there is no such class in the model layer?

Then again, going to controller layer. It is the same situation as db layer. I have OutsiderController and SubContractorController (which extends the first one) (is this correct in first place? to have an extended controller?). But I have no place to put the methods which are concerned with Supplier and if I put them in the OutsiderController the SubContractorController would recieve unneccessary methods.

At the moment I am going for the extra DBSupplier and SupplierController classes, but I have no idea if this is the correct way.

Basically what perplexes me is the "empty" Supplier. Since it is supposed to be an Outsider but has no extra methods or fields, should there be an empty class?

© Programmers or respective owner

Related posts about java

Related posts about design