6-170-spring-2013-Software Studio

ruby on rails and html/css/js/jqurey

client-side programing

  • JS, html, css, jquery, ajax
  • react

manipulating the DOM

  • traverse the elements
  • add and delete elements
  • modify properties(e.g position)
  • registering events(against timers, buttons)
  • making calls to webserver
  • basic page load is synchronous
  • when page arrives, often loads others(images, css, js)
  • complications: caching, asynchronous calls, events

Modularity & dependences

  • client --users-> service

Model-driven development

  • request -> apache -> rails -> mysql -> rails -> apache -> response
  • framework: routing, request data, data mapping, templates, validation, session state <ul>routing: client's name for op, developer's name for method

Separation of concerns

  • Edsger Dijkstra
    let me try to explain to you, what to my staste is characteristic for all intelligent thinking. it is, that one is willing to study in depth an aspet of one's subject matter in isolation for the sake of own consistency, all the time knowing that one is occupying oneself only with one of the aspects... it is what I sometimes have called "the separation of concerns", thich, even if not porfectly possible, is yet the only avaliable technique for effective ordering of one's thoughts, that I know of.
  • semantis
    what things are there
    how are things classified
    how are things named
    what mutable
    what updates happen
    what queries are asked
    what invariants hold
  • representiation
    what information is stored
    which tables or classes
    what are the datatypes
    what columns? associations?
    what are the keys
    encoding generalizations
    optimize common queries
    integrity constraints

operators & properties

  • cardinality of a set
  • union, intersection, differnce
  • domain and range
  • image
  • transoise
  • join
  • a relation R is symmetric
  • a relation R is reflexive
  • a relation R is transitive
  • a relation R is an equivalen
  • a relation R is a function
  • a relation R is injective

Atoms

concepts#

  • weak concepts
    hard to use
    a mess to maintain
    unreliable & buggy
  • strong concepts
    intuitive, predictable
    decoupling & localization
    more dependable
  • standard parctice
    to design something really well, you have to get it. You have to really grok what it's all about. It takes a passionate somthing, chew it up. not just quickly swallow it. Most people don't take the time to do that.

thinking & sketching

  • simulating features
  • normal design practice
  • coping good ideas
  • evaluating products
  • user feedback
  • discarding failed designs
  • "refactoring"
  • focusing: what are the concepts
  • what properties do they have?

instend: core concepts

  • what are the concepts
    that make it work
    that you need to grasp as a user
    that characterize this class of systems
    that characterize this class of systems
    that distinguish it from other system
  • identify the design problem

mistake

  • not a stateful relation
  • should be split into multiple relations
  • relates > 2 atoms

object model

semantics

  • meaning = set of instances
  • an instance is an object diagram
  • non-instances
  • violate some rule in the object model

statics & dynamics

mutability

object model + operations = labeled state transition system

common mistake

  • bad sets
  • using subset for relationship role
  • reading subset as is-a

relationship

  • naming
  • property
  • containment
  • association

multiplicity

    • one or more
    • zero or more
  • ! exactly one
  • ? at most one
  • ommit =*

idioms

  • Tony Hoare
    I gave desperate warnings against the obscurity, the complexity, and over-ambition of new design, but my warnings went unheeded. I conclude that there are two ways of constructing a software design: One way is to make it so simple there are obviously no deficiencies and the other way is to make it so complicated that there are no obviius deficiencies
  • well-established concepts
  • used in many apps and context

format problem

  • a design problem to be solved

solution

  • one or more concepts

example

  • in well known apps

refinements

  • more elaborate forms often used

object model

  • concepts & relationships

Every problem in computer science can be solved by introducing another level of indirection

requst data

  • query strings from GETs
  • form data from POSTs

web app = data conversion

  • update request -> request.form -> database table -> response -> show request

data mapping

  • basic idea
    object in heap = row in table
  • object relational mapper
    generates database schema from class defs
    back up object methods with SQL updates/queries

HTTP methos

  • GET : get a document from a server
  • POST: send a document to a server
  • PUT: updata a document at a server
  • DELETE: delete a document from a server

request components

  • query string: for searching
  • body: for new version of page

four function of persistent storage

  • CRUD: create, read, update, delete
  • SQL: insert, select, update, delete
  • HTTP: POST, GET, PUT, DELETE

RESTful

  • general strategy
    instead of calling an action, create a resource
    instead of 'login', create a session
    instead of 'closing account', create a 'cloing'

Log in and out

  • whatever your login/Authentication plugin does
  • more important to have session in model than to reflect in URIs

RESTful routes

  • client app uses web service API
  • HTTP verb path action used for
  • XSS
  • CSRF

MVC

  • CRUD routes
  • model: data persistence
  • view: url routs/ page routs, process user input
  • controller: How to deals with the data and so on, processing business logic
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,496评论 6 501
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,407评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,632评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,180评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,198评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,165评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,052评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,910评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,324评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,542评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,711评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,424评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,017评论 3 326
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,668评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,823评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,722评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,611评论 2 353

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,322评论 0 10
  • 和梅子的接触舒服又安心,曾记得有一次,要完成一个任务,我找到了她,她在等孩子上课,本想着再找别人帮忙,结果她却义不...
    大晶cleo阅读 139评论 0 0
  • 今天下午4点多去福安那个农贸市场买菜,从农业银行门前穿过,快到市场门口才看见门口堵着好多人水泻不通,外面一圈...
    任容爸爸阅读 124评论 0 3
  • 一翁肥四子 四子活翁难 鸡毛蒜皮事 不赡找客观 老大气不愤 家分不周全 老二看老大 万事有开端 三四皆有理 天塌大...
    姚立红阅读 415评论 0 0
  • 1 别把软弱当做资本 2016年已进入深冬,午饭过后的天光突然暗了下来。天空像一只黑灰色的猛兽不断向这座城市逼近,...
    大风儿阅读 487评论 0 2