
It’s great when a new project appears. The inception of an idea, the formation of the basic functions of the future product, the visual representation of the entire interface – all these efforts are pleasant and interesting to every developer. It often happens when after the idea a developer immediately sits to write the code, without creating any preliminary plan or steps. In our opinion, it is not a good practice.
Today we want to share with you our advice about the development process – we are sure it is critical to work properly on the architecture of the future project. In our article we we will consider the main steps for the proper development of the project architecture of a website based on PHP technologies.
Before you start coding, take your notebook and pencil, and let all your thoughts and ideas be displayed in this way – believe us, it will help you in the future work.
Step 1. Identify the main idea of the system and its functionality
Any project architecture goes from the top down, that is first all the basic systems are thought through, and then their servicing components. We recommend that you make it clear that is the main thing on your website. Usually in online store the point is a catalog of goods, any company’s site should have a list of services, and for the news site it is the possibility of placing an entry.
After the determination the type of site and the underlying components, you can write a couple of necessary strings of code:
High-level classes: they can help you to navigate with the further requirements of the entire system
The class functions – what every block is available to do, for example:
class entries
{
public function entry_create() {}
public function entry_remove() {}
public function entry_get() {}
}
So you have defined your main subsystem, but do not rush to write further. Try to work with bare data and elements to better understand the entire structure of the project.
Step 2. Identify what we are dealing with
Let’s continue to consider our theoretical project of the website, on which the main work will be connected with entries. This stage allows us looking deeper: the function ‘entry_create’ consists of the creation of a title, an entry body (text information) plus adding media files, etc.:
class entries
{
public function entry_create($title, $text) {}
}
Other actions like ‘entry_remove’ and ‘entry_get’ will require some special identificators and that can be realized without problems.
Everything is simple: remember that you work with a computer, and in order to realize all your ideas in the right way, you should describe it all simply and easily in code. Take the most convenient architecture with the minimum set of all the most necessary things, and you will probably can create the appropriate project.
Step 3. Know the results
This point follows from the usual logic of all architectural decisions: any action you wrote in your code should have any result. It is a little bit weird but sometimes a programmer decides not to spend some time in the development of the architecture for prescribing all the action and function results, that may spoil the whole program within only such error in future.
Your ideas should be implemented and should have the following results:
- function ‘entry_create’ causes a creation of a new entry with its identificator
- function ‘entry_remove’ causes the entry deletion, accompanied with the message ‘done’
- function ‘entry_get’ causes the entry reception
Such uniformity in the installation of a result for each function and action helps to ensure the correct operation of the entire system and track correctly any problems and errors. In case of any error there will be the unified report – in PHP we usually recommend to use ‘throw new Exception’.
Step 4. Finally – let’s start coding!
Yes, now it is the time to start animating your website project. With your clear structure of the whole site the development process will be smooth and comfortable. The time spent on architecture will completely pay off your further works, and you can thank yourself for your consciousness and consistency.
To be honest, we told you about the classical MVC development pattern, where M is the process of project architecture creation. If you are fond of effective and high-qualified development, you will be able to use MVC and particularly project architecture in every your project.