2011-04-05 75 views
0

在设计应用程序时,我觉得最简单的方法是先思考我想如何与我的网站上的模型功能进行交互。这种编码风格叫什么?

所以例如,如果我要设计论坛系统我先开始定义中使用的术语,然后我立刻开始在记事本中输入此:

/* 
    - Thread 
     This is a thread a user has created in a board. 

    - Board 
     This is a unique place for threads to be stored. 

    - Categories 
     This is a way to create sub-menu boards. Boards within boards. 

    - Comment 
     This is a reply/comment to a thread. 
*/ 

    // ------------------------------------- 
    // THREAD FUNCTIONS 
    // ------------------------------------- 

    // Add comment to a thread 
    $thread->user_id = '55'; 
    $thread->thread_id = '66'; 
    $thread->add_comment(array('comment' => 'blah')); 

    // Edit comment (basically the same structure as add_comment) 
    $thread->user_id = '55'; 
    $thread->thread_id = '66'; 
    $thread->edit_comment(array('comment' => 'blah2')); 

    // Delete comment: 
    $thread->comment_id = '55'; 
    $thread->delete_comment(); 

    // Get's all the comment details within a thread. 
    $comments = $thread->get('username, comment, date_added, date_edited, subject'); 
    $user_details = $user->user_id('5') 
         ->get('user_title, user_joined_date, 
           user_location, post_count'); 

什么这种方法叫做?我正常吗? ; -D

+0

你很可能是正常的,这被称为设计过程,原型,伪代码?! – markus 2011-04-05 08:13:49

+0

当然是所有这些东西。但是这种设计模式有什么名字,即自上而下,自下而上,螺旋等吗? – 2011-04-05 08:22:34

+0

这不是一种设计模式。这只是你个人的思维设计方法。 – markus 2011-04-05 08:42:42

回答

3

有点看起来像测试驱动开发,没有测试。使用TDD,您首先设计您的API并为其编写测试。就像你在做什么,你不是首先实现代码,你只是在设计。然而,使用TDD的大型专业人员会创建测试用例,在您的代码实际编写完成后应该进行验证。