I have a problem about structures of the complex applications .Because my knowledge background does not come from education , i have had always problem about application's layers , design patterns and programing structures.First of all , I can do whatever I want with php , because I know common functions and I have experience with php. But I want to create bigger and more complicated applications than i did before ,so I always ask questions myself while I am writing code . Is this best place to do this? , is this the best way to do this? , do people use this way to do the same thing?. To answer these questions correctly, I created my own small mvc php framework which really looks like Zend Framework. I did this because I want to clarify all parts of the application . I know that there are lots of design crimes in my framework and all my applications . And I think that the main problem is the border between Controller and Model . I asked lots of questions about this in SO ,but still it is not clear for me . Therefore , I will explain what I know and what I do , and please show my mistakes ,and correct them , or just explain some information about design patterns ,or just show my problem so I can make research about it , because I do not even know my problem , but I know that what I do is not the best way , so I can improve myself .
What i know
- I know active record pattern . For example , we have user class , we use same class to save data to database , and we use same class as a object . So object is active we can create one then if we change it we can save it with same class ( $user = new user('Oguz'); $user->save();)
- I know factory pattern . We have to classes for one object (User_Factory and User). We use user_factory class to acces database for example get user or delete user . And user class is the object it self.
Ok my problem starts when there is a connection between objects (not like manytomany or belonsto ).For example , we have a video website which has a favorite system . The process of adding favorite consists of these steps (1-check the video with this id, check the user with this id . validating steps). While we are just adding or updating just one object we user other objects too (User factory and video factory). Generally i can do all this things in controller . But i fell that this is not the best place to do this . Because i call these steps as a process (adding favorite process ).So this process should not go in controller because we may want to use same process as an api in another controller-action . So i feel like there should be another place which includes this processes for example process library. I do not even know which programing problem i am talking about.
The connection between object does not just exist in validation step.For example think about search process. when user search a string first we have to create new search row (for lastest searches stuff) , then we have to search youtube , if we can not find we have to search other video sites etcetera .So this action is a process search process , i think putting the all logic in controller is a correct way to to this . we use lots of classes and objects so i can not put this process in search objects class .
Thank you for everyone , Sorry for my english . i am very eager to learn more , i have been using php since i am 11 (I am 19 now) . i will be a college student next year (i hope) . i hope this will be a great place to learn more ask more and do more . I ask it now because i can not ignore these questions and wait until becoming college student. Even if you do not answer or you can not understand my question thank you for your reading. Please feel free to edit and improve my question .
I really like coding complex applications (may be not complex for lots of you) . I think that solving problems is very enjoyable.Therefore I am dying to learn what is the standarts of enterprise level coding .Maybe it is not necessary for my case . but i want to create my applications with the best programing approaches.