这本书描述了怎么用asp.net c# sql server建一个企业级社交网站,需要你有asp.net 3.5,c#3.0,sql server2005/2008相关开发经验,适合进阶开发人员读的书。

一直以来喜欢看书,不停地看,却没有做笔记的好习惯。有时候回过头来问自己,还能记起看过的书里面的哪些章节,竟说不出半个字!危险。

这真是一种不良的看书习惯呢。至从购置了亚马逊的电纸书-Kindle4,省却了不少看实体书的高额购置费用,可以尽情的下载,可以任何时候捧着看

,阅读进度时时跟随,标记、书签功能一一俱全。阅读乐趣大增。

上一张Kindle4的靓影。是不是很赞?感觉到电子墨水扑面而来的气味了吗?

ASP.NET.3.5.社交网络开发这本书,目前还没用中文版。要看,只有影印版了。

说到英哥利息,很多人都头冒金星,其实我想说,别怕。因为很多书中用到的很多单词重复率都蛮高的,一些生僻的单词结合语境,也完全可以猜出来。不知不觉,词汇量还扩增了呢,何乐而不为?

下面是我摘抄的本书的一些精华片段:

==========
Using interfaces like this is a good design regardless of other technologies such as StructureMap. It really helps to create a loosely coupled environment. Having said that,StructureMap relies heavily on the use of interfaces to define a PluginFamily. All members of the same PluginFamily are located through the process of reflection and grouped by the interfaces that they inherit from (example: person and PersonStub would both inherit IPerson and would therefore be part of the same PluginFamily). So in the interest of saving some space in this book, you can safely assume that for every class that has a pluggable
==========
在这里,作者用到了StructureMap这个.NET开源插件。StructureMap也是.NET环境下的一个轻量级依赖注入工具,StructureMap是一个灵活的、可扩展的通用“插件”机制的.NET IOC框架,支持.NET1.1和2.0。它与Spring.NET比较类似,但是它只支持使用Attribute的方式,而不能通过XML文件来配置,这样虽然显得不够灵活,但是它避免了项目比较大时XML文件的繁琐问题。详细的就不多说了,网上很多教程。

==========

[ASP.NET.3.5.社交网络开发].asp_dot_net_35_social_networking
- Highlight on Page 61 | Added on Tuesday, August 14, 2012, 08:11 PM

I learned a saying in the Army that has served me well, and applies here too: "It is better to have and not need, than need and not have!"
==========

看到Army没有?原来作者还当过兵呢。呵呵,我们天朝估计没有几个程序员是从部队出来的吧?上面的大致意思是说 作者在部队里学到一句话:“拥有,胜过需要!”。这或许就是意味着从根本上 解决了某些问题。因为彻底拥有了,就不会断断续续的去想要。

[ASP.NET.3.5.社交网络开发].asp_dot_net_35_social_networking
- Highlight on Page 65 | Added on Tuesday, August 14, 2012, 09:09 PM

I prefer that we add a settings file for this rather than make entries to our config file. The reason is that we can specify the type of each entry and programmatically access them via the Settings object. In order to add thisSettings.settings file, navigate to the FisharooCore project in Windows Explorer (not in Visual Studio). There, you should have a Properties folder. In this folder, create a new XML file called Settings.settings
==========

这里作者介绍了一种配置文件:Settings.settings。

因 为经常在项目中需要保存一些运行时变量及程序初始化时加载的参数,因此考虑了写一个存储区,专门来存放参数。以前经常喜欢用全局的方式来调用,但是对设计 模式的理解不断深入以后,开始放弃全局的方式。全局的方式虽然用这方便,可是完全公共的属性,任何对象都可以使用,也使得任何人任何时候都不知道谁该了参 数,改成了什么,导致封装性不够良好。   .net的Settings不仅能够存储程序初始化变量,而且能够在运行时更改,保存,以便应用在下次启动程序时。

[ASP.NET.3.5.社交网络开发].asp_dot_net_35_social_networking
- Highlight on Page 111 | Added on Wednesday, August 15, 2012, 07:00 PM

Normally, when speaking in terms of Domain-driven Design, an Entity is considered to be something very important to the system. Unfortunately, as far as LINQ to SQL is concerned, every class that is derived from a table in your database is an Entity. While this is not true DDD, it is an unwritten law of LINQ currently! This does not mean that we are going to create a repository for something like the AccountPermission class that LINQ generated for us. That object is not a true entity in our design! It is simply a way for us to see related permissions for a given account.
==========

这里作者提到了领域模型设计。但作者认为,不能把LINQ生成的实体表类,全部视作领域类。因为有些类只是为了给另外的几个类之间的搭建关联关系的。

LINQ的自动化生成实体类确实方便,但是不能被它所迷惑。

[ASP.NET.3.5.社交网络开发].asp_dot_net_35_social_networking
- Highlight on Page 143 | Added on Thursday, August 16, 2012, 07:25 AM

//FisharooWeb/Images/CaptchaImage/JpegImage.aspx.cs

using System;

using System.Collections;

using System.ComponentModel;

using System.Data; using System.Drawing;

using System.Drawing.Imaging;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using Fisharoo.FisharooCore.Core;

using Fisharoo.FisharooCore.Core.Impl;

using StructureMap;

public partial class JpegImage : System.Web.UI.Page

{

private Random random = new Random();

private IWebContext _webContext;

private void Page_Load(object sender, System.EventArgs e)

{

_webContext = ObjectFactory.GetInstance<IWebContext>();

_webContext.CaptchaImageText = GenerateRandomCode();

ICaptcha ci = ObjectFactory.GetInstance<ICaptcha>();

ci.Text = _webContext.CaptchaImageText;

ci.Width = 200;

ci.Height = 50;

ci.FamilyName = "Century Schoobook";

Response.Clear();

Response.ContentType = "image/jpeg";

ci.Image.Save(Response.OutputStream, ImageFormat.Jpeg);

ci.Dispose();

}

private string GenerateRandomCode()

{

string s = "";

for (int i = 0; i < 6; i++)
              s = String.Concat(s, this.random.Next(10).ToString());

return s;

}

override protected void OnInit(EventArgs e)

{

InitializeComponent();

base.OnInit(e);

}

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

}

}
==========

上面这段就是用StructureMap插件写出来的图片验证逻辑代码。调用方式很简单:<asp:Image runat="server" ImageUrl='~/images/JpegImage.aspx' />

这种方式就像MVP模式中的Presenter层。像一个中介,让UI层彻底与后台逻辑分离掉。

说 到MVP模式,很多人会联想到MVC。[MVP 是从经典的模式MVC演变而来,它们的基本思想有相通的地方:Controller/Presenter负责逻辑的处理,Model提供数据,View负 责显示。作为一种新的模式,MVP与MVC有着一个重大的区别:在MVP中View并不直接使用Model,它们之间的通信是通过Presenter (MVC中的Controller)来进行的,所有的交互都发生在Presenter内部,而在MVC中View会从直接Model中读取数据而不是通过 Controller。  在MVC里,View是可以直接访问Model的!从而,View里会包含Model信息,不可避免的还要包括一些业务逻辑。 在MVC模型里,更关注的Model的不变,而同时有多个对Model的不同显示,及View。所以,在MVC模型里,Model不依赖于View,但是 View是依赖于Model的。不仅如此,因为有一些业务逻辑在View里实现了,导致要更改View也是比较困难的,至少那些业务逻辑是无法重用的。

[ASP.NET.3.5.社交网络开发].asp_dot_net_35_social_networking
- Highlight on Page 193 | Added on Friday, August 17, 2012, 07:53 AM

The thing that is a bit different here is that we are doing this within an overriddenOnInit()method rather than in the Page_Load() method. This is done so that our dynamically rendered controls will exist in ViewState. The Page_Load() method occurs after ViewState is already established. This means that if our dynamic controls were added in Page_Load(). we would not have access to their toggled values after the f irst postback
==========

作者在这里用到了page.OnInit事件。他在该事件里动态的创建了Pesenter层的实例,并保证了它在Page_Load事件触发前会保存在ViewState中()。

[ASP.NET.3.5.社交网络开发].asp_dot_net_35_social_networking
- Highlight on Page 273 | Added on Saturday, August 18, 2012, 08:26 PM

Remember that we are not letting LINQ track our relationships at this point (to avoid built in concurrency management issues). So be sure to remove all the relationships that pop up as you drag your tables on to the design surface.
==========

这里作者警告我们,我们在用linq产生领域类的时候,千万要记得删掉linq自动产生的表间关系,以免产生并发管理问题。

[ASP.NET.3.5.社交网络开发].asp_dot_net_35_social_networking
- Highlight on Page 346 | Added on Wednesday, August 22, 2012, 07:35 AM

public class UrlRewrite : IHttpModule

{

Private IAccountRepository _accountRepository;

private IBlogRepository _blogRepository;

public UrlRewrite()

{

_accountRepository = ObjectFactory.GetInstance<IAccountRepository>();

_blogRepository = ObjectFactory.GetInstance<IBlogRepository>();

}

public void Init(HttpApplication application)

{

//let's register our event handler

application.PostResolveRequestCache += (new EventHandler(this.Application_OnAfterProcess));

}

public void Dispose()

{

}

private void Application_OnAfterProcess(object source, EventArgs e)

{

HttpApplication application = (HttpApplication)source;

HttpContext context = application.Context;

string[] extensionsToExclude = { ".axd", ".jpg", ".gif", ".png", ".xml", ".config", ".css", ". js", ".aspx", ".htm", ".html" };

foreach (string s in extensionsToExclude)

{

if (application.Request.PhysicalPath.ToLower().Contains(s))

return;

}

if (!System.IO.File.Exists(application.Request.PhysicalPath))

{

if (application.Request.PhysicalPath. ToLower().Contains("blogs"))

{

string[] arr = application.Request.PhysicalPath. ToLower().Split(‘\\');

string blogPageName = arr[arr.Length - 1];

string blogUserName = arr[arr.Length - 2];

blogPageName = blogPageName.Replace(".aspx", "");

if (blogPageName.ToLower() != "profileimage" && blogUserName.ToLower() != "profileavatar")

{

Account account = _accountRepository. GetAccountByUsername(blogUserName);
                   Blog blog = _blogRepository.GetBlogByPageName (blogPageName, account.AccountID);

context.RewritePath("~/blogs/ViewPost.aspx?BlogID=" + blog.BlogID.ToString());

}

else

{

return;

}

}

else

{

string username = application.Request.Path.Replace("/", "");

Account account = _accountRepository.GetAccountByUsername(username);

if (account != null)

{

string UserURL = "~/Profiles/profile.aspx?AccountID=" + account.AccountID.ToString();

context.Response.Redirect(UserURL);

else

{

context.Response.Redirect("~/PageNotFound.aspx");

}

}

}}}

In the UrlRewrite class just seen notice that I added a reference to the BlogRepository so that we can get the blog in question if that is indeed what this rewrite is for. Next, notice that I removed the .aspx extension from the list of extensions to exclude it from processing. This is because we want our pages to look like real pages even though they are actually dynamic (read non-existent) resources.
==========

上面这段代码是关于url重写的。作者巧妙的把当前页的URL后缀名“.aspx”移除,这样看起来就像真正的页,就算是本质上是动态资源。友好URL效果大大体现!

[ASP.NET.3.5.社交网络开发].asp_dot_net_35_social_networking
- Highlight on Page 512 | Added on Saturday, August 25, 2012, 07:19 AM

If you need to send hundreds of emails, then you need to possibly make the same amount of connections to an SMTP server. To reduce this slowness, we will build a system that allows us to stuff(填充) our emails into a queue and send the email later from another system. This will greatly improve our users' experience as they will not have to wait for the web server to make a connection to SMTP and send an email. We will instead stuff the email into our queue and assume(假设) that the email will be delivered from another system.
==========

相信大家在工作中或多或少都做过邮件发送模块。都为邮件的发送延迟懊恼不已,因为SMTP协议是通过IIS集成的,会占用一点的延迟时间(微软的错)。

但如果采用一个独立的邮件系统来发送邮件,是不是就可以解决延迟,减轻IIS的压力?我们的WEB系统就只需要负责将邮件插入队列即可。

==========
[ASP.NET.3.5.社交网络开发].asp_dot_net_35_social_networking
- Highlight on Page 515 | Added on Saturday, August 25, 2012, 07:34 AM

Partitioning We will focus on how to build and utilize a partitioned table. Keep in mind that we only need to do this once the database has gotten to a point where it is starting to feel a bit sluggish(缓慢) (actually, you want to do this prior to feeling sluggish!). These are the general steps for creating the horizontal partition.

1. Create filegroups if you want to put the data on multiple physical disks.

This is the best way to feel the most gain out of this particular performance hop up. This way when you are querying across the partition, the work is split up across      multiple disks.

2. Create a partition function. This defines the range that we will be working with.

3. Create a partition scheme. This allows us to specify which partition sits on which filegroup.

4. With these steps out of the way, we can then start to create the partition tables
==========

上面这段 是关于数据库分区的3个步骤。一般数据库上了千万电信级别 是需要分区的。

第一步创建“文件组”,这样数据就可以打散在多个物理硬盘存放。

第二步创建一个分区函数。这个函数会指定每块分区处理多少行记录数。

第三步创建分区策略。这个策略会指定哪个分区安放到哪个文件组上。

[ASP.NET.3.5.社交网络开发].asp_dot_net_35_social_networking
- Highlight on Page 534 | Added on Saturday, August 25, 2012, 09:17 PM

This is where Lucene.NET comes in handy. The thing to know about Lucene.NET is that it works best searching already indexed data. So this is where we will start creating indexes.
==========

作者提到了Lucene.net. 它是Lucene的.net移植版本,是一个开源的全文检索引擎开发包,即它不是一个完整的全文检索引擎,而是一个全文检索引擎的架构,提供了完整的查询引擎和索引引擎。开发人员可以基于Lucene.net实现全文检索的功能。  Lucene.net是Apache软 件基金会赞助的开源项目,基于Apache License协议。  Lucene.net并不是一个爬行搜索引擎,也不会自动地索引内容。我们得先将要索引的文档中的文本抽取出来,然后再将其加到 Lucene.net索引中。标准的步骤是先初始化一个Analyzer、打开一个IndexWriter、然后再将文档一个接一个地加进去。一旦完成这 些步骤,索引就可以在关闭前得到优化,同时所做的改变也会生效。这个过程可能比开发者习惯的方式更加手工化一些,但却在数据的索引上给予你更多的灵活性。 [摘自百度百科]

[ASP.NET.3.5.社交网络开发].asp_dot_net_35_social_networking
- Highlight on Page 545 | Added on Saturday, August 25, 2012, 09:35 PM

To this point we have discussed speeding up the site from a database point of view, a hardware point of view, an indexing point of view, and a caching point of view. I am sure that it didn't take you too much convincing that all these are wise places to look for eking that last bit of performance out of your site.
==========

这里作者对如何优化一个WEB系统性能,特别是作为一个社交网络的系统,的一些国外常用建议。

有数据库层面,有硬件层面,有索引层面,有缓存层面等等。

看一下老外优雅的数据库设计方案。

我们会发现:

1)       全部采用了骆驼式命名法(Camel-Case)。而我们可能数据库的命名方式千奇百怪,就像江湖中的三教九流来黑木崖聚会一样。

骆驼的由来:   例如,mmyFirstName、myLastName,这样的变量名看上去就像骆驼峰一样此起彼伏,故得名。

2)     表名 后缀“s”: 这样很好的体现了领域是一个集合。

3)     主键ID命名方式: 领域名+ID。

4)     衍射关系表命名方式:领域A名称+领域B名称+"s".

5)     衍射关系表的ID:直接命名为ID即可。

强烈建议那些想立志开发一套开心网、校内网、FaceBook类似系统的朋友们拿起这本书。

附下载地址一枚:http://www.verycd.com/topics/2747422/

也欢迎喜欢写博客的朋友,跟我交流读书感受。

写一本书真的好难,写一本对读者有用的书更是难。做笔记或许是对著者一种最好的致敬方式了。

觉得本文对您起到一些微薄的帮助,就帮我吼一声:顶!留下你的脚印,让我知道您曾经来过。

欢迎访问我的CSDN博客http://blog.csdn.net/UnOpenMyCode

转载于:https://www.cnblogs.com/eman730/archive/2012/08/29/2662663.html

ASP.NET.3.5.社交网络开发[影印版]读书笔记相关推荐

  1. iPhone与iPad开发实战读书笔记

    iPhone开发一些读书笔记 手机应用分类 1.教育工具 2.生活工具 3.社交应用 4.定位工具 5.游戏 6.报纸和杂志的阅读器 7.移动办公应用 8.财经工具 9.手机购物应用 10.风景区相关 ...

  2. JAVA WEB整合开发王者归来 -- 读书笔记 by CZF 完整版

    JAVA WEB整合开发王者归来 -- 读书笔记  目录 第1章 概述. 1 第2章 搭建web开发环境. 1 第3章 Servlet技术. 1 第4章 深入JSP技术. 7 第5章 会话跟踪. 12 ...

  3. javascript设计模式(javascript设计模式与开发实践读书笔记)

    javascript设计模式(javascript设计模式与开发实践读书笔记) 单例模式 策略模式 代理模式 迭代器模式 发布-订阅模式 命令模式 组合模式 模板方法模式 享元模式 职责链模式 中介者 ...

  4. 《HTML5 Canvas核心技术 图形、动画与游戏开发》 读书笔记

    <HTML5 Canvas核心技术 图形.动画与游戏开发> 读书笔记 文章目录 <HTML5 Canvas核心技术 图形.动画与游戏开发> 读书笔记 第1章 基础知识 第2章 ...

  5. 《ASP.NET Core 微服务实战》-- 读书笔记(第11章)

    第 11 章 开发实时应用和服务 在本章,我们将讨论"实时"的准确含义,以及在大部分消费者看来应该属于这一范畴的应用类型 接着,我们将探讨 WebSocket,并分析为什么传统的 ...

  6. 《ASP.NET Core 微服务实战》-- 读书笔记(第10章)

    第 10 章 应用和微服务安全 云应用意味着应用运行所在的基础设施无法掌控,因此安全不能再等到事后再考虑,也不能只是检查清单上毫无意义的复选框 由于安全与云原生应用密切相关,本章将讨论安全话题,并用示 ...

  7. 《ASP.NET Core 微服务实战》-- 读书笔记(第9章)

    第 9 章 微服务系统的配置 微服务系统中的配置需要关注更多其他方面的因素,包括: 配置值的安全读写 值变更的审计能力 配置信息源本身的韧性和可靠性 少量的环境变量难以承载大型.复杂的配置信息 应用要 ...

  8. 《ASP.NET Core 微服务实战》-- 读书笔记(第7章)

    第 7 章 开发 ASP.NET Core Web 应用 ASP.NET Core 基础 在本章,我们将从一个命令行应用开始,并且在不借助任何模板,脚手架和向导的情况下,最终得到一个功能完整的 Web ...

  9. 《ASP.NET Core 微服务实战》-- 读书笔记(第3章)

    第 3 章 使用 ASP.NET Core 开发微服务 微服务定义 微服务是一个支持特定业务场景的独立部署单元.它借助语义化版本管理.定义良好的 API 与其他后端服务交互.它的天然特点就是严格遵守单 ...

最新文章

  1. js 判断js,css是否引入,确保不重复引入
  2. 《数字逻辑设计与计算机组成》一3.3 加法器
  3. 69.2. wget - retrieves files from the web
  4. 《 测试反模式:有效规避常见的92种测试陷阱》——1.3 什么是缺陷
  5. MySQL Transaction--快照读和当前读
  6. windows python读取grib2数据
  7. boost::parameter::aux::maybe相关的测试程序
  8. Python中的WSGI
  9. 爬取网页的通用代码框架
  10. 远程linux服务器,安装集成的xampp,本地电脑远程连接数据库进行使用
  11. 线程1-线程常用方法
  12. 数码照片像素与可冲印照片尺寸对照表
  13. 计算机网络说明文,《Wi-Fi》初中说明文阅读题及答案
  14. 康考迪亚大学 计算机科学,康考迪亚大学 Concordia University
  15. 实验三 面向对象(二)(预习报告)
  16. python绿色蓝色代表什么_蓝绿黄车牌识别(Python)
  17. 小米校招 C++研发 相机部 一二面
  18. 在LINUX如何用键盘复制,粘贴
  19. python 操作 csv 编码问题,繁体字体乱码
  20. 都说幕布适合写作,但是你知道 Effie 吗?

热门文章

  1. excel两个表格数据对比_Excel表格技巧—如何让两个Excel表格同时显示
  2. DeepLearning(李沐老师)
  3. 【企业】如实利用 250 定律,服务好客户
  4. 冒号课堂:知识之上是思想,思想之上是精神
  5. 2014年总结——工匠精神篇
  6. ABP Asp.net core 创建一个http get 请求
  7. ROS学习(3)——仿真平台搭建
  8. 变频器的常用参数设置(古月金真著)
  9. 使用python实现正态分布检验
  10. C++类和对象,结构体