Chinaunix首页 | 论坛 | 博客
  • 博客访问: 134476
  • 博文数量: 73
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 760
  • 用 户 组: 普通用户
  • 注册时间: 2008-01-29 14:07
文章分类
文章存档

2011年(2)

2010年(4)

2009年(40)

2008年(27)

我的朋友

分类:

2009-07-13 17:17:38

 
 一. What's the best way to start writing a PHP program?
      最开始写好PHP程序的方法是什么?     
      Design, design, design. Figure out, on paper, exactly what you want to
      do. Otherwise, you'll just be coding your way around with no real goal.
      设计,计划,方案,理解,手写,确切的明白你想做的,否则,你只是在毫无目标的编写你的程序。
      
      Plan on separating content from logic, it'll always assure cleaner,
       more maintainable code.
      想好把内容与逻辑分开,这样有助于保证清晰的,可扩展的代码。     
     
      Usually the apps I write are DB-related, so to use that sort of
      
application as an example, the first step would be nailing down, with
      fairly broad scope, what sort of data needs to be stored. This doesn't
      have to mean tracking down every possible facet of information that
      will ever be pertinent, just get a good idea. Part of the app design
      may call for it to be extensible anyway, so you don't have to know
      everything ahead of time.
      通常我写的附录都是DB-related,所以都是使用类似于例子的应用。第一步是在适当的程度上明确
      需要存储哪种类型的数据。但是这不是说一定要考虑到相关信息的各种可能,只是获得一个好的想法。
      附录的一部分设计要求至少有扩展性,因此你不需要在开始的时候知道所有的东西。

      Once you have a good understanding of what data needs to be stored,
      design your database. Flow charts are your friend. :) Having a
       visualization of the structure of the DB will come in handy for
      
subsequent steps.
      一旦你明确知道要存储哪种数据,用流程图来设计你的数据库。清楚的展现数据库的结构,会对随后
      的工作带来便利。
     
      Now it's time for an interface between your app and the database.  I
      generally avoid putting direct DB calls in my app as much as possible,
      your feelings may vary.  Now that Pear is around, I've been using that
      for my abstraction.  There are other options, of course.  I tend to
      write three functions for each logical grouping of database fields. 
      For example, if it were a web log, there may be some groups of fields
      such as Users, Entries, Categories, and Polls.  For these, I would
      write getEntry, setEntry, deleteEntry, getUser, setUser, deleteUser,
      and so on.  I may not find a need to use all these functions, but
      being able to assume they're there if I come to that point later on is
      handy.
      首先要在前台与数据库间做好接口,


阅读(403) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~