大型网站上的功能实现顺序,

发布于 2024-12-10 09:37:09 字数 279 浏览 0 评论 0 原文

我一生中的大部分时间都更像是一名营销人员。然而,我最近决定换个方向,为我正在工作的一家雄心勃勃的初创公司学习编程。基本上,该项目基于社交网络元素(关注、提要、帖子、通知等),但有所不同。我想知道应该按什么顺序编写网站基础设施的代码。我认为首先在 MYSQL 中写下整个数据库架构,然后用 PHP 编写所有数据库查询,然后制作注册页面,然后用 PHP 编写网站的整个后端。这种做法正确吗?我将不胜感激您能给我的任何指示。我应该先从后端开始吗?高度可扩展的网站的哪些基础设施组件最好建议我使用 C++ 而不是 PHP 来完成?

谢谢

I have been more of a marketing guy most of my life. However, i have recently decided to shift gear and learn programming for an ambitious start-up that i am working on. Basically, the project is based on elements of social networking elements (follow, feed, posts, notifications etc) but with a twist. I wanted to know in what order should i write the code for the infrastructure of the website. I thought ill first write down the entire database schema in MYSQL, then write all database queries with PHP, followed by making the registration page and then code entire backend of the website in PHP. Is this approach correct? I will appreciate any directions you can give me. Should i first start with the backend? What are some of the infrastructure components of a high scalable website that i will be better advised to do in C++ and not PHP?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

没有伤那来痛 2024-12-17 09:37:09

您所描述的是经典的瀑布模型。它几乎永远不会起作用,因为规范会改变,因为

  • 客户的需求发生了变化(您的案例中的启动)
  • 客户与软件的 alpha 版本交互
  • 您意识到某些问题可以以不同的方式解决

因此,我建议您实施逐个功能。从一个空数据库和一个仅连接到该数据库的 php 脚本开始,然后实现一项又一项功能。

对于每个功能,确定需要添加哪些数据库字段。您可以使用现有的数据库条目或重组数据库以适应新的表和行吗?

然后,您可以同时或依次执行以下三个步骤:

  • 更改代码中数据库对象的模型。模型的基本测试将为您节省很多白发。
  • 添加控制器来执行新操作,或修改现有操作。同样,控制器测试对于确保以后不会破坏该功能至关重要。
  • 添加或修改视图 (HTML/CSS/JavaScript)。如果您不确定该功能到底应该做什么,您可以从视图开始,并向管理层提供一个粗略的(仅 HTML)版本。如果更改请求开始与元素的精确位置或颜色相关,您就知道自己走在正确的轨道上。您可以手动测试视图(使用不同的浏览器)和/或使用 Selenium

严格的 MVC 和测试都不是必需的,但它们极大地简化了软件开发,并允许您确定您的代码实际上可以在生产中运行。

What you describe is the classic Waterfall Model. It almost never works, since the specifications will change because a combination of

  • Changed requirements by the customer (the startup in your case)
  • The customer interacting with alpha versions of the software
  • You realizing something could be solved differently

Therefore, I'd recommend you implement feature by feature. Start with an empty database and a php script that just connects to that database, and implement one feature after the next.

For each feature, determine which database fields need to be added. Can you use existing database entries or restructure your database to accommodate the new tables and rows?

Then, you can do the following three steps concurrently or one after another:

  • Change the model of the database objects in your code. Basic tests of the model will save you a lot of gray hairs later on.
  • Add a controller to perform the new actions, or modify an existing one. Again, controller tests are essential to make sure you don't break the feature later on.
  • Add or modify a view (HTML/CSS/JavaScript). You can start with the view if you're unsure about what exactly the feature should do, and present a rough (only HTML) version to the management. If the change requests start to pertain to the precise positions or colors of elements, you know you're on the right track. You can test the View manually (with different browsers) and/or with Selenium.

Neither strict MVC nor tests are required, but they simplify software development a great deal and allow you to be certain that your code will actually work in production.

掩于岁月 2024-12-17 09:37:09

PHP 具有一些与 MySQL 数据库交互以及向数据库服务器发送 SQL 命令的强大功能。

您的数据库结构应该尝试获取网站的所有数据元素(用户详细信息、消息、评论等),并将这些信息分解为其最合乎逻辑和最有效的结构。这是通过将大量数据分解为逻辑和离散表来实现的,使用索引号(主键)或您希望关联每个表中的元组的任何字段(外键)进行引用。

让数据库进入这个阶段被称为第四范式(4NF)或博伊斯科德范式(BCNF)。

一旦弄清楚数据库的结构,您就可以使用 SQL 命令对其进行查询,将数据放入某个表中或检索它。

假设您使用 PHP 的 mysql_query ( string $query [, resource $link_identifier ] ) ( http://www.php.net/manual/en/function.mysql-query.php )然后您可以将 SQL 数据加载到数组中,并打印出其中的数据一些 HTML。

一旦你开始这样做,你可能还想使用 PHP $_SESSION 全局变量来跟踪任何登录的用户。该全局使用 cookie 来跟踪经过身份验证的用户,对于登录用户非常有用。您需要实现一些登录代码来匹配用户名和密码,然后创建会话(如果通过)。

希望有帮助! :)

PHP has got some great features for interacting with a MySQL database, and sending SQL commands to the database server.

Your database structure should attempt to take all of the data elements of your website (user details, messages, comments etc.) and break that information down into its most logical and efficient structure. This is achieved by breaking the whole lot of data into logical and discrete tables, referenced using index numbers (primary keys) or whichever fields (foreign keys) you wish to associate the tuples in each table.

Getting the database to this stage is known as 4th Normal Form (4NF) or Boyce Codd Normal Form (BCNF).

Once you have figured out the structure of your database, you can then go about querying it to either put data in some table or retrieve it, using SQL commands.

Assuming you use PHP's mysql_query ( string $query [, resource $link_identifier ] ) ( http://www.php.net/manual/en/function.mysql-query.php ) you can then load the SQL data into an array, and print out the data amongst some HTML.

Once you get this going you might also want to use PHP $_SESSION global var to keep track of any logged in users. This global uses a cookie to track authenticated users and is very useful for logging in users. You would need to implement some logging in code to match username to password, and then create the session if it's a good pass.

Hope it helps! :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文