Jump to content

Some help on OOP design pattern


resolate

Recommended Posts

Hello,

 

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! 

 

Grtz,

 

Resolate

 

 

 

 

 

 

 

post-204469-0-83548800-1496597025_thumb.jpg

post-204469-0-74275700-1496597033_thumb.jpg

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 ... ?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.