Jump to content

Some help on OOP design pattern


Recommended Posts



I am a newbie and catching up on php OOP. I have a handy project that i would like to mold into a OOP-driven web application.


For the sake of simplicity i will describe a minor part of the application's goals. I should be able to scale later, but the most important thing is getting the design pattern ready. 


Goal of the application:


I wish to provide people with different loan types (eg mortgage loan; declining,...) as to allow them to pick their best suitable type. 


For this i use a fom that catches the basic loan information and goes to work. For simplicity let's say that i only require the following fields:

  • Ammount loaned (€)
  • rate (%)
  • periode (years)
  • (i will add more later like taxrate; early repayments, number of kids,... everything that changes the outcome of tax benefits etc)

And let's say that to start off, we only have 2 types of loans: 

  • mortgage loan
  • declining loan
  • (more options added later that make use of early repayments)

The things i need the app to output are:


A different tab for each type of loan under which can be found:

  • Amortization table
  • tax benefit
  • summary in KPIs (ROI (-), total ammount payed, total interest paid,...

And one final summary screen comparing all the elements of the different loan types. 


So far everything clear in my mind.... As for the design pattern this would be my idea:


  • create a (service) validator class that validates form input and instantializes upon succes a new (model) class that contains the validated input
  • Input (model) class as described above
  • Loan class being abstract containing financial methods to calculate the payments in the different periods
  • Loan classes based upon the abstract class but differing by type and thus overriding some of the methods for the specific type.
  • Maybe a different class to contain the results of the calculation (model)?

I made all these calculations in excel when i had to make the decision of buying a house. The reason why i want to turn this into a webapp is because of people asking me about those calculations, so why not make it available for everyone (atleast those in my country as tax regulation will surely differ). I have added screenshots from my excel file to give you a better idea of what i am trying to accomplish. I made it work in excel VBA with very bad procedural code. I Could do the same in PHP, but then i d not be improving myself... So let's get OOP going!


What do you think about this idea? And for the purpose of it being programmed as OO? Should i take a different approach with my classes? 


Any help is well appreciated! 














Link to comment
Share on other sites

An extendable Loan class seems a fine idea.  Also a Form_Validator class ... but, of course, you should also do verification in JavaScript to ease server processing load and for convenience in the UX.

As a matter of fact, it sounds as if the entire thing could be an AJAX-based single-page application, to some extent.  In which case you'd need PHP mostly for a back-end API ... ?

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.