Title: Book Review: ASP.NET 4 Social Networking
Slug: book-review-asp-net-4-social-networking
Date: 2011-08-23 06:50:00
Author: Kartones
Lang: en
Tags: Development, Books, Social Networks, ASP.NET, LINQ, C#
og_image: https://images.kartones.net/posts/screenshots/book_aspnet4_socialnetwork_packt.jpg
Description: The book provides a good start for building a social network with ASP.NET 4.0, but the architecture won't scale if the site grows. The book covers various frameworks and features, but also has some cons. Overall, it sets the basis for a decent social network with low usage and quite some features.

<p><p>Another book review, this time about how to build a social network with ASP.NET 4.0.</p>

<p>Note: Free evaluation copy provided by the publisher.</p>

<h3>Review</h3>

<p><img alt="ASP.NET 4 Social Networking" src="https://images.kartones.net/posts/screenshots/book_aspnet4_socialnetwork_packt.jpg"></p>

<p>
<b>Title</b>: <a href="http://www.packtpub.com/asp-net-4-social-networking/book" rel="nofollow">ASP.NET 4 Social Networking</a><br>
<b>Author</b>: Atul Gupta, Sudhanshu Hate, Andrew Siemer<br>
</p>

<p>This book is about how to build a Social Network (a fish owners one as an
example), by using ASP.NET, C# and some frameworks: MEF, EF, ADO.NET EF. </p>

<p>Some of those frameworks are not lightweight but at the same time they are
very ordered and the code is well structured so swapping is easy.</p>

<p>Some interesting points or highlights after reading it:</p>

<p>Uses an events-based newsfeed, same principle as facebook does. Nice details
as being able to hide stuff. </p>

<p>Friendly urls for profiles and other sections, in fact, sometimes is a bit
overabused to search for SEO, when a social network might be more private. But
just having the concept of forums… means the authors wanted to add as much
"social stuff" as possible, even if doesn't't fully fit.</p>

<p>Precalculates and stores different photo sizes on upload (right), but does it
synchronously (wrong, can get to long waits or timeouts).</p>

<p>Lazy loading vs eager loading, the endless discussion (here decides to do
eager loading of some things).</p>

<p>User search is pretty basic, using LINQ to search in a few fields.</p>

<p>Blogs are curiously created: Allow to publish public posts (even with
friendly urls), but doesn't syndicates in a RSS feed so limits that public
exposure.</p>

<p>Builds a forum, quite extrange and atypical in a social network (is among the
RSS one of the things they have semi-killed). Voting, marking forum replies as
answers and user rankings are... a bit out of scope for a social network, more
fit for a pure forum. At least the ratings are correctly decoupled and
system-wide usable (providing good extensibility).</p>

<p>Very simple privacy management in general: Either public or private, with
just some cases of membership/access requests.<br></p>

<p>Last chapter presents scalability advices: Moving to a SOA architecture (with
WCF), separating frontend servers to a farm with load balancing, service servers
and DB tier, caching using AppFabric's Caching component or Memcached. Also
moves the email sending process to a queued, async. system. Also mentions
logical deletion and then system process to wipe deleted items, DB Indexing and
data partitioning (does SQL Server level partitioning instead of handling it via
code), and Lucene.NET for searching.<br> </p>

<p>But also has some cons:</p>

<ul>
<li>Uses database table relationships (referential inegrity via DB), uncommon
due to caching problems
</li>

<li>HTML inside messages in service layers
</li>

<li>Favors code-behind dynamic html generation instead of using subviews
</li>

<li>Stores profile avatar images in the DB (ouch!)
</li>

<li>Friendship defined as one-way relation (instead in the more flexible two-way
friend-friend relation).This results in crap code related to it (like friend
search), because it must have "originator ID is friend of X” OR "destination ID
is friend of X”.
</li>

<li>Presentation entities to lessen the problem of eager loading (but not
avoiding it, just lowering memory usage).
</li>

<li>And the .NET 4 in the name... would have worked equally with 3.5 (I can't
recall anything FW4.0 specific in the book).
</li>

<li>Dynamic attributes idea is nice but not scalable (even less needing to rows
in different tables for each attribute.</li>
</ul>

<p>The book mentions or implements nany tiny details not obvious but even
sometimes missing on large websites (e.g. Terms of Use versioning and tracking
of last accepted version by the users, Easy and mockable configuration
manager).</p>

<p>As for the results, as you could expect, an architecture clean and not badly designed, but that won't scale if the site gets successful and grows. Still, it represents a good start, just don't expect anything exceptional or highly optimized for medium websites.</p>

<p>As a conclusion, the book won't show you groundbreaking secrets nor
incredible algorithms, but will set the basis for a decent social network with
low usage and quite some features. You will probably want to cut out some
unwanted features, but the code is easy to read and well structured. Way better coded than
<a href="https://blog.kartones.net/post/book-review-php-5-social-networking/">other book I reviewed</a>.</p>
