Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Design Pattern Advise [closed]

I have two years worth of PHP experience however I have never worked with design patterns. I have recently been given a task at work that has made me question the wisdom of that decision.

I have been asked to create a system that:

  1. Insert orders into a database. These orders can have a multitude of attributes and control logic that needs to be applied. The system will not be directly responsible for a front end, it will receive commands via an API.

  2. Write the scripts that extracts orders from the database, decide which supplier to send with and create the associated files for uploading to a provider. File formates vary (XML, CSV).

  3. Process incoming files from suppliers in the various formates (XML, CVS) and update the databases. Also FTP will have to be utilised to gather the files from the remote host.

I would like a central control class that can service each of the required functions, one point of access so to speak. This would then extend into the various specific functionality as required.

I am wondering if it is worth learning a design pattern to facilitate this system, if so could someone point me in a direction as there are many. Any advise on my issue would be very helpful.

Thanks in advance

like image 812
Joe Avatar asked Nov 06 '22 12:11

Joe


2 Answers

Keep in mind that a design pattern won't solve your problem, rather it's a reusable abstract method of a solving a problem (or given set of problems.)

Based on your description and idea, it sounds like you already have a grasp of the situation and how you would like to handle it.

I'm not one to get caught up in design patterns too much, I'd probably just run with what you have if I were you.

$0.02

like image 95
Ian P Avatar answered Nov 12 '22 18:11

Ian P


Yes it's a worthwhile effort, however as it will not solve your problem. If you have been coding without them you sometimes use them in a mixture of patterns and thing are not always clear. Having names and template may make your code clearer and easier to maintain.

In the last 2 year I have been brushing up on design patterns and how to better model solution, and I believe it has payed off.

I personally read used these books for my studies:

  • Design Patterns: Elements of Reusable Object-Oriented Software this is the classic book on design pattern. Not necessary a easy read but very good reference.
  • Domain-Driven Design: Tackling Complexity in the Heart of Software by Eric Evans This is an excellent book on how to approach you model looking at the domain. Some knowledge of design patterns will help here.

I do think studying design design patterns can help you improve your design. Having clear names will aid people that coming on later.

like image 33
Thomas Avatar answered Nov 12 '22 17:11

Thomas