Skip to Content
Node与Express开发(第2版)
book

Node与Express开发(第2版)

by Ethan Brown
June 2021
Intermediate to advanced
290 pages
9h 21m
Chinese
Posts & Telecom Press
Content preview from Node与Express开发(第2版)
38
|
第
5
章
5.3
 逻辑与表示
大体而言,网站有两个层面:
逻辑
(常被叫作
业务逻辑
,我不这么叫是因为这种叫法多少
有些商业意味)和
表示
。你可以认为网站的逻辑只存在于人的头脑里。比如说,在草地鹨
旅游的场景里,可能会有一条规则:客户必须拥有合法驾照才能租借踏板车。这是一条基
于数据的简单规则,说明用户拥有合法的驾照才能完成每一次踏板车预订。而
表示
跟这条
规则是分离的,可能它只是体现在订单页中最终表单的一个复选框,或者是用户必须提供
而由网站来验证的合法驾照号码。区分逻辑与表示很重要,因为在逻辑层面,事情应该尽
可能清楚和简单;而在表示层面,可以根据需要选择复杂或简单。表示会受易用性和美学
方面的制约,逻辑则不会。
你应该尽可能地把逻辑和表示划分清楚。对此有很多种方式,而本书选择把逻辑封装进
JavaScript
模块
。表示则是一个组合,包含
HTML
、
CSS
、多媒体、
JavaScript
,以及像
React
、
Vu
e
或
Angular
这样的前端框架。
5.4
 测试类型
本书考虑的测试类型可以分为两大类:单元测试和集成测试(我把系统测试也看作一种集
成测试)。单元测试相当精细,需要测试单个组件确保其功能正常,集成测试则测试多个
组件的交互,甚至会测试整个系统。
一般来说,单元测试对逻辑层面的测试更有用,也更合适。而集成测试对逻辑和表示两个
层面都有用。
5.5
 
QA
技术
本书将使用以下技术和软件来完成全面测试。
单元测试
单元测试覆盖应用的最小功能单元,通常是单个函数。单元测试基本都是由开发人员而
不是
QA
专员
(尽管
QA
专员应该有权评估单元测试的质量和覆盖率)所写。本书中将 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

面向对象的思考过程(原书第5版)

面向对象的思考过程(原书第5版)

马特 魏斯费尔德
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua

Publisher Resources

ISBN: 9787115565099