The document discusses the benefits of using a framework like SproutCore for building large, complex web applications. It outlines how SproutCore separates an application into distinct Models, Views, and Controllers. Models manage the application data, Views handle DOM manipulation and display, and Controllers tie everything together. This isolation of concerns makes the code more modular and reusable, preventing views from becoming tangled together ("spaghetti code"). The document provides an example of how SproutCore implements a Twitter-like following feature with isolated, reusable Views, Models, and bindings between them to update automatically on data changes.
11. $(".follow-me").live("click", function() {
var link = $(this).parent().prev();
var count =
parseInt($("#following span.count").text());
var newLink = $("<li class='user'>")
.append(link.clone());
$("#following").prepend(newLink);
$("#following span.count").text(count + 1);
});
12. D E F G
Following 187
Who to follow
A
wycats · Follow
Yehuda Katz
B
okito · Follow
Charles Jolley
C
wifelette · Follow
Leah Silber
13. D E F G
Following 187
Who to follow
A
wycats · Follow
Yehuda Katz
B
okito · Follow
Charles Jolley
C
wifelette · Follow
Leah Silber
14. Edge cases
Start with less than 4
D E F
Following 187
Who to follow
A
wycats · Follow
Yehuda Katz
B
okito · Follow
Charles Jolley
C
wifelette · Follow
Leah Silber
15. Edge cases
Start with less than 4
Unfollowing
A D E F
Following 188
Who to follow
A
wycats · Unfollow
Yehuda Katz
B
okito · Follow
Charles Jolley
C
wifelette · Follow
Leah Silber
25. D E F G
Following 187
following.length
following[N]
[1][0] [2] [3]
26. Who to follow
A
wycats · Follow
Yehuda Katz
B
okito · Follow
Charles Jolley
C
wifelette · Follow
Leah Silber
A.isFollowed
B.isFollowed
C.isFollowed
users
[0]
[1]
[2]
27. D E F G
Following 187
following
Who to follow
A
wycats · Follow
Yehuda Katz
B
okito · Follow
Charles Jolley
C
wifelette · Follow
Leah Silber
recommendations
29. Twitter.following
User
isFollowedChanged: function() {
var followed = this.get('isFollowed');
if(followed) {
Twitter.following.unshiftObject(this);
} else {
Twitter.following.removeObject(this);
}
}.observes('isFollowed')
D E F G
Following 187
following
Users
30. Who to follow
A
wycats · Follow
Yehuda Katz
B
okito · Follow
Charles Jolley
C
wifelette · Follow
Leah Silber
recommendations
Twitter.recommendations
Users
31. Who to follow
A
wycats · Follow
Yehuda Katz
B
okito · Follow
Charles Jolley
C
wifelette · Follow
Leah Silber
recommendations
Twitter.recommendations
Users
click =>
user.set('isFollowed', true)
33. D E F G
Following 187
following
Who to follow
A
wycats · Follow
Yehuda Katz
B
okito · Follow
Charles Jolley
C
wifelette · Follow
Leah Silber
recommendations
Totally
Isolated
Views