<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>kevin Mocha - Life | Career</title>
    <link>http://blog.ilovedoudou.com/</link>
    <description>Bookmarks collected from web.</description>
    <language>en-us</language>
    <copyright>Kevin Mocha</copyright>
    <lastBuildDate>Fri, 30 Jul 2010 14:37:29 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.9.6264.0</generator>
    <managingEditor>lulustock@gmail.com</managingEditor>
    <webMaster>lulustock@gmail.com</webMaster>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=9dd16a1e-f68e-4878-a2e0-ebcfd18f971a</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,9dd16a1e-f68e-4878-a2e0-ebcfd18f971a.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,9dd16a1e-f68e-4878-a2e0-ebcfd18f971a.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=9dd16a1e-f68e-4878-a2e0-ebcfd18f971a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a title="http://www.project-management-podcast.com/" href="http://www.project-management-podcast.com/">http://www.project-management-podcast.com/</a>
        </p>
        <p>
          <a title="http://www.project-management-prepcast.com/" href="http://www.project-management-prepcast.com/">http://www.project-management-prepcast.com/</a>
        </p>
        <p>
          <a title="http://www.pmi.org/PDF/pdc_pmphandbook.pdf" href="http://www.pmi.org/PDF/pdc_pmphandbook.pdf">http://www.pmi.org/PDF/pdc_pmphandbook.pdf</a>
        </p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=9dd16a1e-f68e-4878-a2e0-ebcfd18f971a" />
      </body>
      <title>PMP Resource</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,9dd16a1e-f68e-4878-a2e0-ebcfd18f971a.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,9dd16a1e-f68e-4878-a2e0-ebcfd18f971a.aspx</link>
      <pubDate>Fri, 30 Jul 2010 14:37:29 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a title="http://www.project-management-podcast.com/" href="http://www.project-management-podcast.com/"&gt;http://www.project-management-podcast.com/&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://www.project-management-prepcast.com/" href="http://www.project-management-prepcast.com/"&gt;http://www.project-management-prepcast.com/&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://www.pmi.org/PDF/pdc_pmphandbook.pdf" href="http://www.pmi.org/PDF/pdc_pmphandbook.pdf"&gt;http://www.pmi.org/PDF/pdc_pmphandbook.pdf&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=9dd16a1e-f68e-4878-a2e0-ebcfd18f971a" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,9dd16a1e-f68e-4878-a2e0-ebcfd18f971a.aspx</comments>
      <category>Life / Career</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=1750104e-60e9-49d0-994b-884d8d5710a4</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,1750104e-60e9-49d0-994b-884d8d5710a4.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,1750104e-60e9-49d0-994b-884d8d5710a4.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1750104e-60e9-49d0-994b-884d8d5710a4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Vulnerability Scanners<br />
Discovery Tools<br />
Port Scanners<br />
Sniffers<br />
Password Crackers<br />
Intrusion Detection System (snort, ISS RealSecure)<br />
Firewalls<br />
Denial-of-Services Attacks
</p>
        <p>
Algorithm 
<br />
RSA (Factorization Problem) 
<br />
Eclipse Curve (Discrete Logarithm)<br />
Diffie-Hellman (DHP) 
</p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=1750104e-60e9-49d0-994b-884d8d5710a4" />
      </body>
      <title>Security</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,1750104e-60e9-49d0-994b-884d8d5710a4.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,1750104e-60e9-49d0-994b-884d8d5710a4.aspx</link>
      <pubDate>Wed, 05 May 2010 03:43:14 GMT</pubDate>
      <description>&lt;p&gt;
Vulnerability Scanners&lt;br&gt;
Discovery Tools&lt;br&gt;
Port Scanners&lt;br&gt;
Sniffers&lt;br&gt;
Password Crackers&lt;br&gt;
Intrusion Detection System (snort, ISS RealSecure)&lt;br&gt;
Firewalls&lt;br&gt;
Denial-of-Services Attacks
&lt;/p&gt;
&lt;p&gt;
Algorithm 
&lt;br&gt;
RSA (Factorization Problem) 
&lt;br&gt;
Eclipse Curve (Discrete Logarithm)&lt;br&gt;
Diffie-Hellman (DHP) 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=1750104e-60e9-49d0-994b-884d8d5710a4" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,1750104e-60e9-49d0-994b-884d8d5710a4.aspx</comments>
      <category>Life / Career</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=bf2451c3-6dfe-41b5-b2da-e6c08bf38a3a</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,bf2451c3-6dfe-41b5-b2da-e6c08bf38a3a.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,bf2451c3-6dfe-41b5-b2da-e6c08bf38a3a.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=bf2451c3-6dfe-41b5-b2da-e6c08bf38a3a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a title="http://www.dotnetfunda.com/interview/ShowCatQuestion.aspx?category=34" href="http://www.dotnetfunda.com/interview/ShowCatQuestion.aspx?category=34">http://www.dotnetfunda.com/interview/ShowCatQuestion.aspx?category=34</a>
        </p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=bf2451c3-6dfe-41b5-b2da-e6c08bf38a3a" />
      </body>
      <title>Interview Resources</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,bf2451c3-6dfe-41b5-b2da-e6c08bf38a3a.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,bf2451c3-6dfe-41b5-b2da-e6c08bf38a3a.aspx</link>
      <pubDate>Mon, 29 Mar 2010 04:05:49 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a title="http://www.dotnetfunda.com/interview/ShowCatQuestion.aspx?category=34" href="http://www.dotnetfunda.com/interview/ShowCatQuestion.aspx?category=34"&gt;http://www.dotnetfunda.com/interview/ShowCatQuestion.aspx?category=34&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=bf2451c3-6dfe-41b5-b2da-e6c08bf38a3a" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,bf2451c3-6dfe-41b5-b2da-e6c08bf38a3a.aspx</comments>
      <category>DotNet;Life / Career</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=2e9d170a-7f75-410a-ba30-9d85e800ad61</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,2e9d170a-7f75-410a-ba30-9d85e800ad61.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,2e9d170a-7f75-410a-ba30-9d85e800ad61.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=2e9d170a-7f75-410a-ba30-9d85e800ad61</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a title="http://www.codeproject.com/KB/webservices/Programming_WCF.aspx" href="http://www.codeproject.com/KB/webservices/Programming_WCF.aspx">http://www.codeproject.com/KB/webservices/Programming_WCF.aspx</a>
        </p>
        <p>
The WCF programming model unifies <a href="http://en.wikipedia.org/wiki/Web_Services">Web
Services</a>, <a href="http://en.wikipedia.org/wiki/.NET_Remoting">.NET Remoting</a>, <a href="http://en.wikipedia.org/wiki/Microsoft_Transaction_Server">Distributed
Transactions</a>, and <a href="http://en.wikipedia.org/wiki/Microsoft_Message_Queuing">Message
Queues</a> into a single <a href="http://en.wikipedia.org/wiki/Service-oriented_architecture">Service-oriented
programming</a> model for <a href="http://en.wikipedia.org/wiki/Distributed_computing">distributed
computing</a>. WCF uses <a href="http://en.wikipedia.org/wiki/SOAP">SOAP</a> messages
for communication between two processes, thereby making WCF-based applications interoperable
with any other process that communicates via SOAP messages.
</p>
        <p>
A WCF Service is composed of three components parts viz, 
</p>
        <p>
1) <strong>Service Class -</strong> A WCF service class implements some service as
a set of methods. 
</p>
        <p>
2) <strong>Host Environment</strong> - A Host environment can be a Console application
or a Windows Service or a Windows Forms application or IIS as in case of the normal
asmx web service in .NET. 
</p>
        <p>
3) <strong>Endpoints</strong> - All communications with the WCF service will happen
via the endpoints. The endpoint is composed of 3 parts (collectively called as ABC's
of endpoint) as defines below: 
</p>
        <p>
          <strong>Address: </strong>The endpoints specify a Address that defines where the endpoint
is hosted. 
</p>
        <p>
          <strong>Contract: </strong>The endpoints specify a Contract that defines which methods
of the Service class will be accessible via the endpoint; each endpoint may expose
a different set of methods. 
</p>
        <p>
          <strong>Binding: </strong>The endpoints also define a binding that specifies how a
client will communicate with the service and the address where the endpoint is hosted.Various
components of the WCF are depicted in the figure below. 
</p>
        <p>
          <img alt="Screenshot - WCF_Arch.gif" src="http://www.codeproject.com/KB/webservices/Programming_WCF/WCF_Arch.gif" width="398" height="164" />
        </p>
        <p>
Who How What
</p>
        <p>
There are three types of contracts namely,
</p>
        <p>
          <strong>Service Contracts - </strong>Describes the operations a service can perform.
Maps CLR types to WSDL.<br /><strong>Data Contracts</strong> - Describes a data structure. Maps CLR types to XSD.<br /><strong>Messaga Contracts - </strong>Defines the structure of the message on the wire.
Maps CLR types to SOAP messages.
</p>
        <p>
Bindings can be defined in config file as well as programattically.
</p>
        <p>
Services have behaviors that control their concurrency, throttling, transactions,<br />
security, and other system semantics. 
</p>
        <p>
  
</p>
        <p>
Metadata in WCF refers to the information that describes precisely how to<br />
communicate with a service. Clients can request metadata from a running<br />
service to learn about their endpoints and the message formats that they 
</p>
        <p>
require. At design time, clients send a request message defined by the<br />
WS-MetadataExchange standard and receive WSDL in return. The WSDL<br />
can be used by the client to define a proxy class and configuration file that<br />
will later be used at runtime to communicate with the service. Figure 1.4<br />
shows this interaction. 
</p>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/WCFOverview_D799/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/WCFOverview_D799/image_thumb.png" width="424" height="205" />
          </a>
        </p>
        <p>
Use svcutil.exe to generate the proxy code
</p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=2e9d170a-7f75-410a-ba30-9d85e800ad61" />
      </body>
      <title>WCF Overview</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,2e9d170a-7f75-410a-ba30-9d85e800ad61.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,2e9d170a-7f75-410a-ba30-9d85e800ad61.aspx</link>
      <pubDate>Tue, 09 Mar 2010 20:17:35 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a title="http://www.codeproject.com/KB/webservices/Programming_WCF.aspx" href="http://www.codeproject.com/KB/webservices/Programming_WCF.aspx"&gt;http://www.codeproject.com/KB/webservices/Programming_WCF.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The WCF programming model unifies &lt;a href="http://en.wikipedia.org/wiki/Web_Services"&gt;Web
Services&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/.NET_Remoting"&gt;.NET Remoting&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Microsoft_Transaction_Server"&gt;Distributed
Transactions&lt;/a&gt;, and &lt;a href="http://en.wikipedia.org/wiki/Microsoft_Message_Queuing"&gt;Message
Queues&lt;/a&gt; into a single &lt;a href="http://en.wikipedia.org/wiki/Service-oriented_architecture"&gt;Service-oriented
programming&lt;/a&gt; model for &lt;a href="http://en.wikipedia.org/wiki/Distributed_computing"&gt;distributed
computing&lt;/a&gt;. WCF uses &lt;a href="http://en.wikipedia.org/wiki/SOAP"&gt;SOAP&lt;/a&gt; messages
for communication between two processes, thereby making WCF-based applications interoperable
with any other process that communicates via SOAP messages.
&lt;/p&gt;
&lt;p&gt;
A WCF Service is composed of three components parts viz, 
&lt;p&gt;
1) &lt;strong&gt;Service Class -&lt;/strong&gt; A WCF service class implements some service as
a set of methods. 
&lt;p&gt;
2) &lt;strong&gt;Host Environment&lt;/strong&gt; - A Host environment can be a Console application
or a Windows Service or a Windows Forms application or IIS as in case of the normal
asmx web service in .NET. 
&lt;p&gt;
3) &lt;strong&gt;Endpoints&lt;/strong&gt; - All communications with the WCF service will happen
via the endpoints. The endpoint is composed of 3 parts (collectively called as ABC's
of endpoint) as defines below: 
&lt;p&gt;
&lt;strong&gt;Address: &lt;/strong&gt;The endpoints specify a Address that defines where the endpoint
is hosted. 
&lt;p&gt;
&lt;strong&gt;Contract: &lt;/strong&gt;The endpoints specify a Contract that defines which methods
of the Service class will be accessible via the endpoint; each endpoint may expose
a different set of methods. 
&lt;p&gt;
&lt;strong&gt;Binding: &lt;/strong&gt;The endpoints also define a binding that specifies how a
client will communicate with the service and the address where the endpoint is hosted.Various
components of the WCF are depicted in the figure below. 
&lt;p&gt;
&lt;img alt="Screenshot - WCF_Arch.gif" src="http://www.codeproject.com/KB/webservices/Programming_WCF/WCF_Arch.gif" width="398" height="164"&gt; 
&lt;p&gt;
Who How What
&lt;/p&gt;
&lt;p&gt;
There are three types of contracts namely,
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Service Contracts - &lt;/strong&gt;Describes the operations a service can perform.
Maps CLR types to WSDL.&lt;br&gt;
&lt;strong&gt;Data Contracts&lt;/strong&gt; - Describes a data structure. Maps CLR types to XSD.&lt;br&gt;
&lt;strong&gt;Messaga Contracts - &lt;/strong&gt;Defines the structure of the message on the wire.
Maps CLR types to SOAP messages.
&lt;/p&gt;
&lt;p&gt;
Bindings can be defined in config file as well as programattically.
&lt;/p&gt;
&lt;p&gt;
Services have behaviors that control their concurrency, throttling, transactions,&lt;br&gt;
security, and other system semantics. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Metadata in WCF refers to the information that describes precisely how to&lt;br&gt;
communicate with a service. Clients can request metadata from a running&lt;br&gt;
service to learn about their endpoints and the message formats that they 
&lt;p&gt;
require. At design time, clients send a request message defined by the&lt;br&gt;
WS-MetadataExchange standard and receive WSDL in return. The WSDL&lt;br&gt;
can be used by the client to define a proxy class and configuration file that&lt;br&gt;
will later be used at runtime to communicate with the service. Figure 1.4&lt;br&gt;
shows this interaction. 
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/WCFOverview_D799/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/WCFOverview_D799/image_thumb.png" width="424" height="205"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Use svcutil.exe to generate the proxy code
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=2e9d170a-7f75-410a-ba30-9d85e800ad61" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,2e9d170a-7f75-410a-ba30-9d85e800ad61.aspx</comments>
      <category>DotNet;Life / Career</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=bc74545d-dbbc-4b34-bfd8-238e1e472dff</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,bc74545d-dbbc-4b34-bfd8-238e1e472dff.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,bc74545d-dbbc-4b34-bfd8-238e1e472dff.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=bc74545d-dbbc-4b34-bfd8-238e1e472dff</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a title="http://en.wikipedia.org/wiki/Component-oriented_programming" href="http://en.wikipedia.org/wiki/Component-oriented_programming">http://en.wikipedia.org/wiki/Component-oriented_programming</a>
        </p>
        <p>
The main idea is <i>separation of concerns</i>;
</p>
        <p>
Software engineers regard components as part of the starting platform for service
orientation. Components play this role, for example, in <a href="http://en.wikipedia.org/wiki/Web_Services">Web
Services</a>, and more recently, in <a href="http://en.wikipedia.org/wiki/Service-oriented_architecture">Service-Oriented
Architecture (SOA)</a> - whereby a component is converted<sup>[<i><a href="http://en.wikipedia.org/wiki/Wikipedia:Avoid_weasel_words">by
whom?</a></i>]</sup> into a <i>service</i> and subsequently inherits further characteristics
beyond that of an ordinary component.
</p>
        <p>
An individual component is a software package or a <a href="http://en.wikipedia.org/wiki/Modular_programming">module</a> that
encapsulates a set of related functions (or data).
</p>
        <p>
All system processes are placed into separate components so that all of the data and
functions inside each component are semantically related (just as with the contents
of classes). Because of this principle, it is often said that components are <i>modular</i> and <i>cohesive</i>.
</p>
        <p>
With regard to system-wide co-ordination, components communicate with each other <strong>via <i>interfaces</i></strong>.
When a component offers services to the rest of the system, it adopts a <i>provided</i> interface
which specifies the services that can be utilized by other components and how. This
interface can be seen as a <strong>signature</strong> of the component - the client
does not need to know about the inner workings of the component (implementation) in
order to make use of it. This principle results in components referred to as <i><strong><font color="#ff0000">encapsulated</font></strong></i>.
</p>
        <p>
Another important attribute of components is that they are <i><strong><font color="#ff0000">substitutable</font></strong></i>,
</p>
        <p>
Software components often take <strong>the form of </strong><a href="http://en.wikipedia.org/wiki/Object_%28computing%29"><strong>objects</strong></a><strong> or
collections of objects</strong> (from <a href="http://en.wikipedia.org/wiki/Object-oriented_programming">object-oriented
programming</a>), in some binary or textual form, adhering to some <a href="http://en.wikipedia.org/wiki/Interface_description_language">interface
description language</a> (IDL) so that the component may exist autonomously from other
components in a <a href="http://en.wikipedia.org/wiki/Computer">computer</a>.
</p>
        <p>
          <a href="http://en.wikipedia.org/wiki/Reusability">
            <strong>
              <font color="#ff0000">Reusability</font>
            </strong>
          </a> is
an important characteristic of a high-quality software component. A software component
should be designed and implemented so that it can be reused in many different programs. 
</p>
        <p>
It takes significant effort and awareness to write a software component that is effectively
reusable. The component needs to be: 
</p>
        <ul>
          <li>
fully documented 
</li>
          <li>
thoroughly tested 
<ul><li>
robust - with comprehensive input-validity checking 
</li><li>
able to pass back appropriate <a href="http://en.wikipedia.org/wiki/Error_message">error
messages</a> or return codes 
</li></ul></li>
          <li>
designed with an awareness that it <i>will</i> be put to unforeseen uses 
</li>
        </ul>
        <h4>Differences from object-oriented programming
</h4>
        <p>
Proponents of <a href="http://en.wikipedia.org/wiki/Object-oriented_programming">object-oriented
programming</a> (OOP) maintain that software should be written according to a mental
model of the actual or imagined objects it represents. OOP and the related disciplines
of <a href="http://en.wikipedia.org/wiki/Object-oriented_design">object-oriented design</a> and <a href="http://en.wikipedia.org/wiki/Object-oriented_analysis">object-oriented
analysis</a> focus on modeling real-world<sup>[<i><a href="http://en.wikipedia.org/wiki/Wikipedia:Citation_needed">citation
needed</a></i>]</sup> interactions and attempting to create "verbs" and "nouns" which
can be used in intuitive<sup>[<i><a href="http://en.wikipedia.org/wiki/Wikipedia:Citation_needed">citation
needed</a></i>]</sup> ways, ideally by end users as well as by programmers coding
for those end users. 
</p>
        <p>
Component-based software engineering, by contrast, makes no such assumptions, and
instead states that developers should construct software by gluing together prefabricated
components - much like in the fields of <a href="http://en.wikipedia.org/wiki/Electronics">electronics</a> or <a href="http://en.wikipedia.org/wiki/Mechanics">mechanics</a>.
Some peers<sup>[<i><a href="http://en.wikipedia.org/wiki/Wikipedia:Avoid_weasel_words">who?</a></i>]</sup> will
even talk of modularizing systems as software components as a new <a href="http://en.wikipedia.org/wiki/Programming_paradigm">programming
paradigm</a>. 
</p>
        <p>
  
</p>
        <p>
  
</p>
        <p>
  
</p>
        <p>
          <em>
            <strong>
              <font color="#0080ff">Component-based development (CBD) is an extension
of object-oriented programming. CBD does away with the language and vendor-specific
limitations of OOP, and makes software reuse more practical and accelerates the development
process. Event-based programming is the next logical step in CBD, and makes components
more reusable due to their decoupled nature. But event-based systems are easier to
develop, which means they are cheaper and more reliable than traditional OOP or CBD
systems.</font>
            </strong>
          </em>
          <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=bc74545d-dbbc-4b34-bfd8-238e1e472dff" />
        </p>
      </body>
      <title>Component-Oriented Programming</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,bc74545d-dbbc-4b34-bfd8-238e1e472dff.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,bc74545d-dbbc-4b34-bfd8-238e1e472dff.aspx</link>
      <pubDate>Tue, 09 Mar 2010 19:22:24 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a title="http://en.wikipedia.org/wiki/Component-oriented_programming" href="http://en.wikipedia.org/wiki/Component-oriented_programming"&gt;http://en.wikipedia.org/wiki/Component-oriented_programming&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The main idea is &lt;i&gt;separation of concerns&lt;/i&gt;;
&lt;/p&gt;
&lt;p&gt;
Software engineers regard components as part of the starting platform for service
orientation. Components play this role, for example, in &lt;a href="http://en.wikipedia.org/wiki/Web_Services"&gt;Web
Services&lt;/a&gt;, and more recently, in &lt;a href="http://en.wikipedia.org/wiki/Service-oriented_architecture"&gt;Service-Oriented
Architecture (SOA)&lt;/a&gt; - whereby a component is converted&lt;sup&gt;[&lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Wikipedia:Avoid_weasel_words"&gt;by
whom?&lt;/a&gt;&lt;/i&gt;]&lt;/sup&gt; into a &lt;i&gt;service&lt;/i&gt; and subsequently inherits further characteristics
beyond that of an ordinary component.
&lt;/p&gt;
&lt;p&gt;
An individual component is a software package or a &lt;a href="http://en.wikipedia.org/wiki/Modular_programming"&gt;module&lt;/a&gt; that
encapsulates a set of related functions (or data).
&lt;/p&gt;
&lt;p&gt;
All system processes are placed into separate components so that all of the data and
functions inside each component are semantically related (just as with the contents
of classes). Because of this principle, it is often said that components are &lt;i&gt;modular&lt;/i&gt; and &lt;i&gt;cohesive&lt;/i&gt;.
&lt;/p&gt;
&lt;p&gt;
With regard to system-wide co-ordination, components communicate with each other &lt;strong&gt;via &lt;i&gt;interfaces&lt;/i&gt;&lt;/strong&gt;.
When a component offers services to the rest of the system, it adopts a &lt;i&gt;provided&lt;/i&gt; interface
which specifies the services that can be utilized by other components and how. This
interface can be seen as a &lt;strong&gt;signature&lt;/strong&gt; of the component - the client
does not need to know about the inner workings of the component (implementation) in
order to make use of it. This principle results in components referred to as &lt;i&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;encapsulated&lt;/font&gt;&lt;/strong&gt;&lt;/i&gt;.
&lt;/p&gt;
&lt;p&gt;
Another important attribute of components is that they are &lt;i&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;substitutable&lt;/font&gt;&lt;/strong&gt;&lt;/i&gt;,
&lt;/p&gt;
&lt;p&gt;
Software components often take &lt;strong&gt;the form of &lt;/strong&gt;&lt;a href="http://en.wikipedia.org/wiki/Object_%28computing%29"&gt;&lt;strong&gt;objects&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; or
collections of objects&lt;/strong&gt; (from &lt;a href="http://en.wikipedia.org/wiki/Object-oriented_programming"&gt;object-oriented
programming&lt;/a&gt;), in some binary or textual form, adhering to some &lt;a href="http://en.wikipedia.org/wiki/Interface_description_language"&gt;interface
description language&lt;/a&gt; (IDL) so that the component may exist autonomously from other
components in a &lt;a href="http://en.wikipedia.org/wiki/Computer"&gt;computer&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://en.wikipedia.org/wiki/Reusability"&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;Reusability&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; is
an important characteristic of a high-quality software component. A software component
should be designed and implemented so that it can be reused in many different programs. 
&lt;p&gt;
It takes significant effort and awareness to write a software component that is effectively
reusable. The component needs to be: 
&lt;ul&gt;
&lt;li&gt;
fully documented 
&lt;li&gt;
thoroughly tested 
&lt;ul&gt;
&lt;li&gt;
robust - with comprehensive input-validity checking 
&lt;li&gt;
able to pass back appropriate &lt;a href="http://en.wikipedia.org/wiki/Error_message"&gt;error
messages&lt;/a&gt; or return codes 
&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
designed with an awareness that it &lt;i&gt;will&lt;/i&gt; be put to unforeseen uses 
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Differences from object-oriented programming
&lt;/h4&gt;
&lt;p&gt;
Proponents of &lt;a href="http://en.wikipedia.org/wiki/Object-oriented_programming"&gt;object-oriented
programming&lt;/a&gt; (OOP) maintain that software should be written according to a mental
model of the actual or imagined objects it represents. OOP and the related disciplines
of &lt;a href="http://en.wikipedia.org/wiki/Object-oriented_design"&gt;object-oriented design&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Object-oriented_analysis"&gt;object-oriented
analysis&lt;/a&gt; focus on modeling real-world&lt;sup&gt;[&lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Wikipedia:Citation_needed"&gt;citation
needed&lt;/a&gt;&lt;/i&gt;]&lt;/sup&gt; interactions and attempting to create "verbs" and "nouns" which
can be used in intuitive&lt;sup&gt;[&lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Wikipedia:Citation_needed"&gt;citation
needed&lt;/a&gt;&lt;/i&gt;]&lt;/sup&gt; ways, ideally by end users as well as by programmers coding
for those end users. 
&lt;p&gt;
Component-based software engineering, by contrast, makes no such assumptions, and
instead states that developers should construct software by gluing together prefabricated
components - much like in the fields of &lt;a href="http://en.wikipedia.org/wiki/Electronics"&gt;electronics&lt;/a&gt; or &lt;a href="http://en.wikipedia.org/wiki/Mechanics"&gt;mechanics&lt;/a&gt;.
Some peers&lt;sup&gt;[&lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Wikipedia:Avoid_weasel_words"&gt;who?&lt;/a&gt;&lt;/i&gt;]&lt;/sup&gt; will
even talk of modularizing systems as software components as a new &lt;a href="http://en.wikipedia.org/wiki/Programming_paradigm"&gt;programming
paradigm&lt;/a&gt;. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;em&gt;&lt;strong&gt;&lt;font color="#0080ff"&gt;Component-based development (CBD) is an extension
of object-oriented programming. CBD does away with the language and vendor-specific
limitations of OOP, and makes software reuse more practical and accelerates the development
process. Event-based programming is the next logical step in CBD, and makes components
more reusable due to their decoupled nature. But event-based systems are easier to
develop, which means they are cheaper and more reliable than traditional OOP or CBD
systems.&lt;/font&gt;&lt;/strong&gt;&lt;/em&gt;&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=bc74545d-dbbc-4b34-bfd8-238e1e472dff" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,bc74545d-dbbc-4b34-bfd8-238e1e472dff.aspx</comments>
      <category>Design;Life / Career</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=2f2a66c4-a599-4a92-bfa1-7f859162fb34</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,2f2a66c4-a599-4a92-bfa1-7f859162fb34.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,2f2a66c4-a599-4a92-bfa1-7f859162fb34.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=2f2a66c4-a599-4a92-bfa1-7f859162fb34</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Web 2.0 addresses the new web technologies that are used to bring more <strong>interactivity</strong> to
web<br />
applications. 
</p>
        <p>
Additionally, Web 2.0 also includes a behavioral shift on the web, where users are<br />
encouraged to customize their own content on web applications rather than view static/<br />
generic content supplied by an organization.
</p>
        <p>
In addition to the technology and behavior changes, Web 2.0 can also mean the shift<br />
from shrink-wrapped software to software as a service. 
</p>
        <p>
  
</p>
        <p>
Another aspect of Web 2.0 are mash-up and plug-in pages. (Personal google page) 
</p>
        <p>
  
</p>
        <p>
Injection attacks are based on a single problem that persists in many technologies:
namely,<br />
no strict separation exists between program instructions and user data (also referred
to as<br />
user input). This problem allows for attackers to sneak program instructions into
places<br />
where the developer expected only benign data. By sneaking in program instructions,
the<br />
attacker can instruct the program to perform actions of the attacker’s choosing. 
</p>
        <p>
  
</p>
        <p>
          <strong>
            <font color="#0000ff" size="3">Input Injection</font>
          </strong>
        </p>
        <p>
          <strong>
          </strong>  
</p>
        <p>
          <strong>SQL Injection</strong>
        </p>
        <p>
  
</p>
        <p>
SELECT id FROM user_table WHERE username = '' <font color="#ff0000">OR 1=1 -- </font>'
AND password<br />
= PASSWORD('x') 
</p>
        <p>
  
</p>
        <p>
Injection attacks are not necessary blind attacks. Many web applications are developed<br />
with open-source tools. To make injection attacks more successful, download free or<br />
evaluation copies of products and set up your own test system. Once you have found
an<br />
error in your test system, it is highly probable that the same issue will exist on
all web<br />
applications using that tool. 
</p>
        <p>
  
</p>
        <p>
Cure: 1. constrain data types, escape user input, prepared statements (the best) 
</p>
        <p>
  
</p>
        <p>
          <strong>XPath Injection</strong>
        </p>
        <p>
//users[username/text()='admin' and password/text()='' or '1'='1' ]/id/text() 
</p>
        <p>
  
</p>
        <p>
          <strong>Command Injection </strong>(Escape) 
</p>
        <p>
          <strong>Directory Transversal Attacks<br />
XXE (XML eXternal Entity) Attacks </strong>(prohibit the external entity in XML parser) 
</p>
        <p>
          <strong>LDAP Injection<br /></strong>whitelisting characters—that is, allow<br />
alphanumeric characters (a–z, A–Z, and 0–9) and deny all other characters.<br /><strong>Buffer Overflows</strong><br />
The injection aspect of buffer overflows is that the attacker injects<br />
machine instructions (called shell code) into some user input. The attacker somewhat
needs to<br />
know where the shell code will end up in the memory of the computer running the web<br />
application. Then the attacker overwrites the return address to point to the memory
location<br />
of the shell code. <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=2f2a66c4-a599-4a92-bfa1-7f859162fb34" /></p>
      </body>
      <title>Web 2.0 Security (part 1)</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,2f2a66c4-a599-4a92-bfa1-7f859162fb34.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,2f2a66c4-a599-4a92-bfa1-7f859162fb34.aspx</link>
      <pubDate>Sun, 07 Mar 2010 05:08:42 GMT</pubDate>
      <description>&lt;p&gt;
Web 2.0 addresses the new web technologies that are used to bring more &lt;strong&gt;interactivity&lt;/strong&gt; to
web&lt;br&gt;
applications. 
&lt;/p&gt;
&lt;p&gt;
Additionally, Web 2.0 also includes a behavioral shift on the web, where users are&lt;br&gt;
encouraged to customize their own content on web applications rather than view static/&lt;br&gt;
generic content supplied by an organization.
&lt;/p&gt;
&lt;p&gt;
In addition to the technology and behavior changes, Web 2.0 can also mean the shift&lt;br&gt;
from shrink-wrapped software to software as a service. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Another aspect of Web 2.0 are mash-up and plug-in pages. (Personal google page) 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Injection attacks are based on a single problem that persists in many technologies:
namely,&lt;br&gt;
no strict separation exists between program instructions and user data (also referred
to as&lt;br&gt;
user input). This problem allows for attackers to sneak program instructions into
places&lt;br&gt;
where the developer expected only benign data. By sneaking in program instructions,
the&lt;br&gt;
attacker can instruct the program to perform actions of the attacker’s choosing. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="3"&gt;Input Injection&lt;/font&gt;&lt;/strong&gt; 
&lt;p&gt;
&lt;strong&gt;&lt;/strong&gt;&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;SQL Injection&lt;/strong&gt; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
SELECT id FROM user_table WHERE username = '' &lt;font color="#ff0000"&gt;OR 1=1 -- &lt;/font&gt;'
AND password&lt;br&gt;
= PASSWORD('x') 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Injection attacks are not necessary blind attacks. Many web applications are developed&lt;br&gt;
with open-source tools. To make injection attacks more successful, download free or&lt;br&gt;
evaluation copies of products and set up your own test system. Once you have found
an&lt;br&gt;
error in your test system, it is highly probable that the same issue will exist on
all web&lt;br&gt;
applications using that tool. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Cure: 1. constrain data types, escape user input, prepared statements (the best) 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;XPath Injection&lt;/strong&gt; 
&lt;p&gt;
//users[username/text()='admin' and password/text()='' or '1'='1' ]/id/text() 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;Command Injection &lt;/strong&gt;(Escape) 
&lt;p&gt;
&lt;strong&gt;Directory Transversal Attacks&lt;br&gt;
XXE (XML eXternal Entity) Attacks &lt;/strong&gt;(prohibit the external entity in XML parser) 
&lt;p&gt;
&lt;strong&gt;LDAP Injection&lt;br&gt;
&lt;/strong&gt;whitelisting characters—that is, allow&lt;br&gt;
alphanumeric characters (a–z, A–Z, and 0–9) and deny all other characters.&lt;br&gt;
&lt;strong&gt;Buffer Overflows&lt;/strong&gt;
&lt;br&gt;
The injection aspect of buffer overflows is that the attacker injects&lt;br&gt;
machine instructions (called shell code) into some user input. The attacker somewhat
needs to&lt;br&gt;
know where the shell code will end up in the memory of the computer running the web&lt;br&gt;
application. Then the attacker overwrites the return address to point to the memory
location&lt;br&gt;
of the shell code. &lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=2f2a66c4-a599-4a92-bfa1-7f859162fb34" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,2f2a66c4-a599-4a92-bfa1-7f859162fb34.aspx</comments>
      <category>Life / Career;Web</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=96b414d4-7024-4eaf-b68d-d3239f7f8a8a</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,96b414d4-7024-4eaf-b68d-d3239f7f8a8a.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,96b414d4-7024-4eaf-b68d-d3239f7f8a8a.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=96b414d4-7024-4eaf-b68d-d3239f7f8a8a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#0000ff" size="2">
            <strong>                                              
Security</strong>
          </font>
        </p>
        <p>
HTTP offers integrated mechanisms for authenticating users. Collectively referred
to as HTTP authentication, these mechanisms provide a way for users to be authenticated
without the necessity of any server-side programming logic. This can be especially
helpful for restricting access to static resources (such as images or HTML files).
Of course, server-side scripts can also implement HTTP authentication, although Web
developers often authenticate users in the application logic itself. 
</p>
        <p>
There are two basic types of HTTP authentication: 
</p>
        <ul>
          <li>
            <p>
Basic authentication<a name="idd1e25584"></a><a name="idd1e25589"></a><a name="idd1e25594"></a></p>
          </li>
          <li>
            <p>
Digest authentication
</p>
          </li>
        </ul>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_thumb.png" width="395" height="153" />
          </a>
          <a name="idd1e25602">
          </a>
          <a name="idd1e25607">
          </a>
          <a name="idd1e25612">
          </a>
        </p>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_4.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_thumb_1.png" width="434" height="153" />
          </a>
        </p>
        <p>
An elegant solution to these types of problems is SSL, Secure Sockets Layer. In 1994,
Netscape released the specification of Secure Sockets Layer. By 1995, version 3.0
of SSL was released, and it has since taken the Web by storm. SSL has dramatically
changed the way people use the Web, and it provides a very good solution to many of
the Web's shortcomings, most importantly: 
</p>
        <ul>
          <li>
            <p>
Data integrity— SSL can <a name="idd1e27328"></a><a name="idd1e27333"></a>help ensure
that data (HTTP messages) cannot be changed while in transit.
</p>
          </li>
          <li>
            <p>
Data confidentiality— SSL<a name="idd1e27351"></a><a name="idd1e27356"></a> provides
strong cryptographic techniques used to encrypt HTTP messages.
</p>
          </li>
          <li>
            <p>
Identification— SSL can<a name="idd1e27374"></a><a name="idd1e27379"></a> offer reasonable
assurance as to the identity of a Web server. It can also be used to validate the
identity of a client, but this is less common.
</p>
          </li>
        </ul>
        <p>
A digital certificate is a document that declares that a particular public key is
owned by a particular Web site (see <a href="#ch18fig003">Figure 18.3</a>). The CA's
role is very similar to a notary whose responsibility is to ensure the correct identity
of people signing a legal document. 
</p>
        <p>
  
</p>
        <p>
SSL is basically a protocol<a name="idd1e27890"></a><a name="idd1e27895"></a> that
employs both symmetric and asymmetric cryptography to protect messages that use TCP
as the transport-level protocol. Because of the high performance expense of asymmetric
cryptography, it is only used to exchange the randomly generated symmetric key that
is then used for the symmetric encryption of the HTTP messages. 
</p>
        <p>
  
</p>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_6.png">
            <img style="border-bottom: 0px; border-left: 0px; margin: 0px 20px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_thumb_2.png" width="299" height="137" />
          </a>
        </p>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_8.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_thumb_3.png" width="425" height="253" />
          </a> https
on port 443
</p>
        <p>
Whenever a Web browser connects to a Web site over a secure connection, it requires
that the SSL certificate<a name="idd1e27937"></a><a name="idd1e27942"></a> the Web
server presents meets three main conditions:
</p>
        <ul>
          <li>
            <p>
The domain name on the certificate must match the domain name the Web browser believes
itself to be requesting a resource from.
</p>
          </li>
          <li>
            <p>
The certificate must be valid (not expired).
</p>
          </li>
          <li>
            <p>
The certificate must be signed by a trusted certificate authority (CA).
</p>
          </li>
        </ul>
        <p>
Transport Layer Security (TLS) <a name="idd1e28483"></a><a name="idd1e28489"></a><a name="idd1e28494"></a>is
a formally standardized version of SSL. The biggest difference, in fact, is that TLS
is defined and maintained by an international standards body, the Internet Engineering
Task Force (IETF). <a name="idd1e28498"></a><a name="idd1e28504"></a><a name="idd1e28509"></a><a name="idd1e28512"></a>SSL
is developed and maintained by Netscape. 
</p>
        <p>
  
</p>
        <p>
One of the advantages of the IETF's involvement in TLS is that they also control the
HTTP protocol. <a name="idd1e28528"></a><a name="idd1e28535"></a><a name="idd1e28542"></a><a name="idd1e28547"></a>This
situation can possibly be credited for RFC 2817, which describes a method for using
the <tt>Upgrade</tt> general header to upgrade to HTTP over TLS. The significance
of this is that it allows for a change in protocol without having to utilize a separate
port. Thus, a Web server that supports this technique can implement TLS over port
80. An example of a Web client's request is the following:
</p>
        <pre>GET / HTTP/1.1 
Host: 127.0.0.1 
Upgrade: TLS/1.0 
Connection: Upgrade </pre>
        <p>
A Web server that accepts this upgrade will issue an HTTP response similar to the
following:
</p>
        <pre>HTTP/1.1 101 Switching Protocols 
Upgrade: TLS/1.0, HTTP/1.1 
Connection: Upgrade </pre>
        <p>
At this point, a typical SSL handshake<a name="idd1e28574"></a><a name="idd1e28577"></a> will
take place over the current connection. It is sometimes confusing to consider that
the SSL handshake can take place over port 80 at this point while the Web server can
still accept normal HTTP requests over the same port. Note that the upgrade only affects
the current TCP connection. Just as a Web server does not (barring extremely odd memory
collisions) send the wrong HTTP response to the wrong Web client, it can also keep
protocol upgrades straight. <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=96b414d4-7024-4eaf-b68d-d3239f7f8a8a" /></p>
      </body>
      <title>Summary of HTTP Developer&amp;rsquo;s Handbook (part 3)</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,96b414d4-7024-4eaf-b68d-d3239f7f8a8a.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,96b414d4-7024-4eaf-b68d-d3239f7f8a8a.aspx</link>
      <pubDate>Sun, 07 Mar 2010 01:06:37 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color="#0000ff" size="2"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Security&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
HTTP offers integrated mechanisms for authenticating users. Collectively referred
to as HTTP authentication, these mechanisms provide a way for users to be authenticated
without the necessity of any server-side programming logic. This can be especially
helpful for restricting access to static resources (such as images or HTML files).
Of course, server-side scripts can also implement HTTP authentication, although Web
developers often authenticate users in the application logic itself. 
&lt;p&gt;
There are two basic types of HTTP authentication: 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
Basic authentication&lt;a name="idd1e25584"&gt;&lt;/a&gt;&lt;a name="idd1e25589"&gt;&lt;/a&gt;&lt;a name="idd1e25594"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Digest authentication
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_thumb.png" width="395" height="153"&gt;&lt;/a&gt; &lt;a name="idd1e25602"&gt;&lt;/a&gt;&lt;a name="idd1e25607"&gt;&lt;/a&gt;&lt;a name="idd1e25612"&gt;&lt;/a&gt; 
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_thumb_1.png" width="434" height="153"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
An elegant solution to these types of problems is SSL, Secure Sockets Layer. In 1994,
Netscape released the specification of Secure Sockets Layer. By 1995, version 3.0
of SSL was released, and it has since taken the Web by storm. SSL has dramatically
changed the way people use the Web, and it provides a very good solution to many of
the Web's shortcomings, most importantly: 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
Data integrity— SSL can &lt;a name="idd1e27328"&gt;&lt;/a&gt;&lt;a name="idd1e27333"&gt;&lt;/a&gt;help ensure
that data (HTTP messages) cannot be changed while in transit.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Data confidentiality— SSL&lt;a name="idd1e27351"&gt;&lt;/a&gt;&lt;a name="idd1e27356"&gt;&lt;/a&gt; provides
strong cryptographic techniques used to encrypt HTTP messages.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Identification— SSL can&lt;a name="idd1e27374"&gt;&lt;/a&gt;&lt;a name="idd1e27379"&gt;&lt;/a&gt; offer reasonable
assurance as to the identity of a Web server. It can also be used to validate the
identity of a client, but this is less common.
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
A digital certificate is a document that declares that a particular public key is
owned by a particular Web site (see &lt;a href="#ch18fig003"&gt;Figure 18.3&lt;/a&gt;). The CA's
role is very similar to a notary whose responsibility is to ensure the correct identity
of people signing a legal document. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
SSL is basically a protocol&lt;a name="idd1e27890"&gt;&lt;/a&gt;&lt;a name="idd1e27895"&gt;&lt;/a&gt; that
employs both symmetric and asymmetric cryptography to protect messages that use TCP
as the transport-level protocol. Because of the high performance expense of asymmetric
cryptography, it is only used to exchange the randomly generated symmetric key that
is then used for the symmetric encryption of the HTTP messages. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 20px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_thumb_2.png" width="299" height="137"&gt;&lt;/a&gt; 
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_8.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_11AB8/image_thumb_3.png" width="425" height="253"&gt;&lt;/a&gt; https
on port 443
&lt;/p&gt;
&lt;p&gt;
Whenever a Web browser connects to a Web site over a secure connection, it requires
that the SSL certificate&lt;a name="idd1e27937"&gt;&lt;/a&gt;&lt;a name="idd1e27942"&gt;&lt;/a&gt; the Web
server presents meets three main conditions:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
The domain name on the certificate must match the domain name the Web browser believes
itself to be requesting a resource from.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
The certificate must be valid (not expired).
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
The certificate must be signed by a trusted certificate authority (CA).
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Transport Layer Security (TLS) &lt;a name="idd1e28483"&gt;&lt;/a&gt;&lt;a name="idd1e28489"&gt;&lt;/a&gt;&lt;a name="idd1e28494"&gt;&lt;/a&gt;is
a formally standardized version of SSL. The biggest difference, in fact, is that TLS
is defined and maintained by an international standards body, the Internet Engineering
Task Force (IETF). &lt;a name="idd1e28498"&gt;&lt;/a&gt;&lt;a name="idd1e28504"&gt;&lt;/a&gt;&lt;a name="idd1e28509"&gt;&lt;/a&gt;&lt;a name="idd1e28512"&gt;&lt;/a&gt;SSL
is developed and maintained by Netscape. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
One of the advantages of the IETF's involvement in TLS is that they also control the
HTTP protocol. &lt;a name="idd1e28528"&gt;&lt;/a&gt;&lt;a name="idd1e28535"&gt;&lt;/a&gt;&lt;a name="idd1e28542"&gt;&lt;/a&gt;&lt;a name="idd1e28547"&gt;&lt;/a&gt;This
situation can possibly be credited for RFC 2817, which describes a method for using
the &lt;tt&gt;Upgrade&lt;/tt&gt; general header to upgrade to HTTP over TLS. The significance
of this is that it allows for a change in protocol without having to utilize a separate
port. Thus, a Web server that supports this technique can implement TLS over port
80. An example of a Web client's request is the following:&lt;pre&gt;GET / HTTP/1.1 
Host: 127.0.0.1 
Upgrade: TLS/1.0 
Connection: Upgrade &lt;/pre&gt;
&lt;p&gt;
A Web server that accepts this upgrade will issue an HTTP response similar to the
following:&lt;pre&gt;HTTP/1.1 101 Switching Protocols 
Upgrade: TLS/1.0, HTTP/1.1 
Connection: Upgrade &lt;/pre&gt;
&lt;p&gt;
At this point, a typical SSL handshake&lt;a name="idd1e28574"&gt;&lt;/a&gt;&lt;a name="idd1e28577"&gt;&lt;/a&gt; will
take place over the current connection. It is sometimes confusing to consider that
the SSL handshake can take place over port 80 at this point while the Web server can
still accept normal HTTP requests over the same port. Note that the upgrade only affects
the current TCP connection. Just as a Web server does not (barring extremely odd memory
collisions) send the wrong HTTP response to the wrong Web client, it can also keep
protocol upgrades straight. &lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=96b414d4-7024-4eaf-b68d-d3239f7f8a8a" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,96b414d4-7024-4eaf-b68d-d3239f7f8a8a.aspx</comments>
      <category>Life / Career;Web</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=205ad14d-1123-4af7-9e85-7c02b4eb649a</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,205ad14d-1123-4af7-9e85-7c02b4eb649a.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,205ad14d-1123-4af7-9e85-7c02b4eb649a.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=205ad14d-1123-4af7-9e85-7c02b4eb649a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strong>
            <font color="#0000ff" size="2">Maintaining State</font>
          </strong>
        </p>
        <p>
If a unique response per client is desired, something in the HTTP request itself must
be unique.
</p>
        <p>
Once a method of state management has been established, you need only to authenticate
the user once. <a name="idd1e20028"></a>Because state management provides a way to
identify a Web client, user identification simply requires that you remember which
user is associated with which client upon authentication. 
</p>
        <p>
          <a href="0672324547_">
            <img border="0" src="FILES/pixel.gif" width="1" height="1" />
          </a>
        </p>
        <p>
When I speak of maintaining state,<a name="idd1e20042"></a><a name="idd1e20047"></a><a name="idd1e20050"></a> I
am only speaking of client identification, which is accomplished by associating <strong>multiple</strong> HTTP
requests. 
</p>
        <p>
Maintaining session, <a name="idd1e20057"></a>on the other hand, requires two related
tasks: 
</p>
        <ul>
          <li>
            <p>
Identifying the client (state management)
</p>
          </li>
          <li>
            <p>
Retaining information about the client
</p>
          </li>
        </ul>
        <p>
Although cookies are most often described in conversation as if they are entities
(for example, "a Web server sends you a cookie"), they are much easier to understand
at a functional level if you consider them an extension of the HTTP protocol, which
is actually more correct. Cookies can be defined as the addition of two HTTP headers<a name="idd1e20166"></a><a name="idd1e20173"></a><a name="idd1e20176"></a><a name="idd1e20181"></a><a name="idd1e20188"></a><a name="idd1e20191"></a>: 
</p>
        <ul>
          <li>
            <p>
              <tt>Set-Cookie</tt> response header
</p>
          </li>
          <li>
            <p>
              <tt>Cookie</tt> request header
</p>
          </li>
        </ul>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_E00E/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; margin: 0px 20px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_E00E/image_thumb.png" width="375" height="449" />
          </a>
        </p>
        <p>
    A common question seen on mailing lists and discussion forums for
Web developers is how to test whether the client is accepting cookies, and many people
do not understand the answer. As is evident in <a href="#ch11fig003">Figure 11.3</a>,
it is impossible to determine whether the client accepted the cookie until the second
request is sent (step 3 in the figure). If the cookie is included in the second request,
the client accepted it. If not, the client rejected it.
</p>
        <p>
Some developers choose to force the issue of determining whether the client accepts
cookies by redirecting the client to a second URL upon entrance.
</p>
        <p>
Cookies have become a source of<a name="idd1e20678"></a><a name="idd1e20683"></a><a name="idd1e20688"></a><a name="idd1e20693"></a> privacy
concern in recent years. As with most technologies in the computer industry, this
reputation has been earned by the misuse of the technology more than the technology
itself.
</p>
        <p>
Whether using files or a database to store the session information, there are three
basic elements you will want to store for each session's record:
</p>
        <ul>
          <li>
            <p>
Unique identifier
</p>
          </li>
          <li>
            <p>
Timestamp of last access
</p>
          </li>
          <li>
            <p>
Client data
</p>
          </li>
        </ul>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_E00E/image_4.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_E00E/image_thumb_1.png" width="454" height="305" />
          </a>
        </p>
        <p>
 
</p>
        <p>
          <font color="#0000ff" size="2">
            <strong>Improve the performance</strong>
          </font>
        </p>
        <p>
Caching can refer to many concepts. <a name="idd1e22437"></a>The general meaning of
cache is to store a copy of something to prevent the necessity of retrieving it again.
When speaking of Web development, there are three main types of caching: 
</p>
        <ul>
          <li>
            <p>
Caching on the server— Storing<a name="idd1e22455"></a><a name="idd1e22460"></a> a
complete or partially generated resource on the server to keep from having to regenerate
it.
</p>
          </li>
          <li>
            <p>
Caching on the client— Storing<a name="idd1e22478"></a><a name="idd1e22483"></a> a
resource on the client to keep from having to receive the entire resource again.
</p>
          </li>
          <li>
            <p>
Proxy caching— Storing<a name="idd1e22501"></a><a name="idd1e22506"></a> a resource
on a proxy to allow direct replies to an HTTP request rather than having to receive
the entire resource from the origin server again.
</p>
          </li>
        </ul>
        <p>
Although there are many side advantages <a name="idd1e22513"></a><a name="idd1e22518"></a>to
caching, there are three core benefits: 
</p>
        <ul>
          <li>
            <p>
Improve response time from a user perspective— This is what most Web developers focus
on, the user experience.
</p>
          </li>
          <li>
            <p>
Lessen network load— Many Web developers overlook this metric because bandwidth is
often viewed as an expendable resource, where more can be purchased as needed.
</p>
          </li>
          <li>
            <p>
Lessen server load— This metric is more difficult to overlook, as it directly impacts
the user experience in terms of performance and reliability (stressed servers fail
more often).
</p>
          </li>
        </ul>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong> 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">
            </font>
          </strong>
        </p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=205ad14d-1123-4af7-9e85-7c02b4eb649a" />
      </body>
      <title>Summary of HTTP Developer&amp;rsquo;s Handbook (part 3)</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,205ad14d-1123-4af7-9e85-7c02b4eb649a.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,205ad14d-1123-4af7-9e85-7c02b4eb649a.aspx</link>
      <pubDate>Sat, 06 Mar 2010 20:56:19 GMT</pubDate>
      <description>&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;Maintaining State&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
If a unique response per client is desired, something in the HTTP request itself must
be unique.
&lt;/p&gt;
&lt;p&gt;
Once a method of state management has been established, you need only to authenticate
the user once. &lt;a name="idd1e20028"&gt;&lt;/a&gt;Because state management provides a way to
identify a Web client, user identification simply requires that you remember which
user is associated with which client upon authentication. 
&lt;p&gt;
&lt;a href="0672324547_"&gt;&lt;img border="0" src="FILES/pixel.gif" width="1" height="1"&gt;&lt;/a&gt; 
&lt;p&gt;
When I speak of maintaining state,&lt;a name="idd1e20042"&gt;&lt;/a&gt;&lt;a name="idd1e20047"&gt;&lt;/a&gt;&lt;a name="idd1e20050"&gt;&lt;/a&gt; I
am only speaking of client identification, which is accomplished by associating &lt;strong&gt;multiple&lt;/strong&gt; HTTP
requests. 
&lt;p&gt;
Maintaining session, &lt;a name="idd1e20057"&gt;&lt;/a&gt;on the other hand, requires two related
tasks: 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
Identifying the client (state management)
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Retaining information about the client
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Although cookies are most often described in conversation as if they are entities
(for example, "a Web server sends you a cookie"), they are much easier to understand
at a functional level if you consider them an extension of the HTTP protocol, which
is actually more correct. Cookies can be defined as the addition of two HTTP headers&lt;a name="idd1e20166"&gt;&lt;/a&gt;&lt;a name="idd1e20173"&gt;&lt;/a&gt;&lt;a name="idd1e20176"&gt;&lt;/a&gt;&lt;a name="idd1e20181"&gt;&lt;/a&gt;&lt;a name="idd1e20188"&gt;&lt;/a&gt;&lt;a name="idd1e20191"&gt;&lt;/a&gt;: 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
&lt;tt&gt;Set-Cookie&lt;/tt&gt; response header
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;tt&gt;Cookie&lt;/tt&gt; request header
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_E00E/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 20px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_E00E/image_thumb.png" width="375" height="449"&gt;&lt;/a&gt; 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; A common question seen on mailing lists and discussion forums for
Web developers is how to test whether the client is accepting cookies, and many people
do not understand the answer. As is evident in &lt;a href="#ch11fig003"&gt;Figure 11.3&lt;/a&gt;,
it is impossible to determine whether the client accepted the cookie until the second
request is sent (step 3 in the figure). If the cookie is included in the second request,
the client accepted it. If not, the client rejected it.
&lt;/p&gt;
&lt;p&gt;
Some developers choose to force the issue of determining whether the client accepts
cookies by redirecting the client to a second URL upon entrance.
&lt;/p&gt;
&lt;p&gt;
Cookies have become a source of&lt;a name="idd1e20678"&gt;&lt;/a&gt;&lt;a name="idd1e20683"&gt;&lt;/a&gt;&lt;a name="idd1e20688"&gt;&lt;/a&gt;&lt;a name="idd1e20693"&gt;&lt;/a&gt; privacy
concern in recent years. As with most technologies in the computer industry, this
reputation has been earned by the misuse of the technology more than the technology
itself.
&lt;/p&gt;
&lt;p&gt;
Whether using files or a database to store the session information, there are three
basic elements you will want to store for each session's record:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
Unique identifier
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Timestamp of last access
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Client data
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_E00E/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/SummaryofHTTPDevelopersHandbookpart3_E00E/image_thumb_1.png" width="454" height="305"&gt;&lt;/a&gt; 
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;font color="#0000ff" size="2"&gt;&lt;strong&gt;Improve the performance&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Caching can refer to many concepts. &lt;a name="idd1e22437"&gt;&lt;/a&gt;The general meaning of
cache is to store a copy of something to prevent the necessity of retrieving it again.
When speaking of Web development, there are three main types of caching: 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
Caching on the server— Storing&lt;a name="idd1e22455"&gt;&lt;/a&gt;&lt;a name="idd1e22460"&gt;&lt;/a&gt; a
complete or partially generated resource on the server to keep from having to regenerate
it.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Caching on the client— Storing&lt;a name="idd1e22478"&gt;&lt;/a&gt;&lt;a name="idd1e22483"&gt;&lt;/a&gt; a
resource on the client to keep from having to receive the entire resource again.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Proxy caching— Storing&lt;a name="idd1e22501"&gt;&lt;/a&gt;&lt;a name="idd1e22506"&gt;&lt;/a&gt; a resource
on a proxy to allow direct replies to an HTTP request rather than having to receive
the entire resource from the origin server again.
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Although there are many side advantages &lt;a name="idd1e22513"&gt;&lt;/a&gt;&lt;a name="idd1e22518"&gt;&lt;/a&gt;to
caching, there are three core benefits: 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
Improve response time from a user perspective— This is what most Web developers focus
on, the user experience.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Lessen network load— Many Web developers overlook this metric because bandwidth is
often viewed as an expendable resource, where more can be purchased as needed.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Lessen server load— This metric is more difficult to overlook, as it directly impacts
the user experience in terms of performance and reliability (stressed servers fail
more often).
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=205ad14d-1123-4af7-9e85-7c02b4eb649a" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,205ad14d-1123-4af7-9e85-7c02b4eb649a.aspx</comments>
      <category>Life / Career;Web</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=446f37a8-bb6b-41e2-875d-b60efc20ff94</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,446f37a8-bb6b-41e2-875d-b60efc20ff94.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,446f37a8-bb6b-41e2-875d-b60efc20ff94.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=446f37a8-bb6b-41e2-875d-b60efc20ff94</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It is important to remember that an HTTP response completes the HTTP transaction.
Many people new to Web development have a difficult time distinguishing between server-side
code (code that executes on the server) and client-side code (code that executes on
the client). Scripting languages such as PHP, ColdFusion, and JSP are executed on
the server, and their output is included in the HTTP response. In fact, their output
is the content of the HTTP response, and most modern Web scripting languages also
allow for some manipulation of the HTTP as well, such as altering or adding headers,
changing status codes, and so on. Once the Web client receives the HTTP response,
the transaction is complete. The Web client will then render the page, execute client-side
scripts such as JavaScript, load images (by issuing separate <tt>GET</tt> requests),
and so on. 
</p>
        <p>
  
</p>
        <p>
          <em>
            <font color="#0080c0">With HTTP/1.1, persistent connections are the default behavior.
This means that the Web server will not close the connection after sending the HTTP
response unless the client intends to close the connection after receiving it. In
this case, the client will include the following header in the HTTP request:</font>
          </em>
        </p>
        <pre>
          <em>
            <font color="#0080c0">Connection: close </font>
          </em>
        </pre>
        <p>
          <em>
            <font color="#0080c0">Alternatively, the server can close the connection upon
sending the HTTP response, although it should be polite and include the same header
as shown previously so that the Web client expects this action.</font>
          </em>
        </p>
        <p>
          <em>
            <font color="#0080c0">
            </font>
          </em>  
</p>
        <p>
An HTTP response is broken into the following three logical pieces: 
</p>
        <ul>
          <li>
            <p>
Status line<a name="idd1e10818"></a><a name="idd1e10825"></a><a name="idd1e10832"></a><a name="idd1e10839"></a></p>
          </li>
          <li>
            <p>
HTTP headers<a name="idd1e10847"></a><a name="idd1e10854"></a><a name="idd1e10861"></a><a name="idd1e10868"></a><a name="idd1e10871"></a></p>
          </li>
          <li>
            <p>
Content<a name="idd1e10881"></a><a name="idd1e10888"></a><a name="idd1e10895"></a><a name="idd1e10902"></a></p>
          </li>
        </ul>
        <p>
An example status line is as follows:
</p>
        <pre>HTTP/1.1 200 OK </pre>
        <p>
The status line contains three elements: 
</p>
        <ul>
          <li>
            <p>
The version of HTTP being used, in the format <tt>HTTP/</tt><tt>x.x</tt></p>
          </li>
          <li>
            <p>
The status code
</p>
          </li>
          <li>
            <p>
A short description of the status code
</p>
          </li>
        </ul>
        <p>
There are three types of HTTP headers allowed in a response: 
</p>
        <ul>
          <li>
            <p>
General headers
</p>
          </li>
          <li>
            <p>
Response headers
</p>
          </li>
          <li>
            <p>
Entity headers
</p>
          </li>
        </ul>
        <p>
  
</p>
        <p>
Status codes are grouped into the following ranges: 
</p>
        <ul>
          <li>
            <p>
Informational (100-199)
</p>
          </li>
          <li>
            <p>
Successful (200-299)
</p>
          </li>
          <li>
            <p>
Redirection (300-399)
</p>
          </li>
          <li>
            <p>
Client error (400-499)
</p>
          </li>
          <li>
            <p>
Server error (500-599)
</p>
          </li>
        </ul>
        <p>
  
</p>
        <ul>
          <li>
100 Continue</li>
          <li>
101 Switching Protocols</li>
          <li>
200 OK</li>
          <li>
400 Bad Request</li>
          <li>
401 Unauthorized</li>
          <li>
403 Forbidden</li>
          <li>
404 Not Found</li>
          <li>
500 Internal Server Error</li>
          <li>
502 Bad Gateway</li>
          <li>
503 Service Unavailable</li>
        </ul>
        <p>
          <tt>Content-Disposition</tt>, combined with a proper <tt>Content-Type</tt> header,
provides the developer absolute control over the interpretation of the resource's
media type<a name="idd1e19751"></a><a name="idd1e19758"></a><a name="idd1e19765"></a><a name="idd1e19772"></a><a name="idd1e19775"></a>.
</p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=446f37a8-bb6b-41e2-875d-b60efc20ff94" />
      </body>
      <title>Summary of HTTP Developer&amp;rsquo;s Handbook (part2)</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,446f37a8-bb6b-41e2-875d-b60efc20ff94.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,446f37a8-bb6b-41e2-875d-b60efc20ff94.aspx</link>
      <pubDate>Sat, 06 Mar 2010 05:51:07 GMT</pubDate>
      <description>&lt;p&gt;
It is important to remember that an HTTP response completes the HTTP transaction.
Many people new to Web development have a difficult time distinguishing between server-side
code (code that executes on the server) and client-side code (code that executes on
the client). Scripting languages such as PHP, ColdFusion, and JSP are executed on
the server, and their output is included in the HTTP response. In fact, their output
is the content of the HTTP response, and most modern Web scripting languages also
allow for some manipulation of the HTTP as well, such as altering or adding headers,
changing status codes, and so on. Once the Web client receives the HTTP response,
the transaction is complete. The Web client will then render the page, execute client-side
scripts such as JavaScript, load images (by issuing separate &lt;tt&gt;GET&lt;/tt&gt; requests),
and so on. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;em&gt;&lt;font color="#0080c0"&gt;With HTTP/1.1, persistent connections are the default behavior.
This means that the Web server will not close the connection after sending the HTTP
response unless the client intends to close the connection after receiving it. In
this case, the client will include the following header in the HTTP request:&lt;/font&gt;&lt;/em&gt;&lt;pre&gt;&lt;em&gt;&lt;font color="#0080c0"&gt;Connection:
close &lt;/font&gt;&lt;/em&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;em&gt;&lt;font color="#0080c0"&gt;Alternatively, the server can close the connection upon
sending the HTTP response, although it should be polite and include the same header
as shown previously so that the Web client expects this action.&lt;/font&gt;&lt;/em&gt; 
&lt;p&gt;
&lt;em&gt;&lt;font color="#0080c0"&gt;&lt;/font&gt;&lt;/em&gt;&amp;nbsp; 
&lt;p&gt;
An HTTP response is broken into the following three logical pieces: 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
Status line&lt;a name="idd1e10818"&gt;&lt;/a&gt;&lt;a name="idd1e10825"&gt;&lt;/a&gt;&lt;a name="idd1e10832"&gt;&lt;/a&gt;&lt;a name="idd1e10839"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
HTTP headers&lt;a name="idd1e10847"&gt;&lt;/a&gt;&lt;a name="idd1e10854"&gt;&lt;/a&gt;&lt;a name="idd1e10861"&gt;&lt;/a&gt;&lt;a name="idd1e10868"&gt;&lt;/a&gt;&lt;a name="idd1e10871"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Content&lt;a name="idd1e10881"&gt;&lt;/a&gt;&lt;a name="idd1e10888"&gt;&lt;/a&gt;&lt;a name="idd1e10895"&gt;&lt;/a&gt;&lt;a name="idd1e10902"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
An example status line is as follows:&lt;pre&gt;HTTP/1.1 200 OK &lt;/pre&gt;
&lt;p&gt;
The status line contains three elements: 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
The version of HTTP being used, in the format &lt;tt&gt;HTTP/&lt;/tt&gt;&lt;tt&gt;x.x&lt;/tt&gt;
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
The status code
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
A short description of the status code
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
There are three types of HTTP headers allowed in a response: 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
General headers
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Response headers
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Entity headers
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Status codes are grouped into the following ranges: 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
Informational (100-199)
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Successful (200-299)
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Redirection (300-399)
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Client error (400-499)
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Server error (500-599)
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&amp;nbsp; 
&lt;ul&gt;
&lt;li&gt;
100 Continue&lt;/li&gt;
&lt;li&gt;
101 Switching Protocols&lt;/li&gt;
&lt;li&gt;
200 OK&lt;/li&gt;
&lt;li&gt;
400 Bad Request&lt;/li&gt;
&lt;li&gt;
401 Unauthorized&lt;/li&gt;
&lt;li&gt;
403 Forbidden&lt;/li&gt;
&lt;li&gt;
404 Not Found&lt;/li&gt;
&lt;li&gt;
500 Internal Server Error&lt;/li&gt;
&lt;li&gt;
502 Bad Gateway&lt;/li&gt;
&lt;li&gt;
503 Service Unavailable&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;tt&gt;Content-Disposition&lt;/tt&gt;, combined with a proper &lt;tt&gt;Content-Type&lt;/tt&gt; header,
provides the developer absolute control over the interpretation of the resource's
media type&lt;a name="idd1e19751"&gt;&lt;/a&gt;&lt;a name="idd1e19758"&gt;&lt;/a&gt;&lt;a name="idd1e19765"&gt;&lt;/a&gt;&lt;a name="idd1e19772"&gt;&lt;/a&gt;&lt;a name="idd1e19775"&gt;&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=446f37a8-bb6b-41e2-875d-b60efc20ff94" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,446f37a8-bb6b-41e2-875d-b60efc20ff94.aspx</comments>
      <category>Life / Career;Web</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=389d2abf-ee9d-4921-8234-11cdc21b57e3</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,389d2abf-ee9d-4921-8234-11cdc21b57e3.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,389d2abf-ee9d-4921-8234-11cdc21b57e3.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=389d2abf-ee9d-4921-8234-11cdc21b57e3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#0000ff" size="3">
            <strong>Form 2.0 data binding</strong>
          </font>
        </p>
        <pre class="csharpcode">Binding nameBinding = <span class="kwrd">new</span> Binding(<span class="str">"Text"</span>, <span class="kwrd">this</span>.raceCarDriver, <span class="str">"Name"</span>, <span class="kwrd">true</span>); <span class="kwrd">this</span>.nameTextBox.DataBindings.Add(nameBinding);
or <span class="kwrd">this</span>.nameTextBox.DataBindings.Add( <span class="str">"Text"</span>, <span class="kwrd">this</span>.raceCarDriver, <span class="str">"Name"</span>);
The minimum implementation that <span class="kwrd">is</span> considered a list data
source by the Windows Forms binding engine <span class="kwrd">is</span> a <span class="kwrd">class</span> that
implements the IList <span class="kwrd">interface</span> (from System.Collections). <span class="kwrd">this</span>.BindingManager.Position
= 0; RefreshItems(); <span class="kwrd">this</span>.raceCarDriversListBox.DataSource
= <span class="kwrd">this</span>.raceCarDrivers; <span class="kwrd">this</span>.raceCarDriversListBox.DisplayMember
= <span class="str">"Name"</span>; <span class="kwrd">void</span> addButton_Click(<span class="kwrd">object</span> sender,
EventArgs e) { <span class="rem">// Add item to list data source directly</span> RaceCarDriver
raceCarDriver = <span class="kwrd">new</span> RaceCarDriver(<span class="str">"Nelson
Piquet"</span>, 300); <span class="kwrd">this</span>.raceCarDrivers.Add(raceCarDriver); <span class="rem">//
Select new item</span><span class="kwrd">this</span>.BindingManager.Position = <span class="kwrd">this</span>.BindingManager.Count
- 1; } <span class="kwrd">private</span><span class="kwrd">void</span> deleteButton_Click(<span class="kwrd">object</span> sender,
EventArgs e) { <span class="rem">// Remove item from list data source directly</span><span class="kwrd">this</span>.raceCarDrivers.Remove(
(RaceCarDriver)<span class="kwrd">this</span>.BindingManager.Current); }</pre>
        <style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
        <pre>
        </pre>
        <p>
          <strong>BindingList&lt;T&gt;-&gt;IBindingList-&gt;IList</strong>
          <br />
BindingList&lt;T&gt; nicely implements the list management (AllowEdit, AllowNew, AllowRemove,
and AddNew) and change notification (SupportsChangeNotification, ListChanged) functional
subsets of IBindingList.<sup><a href="#ch16fn05">[5]</a></sup> And because it's generic,
it can turn any type into a strongly typed list data source with data-binding-savvy
list management and change notification using something like the following code<br /></p>
        <h6>Two-Way Item Change Synchronization
</h6>
        <p>
When the values in a DataGridView row are changed, DataGridView automatically replicates
the changes to the bound list data source. Similarly, when changes are made to an
item in the list data source of BindingList&lt;T&gt;, an item change notification
is broadcast to all bound controls. 
</p>
        <p>
  
</p>
        <p>
BindingList&lt;T&gt; allows us to use almost any class to create a data-binding-savvy
strongly typed list data source. However, some item classes come already associated
with their own collection classes. Although any collection class that implements IList
can be used as a list data source, you don't get full-flavor data binding if you don't
implement IBindingListnamely, support for two-way list and item change notification. 
</p>
        <p>
To gain this support and to avoid the highly involved implementation of IBindingList
ourselves, we'd love to be able to "upgrade" an existing IList implementation to IBindingList.
The class that performs this upgrade for you is <strong>BindingSource</strong>. 
</p>
        <p>
The BindingSource component (from System.Windows.Forms) consumes either item types
or list types and exposes them as IBindingList implementations. 
</p>
        <p>
  
</p>
        <p>
if you need to implement a VCR-type control to navigate the items in a data source,
you don't have to acquire a BindingManager and you don't have to manually create your
own navigation methods. Instead, you simply rely on the BindingSource to manage currency
and use its currency-oriented methods as required: 
</p>
        <p>
  
</p>
        <p>
void moveFirstButton_Click(object sender, EventArgs e) 
</p>
        <p>
{ this.employeesBindingSource.MoveFirst(); RefreshItems(); } 
</p>
        <p>
  
</p>
        <p>
Master-Detail binding<br /><a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/d0ca6d3651bd.Netreviewpart2_D671/image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/d0ca6d3651bd.Netreviewpart2_D671/image_thumb.png" width="536" height="246" /></a></p>
        <p>
 
</p>
        <p>
          <strong>
            <font color="#0000ff" size="2">Why [STAThread]</font>
          </strong>
        </p>
        <p>
          <code>When the STAThreadAttribute is applied, it changes the apartment state of the
current thread to be single threaded. Without getting into a huge discussion about
COM and threading, this attribute ensures the communication mechanism between the
current thread and other threads that may want to talk to it via COM. When you're
using Windows Forms, depending on the feature you're using, it may be using COM interop
in order to communicate with operating system components. Good examples of this are
the Clipboard and the File Dialogs.</code>
        </p>
        <p>
          <code>
            <font color="#0000ff" size="2">
              <strong>SingleInstanceApplication</strong>
            </font>
          </code>
        </p>
        <p>
// SingleInstanceApplication.cs 
<br />
class SingleInstanceApplication : <strong>WindowsFormsApplicationBase</strong><br />
{ ... protected override void OnCreateMainForm() { this.MainForm = new MainForm();
}<code><font color="#0000ff" size="2"><strong><br /></strong></font></code></p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=389d2abf-ee9d-4921-8234-11cdc21b57e3" />
      </body>
      <title>.Net review (part 2)</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,389d2abf-ee9d-4921-8234-11cdc21b57e3.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,389d2abf-ee9d-4921-8234-11cdc21b57e3.aspx</link>
      <pubDate>Fri, 05 Mar 2010 20:13:20 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color="#0000ff" size="3"&gt;&lt;strong&gt;Form 2.0 data binding&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;Binding nameBinding = &lt;span class="kwrd"&gt;new&lt;/span&gt; Binding(&lt;span class="str"&gt;"Text"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.raceCarDriver, &lt;span class="str"&gt;"Name"&lt;/span&gt;, &lt;span class="kwrd"&gt;true&lt;/span&gt;); &lt;span class="kwrd"&gt;this&lt;/span&gt;.nameTextBox.DataBindings.Add(nameBinding);
or &lt;span class="kwrd"&gt;this&lt;/span&gt;.nameTextBox.DataBindings.Add( &lt;span class="str"&gt;"Text"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.raceCarDriver, &lt;span class="str"&gt;"Name"&lt;/span&gt;);
The minimum implementation that &lt;span class="kwrd"&gt;is&lt;/span&gt; considered a list data
source by the Windows Forms binding engine &lt;span class="kwrd"&gt;is&lt;/span&gt; a &lt;span class="kwrd"&gt;class&lt;/span&gt; that
implements the IList &lt;span class="kwrd"&gt;interface&lt;/span&gt; (from System.Collections). &lt;span class="kwrd"&gt;this&lt;/span&gt;.BindingManager.Position
= 0; RefreshItems(); &lt;span class="kwrd"&gt;this&lt;/span&gt;.raceCarDriversListBox.DataSource
= &lt;span class="kwrd"&gt;this&lt;/span&gt;.raceCarDrivers; &lt;span class="kwrd"&gt;this&lt;/span&gt;.raceCarDriversListBox.DisplayMember
= &lt;span class="str"&gt;"Name"&lt;/span&gt;; &lt;span class="kwrd"&gt;void&lt;/span&gt; addButton_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender,
EventArgs e) { &lt;span class="rem"&gt;// Add item to list data source directly&lt;/span&gt; RaceCarDriver
raceCarDriver = &lt;span class="kwrd"&gt;new&lt;/span&gt; RaceCarDriver(&lt;span class="str"&gt;"Nelson
Piquet"&lt;/span&gt;, 300); &lt;span class="kwrd"&gt;this&lt;/span&gt;.raceCarDrivers.Add(raceCarDriver); &lt;span class="rem"&gt;//
Select new item&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.BindingManager.Position = &lt;span class="kwrd"&gt;this&lt;/span&gt;.BindingManager.Count
- 1; } &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; deleteButton_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender,
EventArgs e) { &lt;span class="rem"&gt;// Remove item from list data source directly&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.raceCarDrivers.Remove(
(RaceCarDriver)&lt;span class="kwrd"&gt;this&lt;/span&gt;.BindingManager.Current); }&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;strong&gt;BindingList&amp;lt;T&amp;gt;-&amp;gt;IBindingList-&amp;gt;IList&lt;/strong&gt;
&lt;br&gt;
BindingList&amp;lt;T&amp;gt; nicely implements the list management (AllowEdit, AllowNew, AllowRemove,
and AddNew) and change notification (SupportsChangeNotification, ListChanged) functional
subsets of IBindingList.&lt;sup&gt;&lt;a href="#ch16fn05"&gt;[5]&lt;/a&gt;&lt;/sup&gt; And because it's generic,
it can turn any type into a strongly typed list data source with data-binding-savvy
list management and change notification using something like the following code&lt;br&gt;
&lt;/p&gt;
&lt;h6&gt;Two-Way Item Change Synchronization
&lt;/h6&gt;
&lt;p&gt;
When the values in a DataGridView row are changed, DataGridView automatically replicates
the changes to the bound list data source. Similarly, when changes are made to an
item in the list data source of BindingList&amp;lt;T&amp;gt;, an item change notification
is broadcast to all bound controls. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
BindingList&amp;lt;T&amp;gt; allows us to use almost any class to create a data-binding-savvy
strongly typed list data source. However, some item classes come already associated
with their own collection classes. Although any collection class that implements IList
can be used as a list data source, you don't get full-flavor data binding if you don't
implement IBindingListnamely, support for two-way list and item change notification. 
&lt;p&gt;
To gain this support and to avoid the highly involved implementation of IBindingList
ourselves, we'd love to be able to "upgrade" an existing IList implementation to IBindingList.
The class that performs this upgrade for you is &lt;strong&gt;BindingSource&lt;/strong&gt;. 
&lt;p&gt;
The BindingSource component (from System.Windows.Forms) consumes either item types
or list types and exposes them as IBindingList implementations. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
if you need to implement a VCR-type control to navigate the items in a data source,
you don't have to acquire a BindingManager and you don't have to manually create your
own navigation methods. Instead, you simply rely on the BindingSource to manage currency
and use its currency-oriented methods as required: 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
void moveFirstButton_Click(object sender, EventArgs e) 
&lt;p&gt;
{ this.employeesBindingSource.MoveFirst(); RefreshItems(); } 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Master-Detail binding&lt;br&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/d0ca6d3651bd.Netreviewpart2_D671/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/d0ca6d3651bd.Netreviewpart2_D671/image_thumb.png" width="536" height="246"&gt;&lt;/a&gt; 
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff" size="2"&gt;Why [STAThread]&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;When the STAThreadAttribute is applied, it changes the apartment state of the
current thread to be single threaded. Without getting into a huge discussion about
COM and threading, this attribute ensures the communication mechanism between the
current thread and other threads that may want to talk to it via COM. When you're
using Windows Forms, depending on the feature you're using, it may be using COM interop
in order to communicate with operating system components. Good examples of this are
the Clipboard and the File Dialogs.&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;&lt;font color="#0000ff" size="2"&gt;&lt;strong&gt;SingleInstanceApplication&lt;/strong&gt;&lt;/font&gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
// SingleInstanceApplication.cs 
&lt;br&gt;
class SingleInstanceApplication : &lt;strong&gt;WindowsFormsApplicationBase&lt;/strong&gt; 
&lt;br&gt;
{ ... protected override void OnCreateMainForm() { this.MainForm = new MainForm();
}&lt;code&gt;&lt;font color="#0000ff" size="2"&gt;&lt;strong&gt;
&lt;br&gt;
&lt;/p&gt;
&gt;&gt;&gt;&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=389d2abf-ee9d-4921-8234-11cdc21b57e3" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,389d2abf-ee9d-4921-8234-11cdc21b57e3.aspx</comments>
      <category>DotNet;Life / Career</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=e0ded28d-bb6b-4275-9dd9-8b04cb0c4aa4</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,e0ded28d-bb6b-4275-9dd9-8b04cb0c4aa4.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,e0ded28d-bb6b-4275-9dd9-8b04cb0c4aa4.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=e0ded28d-bb6b-4275-9dd9-8b04cb0c4aa4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strong>
            <font color="#0000ff">CLR and .NET Framework</font>
          </strong>
        </p>
        <p>
The CLR is the runtime for executing managed code. C# is one of several managed<br />
languages that get compiled into managed code. Managed code is packaged into an<br />
assembly, in the form of either an executable file (an .exe) or a library (a .dll),
along<br />
with type information, or metadata.<br /><br />
Managed code is represented in Intermediate Language or IL. When the CLR loads<br />
an assembly, it converts the IL into the native code of the machine, such as x86.
This<br />
conversion is done by the CLR’s JIT (Just-In-Time) compiler. An assembly retains 
</p>
        <p>
almost all of the original source language constructs, which makes it easy to inspect<br />
and even generate code dynamically.<br /></p>
        <p>
The CLR performs as a host for numerous runtime services. Examples of these services<br />
include memory management, the loading of libraries, and security services.<br />
The CLR is language-neutral, allowing developers to build applications in multiple<br />
languages (e.g., C#, Visual Basic .NET, Managed C++, Delphi.NET, Chrome .NET,<br />
and J#). 
</p>
        <p>
  
</p>
        <p>
  
</p>
        <p>
          <strong>
            <font color="#0000ff">How the Garbage Collector Works:</font>
          </strong>
        </p>
        <p>
The GC begins with its root object references, and walks the object graph, marking<br />
all the objects it touches as reachable. Once this process is complete, all objects
that<br />
have not been marked are considered unused, and are subject to garbage collection.<br />
Unused objects without finalizers are immediately discarded; unused objects with<br />
finalizers are enqueued for processing on the finalizer thread after the GC is complete.<br />
These objects then become eligible for collection in the next GC for the object’s<br />
generation (unless resurrected). 
</p>
        <p>
  
</p>
        <p>
The remaining “live” objects are then shifted to the start of the heap (compacted),<br />
freeing space for more objects. This compaction serves two purposes: it avoids 
</p>
        <p>
memory fragmentation, and it allows the GC to employ a very simple strategy when<br />
allocating new objects, which is to always allocate memory at the end of the heap.<br />
This avoids the potentially time-consuming task of maintaining a list of free memory<br />
segments. 
</p>
        <p>
  
</p>
        <p>
If there is insufficient space to allocate memory for a new object after garbage<br />
collection, and the operating system is unable to grant further memory, an<br />
OutOfMemoryException is thrown. 
</p>
        <p>
  
</p>
        <p>
          <em>Generational collection<br /></em>The most important optimization is that the GC is generational. This takes advantage<br />
of the fact that although many objects are allocated and discarded rapidly, certain<br />
objects are long-lived and thus don’t need to be traced during every collection.<br />
Basically, the GC divides the managed heap into three generations. Objects that have<br />
just been allocated are in Gen0 and objects that have survived one collection cycle<br />
are in Gen1; all other objects are in Gen2. 
</p>
        <p>
  
</p>
        <p>
          <em>The large object heap</em>
          <br />
The GC uses a separate heap called the Large Object Heap (LOH) for objects larger<br />
than a certain threshold (currently 85,000 bytes). This avoids excessive Gen0<br />
collections—without the LOH, allocating a series of 16 MB objects might trigger a<br />
Gen0 collection after every allocation. 
</p>
        <p>
The LOH is not subject to compaction, because moving large blocks of memory<br />
during garbage collection would be prohibitively expensive. This has two<br />
consequences: 
</p>
        <p>
1. Allocations can be slower<br />
2. The LOH is subject to fragmentation 
</p>
        <p>
The large object heap is also nongenerational: all objects are treated as Gen2. 
</p>
        <p>
  
</p>
        <p>
          <em>Concurrent and background collection</em>
        </p>
        <p>
The GC must freeze (block) your execution threads for periods during a collection.<br />
This includes the entire period during which a Gen0 or Gen1 collection takes place.<br />
The GC makes a special attempt, though, at allowing threads to run during a Gen2<br />
collection 
</p>
        <p>
  
</p>
        <p>
Forcing Garbage Collection (not recommend) 
</p>
        <p>
GC.Collect() 
</p>
        <p>
  
</p>
        <p>
          <strong>A good guideline is to implement IDisposable yourself if any field in your
class is assigned an object that implements IDisposable. </strong>(Such as System.Timers.Timer)(System.Threading.Timer
is different) 
</p>
        <p>
  
</p>
        <p>
Monitor the memory leaks: long memoryUsed = GC.GetTotalMemory (true); 
</p>
        <p>
  
</p>
        <p>
Occasionally, it’s useful to hold a reference to an object that’s “invisible” to the
GC<br />
in terms of keeping the object alive. This is called a <strong><font color="#0000ff">weak
reference</font></strong>, and is implemented<br />
by the System.WeakReference class. 
</p>
        <p>
  
</p>
        <p>
One use for WeakReference is to cache large object graphs.<br /><a title="http://www.shafqatahmed.com/2008/01/weakreference-b.html" href="http://www.shafqatahmed.com/2008/01/weakreference-b.html">http://www.shafqatahmed.com/2008/01/weakreference-b.html</a></p>
        <p>
  
</p>
        <p>
  
</p>
        <p>
          <strong>
            <font color="#0000ff">Asynchronous Methods</font>
          </strong>
        </p>
        <p>
asynchronous programming model or APM<br /></p>
        <p>
An asynchronous method aims never to block any thread, instead using a pattern of<br />
returning with a callback. 
</p>
        <p>
  
</p>
        <p>
The end goal of the APM is thread economy. 
</p>
        <p>
The purpose of asynchronous methods isn’t to<br />
provide a convenient mechanism for executing a method in parallel with the caller;<br />
it’s to optimize thread resources. 
</p>
        <p>
  
</p>
        <p>
Here’s the golden rule of the APM: <strong>Make good use of the CPU, or exit with
a callback!</strong></p>
        <p>
          <strong>
          </strong>  
</p>
        <p>
The primary use for asynchronous methods is handling many potentially longrunning<br />
concurrent requests—typically over slow network connections. 
</p>
        <p>
  
</p>
        <p>
IAsyncResult BeginXXX (in/ref-args, AsyncCallback callback, object state);<br />
return-type EndXXX (out/ref-args, IAsyncResult asyncResult);<br />
public delegate void AsyncCallback (IAsyncResult ar); 
</p>
        <p>
  
</p>
        <p>
To avoid blocking, you will nearly always call the EndXXX method from inside the<br />
callback method. Callbacks always run on pooled threads. 
</p>
        <p>
  
</p>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/fb9127b647d3.Netreview1_D2BC/image_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/fb9127b647d3.Netreview1_D2BC/image_thumb.png" width="574" height="192" />
          </a>
        </p>
        <p>
  
</p>
        <p>
          <a title="http://en.csharp-online.net/CSharp_Delegates_and_Events%E2%80%94Asynchronous_method_calls" href="http://en.csharp-online.net/CSharp_Delegates_and_Events%E2%80%94Asynchronous_method_calls">http://en.csharp-online.net/CSharp_Delegates_and_Events%E2%80%94Asynchronous_method_calls</a>
          <br />
          <a title="http://msdn.microsoft.com/en-us/library/h80ttd5f.aspx" href="http://msdn.microsoft.com/en-us/library/h80ttd5f.aspx">http://msdn.microsoft.com/en-us/library/h80ttd5f.aspx</a>
        </p>
        <p>
          <font color="#0000ff" size="3">Collections</font>
        </p>
        <p>
ICollection Properties
</p>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/fb9127b647d3.Netreview1_D2BC/image_6.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/fb9127b647d3.Netreview1_D2BC/image_thumb_2.png" width="510" height="253" />
          </a>
        </p>
        <p>
          <a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/fb9127b647d3.Netreview1_D2BC/image_4.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/fb9127b647d3.Netreview1_D2BC/image_thumb_1.png" width="557" height="198" />
          </a>
        </p>
        <p>
IComparer 
<br />
Copmare method
</p>
        <p>
IEqualityComparer<br />
GetHashCode, Equals
</p>
        <p>
SortedList calss is a dictionary.
</p>
        <p>
          <font color="#0000ff" size="2">
            <strong>Race conditions and deadlocks</strong>
          </font>
        </p>
        <p>
        </p>
        <p>
          <a title="http://support.microsoft.com/kb/317723" href="http://support.microsoft.com/kb/317723">http://support.microsoft.com/kb/317723</a>
        </p>
        <p>
A <i>race condition</i> occurs when two threads access a shared variable at the same
time. The first thread reads the variable, and the second thread reads the same value
from the variable. Then the first thread and second thread perform their operations
on the value, and they race to see which thread can write the value last to the shared
variable. The value of the thread that writes its value last is preserved, because
the thread is writing over the value that the previous thread wrote.
</p>
        <p>
A <i>deadlock</i> occurs when two threads each lock a different variable at the same
time and then try to lock the variable that the other thread already locked. As a
result, each thread stops executing and waits for the other thread to release the
variable. Because each thread is holding the variable that the other thread wants,
nothing occurs, and the threads remain deadlocked.
</p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=e0ded28d-bb6b-4275-9dd9-8b04cb0c4aa4" />
      </body>
      <title>.Net review 1</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,e0ded28d-bb6b-4275-9dd9-8b04cb0c4aa4.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,e0ded28d-bb6b-4275-9dd9-8b04cb0c4aa4.aspx</link>
      <pubDate>Thu, 04 Mar 2010 19:57:29 GMT</pubDate>
      <description>&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff"&gt;CLR and .NET Framework&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The CLR is the runtime for executing managed code. C# is one of several managed&lt;br&gt;
languages that get compiled into managed code. Managed code is packaged into an&lt;br&gt;
assembly, in the form of either an executable file (an .exe) or a library (a .dll),
along&lt;br&gt;
with type information, or metadata.&lt;br&gt;
&lt;br&gt;
Managed code is represented in Intermediate Language or IL. When the CLR loads&lt;br&gt;
an assembly, it converts the IL into the native code of the machine, such as x86.
This&lt;br&gt;
conversion is done by the CLR’s JIT (Just-In-Time) compiler. An assembly retains 
&lt;p&gt;
almost all of the original source language constructs, which makes it easy to inspect&lt;br&gt;
and even generate code dynamically.&lt;br&gt;
&lt;p&gt;
The CLR performs as a host for numerous runtime services. Examples of these services&lt;br&gt;
include memory management, the loading of libraries, and security services.&lt;br&gt;
The CLR is language-neutral, allowing developers to build applications in multiple&lt;br&gt;
languages (e.g., C#, Visual Basic .NET, Managed C++, Delphi.NET, Chrome .NET,&lt;br&gt;
and J#). 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff"&gt;How the Garbage Collector Works:&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The GC begins with its root object references, and walks the object graph, marking&lt;br&gt;
all the objects it touches as reachable. Once this process is complete, all objects
that&lt;br&gt;
have not been marked are considered unused, and are subject to garbage collection.&lt;br&gt;
Unused objects without finalizers are immediately discarded; unused objects with&lt;br&gt;
finalizers are enqueued for processing on the finalizer thread after the GC is complete.&lt;br&gt;
These objects then become eligible for collection in the next GC for the object’s&lt;br&gt;
generation (unless resurrected). 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
The remaining “live” objects are then shifted to the start of the heap (compacted),&lt;br&gt;
freeing space for more objects. This compaction serves two purposes: it avoids 
&lt;p&gt;
memory fragmentation, and it allows the GC to employ a very simple strategy when&lt;br&gt;
allocating new objects, which is to always allocate memory at the end of the heap.&lt;br&gt;
This avoids the potentially time-consuming task of maintaining a list of free memory&lt;br&gt;
segments. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
If there is insufficient space to allocate memory for a new object after garbage&lt;br&gt;
collection, and the operating system is unable to grant further memory, an&lt;br&gt;
OutOfMemoryException is thrown. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;em&gt;Generational collection&lt;br&gt;
&lt;/em&gt;The most important optimization is that the GC is generational. This takes advantage&lt;br&gt;
of the fact that although many objects are allocated and discarded rapidly, certain&lt;br&gt;
objects are long-lived and thus don’t need to be traced during every collection.&lt;br&gt;
Basically, the GC divides the managed heap into three generations. Objects that have&lt;br&gt;
just been allocated are in Gen0 and objects that have survived one collection cycle&lt;br&gt;
are in Gen1; all other objects are in Gen2. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;em&gt;The large object heap&lt;/em&gt;
&lt;br&gt;
The GC uses a separate heap called the Large Object Heap (LOH) for objects larger&lt;br&gt;
than a certain threshold (currently 85,000 bytes). This avoids excessive Gen0&lt;br&gt;
collections—without the LOH, allocating a series of 16 MB objects might trigger a&lt;br&gt;
Gen0 collection after every allocation. 
&lt;p&gt;
The LOH is not subject to compaction, because moving large blocks of memory&lt;br&gt;
during garbage collection would be prohibitively expensive. This has two&lt;br&gt;
consequences: 
&lt;p&gt;
1. Allocations can be slower&lt;br&gt;
2. The LOH is subject to fragmentation 
&lt;p&gt;
The large object heap is also nongenerational: all objects are treated as Gen2. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;em&gt;Concurrent and background collection&lt;/em&gt; 
&lt;p&gt;
The GC must freeze (block) your execution threads for periods during a collection.&lt;br&gt;
This includes the entire period during which a Gen0 or Gen1 collection takes place.&lt;br&gt;
The GC makes a special attempt, though, at allowing threads to run during a Gen2&lt;br&gt;
collection 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Forcing Garbage Collection (not recommend) 
&lt;p&gt;
GC.Collect() 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;A good guideline is to implement IDisposable yourself if any field in your
class is assigned an object that implements IDisposable. &lt;/strong&gt;(Such as System.Timers.Timer)(System.Threading.Timer
is different) 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Monitor the memory leaks: long memoryUsed = GC.GetTotalMemory (true); 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Occasionally, it’s useful to hold a reference to an object that’s “invisible” to the
GC&lt;br&gt;
in terms of keeping the object alive. This is called a &lt;strong&gt;&lt;font color="#0000ff"&gt;weak
reference&lt;/font&gt;&lt;/strong&gt;, and is implemented&lt;br&gt;
by the System.WeakReference class. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
One use for WeakReference is to cache large object graphs.&lt;br&gt;
&lt;a title="http://www.shafqatahmed.com/2008/01/weakreference-b.html" href="http://www.shafqatahmed.com/2008/01/weakreference-b.html"&gt;http://www.shafqatahmed.com/2008/01/weakreference-b.html&lt;/a&gt; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;&lt;font color="#0000ff"&gt;Asynchronous Methods&lt;/font&gt;&lt;/strong&gt; 
&lt;p&gt;
asynchronous programming model or APM&lt;br&gt;
&lt;p&gt;
An asynchronous method aims never to block any thread, instead using a pattern of&lt;br&gt;
returning with a callback. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
The end goal of the APM is thread economy. 
&lt;p&gt;
The purpose of asynchronous methods isn’t to&lt;br&gt;
provide a convenient mechanism for executing a method in parallel with the caller;&lt;br&gt;
it’s to optimize thread resources. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Here’s the golden rule of the APM: &lt;strong&gt;Make good use of the CPU, or exit with
a callback!&lt;/strong&gt; 
&lt;p&gt;
&lt;strong&gt;&lt;/strong&gt;&amp;nbsp; 
&lt;p&gt;
The primary use for asynchronous methods is handling many potentially longrunning&lt;br&gt;
concurrent requests—typically over slow network connections. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
IAsyncResult BeginXXX (in/ref-args, AsyncCallback callback, object state);&lt;br&gt;
return-type EndXXX (out/ref-args, IAsyncResult asyncResult);&lt;br&gt;
public delegate void AsyncCallback (IAsyncResult ar); 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
To avoid blocking, you will nearly always call the EndXXX method from inside the&lt;br&gt;
callback method. Callbacks always run on pooled threads. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/fb9127b647d3.Netreview1_D2BC/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/fb9127b647d3.Netreview1_D2BC/image_thumb.png" width="574" height="192"&gt;&lt;/a&gt; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;a title="http://en.csharp-online.net/CSharp_Delegates_and_Events%E2%80%94Asynchronous_method_calls" href="http://en.csharp-online.net/CSharp_Delegates_and_Events%E2%80%94Asynchronous_method_calls"&gt;http://en.csharp-online.net/CSharp_Delegates_and_Events%E2%80%94Asynchronous_method_calls&lt;/a&gt;
&lt;br&gt;
&lt;a title="http://msdn.microsoft.com/en-us/library/h80ttd5f.aspx" href="http://msdn.microsoft.com/en-us/library/h80ttd5f.aspx"&gt;http://msdn.microsoft.com/en-us/library/h80ttd5f.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color="#0000ff" size="3"&gt;Collections&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
ICollection Properties
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/fb9127b647d3.Netreview1_D2BC/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/fb9127b647d3.Netreview1_D2BC/image_thumb_2.png" width="510" height="253"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/fb9127b647d3.Netreview1_D2BC/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.ilovedoudou.com/content/binary/WindowsLiveWriter/fb9127b647d3.Netreview1_D2BC/image_thumb_1.png" width="557" height="198"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
IComparer 
&lt;br&gt;
Copmare method
&lt;/p&gt;
&lt;p&gt;
IEqualityComparer&lt;br&gt;
GetHashCode, Equals
&lt;/p&gt;
&lt;p&gt;
SortedList calss is a dictionary.
&lt;/p&gt;
&lt;p&gt;
&lt;font color="#0000ff" size="2"&gt;&lt;strong&gt;Race conditions and deadlocks&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://support.microsoft.com/kb/317723" href="http://support.microsoft.com/kb/317723"&gt;http://support.microsoft.com/kb/317723&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
A &lt;i&gt;race condition&lt;/i&gt; occurs when two threads access a shared variable at the same
time. The first thread reads the variable, and the second thread reads the same value
from the variable. Then the first thread and second thread perform their operations
on the value, and they race to see which thread can write the value last to the shared
variable. The value of the thread that writes its value last is preserved, because
the thread is writing over the value that the previous thread wrote.
&lt;/p&gt;
&lt;p&gt;
A &lt;i&gt;deadlock&lt;/i&gt; occurs when two threads each lock a different variable at the same
time and then try to lock the variable that the other thread already locked. As a
result, each thread stops executing and waits for the other thread to release the
variable. Because each thread is holding the variable that the other thread wants,
nothing occurs, and the threads remain deadlocked.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=e0ded28d-bb6b-4275-9dd9-8b04cb0c4aa4" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,e0ded28d-bb6b-4275-9dd9-8b04cb0c4aa4.aspx</comments>
      <category>DotNet;Life / Career</category>
    </item>
    <item>
      <trackback:ping>http://blog.ilovedoudou.com/Trackback.aspx?guid=79a6e3c5-0394-40a8-99df-303c04740105</trackback:ping>
      <pingback:server>http://blog.ilovedoudou.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.ilovedoudou.com/PermaLink,guid,79a6e3c5-0394-40a8-99df-303c04740105.aspx</pingback:target>
      <dc:creator>Kevin Mocha</dc:creator>
      <wfw:comment>http://blog.ilovedoudou.com/CommentView,guid,79a6e3c5-0394-40a8-99df-303c04740105.aspx</wfw:comment>
      <wfw:commentRss>http://blog.ilovedoudou.com/SyndicationService.asmx/GetEntryCommentsRss?guid=79a6e3c5-0394-40a8-99df-303c04740105</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a title="http://money.cnn.com/magazines/fortune/bestcompanies/2009/" href="http://money.cnn.com/magazines/fortune/bestcompanies/2009/">http://money.cnn.com/magazines/fortune/bestcompanies/2009/</a>
        </p>
        <p>
          <a title="http://money.cnn.com/magazines/moneymag/bplive/2006/top100/index.html" href="http://money.cnn.com/magazines/moneymag/bplive/2006/top100/index.html">http://money.cnn.com/magazines/moneymag/bplive/2006/top100/index.html</a>
        </p>
        <p>
          <a title="http://www.mitbbs.com/bbsdoc3/chinese.faq/Texas/city/Austin/Austinfeeling/5" href="http://www.mitbbs.com/bbsdoc3/chinese.faq/Texas/city/Austin/Austinfeeling/5">http://www.mitbbs.com/bbsdoc3/chinese.faq/Texas/city/Austin/Austinfeeling/5</a>
        </p>
        <p>
          <a title="http://studentorgs.utexas.edu/cssa/links/in.htm" href="http://studentorgs.utexas.edu/cssa/links/in.htm">http://studentorgs.utexas.edu/cssa/links/in.htm</a>
        </p>
        <p>
          <a title="http://en.wikipedia.org/wiki/Austin,_Texas#Economy" href="http://en.wikipedia.org/wiki/Austin,_Texas#Economy">http://en.wikipedia.org/wiki/Austin,_Texas#Economy</a>
        </p>
        <img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=79a6e3c5-0394-40a8-99df-303c04740105" />
      </body>
      <title>Job Research</title>
      <guid isPermaLink="false">http://blog.ilovedoudou.com/PermaLink,guid,79a6e3c5-0394-40a8-99df-303c04740105.aspx</guid>
      <link>http://blog.ilovedoudou.com/PermaLink,guid,79a6e3c5-0394-40a8-99df-303c04740105.aspx</link>
      <pubDate>Wed, 02 Dec 2009 14:58:36 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a title="http://money.cnn.com/magazines/fortune/bestcompanies/2009/" href="http://money.cnn.com/magazines/fortune/bestcompanies/2009/"&gt;http://money.cnn.com/magazines/fortune/bestcompanies/2009/&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://money.cnn.com/magazines/moneymag/bplive/2006/top100/index.html" href="http://money.cnn.com/magazines/moneymag/bplive/2006/top100/index.html"&gt;http://money.cnn.com/magazines/moneymag/bplive/2006/top100/index.html&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://www.mitbbs.com/bbsdoc3/chinese.faq/Texas/city/Austin/Austinfeeling/5" href="http://www.mitbbs.com/bbsdoc3/chinese.faq/Texas/city/Austin/Austinfeeling/5"&gt;http://www.mitbbs.com/bbsdoc3/chinese.faq/Texas/city/Austin/Austinfeeling/5&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://studentorgs.utexas.edu/cssa/links/in.htm" href="http://studentorgs.utexas.edu/cssa/links/in.htm"&gt;http://studentorgs.utexas.edu/cssa/links/in.htm&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://en.wikipedia.org/wiki/Austin,_Texas#Economy" href="http://en.wikipedia.org/wiki/Austin,_Texas#Economy"&gt;http://en.wikipedia.org/wiki/Austin,_Texas#Economy&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.ilovedoudou.com/aggbug.ashx?id=79a6e3c5-0394-40a8-99df-303c04740105" /&gt;</description>
      <comments>http://blog.ilovedoudou.com/CommentView,guid,79a6e3c5-0394-40a8-99df-303c04740105.aspx</comments>
      <category>Life / Career</category>
    </item>
  </channel>
</rss>