<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4670920447169706502</id><updated>2024-09-02T03:31:29.364+05:30</updated><category term="Differences Between Pocket PC 2003 and Smartphone 2003 Controls"/><category term="Embedded Systems"/><category term="IOT"/><category term="M2M"/><category term="Networking"/><category term="OSI"/><category term="Sys.Application.add_load"/><title type='text'>You will definitely get it from here!</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>48</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-366805932404563458</id><published>2019-12-01T21:49:00.002+05:30</published><updated>2019-12-01T21:50:30.703+05:30</updated><title type='text'>When a MAC address itself is unique, why do we still need an IP address to uniquely identify a system on a network?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;WordSection1&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
It is not possible to route a MAC address since it works on a layer above Ethernet. To understand why IP addressing is used in a computer network or over the internet you need to understand how IP routing works.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Basic IP Routing&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
When your computer (PC1) wants to send a packet to some IP address (IPv4) like x.x.x.x, then the first check is if the destination address is in the same IP network as the PC1 itself. If x.x.x.x is in the same network, then the destination   IP can be reached directly, otherwise the packet needs to be sent to the route configured on PC1 and if a route for the destination network / host is not configured explicitly, the packet is routed to the default gateway configured on PC1. Well that was about   how IP routing works at a very high-level. Routers also use dynamic routing protocols and algorithms to find the best possible path.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;MAC addresses&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Once the packet has reached the local network of the destination computer, the communication happens over the Ethernet which is the data link layer. This is where MAC addresses are used to communicate. The sender (which in this case could   be a router or the source computer PC1 if it was in the same network) needs to get the MAC address of the destination computer. There is a special protocol ARP (address resolution protocol) that is used for that. Once the sender has retrieved the MAC address   of the next hop, he sends the data. Before sending the data packet over the Ethernet, it is divided into shorter pieces called frames.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
MAC addresses are needed for communication within the Local Area Network. IP address comes into the picture when the packet has to be routed to a different network.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5EJhCPYEPXbB44HM9rlL4t-rhyphenhyphenw3exXgrQ0wDHTQvE_hd5X40_pM88MHMvXhJ2tXPbiDmUsyCfMN_GaZPC9Kljrvgku8ndXmsCePTq8Z0IE7Tznh9P3QkhvifuEAd6ZVpVH9oJfADoT8/s1600/ip.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;303&quot; data-original-width=&quot;765&quot; height=&quot;252&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5EJhCPYEPXbB44HM9rlL4t-rhyphenhyphenw3exXgrQ0wDHTQvE_hd5X40_pM88MHMvXhJ2tXPbiDmUsyCfMN_GaZPC9Kljrvgku8ndXmsCePTq8Z0IE7Tznh9P3QkhvifuEAd6ZVpVH9oJfADoT8/s640/ip.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Why MAC address are used locally only?&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
With MAC addresses, there is no hierarchy, and thus packet forwarding&amp;nbsp; would not be possible. So, MAC addresses are not used for packet&amp;nbsp; transfer.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
And also, a host&amp;nbsp; (e.g., a computer) cannot determine from the MAC address of another&amp;nbsp; host whether that host is on the same network as the sending host, or on&amp;nbsp; a network bridged to that network. This is the weakness of a MAC&amp;nbsp; address and the reason why it is not used for determining the location&amp;nbsp; of a host. Instead, determining a host&#39;s location, whether it is on the&amp;nbsp; same network or another network, can only be accomplished by means of&amp;nbsp; the IP address.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
To&amp;nbsp; route by MAC addresses, routers would have to account for every machine&amp;nbsp; on the network individually which is a impossible for a&amp;nbsp; network the size of the Internet.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Why we need IP when MACs are so unique?&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
To explain this in layman’s terms, let us compare IP routing to our postal address and routers to various post offices worldwide. Now let’s say your friend in Virginia, USA mails you a post card to your residence address which is like 101   Ganesh Society, Nariman Point, Mumbai-400001, Maharashtra, India. The post card will be first delivered to India then Maharashtra then Mumbai till it finally reaches your apartment.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Now let’s assume your another friend in India were to post you a postcard from New Delhi and he only knows your Aadhar Id (an unique Id for Indian citizen). Will the post office be able to deliver the post card without even referring your   postal address online? The answer is No. This is simply because every post office worldwide relies on each other to deliver the posts.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Now, once again let&#39;s use the analogy of post office and unique ID and assume we had to use only the MAC address or a Unique ID or Aadhar Id to deliver information to another computer somewhere across the world. In this case we would require   a single gigantic post office somewhere in first place. All the posts would be collected by this giant post office and then distributed to each person across the world. Which would also mean that if this post office was to be setup in New York, the post card   from your friend in New Delhi would have to travel to New York before reaching you. This post office might have to handle millions of mails and parcels daily. They would have to maintain postal records for literally each person in the world so that their logistics   team may deliver posts to respective people directly (Since there is no other post office to do the job). This may require infinite amount of resources and delivery teams travelling from just one central post office to each house in the world which is again   next to impossible.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Similarly in the case of computer networks or an Internet, it is not possible to hook every single computer in the world to one network router or switch. We need to break this into smaller network segments, also known as subnets.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/366805932404563458/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/366805932404563458' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/366805932404563458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/366805932404563458'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2019/12/when-mac-address-itself-is-unique-why.html' title='When a MAC address itself is unique, why do we still need an IP address to uniquely identify a system on a network?'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5EJhCPYEPXbB44HM9rlL4t-rhyphenhyphenw3exXgrQ0wDHTQvE_hd5X40_pM88MHMvXhJ2tXPbiDmUsyCfMN_GaZPC9Kljrvgku8ndXmsCePTq8Z0IE7Tznh9P3QkhvifuEAd6ZVpVH9oJfADoT8/s72-c/ip.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-5283809818933988060</id><published>2019-12-01T15:59:00.000+05:30</published><updated>2019-12-01T16:29:56.960+05:30</updated><title type='text'>Horizontal and Vertical Scaling</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;WordSection1&quot;&gt;
&lt;div style=&quot;background: white; margin-bottom: 0.0001pt; margin: 0in; vertical-align: baseline;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;border: none 1.0pt; color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif; padding: 0in;&quot;&gt;Horizontal Scaling&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style=&quot;border: none 1.0pt; color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif; font-weight: normal; padding: 0in;&quot;&gt;   means that you scale by adding more machines&lt;/span&gt;&lt;/strong&gt;&lt;b&gt;&lt;span style=&quot;color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif;&quot;&gt;into your pool of resources whereas&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;border: none 1.0pt; color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif; padding: 0in;&quot;&gt;Vertical   Scaling&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style=&quot;border: none 1.0pt; color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif; font-weight: normal; padding: 0in;&quot;&gt; means that you scale by adding more power (CPU, RAM) to an existing machine&lt;/span&gt;&lt;/strong&gt;&lt;b&gt;&lt;span style=&quot;color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif;&quot;&gt;.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: inherit; color: #171717; font-family: &amp;quot;calibri&amp;quot; , sans-serif; margin-top: 1rem; overflow-wrap: break-word; padding: 0px;&quot;&gt;
Alternative term for Horizontal and Vertical Scaling is also known as &lt;b&gt;Scale Out&lt;/b&gt; and &lt;b&gt;Scale Up&lt;/b&gt; respectively.&lt;/div&gt;
&lt;ul style=&quot;background-color: white; box-sizing: inherit; color: #171717; font-family: &amp;quot;calibri&amp;quot; , sans-serif; list-style: none; margin: 16px 0px 16px 38px; padding: 0px;&quot;&gt;
&lt;li style=&quot;box-sizing: inherit; list-style: outside none disc; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;https://en.wikipedia.org/wiki/Scalability#Horizontal_and_vertical_scaling&quot; style=&quot;background-color: transparent; box-sizing: inherit; cursor: pointer; outline: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; target=&quot;_blank&quot;&gt;Scale up&lt;/a&gt;: Get more CPU, memory, disk space, and extra features like dedicated virtual machines (VMs), custom domains and certificates, staging slots, autoscaling, and more. You scale up by changing the pricing tier of the App Service plan that your app belongs to.&lt;/li&gt;
&lt;li style=&quot;box-sizing: inherit; list-style: outside none disc; margin: 0px; outline: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;https://en.wikipedia.org/wiki/Scalability#Horizontal_and_vertical_scaling&quot; style=&quot;background-color: transparent; box-sizing: inherit; cursor: pointer; outline: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; target=&quot;_blank&quot;&gt;Scale out&lt;/a&gt;: Increase the number of VM instances that run your app. You can scale out to as many as 30 instances, depending on your pricing tier.&amp;nbsp;&lt;a data-linktype=&quot;relative-path&quot; href=&quot;https://docs.microsoft.com/en-us/azure/app-service/environment/intro&quot; style=&quot;background-color: transparent; box-sizing: inherit; cursor: pointer; outline: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; target=&quot;_blank&quot;&gt;App Service Environments&lt;/a&gt;&amp;nbsp;in&amp;nbsp;&lt;span style=&quot;box-sizing: inherit; font-weight: bolder;&quot;&gt;Isolated&lt;/span&gt;&amp;nbsp;tier further increases your scale-out count to 100 instances. For more information about scaling out, see&amp;nbsp;&lt;a data-linktype=&quot;relative-path&quot; href=&quot;https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/insights-how-to-scale&quot; style=&quot;background-color: transparent; box-sizing: inherit; cursor: pointer; outline: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; target=&quot;_blank&quot;&gt;Scale instance count manually or automatically&lt;/a&gt;. There, you find out how to use autoscaling, which is to scale instance count automatically based on predefined rules and schedules.&lt;b&gt;&lt;span style=&quot;color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background: white; box-sizing: inherit; font-stretch: inherit; line-height: inherit; margin-bottom: 0.0001pt; margin: 0in; vertical-align: baseline; word-spacing: 0px;&quot;&gt;
&lt;span style=&quot;color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif;&quot;&gt;An easy way to remember this is to think of a machine on a server rack, we add more machines across the&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;border: none 1.0pt; color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif; padding: 0in;&quot;&gt;horizontal&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;direction   and add more resources to a machine in the&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;border: none 1.0pt; color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif; padding: 0in;&quot;&gt;vertical&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;direction.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div align=&quot;center&quot; style=&quot;background: white; box-sizing: inherit; font-stretch: inherit; line-height: inherit; margin-bottom: 0.0001pt; margin: 0in; text-align: center; vertical-align: baseline; word-spacing: 0px;&quot;&gt;
&lt;span style=&quot;color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5NKB8LnoqJIwg09tUS9LPejkAsTegzAel-KLSA683wpCsl1nnAvOLXKwGP177bqDR1l03JvQ4I90wNC1F-RtusqTfJz6Hjns_YgfzZ6s-CGNJQERbnpziYhrl4UHnS_tMBwv2rFZErVM/s1600/image002-776179.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_6765411338763853698&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5NKB8LnoqJIwg09tUS9LPejkAsTegzAel-KLSA683wpCsl1nnAvOLXKwGP177bqDR1l03JvQ4I90wNC1F-RtusqTfJz6Hjns_YgfzZ6s-CGNJQERbnpziYhrl4UHnS_tMBwv2rFZErVM/s320/image002-776179.png&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: white; box-sizing: inherit; font-stretch: inherit; line-height: inherit; margin-bottom: 12.0pt; margin-left: 0in; margin-right: 0in; vertical-align: baseline; word-spacing: 0px;&quot;&gt;
&lt;span style=&quot;color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif;&quot;&gt;In a database world horizontal-scaling is often based on the partitioning of the data i.e. each node contains only part of the data, in vertical-scaling the data resides on a single node and scaling   is done through multi-core i.e. spreading the load between the CPU and RAM resources of that machine.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: white; box-sizing: inherit; font-stretch: inherit; line-height: inherit; margin-bottom: 12.0pt; margin-left: 0in; margin-right: 0in; vertical-align: baseline; word-spacing: 0px;&quot;&gt;
&lt;span style=&quot;color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif;&quot;&gt;With horizontal-scaling it is often easier to scale dynamically by adding more machines into the existing pool - Vertical-scaling is often limited to the capacity of a single machine, scaling beyond   that capacity often involves downtime and comes with an upper limit.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: white; box-sizing: inherit; font-stretch: inherit; line-height: inherit; margin-bottom: 0.0001pt; margin: 0in; vertical-align: baseline; word-spacing: 0px;&quot;&gt;
&lt;span style=&quot;color: #242729; font-family: &amp;quot;calibri&amp;quot; , sans-serif;&quot;&gt;Good examples of horizontal scaling are Cassandra, MongoDB,&amp;nbsp;&lt;a href=&quot;https://cloud.google.com/spanner&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;border: none 1.0pt; color: #005999; padding: 0in;&quot;&gt;Google Cloud Spanner&lt;/span&gt;&lt;/a&gt;   (a kind of sharding) etc and a good example of vertical scaling is MySQL - Amazon RDS (The cloud version of MySQL). It provides an easy way to scale vertically by switching from small to bigger machines. This process often involves downtime.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/5283809818933988060/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/5283809818933988060' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/5283809818933988060'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/5283809818933988060'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2019/12/horizontal-and-vertical-scaling.html' title='Horizontal and Vertical Scaling'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5NKB8LnoqJIwg09tUS9LPejkAsTegzAel-KLSA683wpCsl1nnAvOLXKwGP177bqDR1l03JvQ4I90wNC1F-RtusqTfJz6Hjns_YgfzZ6s-CGNJQERbnpziYhrl4UHnS_tMBwv2rFZErVM/s72-c/image002-776179.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-110605182721573097</id><published>2019-11-19T17:33:00.001+05:30</published><updated>2019-11-19T17:33:11.270+05:30</updated><title type='text'>.NET Core: Session Wrapper Design Pattern For ASP.NET Core</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;WordSection1&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Here, we&#39;ll learn about Session Wrapper design pattern to ease the access of Session. We&#39;ll make our access of session &quot;Typed&quot;. Also, we may apply any validation or constraint in this wrapper class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Step 1 - Create a Session Manager class&lt;/b&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
In this example, we are going to store two items in Session (i.e. ID &amp;amp; LoginName).&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;ol start=&quot;1&quot; style=&quot;margin-top: 0in;&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l1 level1 lfo3;&quot;&gt;We are injecting IHttpContextAccessor so that we can access the Session variable.&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l1 level1 lfo3;&quot;&gt;We are creating properties which are actually accessing Session variable and returning the data or writing the data to Session.&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l1 level1 lfo3;&quot;&gt;We have added one helping property &quot;IsLoggedIn&quot; which is using other properties to make a decision. We may have more such helping/wrapper properties.&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;using Microsoft.AspNetCore.Http;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;public&amp;nbsp;class&amp;nbsp;SessionManager&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;private&amp;nbsp;readonly&amp;nbsp;ISession&amp;nbsp;_session;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;private&amp;nbsp;const&amp;nbsp;String&amp;nbsp;ID_KEY&amp;nbsp;=&amp;nbsp;&quot;_ID&quot;;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;private&amp;nbsp;const&amp;nbsp;String&amp;nbsp;LOGIN_KEY&amp;nbsp;=&amp;nbsp;&quot;_LoginName&quot;;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;SessionManager(IHttpContextAccessor&amp;nbsp;httpContextAccessor)&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;_session&amp;nbsp;=&amp;nbsp;httpContextAccessor.HttpContext.Session;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;int&amp;nbsp;ID&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;get&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;var&amp;nbsp;v&amp;nbsp;=&amp;nbsp;_session.GetInt32(ID_KEY);&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;if&amp;nbsp;(v.HasValue)&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;return&amp;nbsp;v.Value;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;else&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;return&amp;nbsp;0;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;set&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;_session.SetInt32(ID_KEY,&amp;nbsp;value);&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;String&amp;nbsp;LoginName&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;get&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;return&amp;nbsp;_session.GetString(LOGIN_KEY);&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;set&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;_session.SetString(LOGIN_KEY,&amp;nbsp;value);&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;Boolean&amp;nbsp;IsLoggedIn&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;get&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;if&amp;nbsp;(ID&amp;nbsp;&amp;gt;&amp;nbsp;0)&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;return&amp;nbsp;true;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;else&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;return&amp;nbsp;false;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Step 2&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Registering IHttpContextAccessor and SessionManager in Startup file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;services.AddSingleton&amp;lt;IHttpContextAccessor, HttpContextAccessor&amp;gt;();&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;services.AddScoped&amp;lt;SessionManager&amp;gt;();&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Step 3&lt;/b&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Injecting SessionManager in your classes. Here is an example of Controller class but in the same way, it can be injected in non-controller classes too.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;private&amp;nbsp;readonly&amp;nbsp;SessionManager&amp;nbsp;_sessionManager;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;public&amp;nbsp;HomeController(SessionManager&amp;nbsp;sessionManager)&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;{&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_sessionManager&amp;nbsp;=&amp;nbsp;sessionManager;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;}&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Step 4&lt;/b&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Using SessionManager to access Session Data,&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;_sessionManager.ID&amp;nbsp;=&amp;nbsp;1;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;_sessionManager.LoginName&amp;nbsp;=&amp;nbsp;dto.Login;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;if(_sessionManager.IsLoggedIn&amp;nbsp;==&amp;nbsp;true)&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;{&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ViewBag.Login&amp;nbsp;=&amp;nbsp;_sessionManager.LoginName;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;View();&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Conclusion&lt;/b&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
This wrapper pattern helps using Session without worrying about KeyNames &amp;amp; Makes access easier. It also helps you apply different conditioning and constraints in a wrapper class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;Reference: csharpccorner.com&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/110605182721573097/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/110605182721573097' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/110605182721573097'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/110605182721573097'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2019/11/net-core-session-wrapper-design-pattern.html' title='.NET Core: Session Wrapper Design Pattern For ASP.NET Core'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-6577304927271390559</id><published>2019-11-19T17:25:00.001+05:30</published><updated>2019-11-19T17:32:22.217+05:30</updated><title type='text'>.NET Core: All About Sessions In ASP.NET Core</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;WordSection1&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
We&#39;ll quickly discuss how we used to use &lt;b&gt;Sessions&lt;/b&gt; before  &lt;b&gt;ASP.NET Core&lt;/b&gt; and then we&#39;ll see how to access Sessions in ASP.NET Core.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Session In Pre-ASP.NET Core era&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;ul style=&quot;margin-top: 0in;&quot; type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l1 level1 lfo1;&quot;&gt;You get Session functionality by default (without adding any package)&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l1 level1 lfo1;&quot;&gt;Previously, you would have accessed Session by -&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;ul style=&quot;margin-top: 0in;&quot; type=&quot;circle&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l1 level2 lfo1;&quot;&gt;Session variable in your Controllers/Forms&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l1 level2 lfo1;&quot;&gt;&lt;span style=&quot;color: #0070c0;&quot;&gt;System.Web.HttpContext.Current.Session&lt;/span&gt; in places where you don&#39;t have direct access to the Session variable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l1 level1 lfo1;&quot;&gt;Anything you store in session is stored as Object. You store values in Key/Value format.&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;Session[&quot;mydata&quot;]&amp;nbsp;=&amp;nbsp;10;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
Or to access on those places where Session is not available (e.g. Non-Controller classes)&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;System.Web.HttpContext.Current.Session[&quot;mydata&quot;]&amp;nbsp;=&amp;nbsp;10;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;ul style=&quot;margin-top: 0in;&quot; type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l2 level1 lfo2;&quot;&gt;Quite difficult to mock Session Object for Unit Testing&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Session in ASP.NET Core 2.2&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;ol start=&quot;1&quot; style=&quot;margin-top: 0in;&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l0 level1 lfo3;&quot;&gt;Now, Session is not available by default.&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l0 level1 lfo3;&quot;&gt;You need to add the following package. Meta package by default provides you this.&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;lt;PackageReference&amp;nbsp;Include=&quot;Microsoft.AspNetCore.Session&quot;&amp;nbsp;Version=&quot;2.2.0&quot;&amp;nbsp;/&amp;gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;ol start=&quot;3&quot; style=&quot;margin-top: 0in;&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l0 level1 lfo3;&quot;&gt;In Startup.ConfigureServices, you need to add the following to register services with DI Container.&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;services.AddDistributedMemoryCache();&lt;/span&gt;//To&amp;nbsp;Store&amp;nbsp;session&amp;nbsp;in&amp;nbsp;Memory, This is default implementation of IDistributedCache&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;services.AddSession();&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;ol start=&quot;1&quot; style=&quot;margin-top: 0in;&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l0 level1 lfo4;&quot;&gt;In Startup.Configure, you need to add the following (before UseMVC) to add Session Middleware.&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;app.UseCookiePolicy();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;app.UseSession();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;app.UseMvc(routes&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;ol start=&quot;1&quot; style=&quot;margin-top: 0in;&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l0 level1 lfo5;&quot;&gt;Make sure the following is also there (It is added by default when you use ASP.NET Core MVC Template).&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;app.UseCookiePolicy();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;ol start=&quot;1&quot; style=&quot;margin-top: 0in;&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l0 level1 lfo6;&quot;&gt;ASP.NET Core 2.2 onwards adds Cookie Consent (true) in the Startup file. When an application runs, the user needs to accept Cookie Consent on screen. When the user accepts the policy on the page, it creates   a consent cookie. It is to follow GDPR and to give control to the user if the user wants to store cookies from a site or not. If the user doesn&#39;t accept that, Session does not work because Session requires a cookie to send/receive session Id. You may face   this issue while working with ASP.NET Core MVC default template.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;How to access Session in Controller?&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
You will notice that you don&#39;t have &quot;Session&quot; variable available now. Controller now has a property &quot;HttpContext&quot; which has &quot;Session&quot; variable. So, you can access session in controller by using the following code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;var&amp;nbsp;a&amp;nbsp;=&amp;nbsp;this.HttpContext.Session.GetString(&quot;login&quot;);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;HttpContext.Session.SetString(&quot;login&quot;,&amp;nbsp;dto.Login);&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;How to access Session in Non-Controller class?&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Now, you don&#39;t have System.Web.HttpContext.Current.Session in ASP.NET Core. To access session in non-controller class –&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;margin-top: 0in;&quot; type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l4 level1 lfo7;&quot;&gt;First, register the following service in Startup.ConfigureServices;&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;services.AddSingleton&amp;lt;IHttpContextAccessor,&amp;nbsp;HttpContextAccessor&amp;gt;();&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;ul style=&quot;margin-top: 0in;&quot; type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l4 level1 lfo7;&quot;&gt;Now, register a class (example - TestManager) where you want to access the Session in Startup.ConfigureServices;&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;services.AddScoped&amp;lt;TestManager&amp;gt;();&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;i&gt;&lt;u&gt;Note&lt;br /&gt;  &lt;/u&gt;&lt;/i&gt;You may use AddTransient or AddSingleton according to your logic.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;ul style=&quot;margin-top: 0in;&quot; type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l4 level1 lfo8;&quot;&gt;Now, in TestManager class, add the following code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;private&amp;nbsp;readonly&amp;nbsp;IHttpContextAccessor&amp;nbsp;_httpContextAccessor;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;private&amp;nbsp;readonly&amp;nbsp;ISession&amp;nbsp;_session;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;public&amp;nbsp;TestManager(IHttpContextAccessor&amp;nbsp;httpContextAccessor)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _httpContextAccessor&amp;nbsp;=&amp;nbsp;httpContextAccessor;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _session&amp;nbsp;=&amp;nbsp;_httpContextAccessor.HttpContext.Session;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The above code is receiving &lt;i&gt;IHttpContextAccessor &lt;/i&gt;object through dependency injection and then, it is storing Sessions in a local variable.&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;How to access Session in View file?&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Add the following at the top of your View file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;@using&amp;nbsp;Microsoft.AspNetCore.Http&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;@inject&amp;nbsp;IHttpContextAccessor&amp;nbsp;httpContextAccessor&lt;/span&gt;&amp;nbsp; &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Then, you may access the Session variable in your View like following.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;@httpContextAccessor.HttpContext.Session.GetString(&quot;login&quot;)&lt;/span&gt;&amp;nbsp; &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;What else is changed regarding Session?&lt;/b&gt;&lt;b&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;ul style=&quot;margin-top: 0in;&quot; type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l3 level1 lfo9;&quot;&gt;Session is non-locking now.&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l3 level1 lfo9;&quot;&gt;A session is not created until you have at least one value in it&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l3 level1 lfo9;&quot;&gt;You need to use functions to get &amp;amp; set data. Array syntax is not supported now.&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l3 level1 lfo9;&quot;&gt;Now, ISession only provides Get &amp;amp; Set method which takes &amp;amp; returns data in Byte Array format.&lt;o:p&gt;&lt;/o:p&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l3 level1 lfo9;&quot;&gt;If you want to store data in the String format, you may add the following in your file and use extension methods.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;using&amp;nbsp;Microsoft.AspNetCore.Http;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
It exposes the new extension methods.&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;SetInt32&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;GetInt32&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;SetString&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;GetString&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
Under the hood, these covert the data into bytes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;margin-top: 0in;&quot; type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list: l3 level1 lfo10;&quot;&gt;You may also write your own extension methods. For example, the following Extension Methods help you store &amp;amp; retrieve any complex type.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;public&amp;nbsp;static&amp;nbsp;class&amp;nbsp;SessionExtensions&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;Set&amp;lt;T&amp;gt;(this&amp;nbsp;ISession&amp;nbsp;session,&amp;nbsp;string&amp;nbsp;key,&amp;nbsp;T&amp;nbsp;value)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;session.Set&amp;lt;(key,&amp;nbsp;JsonConvert.SerializeObject(value));&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;static&amp;nbsp;T&amp;nbsp;GetObject&amp;lt;T&amp;gt;(this&amp;nbsp;ISession&amp;nbsp;session,&amp;nbsp;string&amp;nbsp;key)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;var&amp;nbsp;value&amp;nbsp;=&amp;nbsp;session.GetString(key);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;return&amp;nbsp;value&amp;nbsp;==&amp;nbsp;null&amp;nbsp;?&amp;nbsp;default(T)&amp;nbsp;:&amp;nbsp;JsonConvert.DeserializeObject&amp;lt;T&amp;gt;(value);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&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;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.0in;&quot;&gt;
&lt;span style=&quot;color: #0070c0;&quot;&gt;}&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Session concepts are similar to what we&#39;ve seen in earlier .NET Frameworks. The real difference is that now, it is cleaner &amp;amp; more flexible to use.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;Reference: csharpccorner.com&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;font-size: 12.0pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/6577304927271390559/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/6577304927271390559' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/6577304927271390559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/6577304927271390559'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2019/11/net-core-all-about-sessions-in-aspnet_19.html' title='.NET Core: All About Sessions In ASP.NET Core'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-7908607810166686936</id><published>2019-11-19T17:19:00.001+05:30</published><updated>2019-11-19T17:19:35.801+05:30</updated><title type='text'>Project Management - Ten Popular Myths About Leadership and How to Overcome Them</title><content type='html'>&lt;div class=&quot;WordSection1&quot;&gt;  &lt;p style=&quot;background:white;vertical-align:baseline&quot;&gt;&lt;span style=&quot;font-size:16.0pt&quot;&gt;Close your eyes for a second and conjure-up a mental image of a leader. What do you see? Do you picture a politician, CEO&amp;nbsp;or military leader? It&amp;#8217;s easy to see why these type   of images come to someone&#39;s mind. Leaders are often viewed as someone who is decisive, smart&amp;nbsp;and outgoing. In some cases, leaders may appear just a little bit intimidating.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;The problem with an image that suggests an aggressive persona of authority is that it can prevent some potentially strong leaders from pursuing leadership roles or reaching their full potential. It&#39;s easy to misconstrue and have   a misconception of what a leader is and isn&amp;#8217;t.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;With that in mind, let&amp;#8217;s identify 10 of the most popular myths about leadership so that you can discover new opportunities and effectively take charge of your team.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.8rem 0px;outline: 0px;font-size:2.4rem;color:rgba(0, 0, 0, 0.9);font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;1. Entrepreneurial leadership.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;There&amp;#8217;s an assumption that all entrepreneurs are natural-born leaders. The reality is that just because you had a fantastic and timely idea doesn&amp;#8217;t mean that you&amp;#8217;re capable of organizing, operating, and scaling a business -- even   if that become a multi-million dollar business.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;Even though you&amp;#8217;re the &amp;#8220;founder&amp;#8221; of your business, don&amp;#8217;t automatically believe that you&amp;#8217;re in the best position to be its leader. Leadership&amp;nbsp;isn&amp;#8217;t tied to a job description. It&amp;#8217;s having a vision and getting others to buy into   it, growing talent, listening, and influencing others. Those are all qualities that can come from an outside CEO hire, like what&amp;nbsp;&lt;a href=&quot;https://www.entrepreneur.com/article/306533&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color:#665ED0;border:none windowtext 1.0pt;padding:0in&quot;&gt;LinkedIn&lt;/span&gt;&lt;/a&gt;&amp;nbsp;did   with Jeff Weiner, to the lowest levels of your organization.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;If you don&amp;#8217;t feel that you possess strong leadership qualities, then it&amp;#8217;s best to check your ego at the door and hand the reins over to who does maintain the best skills in leadership.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;strong&gt;&lt;span style=&quot;font-size:16.0pt;font-family:&amp;quot;Calibri&amp;quot;,sans-serif;border:none windowtext 1.0pt;padding:0in&quot;&gt;Related:&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-size:16.0pt&quot;&gt;&lt;a href=&quot;https://www.entrepreneur.com/article/196720&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family:&amp;quot;Calibri&amp;quot;,sans-serif;color:#665ED0;border:none windowtext 1.0pt;padding:0in;text-decoration:none&quot;&gt;The   Entrepreneur as Leader&lt;/span&gt;&lt;/strong&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.8rem 0px;outline: 0px;font-size:2.4rem;color:rgba(0, 0, 0, 0.9);font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;2. Leaders can&amp;#8217;t show vulnerability.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;Perhaps one of the most prevalent myths is that leaders, no matter the situation, must dig-in and stand their ground. If they accept fault, change direction, or listen to others, then that&amp;#8217;s a sign of weakness. Of course, this   couldn&amp;#8217;t be further from the truth.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;Strong leaders own their mistakes so that they can learn from them. They&amp;#8217;re receptive to feedback --&amp;nbsp;&lt;a href=&quot;https://www.calendar.com/blog/dont-fear-negative-feedback-use-it-to-increase-productivity/&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color:#665ED0;border:none windowtext 1.0pt;padding:0in&quot;&gt;even   when it&amp;#8217;s negative&lt;/span&gt;&lt;/a&gt;. They don&amp;#8217;t have all the answers. And, they show-off their humanity by listening and caring for their employees.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.8rem 0px;outline: 0px;font-size:2.4rem;color:rgba(0, 0, 0, 0.9);font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;3. A great leader is cold, fierce and omnipotent.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;I&amp;#8217;m sure at some point you&amp;#8217;ve worked with a leader who is a know-it-all. They act tough, talk a big game, and separate themselves from the rest of the team. Now, think about your performance while under this individual? I bet   you weren&amp;#8217;t as productive and motivated as you could have been, right?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;Employees want their leaders to care for them genuinely. They want to feel respected. And, the employee&amp;nbsp;wishes&amp;nbsp;for their thoughts and concerns to be listened to&amp;nbsp;with kindness. The best way to sharpen these leadership skills is   by&amp;nbsp;&lt;a href=&quot;https://www.psychologytoday.com/us/blog/communication-success/201410/how-increase-your-emotional-intelligence-6-essentials&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color:#665ED0;border:none windowtext 1.0pt;padding:0in&quot;&gt;boosting emotional intelligence&lt;/span&gt;&lt;/a&gt;.   Increasing your emotional IQ will help you become more self-aware, empathetic, and a better communicator. As a result, you&amp;#8217;ll build a strong rapport with your team.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.8rem 0px;outline: 0px;font-size:2.4rem;color:rgba(0, 0, 0, 0.9);font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;4. Extroverted leaders are preferred.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;What&amp;#8217;s the difference between extroverts and introverts? Most people believe an extrovert is how they act in social settings. Extroverts are thought to be more outgoing and confident. Introverts are considered shy and withdrawn.   However, being extroverted or introverted has more to do with how we process information.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;Extroverts work through problems by discussing them and seeking the advice and input from others. Introverts process their thoughts and conflicts internally. Because of these differences, it shouldn&amp;#8217;t be surprising that extroverts   are drawn to leadership roles. Being a leader means engaging with other people, right?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;The reality is that not all extroverts are cut-out to be leaders. A lot of successful individuals, such as&amp;nbsp;&lt;a href=&quot;https://www.entrepreneur.com/topic/warren-buffett&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color:#665ED0;border:none windowtext 1.0pt;padding:0in&quot;&gt;Warren   Buffett&lt;/span&gt;&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;https://www.entrepreneur.com/topic/bill-gates&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color:#665ED0;border:none windowtext 1.0pt;padding:0in&quot;&gt;Bill Gates&lt;/span&gt;&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;https://www.entrepreneur.com/topic/barack-obama&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color:#665ED0;border:none windowtext 1.0pt;padding:0in&quot;&gt;Barack   Obama&lt;/span&gt;&lt;/a&gt;, and&amp;nbsp;&lt;a href=&quot;https://www.entrepreneur.com/article/246222&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color:#665ED0;border:none windowtext 1.0pt;padding:0in&quot;&gt;Marissa Mayer,&lt;/span&gt;&lt;/a&gt;&amp;nbsp;are introverts. Just because you&amp;#8217;re not the head of a department or comfortable   in crowds doesn&amp;#8217;t mean that you should sell yourself short. You may still possess the right leadership skills to inspire others.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;strong&gt;&lt;span style=&quot;font-size:16.0pt;font-family:&amp;quot;Calibri&amp;quot;,sans-serif;border:none windowtext 1.0pt;padding:0in&quot;&gt;Related:&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-size:16.0pt&quot;&gt;&lt;a href=&quot;https://www.entrepreneur.com/article/276137&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family:&amp;quot;Calibri&amp;quot;,sans-serif;color:#665ED0;border:none windowtext 1.0pt;padding:0in;text-decoration:none&quot;&gt;Why   Introverts May Be Better at Business Than Extrovert&lt;/span&gt;&lt;/strong&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.8rem 0px;outline: 0px;font-size:2.4rem;color:rgba(0, 0, 0, 0.9);font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;5. There&amp;#8217;s not enough time to develop leadership skills.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;As with any skill worth having, it takes time to develop. Using the &amp;quot;no time&amp;quot; is a poor excuse. We all have the same 24-hours in a day. And, we&amp;#8217;re all swamped. Somehow, plenty of other leaders can deepen their leadership skills   without a problem.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;The problem isn&amp;#8217;t that there aren&amp;#8217;t enough hours in the day. It&amp;#8217;s that&amp;nbsp;&lt;a href=&quot;https://www.calendar.com/blog/6-time-management-myths-that-are-causing-you-to-fail-and-how-to-beat-them/&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color:#665ED0;border:none windowtext 1.0pt;padding:0in&quot;&gt;you   aren&amp;#8217;t managing your time correctly&lt;/span&gt;&lt;/a&gt;. For example, waking-up 30-minutes earlier, batching related work, or delegating less critical tasks to others could free-up extra time. You can then use this time to read, take a course, or work with a coach   or mentor.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.8rem 0px;outline: 0px;font-size:2.4rem;color:rgba(0, 0, 0, 0.9);font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;6. Leadership is synonymous with management.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;Assuming that leadership is synonymous with good management is another common myth about leadership. Adequate direction and guidance cannot always be equated with a good commander. There are some reasonably significant distinctions   between these two roles, such as:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul type=&quot;disc&quot;&gt;  &lt;li class=&quot;MsoNormal&quot; style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.4rem 0px 2.4rem 3.2rem;outline: 0px;background-position-x:0px;background-position-y:0px&quot;&gt;  &lt;span lang=&quot;EN-GB&quot; style=&quot;font-size:16.0pt&quot;&gt;Leaders create a vision; managers establish goals.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.4rem 0px 2.4rem 3.2rem;outline: 0px;background-position-x:0px;background-position-y:0px&quot;&gt;  &lt;span lang=&quot;EN-GB&quot; style=&quot;font-size:16.0pt&quot;&gt;Managers maintain the status quo, while leaders are agents of change.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.4rem 0px 2.4rem 3.2rem;outline: 0px;background-position-x:0px;background-position-y:0px&quot;&gt;  &lt;span lang=&quot;EN-GB&quot; style=&quot;font-size:16.0pt&quot;&gt;Leaders are self-aware and unique. Managers copy others and adapt&amp;nbsp;and adopt others&#39; leadership style.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.4rem 0px 2.4rem 3.2rem;outline: 0px;background-position-x:0px;background-position-y:0px&quot;&gt;  &lt;span lang=&quot;EN-GB&quot; style=&quot;font-size:16.0pt&quot;&gt;Managers control or avoid risk and problems, while leaders are willing to take risks.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.4rem 0px 2.4rem 3.2rem;outline: 0px;background-position-x:0px;background-position-y:0px&quot;&gt;  &lt;span lang=&quot;EN-GB&quot; style=&quot;font-size:16.0pt&quot;&gt;Leaders keep focused on the big picture. Managers work on short-term goals.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.4rem 0px 2.4rem 3.2rem;outline: 0px;background-position-x:0px;background-position-y:0px&quot;&gt;  &lt;span lang=&quot;EN-GB&quot; style=&quot;font-size:16.0pt&quot;&gt;Leaders learn something new every day; managers rely on their existing talents.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.4rem 0px 2.4rem 3.2rem;outline: 0px;background-position-x:0px;background-position-y:0px&quot;&gt;  &lt;span lang=&quot;EN-GB&quot; style=&quot;font-size:16.0pt&quot;&gt;Managers build systems, while leaders construct relationships.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.4rem 0px 2.4rem 3.2rem;outline: 0px;background-position-x:0px;background-position-y:0px&quot;&gt;  &lt;span lang=&quot;EN-GB&quot; style=&quot;font-size:16.0pt&quot;&gt;Leaders coach; managers assign tasks and provide guidance.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.4rem 0px 2.4rem 3.2rem;outline: 0px;background-position-x:0px;background-position-y:0px&quot;&gt;  &lt;span lang=&quot;EN-GB&quot; style=&quot;font-size:16.0pt&quot;&gt;Managers have employees. Leaders, on the other hand, have loyal and dedicated fans.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;If you have a team with multiple&amp;nbsp;or complex goals, it&amp;#8217;s important to know the difference between leadership and management. You can then&amp;nbsp;&lt;a href=&quot;https://www.calendar.com/productivity-habits/&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color:#665ED0;border:none windowtext 1.0pt;padding:0in&quot;&gt;develop   either your leadership or management skills&lt;/span&gt;&lt;/a&gt;&amp;nbsp;-- depending on which you&amp;#8217;re lacking. You may also want to consider finding someone to complement the skills that are scarce.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.8rem 0px;outline: 0px;font-size:2.4rem;color:rgba(0, 0, 0, 0.9);font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;7. All leaders are trailblazers.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;Being a trailblazer isn&amp;#8217;t necessarily a bad thing. Trailblazers, after all, are ambitious, competitive, calculated risk-takers, and goal-oriented. At the same time, they&amp;#8217;re also an independent and the driving force behind a business.   An independent and driving force can make working with others a challenge.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;For example, while you&amp;#8217;re out impressing clients, investors, and customers through speaking engagements and pitches -- there&amp;#8217;s no one back rallying the troops. While trailblazers can definitely get people to jump on-board with   their vision, leaders know when to step back. A true leader or manager will recognize talent and work alongside this team&amp;nbsp;in order to propel everyone towards a shared mission and vision.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.8rem 0px;outline: 0px;font-size:2.4rem;color:rgba(0, 0, 0, 0.9);font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;8. My team members always tell me the truth.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;They may not be lying to you completely. But, your team is probably only giving you half-truths -- especially if you are a hard character to deal with. You may be a complicated, emotionally depleted individual -- thus it should   be easy to understand why you have problems being a leader. If an employee shares bad news with you and you overreact, then why would they open up to you again?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;Your employees should be able to be 100 percent transparent with you -- but if you punish them, do you think they&amp;#8217;ll repeat that same mistake? It&amp;#8217;s not always easy to hear the truth. But, without all the information, you can&amp;#8217;t   make a more informed decision -- nor can you grow as a leader.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;To encourage your team to tell you the truth, build a culture of calmness where you control your emotions. What&amp;#8217;s more, focus on what to do next instead of pointing fingers and giving people a second chance. Make it easy to receive   and provide feedback. Think about furnishing an online survey or focus groups conducted by a third party. When you have an outside source for company &amp;quot;tips&amp;quot; that ensures anonymity -- so that a team member doesn&#39;t have to be afraid of repercussions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;strong&gt;&lt;span style=&quot;font-size:16.0pt;font-family:&amp;quot;Calibri&amp;quot;,sans-serif;border:none windowtext 1.0pt;padding:0in&quot;&gt;Related:&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-size:16.0pt&quot;&gt;&lt;a href=&quot;https://www.entrepreneur.com/article/287229&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family:&amp;quot;Calibri&amp;quot;,sans-serif;color:#665ED0;border:none windowtext 1.0pt;padding:0in;text-decoration:none&quot;&gt;6   Tips for Hearing Tough Feedback&lt;/span&gt;&lt;/strong&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.8rem 0px;outline: 0px;font-size:2.4rem;color:rgba(0, 0, 0, 0.9);font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;9. The best leaders roll up their sleeves and get their hands dirty.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;Obviously, &amp;quot;getting your hands dirty&amp;quot; doesn&amp;#8217;t mean hiding in your office. There may times when you should be working side-by-side with employees -- as long as it&amp;#8217;s on the right activities. As a leader, you should be primarily   focused on tasks like decisions, priorities, and accountabilities. Non-leadership tasks should be automated, delegated, or outsourced so that you&amp;#8217;re not draining yourself mentally or physically.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;Remember -- lead with your work and not by prioritizing the work of others.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:2.8rem 0px;outline: 0px;font-size:2.4rem;color:rgba(0, 0, 0, 0.9);font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;10. Leaders must always be &amp;#8220;on.&amp;#8221;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;Finally, there&amp;#8217;s a misconception that leaders are must be &amp;#8220;on&amp;#8221; 24/7/365. The truth is that everyone, regardless of the leadership position, needs a break from work. Checking your email throughout the weekend or when or vacation   is a guaranteed way to burn yourself.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style=&quot;background:white;vertical-align:baseline;box-sizing: inherit;margin:3.2rem 0px;outline: 0px;font-size:2rem;color:rgba(0, 0, 0, 0.75);line-height:3.2rem;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;background-position-x:0px;background-position-y:0px;word-spacing:0px&quot;&gt;  &lt;span style=&quot;font-size:16.0pt&quot;&gt;&lt;a href=&quot;https://www.calendar.com/blog/time-away-work-increases-productivity/&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color:#665ED0;border:none windowtext 1.0pt;padding:0in&quot;&gt;You need time away&lt;/span&gt;&lt;/a&gt;&amp;nbsp;in order to reflect and focus on   what matters, such as spending time with your family, exercising, or learning new information. By taking breaks, you can clear your head and de-stress. As a result, you&amp;#8217;ll become a more energized, focused, and creative leader.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;/div&gt;  </content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/7908607810166686936/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/7908607810166686936' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/7908607810166686936'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/7908607810166686936'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2019/11/project-management-ten-popular-myths.html' title='Project Management - Ten Popular Myths About Leadership and How to Overcome Them'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-2806419281183240866</id><published>2019-11-19T17:13:00.001+05:30</published><updated>2019-11-19T17:13:57.949+05:30</updated><title type='text'>Remember to think about the user (Customer Experience)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;WordSection1&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitkcHcCbqpinIwwMX83v42K6SnTUne61vI63wAHgqf-drY5tK2XLIUM61YXqgLp4mesy0VSGpQdn9hl6Sd1W3xbguIoNOja-t0-uhgt0mAK4T-n-dk3665B2Tg0F3iCN57AaT0-tx54aA/s1600/image011-720510.jpg&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;592&quot; id=&quot;BLOGGER_PHOTO_ID_6760981697733672066&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitkcHcCbqpinIwwMX83v42K6SnTUne61vI63wAHgqf-drY5tK2XLIUM61YXqgLp4mesy0VSGpQdn9hl6Sd1W3xbguIoNOja-t0-uhgt0mAK4T-n-dk3665B2Tg0F3iCN57AaT0-tx54aA/s640/image011-720510.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/2806419281183240866/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/2806419281183240866' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/2806419281183240866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/2806419281183240866'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2019/11/remember-to-think-about-user-customer.html' title='Remember to think about the user (Customer Experience)'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitkcHcCbqpinIwwMX83v42K6SnTUne61vI63wAHgqf-drY5tK2XLIUM61YXqgLp4mesy0VSGpQdn9hl6Sd1W3xbguIoNOja-t0-uhgt0mAK4T-n-dk3665B2Tg0F3iCN57AaT0-tx54aA/s72-c/image011-720510.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-5190474730048626767</id><published>2019-11-18T19:41:00.001+05:30</published><updated>2019-11-18T19:55:29.123+05:30</updated><title type='text'>How The OSI Works</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Diagram of the OSI Model&lt;/b&gt;&lt;br /&gt;
Refer to it as you read the &#39;Step-by-Step&#39; section below,&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG17Y5Vm43EgI6dh9czJoSn4uTzFrkZztaDWt5szMOLGmokLWTB2AUbr6PPzXj1IBYCDaFkzo9hFU9dtIEx0shCrt6rkxpHdEsqhmOPKvXueQ-wxxKAp4ZP0_MD3VH1nQFmllMjDl9EIk/s1600/OSI+Model+Working+1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;356&quot; data-original-width=&quot;782&quot; height=&quot;289&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG17Y5Vm43EgI6dh9czJoSn4uTzFrkZztaDWt5szMOLGmokLWTB2AUbr6PPzXj1IBYCDaFkzo9hFU9dtIEx0shCrt6rkxpHdEsqhmOPKvXueQ-wxxKAp4ZP0_MD3VH1nQFmllMjDl9EIk/s640/OSI+Model+Working+1.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;HOW THE OSI MODEL WORKS - STEP BY STEP
&lt;/b&gt;&lt;br /&gt;
&lt;ol style=&quot;color: #0f1419; text-align: justify;&quot;&gt;
&lt;li&gt;Network-capable&amp;nbsp;&lt;strong&gt;&lt;span style=&quot;color: red;&quot;&gt;Applications&lt;/span&gt;&lt;/strong&gt;&amp;nbsp;produce&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;&lt;strong&gt;DATA&lt;/strong&gt;&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Each layer in the OSI Model adds its own information to the front of the data it receives from the layer above it. This information in front of the data is called a&amp;nbsp;&lt;strong&gt;header&lt;/strong&gt;&amp;nbsp;and contains information specific to the protocol operating at that layer. The process of adding the header is called&amp;nbsp;&lt;em&gt;encapsulation&lt;/em&gt;. Encapsulated data is transmitted in&amp;nbsp;&lt;em&gt;Protocol Data Units&lt;/em&gt;(PDUs). There are&amp;nbsp;&lt;span style=&quot;color: #ff9900;&quot;&gt;&lt;strong&gt;Presentation&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;PDU&#39;s,&amp;nbsp;&lt;span style=&quot;color: #cccc00;&quot;&gt;&lt;b&gt;Session&lt;/b&gt;&lt;/span&gt;&amp;nbsp;PDU&#39;s,&amp;nbsp;&lt;span style=&quot;color: #33cc00;&quot;&gt;&lt;strong&gt;Transport&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;PDU&#39;s etc. Thus, PDU&#39;s from an upper layer are encapsulated inside the PDU of the layer below it.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;PDU&#39;s are passed down through the stack of layers (called &#39;the stack&#39; for short) optionally repeating the&amp;nbsp;encapsulation&amp;nbsp;process until they can be transmitted over the&amp;nbsp;&lt;span style=&quot;color: #990099;&quot;&gt;&lt;strong&gt;Physical&lt;/strong&gt;&amp;nbsp;&lt;/span&gt;layer. The physical layer is the wire connecting all the&amp;nbsp;computers&amp;nbsp;on the&amp;nbsp;network.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;The OSI standards specify that a layer on host #1 speaks the same language as the same layer on host #2 or any other host on the network. Thus, all hosts can communicate via the&amp;nbsp;&lt;span style=&quot;color: #990099;&quot;&gt;&lt;strong&gt;Physical&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;layer. This communication between layers is represented by the &lt;img border=&quot;0&quot; data-original-height=&quot;7&quot; data-original-width=&quot;42&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEIcPlPh8sF17g-pQTFlKzrHbRzM1na24V8bk87zIBDuLqUj-_QuzQ4OQz1buh7v7qHW1342WpN_F1R2ZshQmXeCqu0MBJFozhVi8qVVEAcgho_rutIxROl-rR2ivOupB8WKmFCs9BHiA/s1600/h-arrow.gif&quot; /&gt;&amp;nbsp;symbols in the diagram above. For example, the&amp;nbsp;&lt;span style=&quot;color: #33cc00;&quot;&gt;&lt;strong&gt;Transport&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;layer on Host 1 should speak the same language as the&amp;nbsp;&lt;span style=&quot;color: #33cc00;&quot;&gt;&lt;strong&gt;Transport&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;layer on Host 2.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;strong&gt;DATA&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;passed upwards is un-encapsulated before being passed further up (represented by the colored brackets&amp;nbsp;&lt;strong&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;color: yellow;&quot;&gt;&lt;span style=&quot;color: #cc00ff;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9999ff;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0099ff;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #33cc00;&quot;&gt;[&lt;/span&gt;[&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&amp;nbsp;).&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;All information is passed down through all layers until it reaches the&amp;nbsp;&lt;span style=&quot;color: #990099;&quot;&gt;&lt;strong&gt;Physical&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;layer (represented by the vertical red arrows).&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;The&amp;nbsp;&lt;span style=&quot;color: #990099;&quot;&gt;&lt;strong&gt;Physical&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;layer chops up the PDU&#39;s and transmits the PDU&#39;s over the physical connection (copper wire, fiber optic cable, radio link etc.). The&amp;nbsp;&lt;span style=&quot;color: #990099;&quot;&gt;&lt;strong&gt;Physical&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;layer provides the real physical connectivity between hosts over which all communication occurs (represented by&lt;img border=&quot;0&quot; data-original-height=&quot;7&quot; data-original-width=&quot;52&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFW7D_P1GZo4zErSHT3ibFIvzpijpuXKK3eUG1aaNmT6KsVUjGT4A-2MYIjDvJywaReW7QAI_sFKYXWsv-Z38PhvZlt_Bpyzj_2x0AyhUhxgMY3CgDuQpeH90AGBanE_NuMJYkYpgmrjk/s1600/h-arrow-r.gif&quot; /&gt;).&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;b&gt;SUMMARY
&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;color: #0f1419; margin-bottom: 12px; margin-top: 12px; padding: 0px 25px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Data from an upper layer is supposed to be passed down and inserted into the payload of a PDU in the layer below it. In the real world, the process of&amp;nbsp;&lt;em&gt;encapsulation&lt;/em&gt;&amp;nbsp;(adding a header) doesn&#39;t always occur at all layers and sometimes things get chopped into smaller pieces so they will be easier to send and receive. Data passed over the&amp;nbsp;Internet&amp;nbsp;gets the first header from the application, then from&amp;nbsp;Transmission Control Protocol&amp;nbsp;(TCP), then&amp;nbsp;Internet Protocol&amp;nbsp;(IP) adds a header and passes it down to a physical connection. After that point, the hardware (Ethernet&amp;nbsp;on&amp;nbsp;LANs) chops the&amp;nbsp;IP&amp;nbsp;data into pieces and slaps its own header on it.&amp;nbsp;Ethernet&amp;nbsp;and other 802.x protocols also place a CRC at the end of the frame in the form of a frame check sequence. Although&amp;nbsp;IP&amp;nbsp;doesn&#39;t conform exactly to the model above, the model is still a good reference point for discussing Internet based network technologies and protocols.&lt;/span&gt;&lt;/div&gt;
See also,&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;https://davenaimish.blogspot.com/2019/11/what-is-osi-model.html&quot; target=&quot;_blank&quot;&gt;What is the OSI Model?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://davenaimish.blogspot.com/2019/11/the-osi-models-seven-layers.html&quot; target=&quot;_blank&quot;&gt;The OSI Model&#39;s Seven Layers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://davenaimish.blogspot.com/2019/11/osi-model-vs-tcpip-model.html&quot; target=&quot;_blank&quot;&gt;OSI Model vs TCP/IP Model&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/5190474730048626767/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/5190474730048626767' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/5190474730048626767'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/5190474730048626767'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2019/11/how-osi-works.html' title='How The OSI Works'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG17Y5Vm43EgI6dh9czJoSn4uTzFrkZztaDWt5szMOLGmokLWTB2AUbr6PPzXj1IBYCDaFkzo9hFU9dtIEx0shCrt6rkxpHdEsqhmOPKvXueQ-wxxKAp4ZP0_MD3VH1nQFmllMjDl9EIk/s72-c/OSI+Model+Working+1.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-5221139634123954530</id><published>2019-11-18T18:39:00.003+05:30</published><updated>2019-11-18T19:57:24.570+05:30</updated><title type='text'>The OSI Model&#39;s Seven Layers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;APPLICATION LAYER&lt;/b&gt;&lt;br /&gt;
The OSI model defines the application layer as being the user interface. The OSI application layer is responsible for displaying data and images to the user in a human-recognizable format and to interface with the presentation layer below it.

&lt;br /&gt;
&lt;br /&gt;
Examples of applications that utilize the network are:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Telnet&lt;/li&gt;
&lt;li&gt;FTP&lt;/li&gt;
&lt;li&gt;Instant Message software (AIM, MSN, ICQ, Yahoo)&lt;/li&gt;
&lt;li&gt;Microsoft Windows File Shares&lt;/li&gt;
&lt;li&gt;Web Browsers (Internet Explorer, Firefox, Google Chrome, Safari)&lt;/li&gt;
&lt;li&gt;Network games of Doom, Quake, Unreal (first-person 3D shooter video games)&lt;/li&gt;
&lt;li&gt;IRC (mIRC)&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;PRESENTATION LAYER&lt;/b&gt;&lt;br /&gt;
The presentation layer handles the conversion of data between a Standards-based or platform independent formats to a format understood by the local machine. This allows for data to be transported between devices and still be understood.&lt;br /&gt;
&lt;br /&gt;
The presentation layer performs the following functions:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Communication with the application layer above.&lt;/li&gt;
&lt;li&gt;Translation of data conforming to cross-platform standards into formats understood by the local machine.&lt;/li&gt;
&lt;li&gt;Communication with the session layer below.&lt;/li&gt;
&lt;li&gt;Examples of Presentation Layer Functions&lt;/li&gt;
&lt;li&gt;Conversion of a Sun .RAS raster graphic to JPG.&lt;/li&gt;
&lt;li&gt;Conversion of ASCII to IBM EBCDIC&lt;/li&gt;
&lt;li&gt;Conversion of .PICT on a MAC to .jpg&lt;/li&gt;
&lt;li&gt;Conversion of .wav to .mp3&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;SESSION LAYER&lt;/b&gt;&lt;br /&gt;
The session layer tracks connections, also called sessions. The session layer should keep track of multiple file downloads requested by a particular FTP application, or multiple telnet connections from a single terminal client, or web page retrievals from a web server.&lt;br /&gt;
&lt;br /&gt;
With TCP/IP this functionality is handled by application software addressing a connection to a remote machine and using a different local port number for each connection.&lt;br /&gt;
&lt;br /&gt;
The session layer performs the following functions:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Communication with the Presentation layer above.&lt;/li&gt;
&lt;li&gt;Organize and manage one or more connections per application, between hosts.&lt;/li&gt;
&lt;li&gt;Communication with the Transport layer below.&lt;/li&gt;
&lt;/ul&gt;
Example,&lt;br /&gt;
Sessions are used to keep track of individual connections to remote servers. Your web browser is an excellent example of the use of sessions.&lt;br /&gt;
&lt;br /&gt;
Your web browser (an application layer object) opens a web page. That page contains text, graphics, Flash objects and perhaps animation. The graphics, the Flash object and the animation are all stored as separate files on the web server. To access them, a separate download must be started. Your web browser opens a separate session to the web server to download each of the individual files. The session layer keeps track of which packets and data belong to which file and keeps track of where they go (in this case, to your web browser).&lt;br /&gt;
&lt;br /&gt;
In most modern Internet applications, the session, presentation and application layers are usually rolled together inside the application itself, thus, your web browser performs all functions of the session, presentation and application layers.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;TRANSPORT LAYER&lt;/b&gt;&lt;br /&gt;
If networking software performs reliable data transfer functions, then the detection of errors, and re-transmission of data to recover those errors or lost data will occur in software managing this layer. The transport layer may use a variety of techniques such as a Cyclic Redundancy Check, windowing and acknowledgements. If data is lost or damaged it is the transport layer&#39;s responsibility to recover from that error.&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Communicate with the Session layer above.&lt;/li&gt;
&lt;li&gt;Reassemble transport Protocol Data Units into data streams&lt;/li&gt;
&lt;li&gt;Reliable protocols operating at this layer will&lt;/li&gt;
&lt;li&gt;Detect errors and lost data&lt;/li&gt;
&lt;li&gt;Recover lost data&lt;/li&gt;
&lt;li&gt;Manage re-transmission of data.&lt;/li&gt;
&lt;li&gt;Segmentation of data streams into transport Protocol Data Units.&lt;/li&gt;
&lt;li&gt;Communicate with the Network layer below.&lt;/li&gt;
&lt;/ul&gt;
Examples of transport layer protocols include:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Transmission Control Protocol (Reliable)&lt;/li&gt;
&lt;li&gt;User Datagram Protocol (Unreliable)&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;NETWORK LAYER&lt;/b&gt;&lt;br /&gt;
It is the network layer&#39;s job to figure out the network topology, handle routing and to prepare data for transmission. The network layer is concerned with the following primary functions:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Communication with the Transport layer above.&lt;/li&gt;
&lt;li&gt;Encapsulation of Transport data into Network layer Protocol Data Units.&lt;/li&gt;
&lt;li&gt;Management of connectivity and routing between hosts or networks.&lt;/li&gt;
&lt;li&gt;Communication with the data link layer below.&lt;/li&gt;
&lt;/ul&gt;
Examples of network layer protocols include:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Internet Protocol&lt;/li&gt;
&lt;li&gt;Internet Control Message Protocol (ICMP or &quot;ping&quot;)&lt;/li&gt;
&lt;li&gt;Internet Gateway Management Protocol (IGMP)&lt;/li&gt;
&lt;li&gt;IPX/SPX&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;DATA LINK LAYER&lt;/b&gt;&lt;br /&gt;
The data link Layer is the second layer of the OSI model. The data link layer performs various functions depending upon the hardware protocol used, but has four primary functions:&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;COMMUNICATION with the Network layer above.&lt;/li&gt;
&lt;li&gt;SEGMENTATION of upper layer datagrams (also called packets) into frames in sizes that can be handled by the communications hardware.&lt;/li&gt;
&lt;li&gt;BIT ORDERING. The data link layer organizes the pattern of data bits into frames before transmission. The frame formatting issues such as stop and start bits, bit order, parity and other functions are handled here. Management of big-endian / little-endian issues are also managed at this layer.&lt;/li&gt;
&lt;li&gt;COMMUNICATION with the Physical layer below&lt;/li&gt;
&lt;/ol&gt;
This layer provides reliable transit of data across a physical link. The data link layer is concerned with physical addressing, network topology, physical link management, error notification, ordered delivery of frames, and flow control.&lt;br /&gt;
&lt;br /&gt;
It should be noted that in most modern network interface adaptors, the Physical and Datalink functions are performed by the network interface adaptor.&lt;br /&gt;
&lt;br /&gt;
Example,&lt;br /&gt;
Ethernet Network Adaptors uses a Media Access Control (MAC) address, which is a physical address that (somewhat) uniquely identifies a network card to the physical network. The Ethernet Adaptor&#39;s primary job at the data link layer is to transmit Ethernet frames onto the wire. It places its own MAC address in the frame, followed by the destination MAC address to which it wishes to communicate, sets various other values in the Ethernet frame (protocol type etc.) and then transmits on the wire. The CSMA/CD protocol that Ethernet uses to control access to the common network bus could be said to occur at the data link layer of the OSI model or could also be called a data link function.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;PHYSICAL LAYER&lt;/b&gt;&lt;br /&gt;
The OSI Model&#39;s layer 1, the Physical Layer, outlines the characteristics of the physical medium between networked devices--cabling, wiring, fiber strands and the air. Transmission and receipt of data from the physical medium (copper wire, fiber, radio frequencies, barbed wire, string etc.) is managed at this layer.&lt;br /&gt;
&lt;br /&gt;
The Physical Layer receives data from the data link Layer, and transmits it to the wire. The physical layer controls the electrical and mechanical functions related to the transmission and receipt of a communications signal. It also manages the encoding and decoding of data contained within the modulated signal.&lt;br /&gt;
&lt;br /&gt;
Note that for two devices to communicate, they must be connected to the same type of physical medium (wiring). 802.3 Ethernet to 802.3 Ethernet, FDDI to FDDI, serial to serial etc. Two end stations using different protocols can only communicate through a multi-protocol bridge or a router.&lt;br /&gt;
&lt;br /&gt;
The physical layer is responsible for:&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Communication with the data link layer above it.&lt;/li&gt;
&lt;li&gt;Fragmentation of data into frames&lt;/li&gt;
&lt;li&gt;Reassembly of frames into data link Protocol Data Units.&lt;/li&gt;
&lt;li&gt;Transmission to the physical media&lt;/li&gt;
&lt;li&gt;Receiving from the physical media&lt;/li&gt;
&lt;li&gt;It should be noted that in most modern network interface adaptors, the physical and data link functions are performed by the adaptor.&lt;/li&gt;
&lt;/ol&gt;
Example Physical Protocols&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;CSMA/CD - Carrier Sense Multiple Access / Collision Detect&lt;/li&gt;
&lt;li&gt;CSMA/CA - Carrier Sense Multiple Access / Collision Avoid&lt;/li&gt;
&lt;li&gt;FDMA - Frequency Division Multiple Access&lt;/li&gt;
&lt;li&gt;MSK - Minimum Shift Keying&lt;/li&gt;
&lt;li&gt;GFMSK - Gaussian-Fitered Minimum Shift Keying&lt;/li&gt;
&lt;li&gt;TDMA - Time Division Multiple Access&lt;/li&gt;
&lt;li&gt;CDMA - Code Division Multiple Access&lt;/li&gt;
&lt;li&gt;B8ZS - Binary 8 Zero Substitution&lt;/li&gt;
&lt;li&gt;2B1Q - 2 Binary 1 Quaternary&lt;/li&gt;
&lt;li&gt;PCM - Pulse Code Modulation&lt;/li&gt;
&lt;li&gt;QAM - Quadrature Amplitude Modulation&lt;/li&gt;
&lt;li&gt;PSK - Phase Shift Keying&lt;/li&gt;
&lt;li&gt;SONET - Synchronous Optical NETworking&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
See also,&lt;br /&gt;
&lt;br /&gt;
&lt;li&gt;&lt;a href=&quot;https://davenaimish.blogspot.com/2019/11/what-is-osi-model.html&quot; target=&quot;_blank&quot;&gt;What is the OSI Model?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://davenaimish.blogspot.com/2019/11/how-osi-works.html&quot; target=&quot;_blank&quot;&gt;How The OSI Works?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://davenaimish.blogspot.com/2019/11/osi-model-vs-tcpip-model.html&quot; target=&quot;_blank&quot;&gt;OSI Model vs TCP/IP Model&lt;/a&gt;&lt;/li&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/5221139634123954530/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/5221139634123954530' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/5221139634123954530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/5221139634123954530'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2019/11/the-osi-models-seven-layers.html' title='The OSI Model&#39;s Seven Layers'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-4126037074752095167</id><published>2019-11-18T17:50:00.000+05:30</published><updated>2019-11-18T19:55:39.644+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Embedded Systems"/><category scheme="http://www.blogger.com/atom/ns#" term="IOT"/><category scheme="http://www.blogger.com/atom/ns#" term="M2M"/><category scheme="http://www.blogger.com/atom/ns#" term="Networking"/><category scheme="http://www.blogger.com/atom/ns#" term="OSI"/><title type='text'>What is the OSI Model</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Open Systems Interconnect (&lt;/b&gt;&lt;b&gt;OSI) Model&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
The &lt;b&gt;International Standards Organization&lt;/b&gt; (ISO) developed a &lt;b&gt;theoretical model of how networks should behave&lt;/b&gt; and how they are put together. This model is called the &lt;b&gt;Open Standards Interconnect&lt;/b&gt; (OSI) Model.
&lt;br /&gt;
&lt;br /&gt;
The OSI Model is a theoretical, &lt;b&gt;seven-layered model of how networks work&lt;/b&gt;. The OSI Model is a &lt;b&gt;theoretical model&lt;/b&gt; of networking that organizes network functions into seven layers,
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Physical layer&lt;/li&gt;
&lt;li&gt;Datalink layer&lt;/li&gt;
&lt;li&gt;Network layer&lt;/li&gt;
&lt;li&gt;Transport layer&lt;/li&gt;
&lt;li&gt;Session layer&lt;/li&gt;
&lt;li&gt;Presentation layer&lt;/li&gt;
&lt;li&gt;Application layer&lt;/li&gt;
&lt;/ol&gt;
It specifies the communication interfaces between the OSI Model&#39;s layers and between network endpoints utilizing an OSI Model-based protocol suite.
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;The OSI Model is a way of thinking about how networks work.&lt;/b&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
The OSI Model is a &lt;b&gt;theoretical model&lt;/b&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;The OSI Model is &lt;b&gt;not a technology&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;The OSI Model is &lt;b&gt;not a protocol&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;The OSI Model is &lt;b&gt;not a program or software&lt;/b&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
The OSI Model sorts network communication functions into seven layers.
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Layer &lt;b&gt;functions are not specified&lt;/b&gt; and &lt;b&gt;should be transparent&lt;/b&gt; to other layers.&lt;/li&gt;
&lt;li&gt;Layer Communications (&lt;b&gt;how layers communicate&lt;/b&gt; with each other) ARE specified in the model&lt;/li&gt;
&lt;li&gt;Layer &lt;b&gt;behavior should be invisible&lt;/b&gt; to other layers&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
The OSI Model was developed as the ISO designed their own suite of networking protocols (the ISO OSI Protocol Suite). The OSI Model is always in the middle of any discussions of networking and network and sometimes computer troubleshooting. The OSI model is used so commonly as a point of reference that you really should learn the OSI Model&#39;s seven layers and learn how the OSI Model explains this layered approach to networking.
&lt;br /&gt;
&lt;br /&gt;
Engineers working on a network problem will frequently say &quot;Well, it&#39;s a data link layer problem&quot;, clearly referring to the data link layer of the OSI Model and more specifically, the physical network connection, not the networking software or the applications. The OSI Model&#39;s layers are so well known that they are referred to by number:&amp;nbsp; &quot;Well, looks like we have a layer 2 problem here&quot;. If you don&#39;t know the OSI Model, you will have great difficulties as a network engineer, or even talking to one.
&lt;br /&gt;
&lt;br /&gt;
See also,&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;https://davenaimish.blogspot.com/2019/11/the-osi-models-seven-layers.html&quot; target=&quot;_blank&quot;&gt;The OSI Model&#39;s Seven Layers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://davenaimish.blogspot.com/2019/11/how-osi-works.html&quot; target=&quot;_blank&quot;&gt;How The OSI Works?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://davenaimish.blogspot.com/2019/11/osi-model-vs-tcpip-model.html&quot; target=&quot;_blank&quot;&gt;OSI Model vs TCP/IP Model&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/4126037074752095167/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/4126037074752095167' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/4126037074752095167'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/4126037074752095167'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2019/11/what-is-osi-model.html' title='What is the OSI Model'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-3997874645103664372</id><published>2019-11-18T11:32:00.004+05:30</published><updated>2019-11-18T19:55:44.998+05:30</updated><title type='text'>OSI Model vs TCP/IP Model</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
There are two network models that describe how networks &lt;b&gt;work&lt;/b&gt;. The &lt;b&gt;OSI Model&lt;/b&gt;, the older model, was designed for the OSI protocol stack. While different organizations were battling over standards, Vint Cerf and Bob Khan worked out the TCP/IP software from which the &lt;b&gt;TCP/IP Model&lt;/b&gt; was co-designed. The diagram below shows how the two networking models compare, and how the logical and physical networking protocols relate to the layers in each of the two models.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikY1P40AFFg7-2QV0efmRO3_TwCS5kIUYmBx5uUlwAKirFOz-OC-WBkwVp85uX7XXIAJIHLxk7fbRyIlM_hxQzU7VqH813YZSR7augiWvyxpTTDu1Mc9Bc2k8xMJMooVoIpgxeK0fyGmM/s1600/network_models.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;543&quot; data-original-width=&quot;628&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikY1P40AFFg7-2QV0efmRO3_TwCS5kIUYmBx5uUlwAKirFOz-OC-WBkwVp85uX7XXIAJIHLxk7fbRyIlM_hxQzU7VqH813YZSR7augiWvyxpTTDu1Mc9Bc2k8xMJMooVoIpgxeK0fyGmM/s1600/network_models.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
There are &lt;b&gt;seven layers in the OSI Model&lt;/b&gt;, only &lt;b&gt;four in the TCP/IP model&lt;/b&gt;. This is because TCP/IP assumes that applications will take care of everything beyond the Transport layer. The TCP/IP model also squashes the OSI&#39;s Physical and Data Link layers together into the Network Access Layer. Internet Protocol really doesn&#39;t (and shouldn&#39;t) care about the hardware underneath, so long as the computer can run the network device and send IP packets over the connection.&lt;br /&gt;
&lt;br /&gt;
See also,&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;https://davenaimish.blogspot.com/2019/11/what-is-osi-model.html&quot; target=&quot;_blank&quot;&gt;What is the OSI Model?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://davenaimish.blogspot.com/2019/11/how-osi-works.html&quot; target=&quot;_blank&quot;&gt;How The OSI Works?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://davenaimish.blogspot.com/2019/11/the-osi-models-seven-layers.html&quot; target=&quot;_blank&quot;&gt;The OSI Model&#39;s Seven Layers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/3997874645103664372/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/3997874645103664372' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/3997874645103664372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/3997874645103664372'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2019/11/osi-model-vs-tcpip-model.html' title='OSI Model vs TCP/IP Model'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikY1P40AFFg7-2QV0efmRO3_TwCS5kIUYmBx5uUlwAKirFOz-OC-WBkwVp85uX7XXIAJIHLxk7fbRyIlM_hxQzU7VqH813YZSR7augiWvyxpTTDu1Mc9Bc2k8xMJMooVoIpgxeK0fyGmM/s72-c/network_models.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-1486520077728615572</id><published>2017-03-28T22:14:00.003+05:30</published><updated>2017-03-28T22:14:48.887+05:30</updated><title type='text'>Salesforce Standard Objects and Sales Process</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
A &lt;b&gt;sales process&lt;/b&gt; is a series of repeatable steps that the sales team will take with a prospect to sell them the product.&amp;nbsp;&lt;span id=&quot;more-1287&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/span&gt;&lt;b&gt;Sales Funnel&lt;/b&gt; is commonly used term for a Sales Process, I feel that a sales funnel is different though as it basically based on activity rates, basically the more you do the more that you will hopefully close. Another commonly used term is &lt;b&gt;Sales Pipeline&lt;/b&gt;, and I think it’s a really good term that fits. Building a good sales process will take a lot of time and effort but it will improve your business.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
Defining a Sales Process is important so that managers can accurately forecast and create realistic pipeline reporting. A properly defined process reduces wastes and is able to scale. In the past, companies simply used to pay high commissions and let the sales staff figure out how to prospect and make the sales that’s proven to work okay in times of rapid growth but it makes on boarding new hires difficult, and predicting revenue incredibly difficult.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
Salesforce, out of the box, has a lot of the necessary tools to implement a simple Sales Process. Most of Salesforce’s standard objects are related to the sales stage&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Leads&lt;/span&gt;&amp;nbsp;are a person that has contact information that you should be able to sell to. Leads have three main sets of standard fields: Business Info, Contact Info, and Address Info. One of the most important fields for future data analysis and understanding whether your company’s marketing is effective is the Lead Source.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
Usually after talking to the lead or reviewing what the lead has done the Sales Rep will qualify them. Leads should be qualified into Accounts, Contacts, and Opportunities as soon as possible. If your company is planning on doing a lot of heavy automation, you may want to&amp;nbsp;automatically convert leads in apex.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Accounts&lt;/span&gt;&amp;nbsp;are the businesses that you have some sort of relationship with. This could be a customer, a partner or something else. I recommend setting up different record types based on the Type field. Usually it makes sense to set the Record type in a trigger or process builder whenever the Type field has been changed. Record Types allow different page layouts to be setup, allow for different workflows or processes.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Contacts&lt;/span&gt;&amp;nbsp;are the people that are in the business that you need to monitor and be in touch. Most often, these will only be the people that Sales and Support need to get in contact with.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Opportunities&lt;/span&gt;&amp;nbsp;are deals in progress. Opportunities are very different from Leads, you can read about the differences in the blog article&amp;nbsp;&lt;a href=&quot;http://davenaimish.blogspot.in/2017/03/difference-between-lead-and-opportunity.html&quot; target=&quot;_blank&quot;&gt;What’s the Differences Between a Lead and an Opportunity&lt;/a&gt;.&amp;nbsp;Opportunities have quite a few standard fields which are used in the Sales Process. For example, one of the most important fields is the Opportunity Stage.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
This Stage field should define the probability of a sale taking place from the sale’s persons perspective and should be used to determine what the Sales Rep should be doing with the Opportunity. Companies spend a significant amount of energy and expense trying to determine what the stages are and what should be done at each stage.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
Make sure that it’s very clear to the sales team when they should be changing the Sales Stage because the wrong stages being set will create inaccurate forecasts. In addition, as your company grows you will probably start looking into implementing marketing automation solution. Commonly used Sales Stages are variations of the following:&lt;/div&gt;
&lt;ul style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; list-style-image: initial; list-style-position: outside; margin: 0px 0px 1.5rem; padding: 0px;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 0px 0px 0px 1.75rem; text-align: justify;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Awareness&lt;/span&gt;: In this stage the prospect has become aware of your company and the solution you are providing. Usually your website will do most of the talking in this stage.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 0px 0px 0px 1.75rem; text-align: justify;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Interest&lt;/span&gt;: the sales rep will try to drum up interest. It usually makes sense to send them some white papers, suggest an ebook, and provide educational webinars.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 0px 0px 0px 1.75rem; text-align: justify;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Evaluation&lt;/span&gt;: In the Evaluation Stage they are comparing your company to your competitors, so it makes sense to have Case Studies, Samples (if Applicable), and conduct demos.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 0px 0px 0px 1.75rem; text-align: justify;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Decision&lt;/span&gt;: Sales Rep is going to provide some customer testimonials, additional proof, etc.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 0px 0px 0px 1.75rem; text-align: justify;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Quote / Negotiation&lt;/span&gt;: In this sales stage the Sales Rep is going to send a customized quote, and probably provide some final literature about ROI.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 0px 0px 0px 1.75rem; text-align: justify;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Closed/Won&lt;/span&gt;: This is the final stage of the process, this is where the buyer confirms they want the product are are ready to pay. In the case of B2B sales, this will probably involve purchase orders.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 0px 0px 0px 1.75rem; text-align: justify;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Closed/Lost&lt;/span&gt;: this isn’t really the ideal stage, but sometimes there’s just somebody your company can’t sell to. Make sure your company is&amp;nbsp;Tracking Why a Opportunity or Lead has been lost.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
Make sure that you have as few sales stages as necessary, so that it’s not impossible to see what’s happening when looking at the forecast and pipeline reporting.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
Regardless of the stages that you decide to use, we always need to remember that the focus needs to be on the customer and what they actually need and when they need it. Marketing and the right amount of comment at the right time can help win an opportunity. In the case of a really long sales cycle, make sure the sales team are leaving notes for themselves. It’s not uncommon for Opportunities to get stuck in a stage for a while.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Probability&lt;/span&gt;&amp;nbsp;is the likelihood that the opportunity will be sold. It’s used to calculated the Expected Revenue.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Expected Revenue&lt;/span&gt;&amp;nbsp;is a formula field that’s equal to Amount * Probability. It doesn’t really make a lot of sense when you look at one opportunity, but across multiple opportunities in the Sales Pipeline and Forecasting Reports it gives a pretty good idea of how much revenue will be won.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Forecast Category&lt;/span&gt;&amp;nbsp;is used in the Pipeline Reporting.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
There’s some boolean formula fields that can be used in reporting. “&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Closed&lt;/span&gt;” and “&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Won&lt;/span&gt;” are pretty self explanatory. Closed will be true if the Stage Type is “Closed/Lost” or “Closed/Won” and Won will be true if the Stage is “Closed/Won”.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/1486520077728615572/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/1486520077728615572' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/1486520077728615572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/1486520077728615572'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2017/03/salesforce-standard-objects-and-sales.html' title='Salesforce Standard Objects and Sales Process'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-315088887452107483</id><published>2017-03-28T22:13:00.001+05:30</published><updated>2017-03-28T22:13:43.744+05:30</updated><title type='text'>Difference between a Lead and Opportunity</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
A lead is basically a person that has contact information that you should be able to sell to, they have been created because they have contacted you in someway with some sort of need whether this be that they filled out a contact form on your website or they exchanged business cards with somebody at a trade show.&lt;span id=&quot;more-1228&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/span&gt;&amp;nbsp;A lead does not have to be somebody that has purchasing authority, it could simply be somebody that has reached out the organization. Always make sure that the&amp;nbsp;Lead Source has been set and that there’s a clear way of knowing what they have done.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
An Opportunity is a deal that you could win or lose. Simply put, an opportunity is basically a lead that has been qualified (in Salesforce terms converted) for some reason. Most organizations convert the lead as soon as they believe its possible to sell to that lead. Qualification criteria could be anything really.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
Companies have different beliefs on what an Opportunity is. Having a clear definition of what a lead is versus what an opportunity is clarifies reporting and expectations and can help improve the relationship between sales and marketing.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
In most companies leads follow a process like this to become qualified&lt;/div&gt;
&lt;ol style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; list-style-image: initial; list-style-position: outside; margin: 0px 0px 1.5rem; padding: 0px;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 0px 0px 0px 1.75rem; text-align: justify;&quot;&gt;Basic Contact Information has been received – Lead is created.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 0px 0px 0px 1.75rem; text-align: justify;&quot;&gt;Sales person or marketing automation reaches out and confirms there’s some sort of interest in the product or company. (Established Need)&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 0px 0px 0px 1.75rem; text-align: justify;&quot;&gt;Sales person confirms that this person / company has authority to make a purchasing decision.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 0px 0px 0px 1.75rem; text-align: justify;&quot;&gt;Opportunity is created &amp;amp; Close Date for Deal is Established.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin: 0px 0px 0px 1.75rem; text-align: justify;&quot;&gt;Quote / Deal Won.&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
In Salesforce, one of the core differences between a lead and an opportunity is that the lead has contact information and is relatively basic. Very few of the standard objects have a relationship with a lead, the opportunity has quite a few standard objects that are related to it. When a Lead is converted, whether it’s converted manually or automatically, a new account, contact, and opportunity can be created.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;Open Sans&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/315088887452107483/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/315088887452107483' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/315088887452107483'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/315088887452107483'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2017/03/difference-between-lead-and-opportunity.html' title='Difference between a Lead and Opportunity'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-1454465291102617138</id><published>2017-03-28T21:55:00.003+05:30</published><updated>2017-03-28T21:55:50.294+05:30</updated><title type='text'>Difference between Salesforce.com and Force.com</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Even though it&#39;s very straight forward, difference between &lt;b&gt;Salesforce.com&lt;/b&gt; and &lt;b&gt;Force.com&lt;/b&gt; has always remained a core question for every newbies. I am hoping this post will help you in understanding the basic difference between this jargon.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Force.com&lt;/b&gt; &lt;b&gt;is the platform&lt;/b&gt; that the Salesforce CRM and your customization&amp;nbsp;run on. The Force.com platform consists of a multi-tenant architecture that runs on application services, web servers and of course database servers. Salesforce is using Java, and Oracle for significant parts of the Force.com Platform.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Force.com is also a platform as a service (PaaS) that can be purchased separately and won’t include a lot of the key CRM functionality like Leads, and Opportunities. Lately, Salesforce has started to advertise an additional cloud called the “AppCloud” which includes services like Heroku which is another server that Salesforce owns.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Salesforce.com is generally used to refer to the CRM functionality&lt;/b&gt; only, so this would be the “sales cloud”, “service cloud”, and marketing related clouds. Salesforce is running on the Force.com Platform.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Salesforce1 is the mobile application&lt;/b&gt; that Salesforce has developed which is available on Android and iOS. It’s possible for developers to add functionality which can be used in the mobile phone application.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/1454465291102617138/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/1454465291102617138' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/1454465291102617138'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/1454465291102617138'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2017/03/difference-between-salesforcecom-and.html' title='Difference between Salesforce.com and Force.com'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-1261770091547736236</id><published>2017-03-28T21:48:00.002+05:30</published><updated>2017-03-28T21:48:18.294+05:30</updated><title type='text'>Google Chrome Extensions for Salesforce Developers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: dosis, sans-serif; font-size: 1.75rem; line-height: 1.2857; margin-bottom: 0.375rem; margin-top: 0px;&quot;&gt;
Salesforce Inspector&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;open sans&amp;quot;, helvetica, arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem;&quot;&gt;
Salesforce Inspectors advertises itself as “Productivity tools for Salesforce administrators and developers to inspect data and metadata directly from the Salesforce UI” and it sure is. I have used this Chrome Extension so many times for confirming whether fields have help text, field labels and see how things are connected.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;open sans&amp;quot;, helvetica, arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem;&quot;&gt;
Install it from&amp;nbsp;&lt;a href=&quot;https://chrome.google.com/webstore/detail/salesforce-inspector/aodjmnfhjibkcdimpodiifdjnnncaafh?hl=en&quot; style=&quot;box-sizing: border-box; color: #666666; outline: none;&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: dosis, sans-serif; font-size: 1.75rem; line-height: 1.2857; margin-bottom: 0.375rem; margin-top: 0px;&quot;&gt;
Salesforce Navigator&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;open sans&amp;quot;, helvetica, arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem;&quot;&gt;
Salesforce Navigator is a super handy little extension that allows developers and admins to search for just about anything in the metadata without having to do lots of clicking.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;open sans&amp;quot;, helvetica, arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem;&quot;&gt;
Install it from&amp;nbsp;&lt;a href=&quot;https://chrome.google.com/webstore/detail/salesforce-navigator/ecjmdlggbilopfkkhggmgebbmbiklcdo?hl=en&quot; style=&quot;box-sizing: border-box; color: #666666; outline: none;&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: dosis, sans-serif; font-size: 1.75rem; line-height: 1.2857; margin-bottom: 0.375rem; margin-top: 0px;&quot;&gt;
Salesforce API FieldNames&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;open sans&amp;quot;, helvetica, arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem;&quot;&gt;
This extension replaces all of the field labels with the API Names on page layouts. I find this is really useful for figuring out what employees are meaning when debugging triggers or fields being changed.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;open sans&amp;quot;, helvetica, arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem;&quot;&gt;
Install it from&amp;nbsp;&lt;a href=&quot;https://chrome.google.com/webstore/detail/salesforce-api-fieldnames/oghajcjpbolpfoikoccffglngkphjgbo?hl=en&quot; style=&quot;box-sizing: border-box; color: #666666; outline: none;&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: dosis, sans-serif; font-size: 1.75rem; line-height: 1.2857; margin-bottom: 0.375rem; margin-top: 0px;&quot;&gt;
Sandbox Favicon&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;open sans&amp;quot;, helvetica, arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem;&quot;&gt;
Sandbox Favicon replaces the favicon with an S which helps remind developers and Salesforce Admins that they’re currently in a sandbox instead of production. I don’t know how many times I’ve went to do something and realized it was production or a sandbox. Over time, this extension has really helped.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;open sans&amp;quot;, helvetica, arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem;&quot;&gt;
Install it from&amp;nbsp;&lt;a href=&quot;https://chrome.google.com/webstore/detail/salesforcecom-sandbox-fav/nkfllgjejgfgcddfccnijhndhdmjkamf&quot; style=&quot;box-sizing: border-box; color: #666666; outline: none;&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: dosis, sans-serif; font-size: 1.75rem; line-height: 1.2857; margin-bottom: 0.375rem; margin-top: 0px;&quot;&gt;
Salesforce Lightning Inspector&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;open sans&amp;quot;, helvetica, arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem;&quot;&gt;
As everything related to Salesforce is slowly starting to switch to Salesforce Lightning, it makes sense to include the Google Chrome DevTools Extension that Salesforce has put together. The extension helps with understanding how events are being fired, and handled along with allow Lightning Components to be inspected.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;open sans&amp;quot;, helvetica, arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem;&quot;&gt;
Install it from&amp;nbsp;&lt;a href=&quot;https://chrome.google.com/webstore/detail/salesforce-lightning-insp/pcpmcffcomlcjgpcheokdfcjipanjdpc&quot; style=&quot;box-sizing: border-box; color: #666666; outline: none;&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: dosis, sans-serif; font-size: 1.75rem; line-height: 1.2857; margin-bottom: 0.375rem; margin-top: 0px;&quot;&gt;
Force.com Utility Belt&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;open sans&amp;quot;, helvetica, arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem;&quot;&gt;
I mainly use this Chrome Extension for the Documentation references, and for the converting from 15 digit Ids to 18 Digit Ids. Jeff Douglas wrote this extension a long time ago, so it’s usefulness has worn out over time.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #3a3a3a; font-family: &amp;quot;open sans&amp;quot;, helvetica, arial, sans-serif; font-size: 16px; line-height: 1.5; margin-bottom: 1.5rem;&quot;&gt;
Install it from&amp;nbsp;&lt;a href=&quot;https://chrome.google.com/webstore/detail/forcecom-utility-belt/bchgkjmjnmekbampjoenadmoekocpbhp&quot; style=&quot;box-sizing: border-box; color: #666666; outline: none;&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/1261770091547736236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/1261770091547736236' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/1261770091547736236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/1261770091547736236'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2017/03/google-chrome-extensions-for-salesforce.html' title='Google Chrome Extensions for Salesforce Developers'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-2378271583348199919</id><published>2015-03-11T17:19:00.001+05:30</published><updated>2015-03-11T17:19:23.588+05:30</updated><title type='text'>Salesforce Trigger - Best Practices </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #fefefe; color: #424242; line-height: 32.4000015258789px;&quot;&gt;In this article I will cover some basics of when to use a before-trigger vs. an after-trigger as well as how to make sure your triggers support bulk DML (Data Manipulation Language) operations and some best practices for creating triggers. There will be a part II to this article that will cover unit testing and some common trigger examples. But I do want to be clear, this is not an article about how to program so you will need to have a basic understanding of the Apex Coding Language and the tools used to develop these triggers such as the&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://wiki.developerforce.com/page/Force.com_IDE&quot; style=&quot;background-color: #fefefe; color: #f03838; line-height: 32.4000015258789px; text-decoration: none;&quot; target=&quot;_blank&quot; title=&quot;Force.com IDE&quot;&gt;Force.com IDE&lt;/a&gt;&lt;span style=&quot;background-color: #fefefe; color: #424242; line-height: 32.4000015258789px;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #fefefe; color: #424242; line-height: 32.4000015258789px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 32.4000015258789px; text-align: start;&quot;&gt;I want to start with first explaining some basics about Apex Triggers. Apex Triggers are event handlers. When a record associated with the trigger is inserted, updated, deleted, or undeleted the Salesforce.com system will &quot;fire&quot; or execute the trigger event. Salesforce will actually execute a trigger in two different contexts: before and after. Before-trigger events are executed before a record has been committed to the database, while after-trigger events are executed after a record is committed to the database.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: #fefefe; line-height: 32.4000015258789px; text-align: start;&quot;&gt;&lt;span style=&quot;color: #424242; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: #fefefe; line-height: 32.4000015258789px; text-align: start;&quot;&gt;&lt;span style=&quot;color: #424242; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;When to use Before-Triggers&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Before-trigger events occur before a record’s changes are committed to the database. This particular event is ideal for performing data validation, setting default values, or performing additional logic and/or calculations. Please keep in mind that in the case of before-insert events, because the event is executed before the record is committed to the database it will not have a record id.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Before-triggers in my opinion are the most efficient and are going to be your goto method for most of the triggers you will write for a couple of reasons. The first being that you can perform data validation and reject a record before it is committed to the database, meaning there is no cost to performance by the system having to roll back an update. Second, you can update fields or set default values for a record without having to initiate another DML command.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;For example the code below illustrates setting a default value on a record. No DML required.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
trigger setDefaultAccountValues on Account (before insert, before update) {&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; for (Account oAccount : trigger.new) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oAccount.Industry = ‘Cloud Computing’;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;br /&gt;&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; line-height: 32.4000015258789px;&quot;&gt;…and that is it. As you can see I simply just set the value of the field I want to change or default. Salesforce will take care of the rest.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;When to use After-Triggers&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 32.4000015258789px;&quot;&gt;After-trigger events occur after a record has been committed to the database, which means that records being inserted will have a record id available. This particular event is ideal for working with data that is external to the record itself such as referenced objects or creating records based on information from the triggered object.&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong style=&quot;background-color: #fefefe; color: #aeadad; font-family: Arial, Helvetica, sans-serif; font-style: italic; line-height: 32.4000015258789px;&quot;&gt;Update:&lt;/strong&gt;&lt;span style=&quot;background-color: #fefefe; color: #aeadad; font-family: Arial, Helvetica, sans-serif; font-style: italic; line-height: 32.4000015258789px;&quot;&gt;&amp;nbsp;It was pointed out in the comments that the order of execution I described isn&#39;t entirely correct. Technically the record isn&#39;t truly committed to the database until after the after-trigger event, assignment rules, auto-response rules, and workflow rules are executed. Triggers execute as part of a transaction which means that any inserts/updates to the database can be rolled back. It is why you can throw an error in an after-trigger event that will prevent a record from being created even though it already has an Id assigned.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: #fefefe; color: #aeadad; font-style: italic; line-height: 32.4000015258789px;&quot;&gt;For more specific details on this topic you can visit the following online article titled&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm&quot; style=&quot;background-color: #fefefe; color: #f03838; font-style: italic; line-height: 32.4000015258789px; text-decoration: none;&quot; target=&quot;_blank&quot; title=&quot;Triggers and Order of Execution&quot;&gt;Triggers and Order of Execution&lt;/a&gt;&lt;span style=&quot;background-color: #fefefe; color: #aeadad; font-style: italic; line-height: 32.4000015258789px;&quot;&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/blockquote&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;line-height: 32.4000015258789px;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;For example the code below illustrates creating an Opportunity after an Account is created.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
trigger createNewAccountOpportunity on Account (after insert) { &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; List&lt;opportunity&gt; listOpportunities = new List&lt;opportunity&gt;();&lt;/opportunity&gt;&lt;/opportunity&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; for (Account oAccount : trigger.new) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Opportunity oOpportunity = new Opportunity();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oOpportunity.Name = oAccount.Name;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oOpportunity.AccountId = oAccount.Id;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oOpportunity.Stage = ‘Proposal’;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oOpportunity.CloseDate = System.today() + 30; //Closes 30 days from today&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; listOpportunities.add(oOpportunity);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; if (listOpportunities.isEmpty() == false) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Database.update(listOpportunities);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; line-height: 1.8;&quot;&gt;As you can see from the code we were able to generate an Opportunity from an Account that was just created and because we needed the Account Id to do this we needed to use an after-trigger. We also borrowed some values from the Account itself to help populate the required fields on the Opportunity, but notice we didn’t query for those values…more on that later in the article.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Another key best practice for after-trigger events is that while it is possible to perform a DML operation on the record that initiated the trigger event, it should be avoided. If you think it through, when you perform a DML operation on a record from a trigger event the system will need to execute all triggers on that object again, not only does this impact performance but it puts us at risk of creating an infinite loop. Salesforce deals with this by only executing your triggers a certain number of times.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Later in this article we will discuss some best practices around how best to setup your execution criteria so that you can hedge against infinite loops and improve performance. Simply put after-trigger events are not the best place to perform DML operations on the triggered record and if you come across a situation where you feel it is necessary I would make sure that you are well aware of the impact that will have when the system recursively executes your trigger events.&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Understanding Trigger Context&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The context of a trigger is very important. We already discussed the before and after update contexts but there is also the context of what data is available to you at the time of trigger execution. In particular I am referring to the ++Trigger++ object. If you go back and review the examples I provided earlier in this article you will notice the use of a variable called “trigger”. This is a reference to an object that holds some information about the record or records that initiated the trigger. It also holds some information about the record as it existed before the update, allowing you to make decisions based on a records previous values. To get some background on what kind of information the trigger context variable provides you can review the&amp;nbsp;&lt;a href=&quot;http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_context_variables.htm&quot; style=&quot;color: #f03838; text-decoration: none;&quot; target=&quot;_blank&quot; title=&quot;Apex Trigger Context&quot;&gt;Apex Trigger Context Documentation&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The trigger.new variable holds the information about the record(s) that was just inserted or updated (please make note that if you are looking for the data that was deleted that you will instead need to use the trigger.old variable to access that data). Salesforce does a bit of magic when it compiles your trigger by looking at the fields that you are referencing and making sure that data is available at runtime. So there is no need to actually attempt to query the information yourself. Just use the fields in your code and trust that Salesforce will take care of the rest.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The after-trigger event example I provided previously demonstrates how you can simply loop through the records in the trigger.new and reference Account fields without the need to query for the data explicitly. Just note that this does not work for data that is related to a record. For example, the sample code below illustrates an attempt to reference information on the user record that is related to an Opportunity as an owner. Interestingly, this does not produce an error instead you just get a null value for the profile name.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
trigger exampleInvalidTrigger on Opportunity (before insert, before update) { &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; for (Opportunity oOpportunity : trigger.new) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (oOpportunity.Owner.Profile.Name == ‘Executive’) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oOpportunity.IsExecutiveOpportunity = true;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
trigger exampleValidTrigger on Opportunity (before insert, before update) { &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Map&lt;id user=&quot;&quot;&gt; mapUsers = new Map&lt;id user=&quot;&quot;&gt;([SELECT Id, Profile.Name FROM User]);&lt;/id&gt;&lt;/id&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; for (Opportunity oOpportunity : trigger.new) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; User oOwner = mapUsers.get(oOpportunity.OwnerId);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (oOwner.Profile.Name == ‘Executive’) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oOpportunity.IsExecutiveOpportunity = true;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
&lt;br /&gt;&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 32.4000015258789px;&quot;&gt;As you can see from the second example we had to query for the profile information in order to use it. Just note that this was just as an example and you will not want to load all users into a map as I did. There are other ways to get this information more efficiently that I will discuss in the next section.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Bulk Mode Triggers&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 1.8; text-align: justify;&quot;&gt;In all of the examples I have illustrated so far you will notice that they all involve looping through a collection of records made available through the trigger.new property. This is because all triggers execute in batch mode, meaning whether it is single record or a hundred you will always need to use the trigger.new collection and thus you should prepare your trigger to be able to handle a batch of records. This forces us to think about how we write our triggers. We have to take care on how we query additional information and also keep in mind how many script statements we are executing per record.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Let’s start by revisiting the example from the previous section. If you recall, I had a requirement to only execute my code if the Opportunity Owner’s Profile Name was set to ‘Executive’. I could have written the trigger like this&lt;/span&gt;&lt;/div&gt;
trigger badExample on Opportunity (before insert, before update) {  &lt;br /&gt;&amp;nbsp; &amp;nbsp; for (Opportunity oOpportunity : trigger.new) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;User oOwner = [SELECT Id, Profile.Name FROM User WHERE Id = :oOpportunity.Id];&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (oOwner.Profile.Name == ‘Executive’) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oOpportunity.IsExecutiveOpportunity = true;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 1.8;&quot;&gt;The above example will actually work for triggers that have one or two opportunities in the trigger.new collection. However, as soon as the number of records increases beyond 100 you will start to get errors indicating that you executed “Too many SOQL queries”. Even if you only expect less than 100 records to be updated at a given time the limit context is counted across the entire transaction. This means that if you have 3 triggers on an object that each run 50 queries then the 3rd trigger to execute will throw an exception. So you will want to keep the number of queries you execute to a minimum. To get a better understanding of the types of limits that you need to be aware please refer to the online&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm&quot; style=&quot;background-color: #fefefe; color: #f03838; font-family: Arial, Helvetica, sans-serif; line-height: 1.8; text-decoration: none;&quot; target=&quot;_blank&quot; title=&quot;Apex Governor Limits Documentation&quot;&gt;Apex Governor Limits Documentation&lt;/a&gt;&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 1.8;&quot;&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The best way I have found to limit the number of queries is to load the data I need into a map so that I can make a single query call and reference that data by record id as needed.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
trigger exampleGoodButInefficientTrigger on Opportunity (before insert, after update) { &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Map&lt;id user=&quot;&quot;&gt; mapUsers = new Map&lt;id user=&quot;&quot;&gt;([SELECT Id, Profile.Name FROM User]);&lt;/id&gt;&lt;/id&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; for (Opportunity oOpportunity : trigger.new) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; User oOwner = mapUsers.get(oOpportunity.OwnerId);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (oOwner.Profile.Name == ‘Executive’) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oOpportunity.IsExecutiveOpportunity = true;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 32.4000015258789px;&quot;&gt;The example above is a good but inefficient example. I loaded all of the users into a map which means I only used one query but I really shouldn’t be loading an entire data set into memory like this. There are other limits to worry about such as heap size (the amount of memory your method is consuming) that we should be conscience of. Here is a better way to do the same thing.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
trigger exampleBetterTrigger on Opportunity (before insert, after update) { &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Set&lt;id&gt; ownerIds = new Set&lt;id&gt;();&lt;/id&gt;&lt;/id&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; for (Opportunity oOpportunity : trigger.new) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ownerIds.add(oOpportunity.OwnerId);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Map&lt;id user=&quot;&quot;&gt; mapUsers = new Map&lt;id user=&quot;&quot;&gt;([SELECT Id, Profile.Name FROM User WHERE Id IN :ownerIds]);&lt;/id&gt;&lt;/id&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; for (Opportunity oOpportunity : trigger.new) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; User oOwner = mapUsers.get(oOpportunity.OwnerId);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (oOwner.Profile.Name == ‘Executive’) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oOpportunity.IsExecutiveOpportunity = true;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 1.8; text-align: justify;&quot;&gt;Now this example is much better. It loops through the list of opportunities first to figure out what owner ids are being used, collects them into a set collection, and then uses that information to only return users that are being used as owners in the opportunity collection. That way we limit the number of records we have in the map reducing our memory footprint and avoiding any map size limit exceptions.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;But we can still do better. The problem is we are doing an extra loop. Again we don’t want to do anything we don’t have to do to keep our code as lean and simple as possible. One way we can avoid doing that initial loop is to let a query do the work for us. This requires the use of a more advanced query technique involving sub-queries. Here is an example of what the query should look like&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
SELECT Id, Profile.Name FROM User WHERE Id IN :(SELECT OwnerId FROM Opportunity WHERE Id IN :oppIds)&lt;br /&gt;&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 32.4000015258789px; text-align: left;&quot;&gt;The first part of the query is fairly standard you simple define which fields you want to select and from which object. The more advanced part is in the where clause. Here we use a sub-query to select and return only the owner ids from the opportunity object where the opportunity id matches an id in the oppIds id collection. Here is this query in use.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
trigger exampleBestTrigger on Opportunity (before insert, after update) { &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Set&lt;id&gt; oppIds = trigger.newMap.keySet();&lt;/id&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Map&lt;id user=&quot;&quot;&gt; mapUsers = new Map&lt;id user=&quot;&quot;&gt;([SELECT Id, Profile.Name FROM User WHERE Id IN (SELECT OwnerId FROM Opportunity WHERE Id IN :oppIds)]);&lt;/id&gt;&lt;/id&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; for (Opportunity oOpportunity : trigger.new) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; User oOwner = mapUsers.get(oOpportunity.OwnerId);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (oOwner.Profile.Name == ‘Executive’) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oOpportunity.IsExecutiveOpportunity = true;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
&lt;span style=&quot;background-color: #fefefe; color: #424242; line-height: 32.4000015258789px;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Now that is much better. In this example we make a single query call and only one loop. But let me draw your attention one other trick in the example above; the map data type. You will notice that I am passing the query to the map when I create it. Traditionally, you would expect the syntax to look similar to the next example.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Map&lt;id user=&quot;&quot;&gt; mapUsers = new Map&lt;id user=&quot;&quot;&gt;();&lt;/id&gt;&lt;/id&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
List&lt;user&gt; listUsers = [SELECT Id, Name FROM Users]; &amp;nbsp;&lt;/user&gt;&lt;/div&gt;
&lt;div&gt;
for (User oUser: listUsers) { &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; mapUsers.put(oUser.Id, oUser); &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 32.4000015258789px; text-align: justify;&quot;&gt;As you can see this requires a loop of the query result to add the values into the map. But in my code I made use of a little Salesforce.com magic. The constructor for a Map is able to take a list of sObjects and generate a map for you. So when I use the following syntax Salesforce.com does the work for me and I can avoid doing that extra loop&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
List&lt;user&gt; listUsers = [SELECT Id, Name FROM Users]; &amp;nbsp;&lt;/user&gt;&lt;/div&gt;
&lt;div&gt;
Map&lt;id user=&quot;&quot;&gt; mapUsers = new Map&lt;id user=&quot;&quot;&gt;(listUsers);&lt;/id&gt;&lt;/id&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
&lt;br /&gt;&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 32.4000015258789px; text-align: justify;&quot;&gt;…or if I want to do this in a single line of code I can do the following.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
Map&lt;id user=&quot;&quot;&gt; mapUsers = new Map&lt;id user=&quot;&quot;&gt;( [SELECT Id, Name FROM Users] );&lt;br /&gt;&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 1.8;&quot;&gt;&lt;span style=&quot;line-height: 32.4000015258789px;&quot;&gt;You will find that Maps are going to be a powerful tool in making your code more efficient and less prone to cause limit exceptions. I encourage you to jump over to the&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_collections_maps.htm&quot; style=&quot;color: #f03838; line-height: 32.4000015258789px; text-decoration: none;&quot; target=&quot;_blank&quot; title=&quot;Apex Map Data Type Documentation&quot;&gt;Apex Map Data Type Documentation&lt;/a&gt;&lt;span style=&quot;line-height: 32.4000015258789px;&quot;&gt;&amp;nbsp;and read more about the various methods and capabilities of maps.&lt;/span&gt;&lt;/span&gt;&lt;/id&gt;&lt;/id&gt;&lt;/div&gt;
&lt;h2 id=&quot;usingtriggercriteria&quot; style=&quot;background-color: #fefefe; color: #424242; margin-bottom: 33px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;Using Trigger Criteria&lt;/span&gt;&lt;/h2&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;In the previous example you saw how we tested the users profile to determine if we wanted to update a field. This is a very important strategy to make note of. In most cases your trigger logic doesn’t need to execute every time an update occurs. More often you are looking for certain conditions to exist before performing your logic. As we did in the last example we simply accessed the users profile name and looked for the value ‘Executive’ and only if that criteria was met do we update the field. However, what if we wanted our trigger to execute when a certain field was changed? The next example will demonstrate that exact scenario.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;To set this up let us consider a use case where the Other Address field on a contact must match the contact’s account billing address. This would mean that when the account billing address is changed that we would then need to update any contacts associated with that account. Because this involves changing multiple child records it isn’t something that can be solved with a workflow rule and field updates. However, you can use a workflow rule and field updates to set the other address on the contact to the account’s billing address when the contact is created, which allows us to focus on changes to the account billing address. Let’s start with the code and then we can break it down.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
trigger updateContactOtherAddress on Account(after insert, after update) { &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; if (trigger.isUpdate) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Identify Account Address Changes&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Set&lt;id&gt; setAccountAddressChangedIds = new Set&lt;id&gt;();&lt;/id&gt;&lt;/id&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (Account oAccount : trigger.new) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Account oOldAccount = trigger.oldMap.get(oAccount.Id);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; boolean bIsChanged = (oAccount.BillingStreet != oOldAccount.BillingStreet || oAccount.BillingCity != oOldAccount.BillingCity);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (bIsChanged) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setAccountAddressChangedIds.add(oAccount.Id);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //If any, get contacts associated with each account&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (setAccountAddressChangedIds.isEmpty() == false) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; List&lt;contact&gt; listContacts = [SELECT Id, AccountId FROM Contact WHERE AccountId IN :setAccountAddressChangedIds];&lt;/contact&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (Contact oContact : listContacts) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Get Account&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oAccount = trigger.newMap.get(oContact.AccountId);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Set Address&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oContact.OtherStreet = oAccount.BillingStreet;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oContact.OtherCity = oAccount.BillingCity;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oContact.OtherState = oAccount.BillingState;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oContact.OtherPostalCode = oAccount.BillingPostalCode;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //If any, execute DML command to save contact addresses&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (listContacts.isEmpty() == false) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; update listContacts;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
&lt;br /&gt;&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 1.8;&quot;&gt;As you can see there are many parts to this trigger. So let’s first look at the context. The trigger is setup to run when a record is inserted and updated. However, because this particular requirement is to update contacts we can ignore any triggers that were made as a result of an insert since an account has to exist before contacts can be associated to it. You will also notice that I chose “after” events rather than “before” events. This is because we are not performing any DML against the account so we are safe from causing the trigger to execute multiple times. Also, we want to only bother updating contacts if the account has been successfully committed to the database.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Now we can start to look at the meat of the trigger. Remember all triggers run in a batch context so we have to assume that a trigger that is fired is the result of multiple accounts being updated at once - typically due to a batch upload or mass update. This means that an update could occur for any number of reasons that has nothing to do with an address change. So the first loop of this trigger is to go through the list of accounts and identify which accounts had an address change.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;If you recall from the documentation along with the trigger.new property there are other properties that we make use of here, in particular: trigger.oldMap and trigger.newMap. These properties are Map data types that contain a key value pair of account id to account object and in the case of trigger.oldMap this contains the account information as it existed before the record was updated. This allows us to test if the account address fields match or have been changed. To do this I access the old account object from the map by the account id. I then compare the address fields to determine if they have changed (Note for the sake of space I only compared two address fields but in a real-world scenario you will want to compare all relevant address fields). Once I identify that the address has been changed then I add that account id to a set collection so that I can use it later to get contacts that will be affected by the change.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;You will notice that along the way I am testing to see if there is any data in each collection. This is so that I don’t run the risk of executing any code in the event that a trigger did not contain any accounts where the address had changed. In the case that changes did occur then I query the related contacts by the set of account ids I collected earlier. I then loop through that collection, access the account by id from the trigger.newMap (since that contains the users updates), set the contact other address fields accordingly, and then finally initiate an update command to update the contacts.&lt;/span&gt;&lt;/div&gt;
&lt;h2 id=&quot;anignoranttriggerisalwaysbestpractice&quot; style=&quot;background-color: #fefefe; color: #424242; margin-bottom: 33px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;An Ignorant Trigger is Always Best Practice&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Yes, an ignorant trigger is what we should be striving for, in fact, the dumber the trigger the better. What I mean by this is if you look at the examples we have been working with thus far they have all had their logic defined in the trigger method itself. There are number of reasons that this is less than desirable:&lt;/span&gt;&lt;/div&gt;
&lt;ol style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; list-style-position: inside; margin: 0px 0px 40px; padding: 0px;&quot;&gt;
&lt;li style=&quot;margin: 0px 0px 10px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The only way to unit test the trigger logic is to issue a DML command&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 10px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The logic defined in the trigger is not re-usable&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 10px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;You can’t control the order of operation for objects that have more than one trigger&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Let’s go right down the line. The first reason is that the only way to unit test the logic of a trigger is to initiate a DML operation. That means that you are limited in the types of unit test scenarios you can create. You are basically limited to creating tests for only scenarios where a record can be inserted or updated. You can’t break your logic into smaller functions and test each individually. This is particularly important in triggers that will be performing some complex logic or performing calculations.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Second, is that the logic you define in a trigger isn’t re-usable. In many cases you can simply rely on the trigger taking care of applying logic to a particular object but what if you need to apply that logic to an object before it is saved or what if you need to reuse parts of the logic; like say a method that performs a calculation.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Finally, and this is a big one, you have no control over the order that a given trigger is executed at runtime. If you have multiple triggers on an object you can’t have any dependencies on a field that another trigger is expected to update. Salesforce.com does not guarantee in which order each of these triggers will fire. Don’t assume anything.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;To address all of these concerns I recommend applying a listener or observer pattern to trigger event methods (the terminology isn’t as important as the solution but from here on I will refer to it as the listener pattern). Essentially, we are downgrading the trigger method to do nothing more than to listen for records being inserted, updated, deleted, or undeleted and then pass that information on to one or more methods. First, let’s take a look at the sample below so that we can get some context on what this looks like.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
trigger AccountBeforeEventListener on Account (before insert, before update) { &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; if (trigger.isInsert) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AccountUtil.setDefaultValues(trigger.new);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AccountUtil.setIndustryCode(trigger.new);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
public class AccountUtil { &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; public static void setDefaultValues(List&lt;account&gt; listAccounts) {&lt;/account&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (Account oAccount : listAccounts) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (oAccount.Industry == null) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oAccount.Industry = ‘Cloud Computing’;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; public static void setIndustryCode(List&lt;account&gt; listAccounts) {&lt;/account&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (Account oAccount : listAccounts) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (oAccount.Industry == ‘Cloud Computing’) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oAccount.Industry_Code__c = ‘CC’;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 1.8;&quot;&gt;I adapted the first example from this article into the listener pattern so it should look familiar. As you can see all of the logic that was originally in the trigger has been moved to a class called AccountUtil with two static methods called setDetaultValues and setIndustryCode. You will notice that I still kept the logic to determine if a trigger is an insert or update command and that is intentional. The trigger really is the best place to decide what context you are dealing with and then send that message on appropriately. In this case, we only want to execute the command for insert trigger events.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;There are a couple of things I want to call attention to about this solution. The first is that with this solution I can call multiple methods in a specific order. Looking at the two methods the first one sets the default industry, if the user didn’t already set it, and the second sets the industry code based on the industry value. Had we left this to chance and created a trigger for each of these methods there is a possibility that the setIndustryCode trigger could run before the defaults trigger and you wouldn’t get the results you expected.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The second item I wanted to call attention to is how the creation of these two methods in a separate class did not impact our context. We are still able to update the fields on an account and not have to issue any DML commands. This is because when the data is passed to the methods from the trigger it is done by reference. Meaning the argument is just a pointer to where that collection of Accounts is stored in memory. So any changes you make from the method are available to the trigger or any other method.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The next question you should be asking then is how many triggers should we have per object. Most would say one. However, I like to step away from convention every now and then to satisfy my own logic. I prefer that before-trigger events and after-trigger events have their own triggers. For me it’s about the psychology of before-trigger being a unique type of event verses an after-trigger event. There really is no good reason for this other than I like it this way. You can actually just have a single method that can divide up the work between before and after events but I prefer keeping things at a much simpler level. Below are some examples of each and you can make your own decision on how you want to manage this.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
//Single Trigger for Before and After Events &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
trigger AccountEventListener on Account (before insert, after insert, before update, after update) { &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; if (trigger.isBefore) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (trigger.isInsert || trigger.isUpdate) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //DO SOMETHING&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; else if (trigger.isAfter) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (trigger.isInsert || trigger.isUpdate) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //DO SOMETHING&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
//Before Event Trigger&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
trigger AccountBeforeEventListener on Account (before insert, before update) { &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; if (trigger.isInsert || trigger.isUpdate) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //DO SOMETHING&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
//After Event Trigger&lt;/div&gt;
&lt;div&gt;
trigger AccountAfterEventListener on Account (after insert, after update) { &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; if (trigger.isInsert || trigger.isUpdate) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //DO SOMETHING&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
&lt;span style=&quot;background-color: #fefefe; color: #424242; font-family: Arial, Helvetica, sans-serif; line-height: 32.4000015258789px;&quot;&gt;As you can see all of the examples will produce the same results and it really is just a matter of preference.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fefefe; color: #424242; font-family: &#39;Open Sans&#39;, arial, sans-serif; font-size: 18px; line-height: 1.8; margin-bottom: 30px; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/2378271583348199919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/2378271583348199919' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/2378271583348199919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/2378271583348199919'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2015/03/salesforce-trigger-best-practices.html' title='Salesforce Trigger - Best Practices '/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-2786799707736422988</id><published>2015-03-05T13:47:00.000+05:30</published><updated>2015-03-05T13:47:15.940+05:30</updated><title type='text'>Record Level Access in Salesforce</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;Data Access in Salesforce&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;To meet your company’s security needs, it’s important to understand what data access means to your users and to you.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #b45f06; font-family: Arial, Helvetica, sans-serif;&quot;&gt;Data Access: User’s Perspective&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;If you put yourself in your users’ shoes, you won’t necessarily know or care how you’re getting access to records, but you might want to understand what having access means within the context of your organization. The following graph can help users visualize the different kinds of access that can be configured in Salesforce.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii4_USLhT0Huc3i_l__liX2IkZpqZmwfoXLN-XH04R1hvkur4uyt8FtRjFAHFP86eRykeRk73mtQzW9Y01d4e42UPjiU2hh-QaWplM8G9nOYD_7Z1HJdDtebhmF0eq1FJS4l2L8AEfeSw/s1600/Untitled+access.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii4_USLhT0Huc3i_l__liX2IkZpqZmwfoXLN-XH04R1hvkur4uyt8FtRjFAHFP86eRykeRk73mtQzW9Y01d4e42UPjiU2hh-QaWplM8G9nOYD_7Z1HJdDtebhmF0eq1FJS4l2L8AEfeSw/s1600/Untitled+access.png&quot; height=&quot;400&quot; width=&quot;377&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;For example, if a user has access to an account field, then they have access to both the account field and the account object itself. However, a specific account record, such as “Account A”, might not be accessible to that user due to additional access control applied via sharing rules or other tools.&lt;/span&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #b45f06; font-family: Arial, Helvetica, sans-serif;&quot;&gt;Data Access: Architect’s Perspective&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;As an architect, you must both understand your user’s perspective and know how to grant users only the appropriate level of access to the data that they should be able to access.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;From an architect’s perspective, data access in Salesforce falls into two main categories: object-level access, which includes field-level access, and record-level access.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Object-level access determines whether a user has access to a particular object, which fields they can see on that object, and which actions they can perform. You configure object level access on user profiles.&lt;/span&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Restricting access&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The “Read,” “Create,” “Edit,” and “Delete” object permissions determine which actions a user can perform on any of the object&#39;s records to which they have access. Field-Level Security allows you to prevent certain users from seeing sensitive or confidential information contained in records they can see.&lt;/span&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Opening up access&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The “View All” and “Modify All” object permissions give users access to all of an object’s records, regardless of record-level access settings.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Record-level access (called “Sharing” in Salesforce) determines which records a user can see for a particular object, using the following tools:&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Organization-wide defaults&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Role hierarchy&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Territory hierarchy&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Sharing rules&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Teams&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Manual sharing&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Programmatic sharing&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Because you have so many options for managing record-level access — and because some of these options are affected by organizational dependencies — determining which records users can access can quickly become complicated. Additionally, you might also be changing your sharing configuration frequently in response to new business requirements. This can trigger record access changes that ripple through your organization. These changes have an even greater impact in very large organizations, where it can take some time to&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;recalculate access for a large number of users, and adjust the tables that record their access rights. For these reasons, it’s important to understand how Salesforce calculates and grants access at the database level.&lt;/span&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Record Access Calculation&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Every time a user attempts to open a record, run a report, access a list view, or search for data using the user interface or API, Salesforce checks the configuration of its record access features to determine which records the user can access. These configurations can be elaborate, especially in large organizations with hundreds of hierarchy nodes, thousands of sharing rules, millions of data rows, and portals for customers and business partners. Processing such dissimilar data and complex relationships would require far more time than&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;the 300-millisecond Salesforce benchmark for rendering pages.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Rather than applying every sharing rule, traversing all hierarchies, and analyzing record access inheritance in real time, Salesforce calculates record access data only when configuration changes occur. The calculated results persist in a way that facilitates rapid scanning and minimizes the number of database table joins necessary to determine record access at run time.&lt;/span&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #b45f06; font-family: Arial, Helvetica, sans-serif;&quot;&gt;Access Grants&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;When an object has its organization-wide default set to Private or Public Read Only, Salesforce uses access grants to define how much access a user or group has to that object’s records. Each access grant gives a specific user or group access to a specific record. It also records the type of sharing tool — sharing rule, team, etc. — used to provide that access. Salesforce uses four types of access grants: explicit grants, group membership grants, inherited grants, and implicit grants.&lt;/span&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Explicit Grants&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Salesforce uses explicit grants when records are shared directly to users or groups. Specifically, Salesforce uses explicit grants when:&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;A user or a queue becomes the owner of a record.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;A sharing rule shares the record to a personal or public group, a queue, a role, or a territory.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;An assignment rule shares the record to a user or a queue.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;A territory assignment rule shares the record to a territory.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;A user manually shares the record to a user, a personal or public group, a queue, a role, or a territory.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;A user becomes part of a team for an account, opportunity, or case.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;A programmatic customization shares the record to a user, a personal or public group, a queue, a role, or a territory.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Note: If your organization doesn’t have an efficient sharing architecture, it might encounter performance problems when you use automated processes that generate a very large number of explicit grants, such as major sales realignments.&lt;/span&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Group Membership Grants&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Grants that occur when a user, personal or public group, queue, role, or territory is a member of a group that has explicit access to the record. For example, if a sharing rule explicitly grants the Strategy group access to the Acme record, and Bob is a member of the Strategy group, Bob’s membership in the Strategy group grants him access to the Acme record.&lt;/span&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Inherited Grants&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Grants that occur when a user, personal or public group, queue, role, or territory inherits access through a role or territory hierarchy, or is a member of a group that inherits access through a group hierarchy.&lt;/span&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Implicit Grants&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Grants that occur when non-configurable record-sharing behaviors built into Salesforce Sales, Service, and Portal applications grant access to certain parent and child records. For example, with this default logic, sometimes referred to as built-in sharing, users can view a parent account record if they have access to its child opportunity, case, or contact record. If those users have access to a parent account record, they can also access its child opportunity, case, and contact records.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Reference:&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;a href=&quot;http://www.salesforce.com/docs/en/cce/record_access_uth/salesforce_record_access_under_the_hood.pdf&quot; target=&quot;_blank&quot;&gt;Record Level Access in Salesforce&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/2786799707736422988/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/2786799707736422988' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/2786799707736422988'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/2786799707736422988'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2015/03/record-level-access-in-salesforce.html' title='Record Level Access in Salesforce'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii4_USLhT0Huc3i_l__liX2IkZpqZmwfoXLN-XH04R1hvkur4uyt8FtRjFAHFP86eRykeRk73mtQzW9Y01d4e42UPjiU2hh-QaWplM8G9nOYD_7Z1HJdDtebhmF0eq1FJS4l2L8AEfeSw/s72-c/Untitled+access.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-4167690666530313922</id><published>2014-07-28T16:24:00.002+05:30</published><updated>2014-07-31T12:23:06.777+05:30</updated><title type='text'>Salesforce : Tips and Tricks</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Deploying from Sandbox - Loss of Permissions, Page Assignments, Field Security etc.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;background-color: #fdfdfd; color: #111111; line-height: 19.600000381469727px;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;When you add profiles to assign permissions in a change set, it only impacts the components of the change set. Change sets are never destructive, so they can&#39;t remove permissions you&#39;ve assigned in production. You are safe to include the profiles during the change set deploy.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;background-color: #fdfdfd; color: #111111; line-height: 19.600000381469727px;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Just be aware some Profile settings are always transferred when you include the profile in the change set (e.g. Profile&#39;s system permissions). To avoid overwriting the production profile settings from sandbox, simple solution is to first send change set with anything (e.g. Account custom field) which is the same on prod and sandbox + all profiles from prod to sandbox - this will apply the production permissions to sandbox - and then you can send your change set from sandbox to prod. As sandbox has already been updated to prod status, you won&#39;t overwrite anything and only add new stuff to the profiles on prod.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;background-color: #fdfdfd; color: #111111; line-height: 19.600000381469727px;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;text-align: left;&quot;&gt;Long story short, the only permissions that get deployed for a specified profile are exactly related to the other items in your deploy. If you have a 1 field, 1 visualforce page, and 1 page layout, only the permissions related to those 3 objects will be pushed to the target org and the remainder of the permissions will be in tact. It will not overwrite other permissions.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;b style=&quot;color: #111111; font-family: Arial, Helvetica, sans-serif; line-height: 19.600000381469727px; text-align: justify;&quot;&gt;Delete Upto 10000* Records From Objects&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style=&quot;color: #111111; font-family: &#39;Helvetica Neue&#39;, Arial, sans-serif; font-size: 14px; line-height: 19.600000381469727px;&quot;&gt;delete [select Id from testObject where flag=&#39;test&#39; LIMIT 10000]&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #111111; font-family: Helvetica Neue, Arial, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 19.600000381469727px;&quot;&gt;Database.delete(&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #111111; font-family: &#39;Helvetica Neue&#39;, Arial, sans-serif; font-size: 14px; line-height: 19.600000381469727px;&quot;&gt;[select Id from testObject where flag=&#39;test&#39; LIMIT 10000]&quot;, false);&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;span style=&quot;color: #111111; font-family: Helvetica Neue, Arial, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 19.600000381469727px;&quot;&gt;*&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px; line-height: 14.687999725341797px; text-align: left;&quot;&gt;DML statements can only process up to&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;ph&quot; style=&quot;background-color: white; font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px; line-height: 14.687999725341797px; text-align: left;&quot;&gt;10,000&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px; line-height: 14.687999725341797px; text-align: left;&quot;&gt;&amp;nbsp;records at a time&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px; line-height: 14.687999725341797px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px; line-height: 14.687999725341797px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px; line-height: 14.687999725341797px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px; line-height: 14.687999725341797px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px; line-height: 14.687999725341797px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px; line-height: 14.687999725341797px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/4167690666530313922/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/4167690666530313922' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/4167690666530313922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/4167690666530313922'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2014/07/salesforce-tips-and-tricks.html' title='Salesforce : Tips and Tricks'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-2229275679616572455</id><published>2014-07-27T15:03:00.005+05:30</published><updated>2014-07-27T15:06:41.203+05:30</updated><title type='text'>Difference between Lookup and Master-Detail in Salesforce</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;There are several differences and several similarities as well.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;&lt;b&gt;Similarities:&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;They both create a one (parent) to many (children) relationship. One Account could have many Opportunites on it.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;They both create a related list on the parent object listing the children.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;Both kinds of relationships are created from the child object in salesforce.com by creating a field that represents the relationship.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;b style=&quot;color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px; text-align: justify;&quot;&gt;Differences:&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;Unless you specify explicitly when creating the relationship, a child in a master-detail reclationship typically cannot be re-parented. With a lookup relationship you just click the magnifying glass next to the lookup field from the child record. (Standard salesforce.com objects are sort of an exception here.)&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;With a master-detail relationship, when you delete the parent record, the child records are deleted as well. With a lookup relationship, the child records are orphaned.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;With a master-detail relationship, you are able to use the &quot;rollup summary&quot; type of formula field on the master record. This allows you to sum/average/count records and fields on the records of the child object. For example you could have a count field on the account object that tells you how many opportunities there are for that account.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;Using a master-detail relationship the child is always created from the parent record. With a lookup field you can set filters to reduce the number of parent records viewed when clicking the magnifying glass to perform the lookup. This allows you to create the child object first, then link it to the parent record later.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px; text-align: justify;&quot;&gt;Here is a link to the ERDs describing the salesforce.com data model:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #7b539d; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px; margin: 0px; outline: 0px; padding: 0px; text-align: justify; text-decoration: none; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;http://www.linkedin.com/redirect?url=http%3A%2F%2Fwww%2Esalesforce%2Ecom%2Fus%2Fdeveloper%2Fdocs%2Fapi%2FContent%2Fdata_model%2Ehtm&amp;amp;urlhash=R6bJ&amp;amp;_t=tracking_disc&quot; rel=&quot;nofollow&quot; style=&quot;border: 0px; color: #7b539d; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;blank&quot;&gt;http://www.salesforce.com/us/developer/docs/api/Content/data_model.htm&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;b style=&quot;color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px; text-align: justify;&quot;&gt;Example of when to use each:&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;Custom Opportunity object with custom Opportunity Parts object. For this I would use Master-Detail. That way if the Opportunity is deleted, the parts records related to the Opportunity would also be deleted. Data related to the parts could be rolled up to the Opportunity and since it&#39;s very unlikely you&#39;d ever have to reassign an opportunity part it would work well.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;Custom Hierarchy object. Use record types to define the levels of the hierarchy and a lookup field from Hierarchy object to itself to create the links. If you delete a higher level of the hierarchy it wouldn&#39;t delete all the lower levels, and you can reassign as the shape of the hierarchy changes.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 13px; line-height: 17px;&quot;&gt;Custom Request object and Standard User object. I&#39;d use a lookup field to the user object if you want to relate a user other than the CreatedBy user. For example if the request needs to be approved by the user&#39;s manager, you could have a lookup field from the Request to the User object that is filled with the manager&#39;s name either by workflow rule or by the user. If the user&#39;s manager changes, the prior requests won&#39;t be deleted.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/2229275679616572455/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/2229275679616572455' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/2229275679616572455'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/2229275679616572455'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2014/07/difference-between-lookup-and-master.html' title='Difference between Lookup and Master-Detail in Salesforce'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-1225089934576865829</id><published>2014-01-19T12:30:00.001+05:30</published><updated>2014-01-19T12:39:24.882+05:30</updated><title type='text'>How to make a Method Thread Safe?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #111111; line-height: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;In multi-threaded applications where multiple threads make calls to the methods of a single object, it is necessary that those calls be synchronized. If code is not synchronized, then one thread might interrupt another thread and the object could be left in an invalid state. A class whose members are protected from such interruptions is called thread-safe.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
Although, there is no rule that makes the code thread safe, the only thing you can do is make sure that your code will work no matter how many times is it being actively executed, each thread can be interrupted at any point, with &lt;b&gt;each thread being in its own state/location&lt;/b&gt;, and this for each function (static or otherwise) that is accessing common objects.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
If a method (instance or static) only references variables scoped within that method then it is thread safe because each thread has its own stack:&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
In this instance, multiple threads could call ThreadSafeMethod concurrently without issue.&lt;/div&gt;
&lt;pre class=&quot;lang-cs prettyprint prettyprinted&quot; style=&quot;background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Thing&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;ThreadSafeMethod&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; parameter1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; number&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;background-color: transparent; border: 0px; color: grey; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;// each thread will have its own variable for number.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
        number &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; parameter1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Length&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; number&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
This is also true if the method calls other class method which only reference locally scoped variables:&lt;/div&gt;
&lt;pre class=&quot;lang-cs prettyprint prettyprinted&quot; style=&quot;background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Thing&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;ThreadSafeMethod&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; parameter1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; number&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
        number &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;GetLength&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;parameter1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; number&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;

    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;GetLength&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; value&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; length &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; value&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Length&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; length&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
If a method accesses any (object state) properties or fields (instance or static) then you need to use locks to ensure that the values are not modified by a different thread.&lt;/div&gt;
&lt;pre class=&quot;lang-cs prettyprint prettyprinted&quot; style=&quot;background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Thing&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; someValue&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;background-color: transparent; border: 0px; color: grey; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;// all threads will read and write to this same field value&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;

    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;NonThreadSafeMethod&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; parameter1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;someValue &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; parameter1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;

        &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; number&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;

        &lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;background-color: transparent; border: 0px; color: grey; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;// Since access to someValue is not synchronised by the class, a separate thread&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;background-color: transparent; border: 0px; color: grey; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;// could have changed its value between this thread setting its value at the start &lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;background-color: transparent; border: 0px; color: grey; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;// of the method and this line reading its value.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
        number &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;someValue&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Length&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; number&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
You should be aware that any parameters passed in to the method which are not either a struct or immutable could be mutated by another thread outside the scope of the method.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
To ensure proper concurrency you need to use locking.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
For further information see&amp;nbsp;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx&quot; style=&quot;background-color: transparent; border: 0px; color: #4a6b82; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;lock statement C# reference&lt;/a&gt;, &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.threading.monitor(v=vs.110).aspx&quot; target=&quot;_blank&quot;&gt;Monitoring&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.threading.readerwriterlockslim.aspx&quot; style=&quot;background-color: transparent; border: 0px; color: #4a6b82; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;ReadWriterLockSlim&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
Lock is mostly useful for providing one at a time functionality, ReadWriterLockSlim is useful if you need multiple readers and single writers.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/1225089934576865829/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/1225089934576865829' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/1225089934576865829'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/1225089934576865829'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2014/01/how-to-make-method-thread-safe.html' title='How to make a Method Thread Safe?'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-3206704331828408217</id><published>2013-12-17T16:32:00.001+05:30</published><updated>2013-12-17T16:37:37.792+05:30</updated><title type='text'>An Introduction To DOM Events</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Skolar Regular&#39;, Palatino, Cambria, &#39;Droid Serif&#39;, Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 1.25em; line-height: 1.35em; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Click, touch, load, drag, change, input, error, resize — the list of possible DOM events is lengthy. Events can be triggered on any part of a document, whether by a user’s interaction or by the browser. They&amp;nbsp;don’t just start and end in one place; they flow though the document, on a life cycle of their own. This life cycle is what makes DOM events so extensible and useful. As developers,&amp;nbsp;&lt;span style=&quot;background-color: transparent; border: 0px; font-family: &#39;Skolar Bold&#39;, Palatino, Cambria, &#39;Droid Serif&#39;, Georgia, &#39;Times New Roman&#39;, Times, serif; font-weight: 700; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;we should understand how DOM events work&lt;/span&gt;, so that we can harness their potential and build engaging experiences.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Throughout my time as a front-end developer, I felt that I was never given a straight explanation of how DOM events work. My aim here is to give you a clear overview of the subject, to get you up to speed more quickly than I did.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
I&amp;nbsp;will introduce the basics of working with DOM events, then delve into their inner workings, explaining how we can make use of them to solve common problems.&lt;/div&gt;
&lt;h3 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Skolar Bold&#39;, Palatino, Cambria, &#39;Droid Serif&#39;, Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 1.5em; line-height: 1.3em; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; vertical-align: baseline;&quot;&gt;
Listening For Events&lt;/h3&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
In the past, browsers have had major inconsistencies in the way they attach event listeners to DOM nodes. Libraries such as&amp;nbsp;&lt;a href=&quot;http://jquery.com/&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot; title=&quot;jQuery&quot;&gt;jQuery&lt;/a&gt;&amp;nbsp;have been invaluable in abstracting away these oddities.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
As we move ever closer to standardized browser environments, we can more safely use the APIs from the official specification.&amp;nbsp;To keep it simple, I will describe how to manage events for the modern Web. If you are writing JavaScript for Internet Explorer (IE) 8 or below, I would advise using a&amp;nbsp;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.removeEventListener#Polyfill_to_support_older_browsers&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot; title=&quot;addEventListener polyfill&quot;&gt;polyfill&lt;/a&gt;&amp;nbsp;or framework (such as&amp;nbsp;&lt;a href=&quot;http://jquery.com/&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot; title=&quot;jQuery&quot;&gt;jQuery&lt;/a&gt;) to manage event listeners.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
In JavaScript, we can listen to events using this:&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;element&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;lt;&lt;/span&gt;event&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;-&lt;/span&gt;name&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;lt;&lt;/span&gt;callback&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;lt;&lt;/span&gt;use&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;-&lt;/span&gt;capture&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; margin: 0.5em 1.5em; outline: 0px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;event-name&lt;/code&gt;&amp;nbsp;(string)&lt;br /&gt;This is the name or type of event that you would like to listen to. It could be any of the standard DOM events (&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;click&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;mousedown&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;touchstart&lt;/code&gt;,&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;transitionEnd&lt;/code&gt;, etc.) or even your own custom event name (we’ll touch on custom events later).&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;callback&lt;/code&gt;&amp;nbsp;(function)&lt;br /&gt;This function gets called when the event happens. The&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;event&lt;/code&gt;&amp;nbsp;object, containing data about the event, is passed as the first argument.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;use-capture&lt;/code&gt;&amp;nbsp;(boolean)&lt;br /&gt;This declares whether the callback should be fired in the “capture” phase. (Don’t worry: We’ll explain what that means a little later.)&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;var&lt;/span&gt; element &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;getElementById&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;element&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;callback&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;alert&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;Hello&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
// Add listener
&lt;/span&gt;element&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; callback&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Skolar Bold&#39;, Palatino, Cambria, &#39;Droid Serif&#39;, Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 1.5em; line-height: 1.3em; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; vertical-align: baseline;&quot;&gt;
Removing Listeners&lt;/h3&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Removing event listeners once they are no longer needed is a best practice (especially in long-running Web applications). To do this, use the&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;element.removeEventListener()&lt;/code&gt;&amp;nbsp;method:&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;element&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;removeEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;lt;&lt;/span&gt;event&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;-&lt;/span&gt;name&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;lt;&lt;/span&gt;callback&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;lt;&lt;/span&gt;use&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;-&lt;/span&gt;capture&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
But&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;removeEventListener&lt;/code&gt;&amp;nbsp;has one catch: You must have a reference to the callback function that was originally bound. Simply calling&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;element.removeEventListener(&#39;click&#39;);&lt;/code&gt;&amp;nbsp;will not work.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Essentially, if we have any interest in removing event listeners (which we should in “long-lived” applications), then we need to keep a handle on our callbacks. This means we cannot use anonymous functions.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;var&lt;/span&gt; element &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;getElementById&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;element&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;callback&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;alert&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;Hello once&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
  element&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;removeEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; callback&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
// Add listener
&lt;/span&gt;element&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; callback&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Skolar Bold&#39;, Palatino, Cambria, &#39;Droid Serif&#39;, Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 1.5em; line-height: 1.3em; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; vertical-align: baseline;&quot;&gt;
Maintaining Callback Context&lt;/h3&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
An easy gotcha is callbacks being called with the incorrect context. Let’s explain with an example.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;var&lt;/span&gt; element &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;getElementById&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;element&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;var&lt;/span&gt; user &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
 firstname&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;Wilson&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;
 greeting&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;alert&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;My name is &#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;+&lt;/span&gt; this&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;firstname&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
 &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
// Attach user.greeting as a callback
&lt;/span&gt;element&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;greeting&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
// alert =&amp;gt; &#39;My name is undefined&#39;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Bold&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.125em; line-height: 22.390625px; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; text-transform: uppercase; vertical-align: baseline;&quot;&gt;
USING ANONYMOUS FUNCTIONS&lt;/h4&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
We expected the callback to correctly alert us with&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;My name is Wilson&lt;/code&gt;. In fact, it alerts us with&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;My name is undefined&lt;/code&gt;. In order for&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;this.firstName&lt;/code&gt;&amp;nbsp;to return&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;Wilson&lt;/code&gt;,&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;user.greeting&lt;/code&gt;&amp;nbsp;must be called within the context (i.e. whatever is left of the dot when called) of&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;user&lt;/code&gt;.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
When we pass the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;greeting&lt;/code&gt;&amp;nbsp;function to the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;addEventListener&lt;/code&gt;&amp;nbsp;method, we are only passing a reference to the function; the context of&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;user&lt;/code&gt;&amp;nbsp;is not passed with it. Internally, the callback is called in the context of&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;element&lt;/code&gt;, which means that&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;this&lt;/code&gt;&amp;nbsp;refers to&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;element&lt;/code&gt;, not to&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;user&lt;/code&gt;. Therefore,&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;this.firstname&lt;/code&gt;&amp;nbsp;is undefined.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
There are two ways to prevent this context mismatch. First, we can call&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;user.greeting()&lt;/code&gt;&amp;nbsp;with the correct context inside an anonymous function.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;element&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
  user&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;greeting&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
 &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; // alert =&amp;gt; &#39;My name is Wilson&#39;
&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Bold&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.125em; line-height: 22.390625px; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; text-transform: uppercase; vertical-align: baseline;&quot;&gt;
FUNCTION.PROTOTYPE.BIND&lt;/h4&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
The last method isn’t so good because now we don’t have a handle on the function when we want to remove it with&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;.removeEventListener()&lt;/code&gt;. Plus, it’s pretty ugly. I prefer to use the&amp;nbsp;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot; title=&quot;Function.prototype.bind&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;.bind()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;method (built into all functions, as of ECMAScript 5) to generate a new function (&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;bound&lt;/code&gt;) that will always run in the given context. We then pass that function as the callback to&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;.addEventListener()&lt;/code&gt;.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;// Overwrite the original function with
&lt;/span&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;// one bound to the context of &#39;user&#39;
&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;greeting &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;greeting&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;bind&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;

// Attach the bound user.greeting as a callback
&lt;/span&gt;button&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;greeting&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
We also have a reference to the callback at hand, which we can use to unbind the listener if need be.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;button&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;removeEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;greeting&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Check the&amp;nbsp;&lt;a href=&quot;http://kangax.github.io/es5-compat-table/#Function.prototype.bind&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;support page&lt;/a&gt;&amp;nbsp;for&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;Function.prototype.bind&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Compatibility&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;polyfill&lt;/a&gt;&amp;nbsp;if you need it.&lt;/div&gt;
&lt;h3 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Skolar Bold&#39;, Palatino, Cambria, &#39;Droid Serif&#39;, Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 1.5em; line-height: 1.3em; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; vertical-align: baseline;&quot;&gt;
The Event Object&lt;/h3&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
The event object is created when the event first happens; it travels with the event on its journey through the DOM. The function that we assign as a callback to an event listener is passed the event object as its first argument. We can use this object to access a wealth of information about the event that has occurred:&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; margin: 0.5em 1.5em; outline: 0px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;type&lt;/code&gt;&amp;nbsp;(string)&lt;br /&gt;This is the name of the event.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;target&lt;/code&gt;&amp;nbsp;(node)&lt;br /&gt;This is the DOM node where the event originated.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;currentTarget&lt;/code&gt;&amp;nbsp;(node)&lt;br /&gt;This is the DOM node that the event callback is currently firing on.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;bubbles&lt;/code&gt;&amp;nbsp;(boolean)&lt;br /&gt;This indicates whether this is a “bubbling” event (which we’ll&amp;nbsp;&lt;a href=&quot;http://coding.smashingmagazine.com/2013/11/12/an-introduction-to-dom-events/#bubble-phase&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;explain later&lt;/a&gt;).&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;preventDefault&lt;/code&gt;&amp;nbsp;(function)&lt;br /&gt;This prevents any default behaviour from occurring that the user agent (i.e. browser) might carry out in relation to the event (for example, preventing a&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;click&lt;/code&gt;&amp;nbsp;event on an&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=4670920447169706502&quot;&gt;&lt;/a&gt;&lt;/code&gt;&amp;nbsp;element from loading a new page).&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;stopPropagation&lt;/code&gt;&amp;nbsp;(function)&lt;br /&gt;This prevents any callbacks from being fired on any nodes further along the event chain, but it does not prevent any additional callbacks of the same event name from being fired on the current node. (We’ll talk about that&amp;nbsp;&lt;a href=&quot;http://coding.smashingmagazine.com/2013/11/12/an-introduction-to-dom-events/#stopping-propagation&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;later&lt;/a&gt;.)&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;stopImmediatePropagation&lt;/code&gt;&amp;nbsp;(function)&lt;br /&gt;This prevents any callbacks from being fired on any nodes further along the event chain, including any additional callbacks of the same event name on the current node.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;cancelable&lt;/code&gt;&amp;nbsp;(boolean)&lt;br /&gt;This indicates whether the default behaviour of this event can be prevented by calling the&amp;nbsp;&lt;a href=&quot;http://coding.smashingmagazine.com/2013/11/12/an-introduction-to-dom-events/#preventing-default&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;event.preventDefault&lt;/code&gt;&lt;/a&gt;&amp;nbsp;method.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;defaultPrevented&lt;/code&gt;&amp;nbsp;(boolean)&lt;br /&gt;This states whether the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;preventDefault&lt;/code&gt;&amp;nbsp;method has been called on the event object.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;isTrusted&lt;/code&gt;&amp;nbsp;(boolean)&lt;br /&gt;An event is said to be “trusted” when it originates from the device itself, not synthesized from within JavaScript.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;eventPhase&lt;/code&gt;&amp;nbsp;(number)&lt;br /&gt;This number represents the phase that the event is currently in: none (&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;0&lt;/code&gt;), capture (&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;1&lt;/code&gt;), target (&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;2&lt;/code&gt;) or bubbling (&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;3&lt;/code&gt;). We’ll go over event phases&amp;nbsp;&lt;a href=&quot;http://coding.smashingmagazine.com/2013/11/12/an-introduction-to-dom-events/#event-phases&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;next&lt;/a&gt;.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;timestamp&lt;/code&gt;&amp;nbsp;(number)&lt;br /&gt;This is the date on which the event occurred.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Many other properties can be found on the event object, but they are specific to the type of event in question. For example, mouse events will include&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;clientX&lt;/code&gt;and&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;clientY&lt;/code&gt;&amp;nbsp;properties on the event object to indicate the location of the pointer in the viewport.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
It’s best to use your favorite browser’s debugger or a&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;console.log&lt;/code&gt;&amp;nbsp;to look more closely at the event object and its properties.&lt;/div&gt;
&lt;h3 id=&quot;event-phases&quot; style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Skolar Bold&#39;, Palatino, Cambria, &#39;Droid Serif&#39;, Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 1.5em; line-height: 1.3em; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; vertical-align: baseline;&quot;&gt;
Event Phases&lt;/h3&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
When a DOM event fires in your app, it doesn’t just fire once where the event originated; it embarks on a journey of three phases. In short, the event flows from the document’s root to the target (i.e. capture phase), then fires on the event target (target phase), then flows back to the document’s root (bubbling phase).&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmo-gsP0BRV4MzNKauSdkIvVly5uyf_Bt4YY3SYEeDigPAz0TOqrPY96GM0dvQoiss08KWPkrPBzLvYTvPLVB_aUnxS2fFVRzf32mOzQ_53pOFAKRRym-LQbDyX8vH6nwRt-cFI77vAiI/s1600/eventflow.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmo-gsP0BRV4MzNKauSdkIvVly5uyf_Bt4YY3SYEeDigPAz0TOqrPY96GM0dvQoiss08KWPkrPBzLvYTvPLVB_aUnxS2fFVRzf32mOzQ_53pOFAKRRym-LQbDyX8vH6nwRt-cFI77vAiI/s1600/eventflow.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Bold&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.125em; line-height: 22.390625px; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; text-transform: uppercase; vertical-align: baseline;&quot;&gt;
CAPTURE PHASE&lt;/h4&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
The first phase is the capture phase. The event starts its journey at the root of the document, working its way down through each layer of the DOM, firing on each node until it reaches the event target. The job of the capture phase is to build the propagation path, which the event will travel back through in the bubbling phase.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
As mentioned, you can listen to events in the capture phase by setting the third argument of&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;addEventListener&lt;/code&gt;&amp;nbsp;to&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;true&lt;/code&gt;. I have not found many use cases for capture phase listeners, but you could potentially prevent any clicks from firing in a certain element if the event is handled in the capture phase.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;var&lt;/span&gt; form &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;querySelector&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;form&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;

form&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
  event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;stopPropagation&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token boolean&quot; style=&quot;background-color: transparent; border: 0px; color: #990055; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; // Note: &#39;true&#39;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
If you’re unsure, listen for events in the bubbling phase by setting the&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;useCapture&lt;/code&gt;&amp;nbsp;flag to&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;false&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;undefined&lt;/code&gt;.&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Bold&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.125em; line-height: 22.390625px; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; text-transform: uppercase; vertical-align: baseline;&quot;&gt;
TARGET PHASE&lt;/h4&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
An event reaching the target is known as the target phase. The event fires on the target node, before reversing and retracing its steps, propagating back to the outermost document level.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
In the case of nested elements, mouse and pointer events are always targeted at the most deeply nested element. If you have listened for a&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;click&lt;/code&gt;&amp;nbsp;event on a&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;&lt;/code&gt;&lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;
&lt;/code&gt;&amp;nbsp;element, and the user actually clicks on a&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;&lt;/code&gt;&amp;nbsp;element in the div, then the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;&lt;/code&gt;&amp;nbsp;element will become the event target. The fact that events “bubble” means that you are able to listen for clicks on the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;&lt;/code&gt;&lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;
&lt;/code&gt;&amp;nbsp;(or any other ancestor node) and still receive a callback once the event passes through.&lt;/div&gt;
&lt;h4 id=&quot;bubble-phase&quot; style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Bold&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.125em; line-height: 22.390625px; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; text-transform: uppercase; vertical-align: baseline;&quot;&gt;
BUBBLING PHASE&lt;/h4&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
After an event has fired on the target, it doesn’t stop there. It bubbles up (or propagates) through the DOM until it reaches the document’s root. This means that the same event is fired on the target’s parent node, followed by the parent’s parent, continuing until there is no parent to pass the event onto.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Think of the DOM as an onion and the event target as the core of the onion. In the capture phase, the event drills into the onion through each layer. When the event reaches the core, it fires (the target phase), and then reverses, working its way back up through each layer (the propagation phase). Once the event has returned to the surface, its journey is over.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Bubbling is useful. It frees us from listening for an event on the exact element it came from; instead, we listen on an element further up the DOM tree, waiting for the event to reach us. If events didn’t bubble, we would have to, in some cases, listen for an event on many different elements to ensure that it is caught.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
The majority of, but not all, events bubble. When events do not bubble, it is usually for a good reason. If in doubt, check&amp;nbsp;&lt;a href=&quot;http://www.w3.org/TR/DOM-Level-3-Events/#event-types&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;the specification&lt;/a&gt;.&lt;/div&gt;
&lt;h3 id=&quot;stopping-propagation&quot; style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Skolar Bold&#39;, Palatino, Cambria, &#39;Droid Serif&#39;, Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 1.5em; line-height: 1.3em; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; vertical-align: baseline;&quot;&gt;
Stopping Propagation&lt;/h3&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Interrupting the path of the event at any point on its journey (i.e. in the capture or bubbling phase) is possible simply by calling the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;stopPropagation&lt;/code&gt;&amp;nbsp;method on the event object. Then, the event will no longer call any listeners on nodes that it travels through on its way to the target and back to the document.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;child&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
 event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;stopPropagation&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;

parent&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; // If the child element is clicked
&lt;/span&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; // this callback will not fire
&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Calling&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;event.stopPropagation()&lt;/code&gt;&amp;nbsp;will not prevent any additional event listeners from being called on the current target if multiple listeners for the same event exist. If you wish to prevent any additional listeners from being called on the current node, you can use the more aggressive&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;event.stopImmediatePropagation()&lt;/code&gt;&amp;nbsp;method.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;child&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
 event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;stopImmediatePropagation&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;

child&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; // If the child element is clicked
&lt;/span&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; // this callback will not fire
&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;preventing-default&quot; style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Skolar Bold&#39;, Palatino, Cambria, &#39;Droid Serif&#39;, Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 1.5em; line-height: 1.3em; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; vertical-align: baseline;&quot;&gt;
Prevent The Browser’s Default Behavior&lt;/h3&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
The browser has default behaviors that will respond when certain events occur in the document. The most common event is a link being clicked. When a&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;click&lt;/code&gt;event occurs on an&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=4670920447169706502&quot;&gt;&lt;/a&gt;&lt;/code&gt;&amp;nbsp;element, it will bubble up to the document level of the DOM, and the browser will interpret the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;href&lt;/code&gt;&amp;nbsp;attribute and reload the window at the new address.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
In Web applications, developers usually want to manage the navigation themselves, without causing the page to refresh. To do this, we need to prevent the browser’s default response to clicks and instead do our own thing. To do this, we call&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;event.preventDefault()&lt;/code&gt;.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;anchor&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
  event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;preventDefault&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
 &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; // Do our own thing
&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
We can prevent many other default behaviors in the browser. For example, we could prevent presses of the space bar from scrolling the page in an HTML5 game, or we could prevent clicks from selecting text.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Calling&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;event.stopPropagation()&lt;/code&gt;&amp;nbsp;here will only prevent callbacks that are attached further down the propagation chain from being fired. It will not prevent the browser from doing its thing.&lt;/div&gt;
&lt;h3 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Skolar Bold&#39;, Palatino, Cambria, &#39;Droid Serif&#39;, Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 1.5em; line-height: 1.3em; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; vertical-align: baseline;&quot;&gt;
Custom Events&lt;/h3&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
The browser is not the only thing that is able to trigger DOM events. We can create our own custom events and dispatch them on any element in the document. This type of event would behave just the same as a regular DOM event.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;var&lt;/span&gt; myEvent &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;CustomEvent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;myevent&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
  detail&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
    name&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;Wilson&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;
  bubbles&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot; style=&quot;background-color: transparent; border: 0px; color: #990055; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;
  cancelable&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot; style=&quot;background-color: transparent; border: 0px; color: #990055; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
// Listen for &#39;myevent&#39; on an element
&lt;/span&gt;myElement&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;myevent&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;alert&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;Hello &#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;+&lt;/span&gt; event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;detail&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
// Trigger the &#39;myevent&#39;
&lt;/span&gt;myElement&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;dispatchEvent&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;myEvent&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Synthesizing “untrusted” DOM events on elements (for example,&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;click&lt;/code&gt;) to simulate user interaction is also possible. This can be useful when testing DOM-related libraries. If you’re interested, the Mozilla Developer Network has a&amp;nbsp;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Events/Creating_and_triggering_events#Triggering_built-in_events&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;write-up on it&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Note the following:&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; margin: 0.5em 1.5em; outline: 0px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;The&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;CustomEvent&lt;/code&gt;&amp;nbsp;API is not available in IE 8 and below.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;The&amp;nbsp;&lt;a href=&quot;http://flightjs.github.io/&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;Flight&lt;/a&gt;&amp;nbsp;framework from Twitter makes use of custom events to communicate between modules. This enforces a highly decoupled, modular architecture.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Skolar Bold&#39;, Palatino, Cambria, &#39;Droid Serif&#39;, Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 1.5em; line-height: 1.3em; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; vertical-align: baseline;&quot;&gt;
Delegate Event Listeners&lt;/h3&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Delegate event listeners are a more convenient and performant way to listen for events on a large number of DOM nodes using a single event listener. For example, if a list contains 100 items that all need to respond to a&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;click&lt;/code&gt;&amp;nbsp;event in a similar way, then we could query the DOM for all of the list items and attach an event listener to each one. This would result in 100 separate event listeners. Whenever a new item is added to the list, the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;click&lt;/code&gt;&amp;nbsp;event listener would have to be added to it. Not only does this risk getting expensive, but it is tricky to maintain.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Delegate event listeners can make our lives a lot easier. Instead of listening for the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;click&lt;/code&gt;&amp;nbsp;event on each element, we listen for it on the parent ul element. When an li is clicked, then the event bubbles up to the ul, triggering the callback. We can identify which li element has been clicked by inspecting the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;event.target&lt;/code&gt;. Below is a crude example to illustrate:&lt;br /&gt;
&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;var&lt;/span&gt; list &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;querySelector&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;ul&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;

list&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;var&lt;/span&gt; target &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
 
  &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;tagName &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;LI&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
    target &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; target&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;parentNode&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;target &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; list&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;

 &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; // Do stuff here
&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
This is better because we have only the overhead of a single event listener, and we no longer have to worry about attaching a new event listener when an item is added to the list. The concept is pretty simple but super-useful.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
I wouldn’t recommend using such a crude implementation in your app. Instead, use an event delegate JavaScript library, such as FT Lab’s&amp;nbsp;&lt;a href=&quot;https://github.com/ftlabs/ftdomdelegate&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot; title=&quot;ftdomdelegate&quot;&gt;ftdomdelegate&lt;/a&gt;. If you’re using jQuery, you can seamlessly use event delegation by passing a selector as the second parameter to the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;.on()&lt;/code&gt;&amp;nbsp;method.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;// Not using event delegation
&lt;/span&gt;$&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;li&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;on&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;

// Using event delegation
&lt;/span&gt;$&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;ul&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;on&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;li&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Skolar Bold&#39;, Palatino, Cambria, &#39;Droid Serif&#39;, Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 1.5em; line-height: 1.3em; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; vertical-align: baseline;&quot;&gt;
Useful Events&lt;/h3&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Bold&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.125em; line-height: 22.390625px; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; text-transform: uppercase; vertical-align: baseline;&quot;&gt;
LOAD&lt;/h4&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;load&lt;/code&gt;&amp;nbsp;event fires on any resource that has finished loading (including any dependent resources). This could be an image, style sheet, script, video, audio file, document or window.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;image&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;load&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
  image&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;classList&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;add&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;has-loaded&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Bold&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.125em; line-height: 22.390625px; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; text-transform: uppercase; vertical-align: baseline;&quot;&gt;
ONBEFOREUNLOAD&lt;/h4&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;window.onbeforeunload&lt;/code&gt;&amp;nbsp;enables developers to ask the user to confirm that they want to leave the page. This can be useful in applications that require the user to save changes that would get lost if the browser’s tab were to be accidentally closed.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;window&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;onbeforeunload &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;textarea&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;value &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; textarea&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;defaultValue&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;Do you want to leave the page and discard changes?&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Note that assigning an&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;onbeforeunload&lt;/code&gt;&amp;nbsp;handler prevents the browser&amp;nbsp;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;from caching the page&lt;/a&gt;, thus making return visits a lot slower. Also,&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;onbeforeunload&lt;/code&gt;handlers must be synchronous.&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Bold&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.125em; line-height: 22.390625px; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; text-transform: uppercase; vertical-align: baseline;&quot;&gt;
STOPPING WINDOW BOUNCE IN MOBILE SAFARI&lt;/h4&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
At the Financial Times, we use a simple&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;event.preventDefault&lt;/code&gt;&amp;nbsp;technique to prevent mobile Safari from bouncing the window when it is scrolled.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;document&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;body&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;touchmove&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
 event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;preventDefault&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Be warned that this will also prevent any native scrolling from working ( such as&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;overflow: scroll&lt;/code&gt;). To allow native scrolling on a subset of elements that need it, we listen for the same event on the scrollable element and set a flag on the event object. In the callback at the document level, we decide whether to prevent the default behavior of the touch event based on the existence of the&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;isScrollable&lt;/code&gt;&amp;nbsp;flag.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;// Lower down in the DOM we set a flag
&lt;/span&gt;scrollableElement&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;touchmove&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
 event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;isScrollable &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot; style=&quot;background-color: transparent; border: 0px; color: #990055; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;

// Higher up the DOM we check for this flag to decide
&lt;/span&gt;&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;// whether to let the browser handle the scroll
&lt;/span&gt;document&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;touchmove&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;!&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;isScrollable&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;preventDefault&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Manipulating the event object is not possible in IE 8 and below. As a workaround, you can set properties on the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;event.target&lt;/code&gt;&amp;nbsp;node.&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Bold&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.125em; line-height: 22.390625px; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; text-transform: uppercase; vertical-align: baseline;&quot;&gt;
RESIZE&lt;/h4&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Listening to the resize event on the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;window&lt;/code&gt;&amp;nbsp;object is super-useful for complex responsive layouts. Achieving a layout with CSS alone is not always possible. Sometimes JavaScript has to help us calculate and set the size of elements. When the window is resized or the device’s orientation changes, then we would likely need to readjust these sizes.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;window&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;resize&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; // update the layout
&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
I recommended using a&amp;nbsp;&lt;a href=&quot;http://davidwalsh.name/function-debounce&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;debounced&lt;/a&gt;&amp;nbsp;callback to normalize the callback rate and prevent extreme thrashing in the layout.&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Bold&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.125em; line-height: 22.390625px; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; text-transform: uppercase; vertical-align: baseline;&quot;&gt;
TRANSITIONEND&lt;/h4&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Today we use CSS to power the majority of transitions and animations in our applications. Sometimes, though, we still need to know when a particular animation has finished.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;el&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;transitionEnd&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;token comment&quot; spellcheck=&quot;true&quot; style=&quot;background-color: transparent; border: 0px; color: slategrey; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; // Do stuff
&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Note the following:&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; margin: 0.5em 1.5em; outline: 0px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;If you’re using&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;@keyframe&lt;/code&gt;&amp;nbsp;animations, use the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;animationEnd&lt;/code&gt;&amp;nbsp;event name, instead of&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;transitionEnd&lt;/code&gt;.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;Like a lot of events,&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;transitionEnd&lt;/code&gt;&amp;nbsp;bubbles. Remember either to call&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;event.stopPropagation()&lt;/code&gt;&amp;nbsp;on any descendant transition events or to check the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;event.target&lt;/code&gt;&amp;nbsp;to prevent callback logic from running when it’s not supposed to.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0.25em 0px; position: relative; vertical-align: baseline;&quot;&gt;Event names are still widely vendor-prefixed (for example,&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;webkitTransitionEnd&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;msTransitionEnd&lt;/code&gt;, etc). Use a library such as&lt;a href=&quot;http://modernizr.com/&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot; title=&quot;Modernizr&quot;&gt;Modernizr&lt;/a&gt;&amp;nbsp;to get the event name’s correct prefix.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Bold&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.125em; line-height: 22.390625px; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; text-transform: uppercase; vertical-align: baseline;&quot;&gt;
ANIMATIONITERATION&lt;/h4&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;animationiteration&lt;/code&gt;&amp;nbsp;event will fire every time a currently animating element completes an iteration. This is useful if we want to stop an animation but not midway through.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;start&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
  div&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;classList&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;add&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;spin&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;stop&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
  div&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;animationiteration&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; callback&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;callback&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
    div&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;classList&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;remove&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;spin&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
    div&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;removeEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;animationiteration&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; callback&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
If you’re interested, I’ve&amp;nbsp;&lt;a href=&quot;http://wilsonpage.co.uk/animation-iteration-event&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;written about the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;animationiteration&lt;/code&gt;&amp;nbsp;event&lt;/a&gt;&amp;nbsp;in a little more detail on my blog.&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Bold&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.125em; line-height: 22.390625px; margin: 0px; outline: 0px; padding: 1.5em 0px 0.5em; text-transform: uppercase; vertical-align: baseline;&quot;&gt;
ERROR&lt;/h4&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
If an error occurs when a resource loads, we might want to do something about it, especially if our users are on a flaky connection. The Financial Times uses this event to detect any images that might have failed to load in an article and instantly hide them. Because the “&lt;a href=&quot;http://www.w3.org/TR/DOM-Level-3-Events/#event-type-error&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;DOM Level 3 Events&lt;/a&gt;” specification has redefined the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;error&lt;/code&gt;&amp;nbsp;event to “not bubble,” we can handle the event in one of two ways.&lt;/div&gt;
&lt;pre class=&quot; language-javascript&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-javascript&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;imageNode&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;addEventListener&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;error&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;
  image&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;display &lt;span class=&quot;token operator&quot; style=&quot;background-color: rgba(255, 255, 255, 0.498039); border: 0px; color: #a67f59; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;none&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
Unfortunately,&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;addEventListener&lt;/code&gt;&amp;nbsp;does not address all use cases. My colleague&lt;a href=&quot;http://twitter.com/pornelski&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;Kornel&lt;/a&gt;&amp;nbsp;has kindly pointed me to an&amp;nbsp;&lt;a href=&quot;http://jsbin.com/esimAWA/2/quiet&quot; style=&quot;-webkit-tap-highlight-color: rgba(229, 59, 44, 0.4); background-color: transparent; border-bottom-color: rgba(0, 0, 0, 0.0980392); border-bottom-style: solid; border-bottom-width: 0.07em; color: #41b7d8; margin: 0px; padding: 0px 0px 0.07em; text-decoration: none; vertical-align: baseline;&quot;&gt;example that demonstrates&lt;/a&gt;&amp;nbsp;that the only way, sadly, to guarantee the execution of image&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;error&lt;/code&gt;&amp;nbsp;event callbacks is to use (the often frowned upon) inline event handlers.&lt;/div&gt;
&lt;pre class=&quot; language-markup&quot; style=&quot;background-color: #f5f2f0; border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; line-height: 22.390625px; margin-bottom: 0.5em; margin-top: 0.5em; outline: 0px; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;code class=&quot; language-markup&quot; style=&quot;border: 0px; direction: ltr; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; tab-size: 4; text-shadow: rgb(255, 255, 255) 0px 0.08em; vertical-align: baseline; word-spacing: normal; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;token tag&quot; style=&quot;background-color: transparent; border: 0px; color: #990055; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;token tag&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;&lt;/span&gt;http://example.com/image.jpg&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot; style=&quot;background-color: transparent; border: 0px; color: #669900; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;onerror&lt;/span&gt;&lt;span class=&quot;token attr-value&quot; style=&quot;background-color: transparent; border: 0px; color: #0077aa; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;&lt;/span&gt;this.style.display&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&#39;none&#39;;&lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot; style=&quot;background-color: transparent; border: 0px; color: #999999; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
The reason for this is that you cannot be sure that the code that binds the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;error&lt;/code&gt;event handler will be executed before the&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;error&lt;/code&gt;&amp;nbsp;event actually happens. Using inline handlers means that when the markup is parsed and the image is requested, our&amp;nbsp;&lt;code style=&quot;background-color: #f5f2f0; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #4e4e4e; font-family: Consolas, Monaco, &#39;Andale Mono&#39;, monospace; font-size: 0.8em; margin: 0px; outline: 0px; padding: 0.15625em 0.3125em; vertical-align: baseline; white-space: pre-line; word-wrap: break-word;&quot;&gt;error&lt;/code&gt;&amp;nbsp;listeners will be attached.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: &#39;Proxima Nova Regular&#39;, &#39;Helvetica Neue&#39;, Calibri, &#39;Droid Sans&#39;, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 22.390625px; outline: 0px; padding: 0.5em 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/3206704331828408217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/3206704331828408217' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/3206704331828408217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/3206704331828408217'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2013/12/an-introduction-to-dom-events.html' title='An Introduction To DOM Events'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmo-gsP0BRV4MzNKauSdkIvVly5uyf_Bt4YY3SYEeDigPAz0TOqrPY96GM0dvQoiss08KWPkrPBzLvYTvPLVB_aUnxS2fFVRzf32mOzQ_53pOFAKRRym-LQbDyX8vH6nwRt-cFI77vAiI/s72-c/eventflow.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-805894799372326035</id><published>2013-10-16T17:28:00.001+05:30</published><updated>2013-10-16T17:30:00.070+05:30</updated><title type='text'>Database Sharding</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h1 style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 21px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Database Sharding&lt;/h1&gt;
&lt;h2 style=&quot;background-color: white; border: 0px; clear: both; color: #444444; font-family: Verdana, sans-serif; font-size: 18px; font-weight: normal; margin: 10px 0px 4px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The Rise of Database Sharding&lt;/h2&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The concept of Database Sharding has been gaining popularity over the past several years, due to the enormous growth in transaction volume and size of business application databases. This is particularly true for many successful online service providers, Software as a Service (SaaS) companies, and social networking Web sites.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Database Sharding can be simply defined as a &quot;shared-nothing&quot; partitioning scheme for large databases across a number of servers, enabling new levels of database performance and scalability achievable. If you think of broken glass, you can get the concept of sharding - breaking your database down into smaller chunks called “shards” and spreading those across a number of distributed servers.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The term &quot;sharding&quot; was coined by Google engineers, and popularized through their publication of the Big Table architecture. However, the concept of &quot;shared-nothing&quot; database partitioning has been around for a decade or more and there have been many implementations over this period, especially high profile in-house built solutions by Internet leaders such as eBay, Amazon, Digg, Flickr, Skype, YouTube, Facebook, Friendster, and Wikipedia.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The focus of this paper is on the need for Database Sharding, the options available for database partitioning, and the key considerations for a successful sharding implementation.&lt;/div&gt;
&lt;h2 style=&quot;background-color: white; border: 0px; clear: both; color: #444444; font-family: Verdana, sans-serif; font-size: 18px; font-weight: normal; margin: 10px 0px 4px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
What Drives the Need for Database Sharding?&lt;/h2&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Database Sharding is a highly scalable approach for improving the throughput and overall performance of high-transaction, large database-centric business applications. Since the inception of the relational database, application engineers and architects have required ever-increasing performance and capacity, based on the simple observation that business databases generally grow in size over time. Adding to this general trend is the extreme expansion of business data due to the evolution of the Internet economy, the Information Age, and the prevalence of high-volume electronic commerce.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
As any experienced database administrator or application developer knows all too well, it is axiomatic that as the size and transaction volume of the database tier incurs linear growth, response times tend to grow logarithmically. This is shown in the following diagram:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOELmIVE9kRnUfKsuxpG6cICpNyxpwX-14vrMFWFceZH7dvihyphenhyphenRHQfV7_eTPP3ugLR8a79KamIadxWsdymfVuRWjy-wj9eguy2mIuTA7KTR2avDPU1ofegdV2qpNoIa4f5nBzX5NkX780/s1600/dbshards-graph.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOELmIVE9kRnUfKsuxpG6cICpNyxpwX-14vrMFWFceZH7dvihyphenhyphenRHQfV7_eTPP3ugLR8a79KamIadxWsdymfVuRWjy-wj9eguy2mIuTA7KTR2avDPU1ofegdV2qpNoIa4f5nBzX5NkX780/s1600/dbshards-graph.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;imgdesc&quot; style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; font-style: italic; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Figure 1. The growth in database transactions and volumes has a large impact on response times.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The reasons for the performance and scalability challenges are inherent to the fundamental design of the database management systems themselves. Databases rely heavily on the primary three components of any computer:&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.5em; list-style: circle; margin: 0px 0px 0px 25px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;CPU&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Memory&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Disk&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Through benchmark tests that we have performed, we know that each of these elements on a single server can only scale to a given point, and then other measures must be taken. While it is clear that disk I/O is the primary bottleneck, as database management systems have improved they also continue to take greater advantage of CPU and memory. In fact, we have observed that it is the matching of these three factors that determines maximum performance. In other words, you cannot add an unlimited number of CPUs (or processing cores) and see a commensurate increase in performance without also improving the memory capacity and performance of the disk drive subsystem. It is also common to see a diminishing return as resources are added to a single database server. These factors are especially true in mixed-use business transaction systems; systems that perform a high volume of read and write transactions, as well as supporting generalized business reporting tasks.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Therefore, as business applications gain sophistication and continue to grow in demand, architects, developers and database administrators have been presented with a constant challenge of maintaining database performance for mission critical systems. This landscape drives the need for Database Sharding.&lt;/div&gt;
&lt;h2 style=&quot;background-color: white; border: 0px; clear: both; color: #444444; font-family: Verdana, sans-serif; font-size: 18px; font-weight: normal; margin: 10px 0px 4px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Database Partitioning Options&lt;/h2&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
It has long been known that database partitioning is the answer to improving the performance and scalability of relational databases. Many techniques have been evolved, including:&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.5em; list-style: circle; margin: 0px 0px 0px 25px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Master/Slave:&lt;/strong&gt;&amp;nbsp;This is the simplest option used by many organizations, with a single Master server for all write (Create Update or Delete, or CRUD) operations, and one or many additional Slave servers that provide read-only operations. The Master uses standard, near-real-time database replication to each of the Slave servers. The Master/Slave model can speed overall performance to a point, allowing read-intensive processing to be offloaded to the Slave servers, but there are several limitations with this approach:&lt;ul style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: 1.5em; list-style-image: initial; list-style-position: initial; margin: 0px 0px 0px 25px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;The single Master server for writes is a clear limit to scalability, and can quickly create a bottleneck.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;The Master/Slave replication mechanism is &quot;near-real-time,&quot; meaning that the Slave servers are not guaranteed to have a current picture of the data that is in the Master. While this is fine for some applications, if your applications require an up-to-date view, this approach is unacceptable.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Many organizations use the Master/Slave approach for high-availability as well, but it suffers from this same limitation given that the Slave servers are not necessarily current with the Master. If a catastrophic failure of the Master server occurs, any transactions that are pending for replication will be lost, a situation that is highly unacceptable for most business transaction applications.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Cluster Computing:&lt;/strong&gt;&amp;nbsp;Cluster computing utilizes many servers operating in a group, with shared messaging between the nodes of the cluster. Most often this scenario relies on a centralized shared disk facility, typically a Storage Area Network (SAN). Each node in the cluster runs a single instance of the database server, operating in various modes:&lt;ul style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: 1.5em; list-style-image: initial; list-style-position: initial; margin: 0px 0px 0px 25px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;For high-availability, many nodes in the cluster can be used for reads, but only one for write (CRUD) operations. This can make reads faster, but write transactions do not see any benefit. If a failure of one node occurs, then another node in the cluster takes over, again continuing to operating against the shared disk facility. This approach has limited scalability due to the single bottleneck for CRUD operations. Even the reads will ultimately hit a performance limit as the centralized shared disk facility can only spread the load so much before diminishing returns are experienced. The read limitations are particularly evident when an application requires complex joins or contains non-optimized SQL statements.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;More advanced clustering techniques rely on real-time memory replication between nodes, keeping the memory image of nodes in the cluster up to date via a real-time messaging system. This allows each node to operate in both read or write mode, but is ultimately limited by the amount of traffic that can be transmitted between nodes (using a typical network or other high-speed communication mechanism). Therefore, as nodes are added, the communication and memory replication overhead increases geometrically, thus hitting severe scalability limits, often with a relatively small number of nodes. This solution also suffers from the same shared disk limitations of a traditional cluster, given that a growing, single large database has increasingly intensive disk I/O.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Table Partitioning:&lt;/strong&gt;&amp;nbsp;Many database management systems support table partitioning, where data in a single large table can be split across multiple disks for improved disk I/O utilization. The partitioning is typically done horizontally (separating rows by range across disk partitions), but can be vertical in some systems as well (placing different columns on separate partitions). This approach can help reduce the disk I/O bottleneck for a given table, but can often make joins and other operations slower. Further, since the approach relies on a single server instance of the database management system, all other CPU and memory contention limitations apply, further limiting scalability.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Federated Tables:&lt;/strong&gt;&amp;nbsp;An offshoot of Table Partitioning is the Federated Table approach, where tables can be accessed across multiple servers. This approach is necessarily highly complex to administer, and lacks efficiency as the federated tables must be accessed over the network. This approach may work for some reporting or analytical tasks, but for general read/write transactions it is not a very likely choice.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The common drawback with each of these approaches is the reliance on shared facilities and resources. Whether relying on shared memory, centralized disk, or processor capacity they each suffer with scalability limitations, not to mention many other drawbacks, including complex administration, lack of support for critical business requirements, and high availability limitations.&lt;/div&gt;
&lt;h2 style=&quot;background-color: white; border: 0px; clear: both; color: #444444; font-family: Verdana, sans-serif; font-size: 18px; font-weight: normal; margin: 10px 0px 4px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Database Sharding, The &quot;Shared-Nothing&quot; Approach&lt;/h2&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Database Sharding provides a method for scalability across independent servers, each with their own CPU, memory and disk. Contrasted with other traditional methods of achieving greater database performance, it does not suffer from many of the typical limitations posed by these other approaches. The concept of a &quot;shared-nothing&quot; database implementation has been under research or discussion for 15+ years, but it appears that the business application market is just now finding the more general need for such capability due to the exponential increase in data volumes over the past several years.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The basic concept of Database Sharding is very straightforward: take a large database, and break it into a number of smaller databases across servers. The concept is illustrated in the following diagram:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQuvDISk5mQSM9MRaSHu0jLbPsaMHlBBscLkZa4T8ohYx1QrUA3S5XaiJyRqoEo-T-1PCxrwhDnU_Zk81ApBdyuFd8veDTljh1GO_Uf3_oR7LMShK79T-LcWOJSKDyDlGl0YcVpfYD5EQ/s1600/dbshards-shardit.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQuvDISk5mQSM9MRaSHu0jLbPsaMHlBBscLkZa4T8ohYx1QrUA3S5XaiJyRqoEo-T-1PCxrwhDnU_Zk81ApBdyuFd8veDTljh1GO_Uf3_oR7LMShK79T-LcWOJSKDyDlGl0YcVpfYD5EQ/s1600/dbshards-shardit.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;imgdesc&quot; style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; font-style: italic; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Figure 2. Database Sharding takes large databases and breaks them down into smaller databases.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The obvious advantage of the shared-nothing Database Sharding approach is improved scalability, growing in a near-linear fashion as more servers are added to the network. However, there are several other advantages of smaller databases, which should not be overlooked when considering a sharding solution:&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.5em; list-style: circle; margin: 0px 0px 0px 25px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Smaller databases are easier to manage.&lt;/em&gt;&amp;nbsp;Production databases must be fully managed for regular backups, database optimization and other common tasks. With a single large database these routine tasks can be very difficult to accomplish, if only in terms of the time window required for completion. Routine table and index optimizations can stretch to hours or days, in some cases making regular maintenance infeasible. By using the sharding approach, each individual &quot;shard&quot; can be maintained independently, providing a far more manageable scenario, performing such maintenance tasks in parallel.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Smaller databases are faster.&lt;/em&gt;&amp;nbsp;The scalability of sharding is apparent, achieved through the distribution of processing across multiple shards and servers in the network. What is less apparent is the fact that each individual shard database will outperform a single large database due to its smaller size. By hosting each shard database on its own server, the ratio between memory and data on disk is greatly improved, thereby reducing disk I/O. This results in less contention for resources, greater join performance, faster index searches, and fewer database locks. Therefore, not only can a sharded system scale to new levels of capacity, individual transaction performance is benefited as well.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Database Sharding can reduce costs.&lt;/em&gt;&amp;nbsp;Most Database Sharding implementations take advantage of lower-cost open source databases, or can even take advantage of &quot;workgroup&quot; versions of commercial databases. Additionally, sharding works well with commodity multi-core server hardware, far less expensive than high-end multi-CPU servers and expensive SANs. The overall reduction in cost due to savings in license fees, software maintenance and hardware investment is substantial, in some cases 70% or more when compared to other solutions.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
There is no doubt that Database Sharding is a viable solution for many organizations, supported by the number of large online vendors and SaaS organizations that have implemented the technology (giants such as Amazon, eBay, and of course Google).&lt;/div&gt;
&lt;h2 style=&quot;background-color: white; border: 0px; clear: both; color: #444444; font-family: Verdana, sans-serif; font-size: 18px; font-weight: normal; margin: 10px 0px 4px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Practicalities of Database Sharding&lt;/h2&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
If Database Sharding is highly scalable, less costly, and improves performance, why hasn&#39;t adoption of the technology been more widespread? Is it feasible for your organization?&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The reality is that Database Sharding is a very useful technology, but like other approaches, there are many factors to consider that ensure a successful implementation. Further, there are some limitations and Database Sharding will not work well for every type of business application. This chapter discusses these critical considerations and how they can be addressed.&lt;/div&gt;
&lt;h2 style=&quot;background-color: white; border: 0px; clear: both; color: #444444; font-family: Verdana, sans-serif; font-size: 18px; font-weight: normal; margin: 10px 0px 4px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Database Sharding Challenges&lt;/h2&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Due to the distributed nature of individual databases, a number of key elements must be taken into account:&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.5em; list-style: circle; margin: 0px 0px 0px 25px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Reliability.&lt;/em&gt;&amp;nbsp;First and foremost, any production business application must be reliable and fault-tolerant, and cannot be subject to frequent outages. The database tier is often the single most critical element in any reliability design, and therefore an implementation of Database Sharding is no exception. In fact, due to the distributed nature of multiple shard databases, the criticality of a well-designed approach is even greater. To ensure a fault-tolerant and reliable approach, the following items are required:&lt;ul style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: 1.5em; list-style-image: initial; list-style-position: initial; margin: 0px 0px 0px 25px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Automated backups of individual Database Shards.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Database Shard redundancy, ensuring at least 2 &quot;live&quot; copies of each shard are available in the event of an outage or server failure. This requires a high-performance, efficient, and reliable replication mechanism.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Cost-effective hardware redundancy, both within and across servers.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Automated failover when an outage or server failure occurs.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Disaster Recovery site management.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Distributed queries.&lt;/em&gt;&amp;nbsp;Many types of queries can be processed far faster using distributed queries, performing parallel processing of interim results on each shard server. This technique can achieve order-of-magnitude improvements in performance, in many cases 10X or more. To enable distributed queries in a seamless manner for the application, it is important to have a facility that can process a segment of the query on each individual shard, and then consolidate the results into a single result set for the application tier. Common queries that can benefit from distributed processing are:&lt;ul style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: 1.5em; list-style-image: initial; list-style-position: initial; margin: 0px 0px 0px 25px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Aggregation of statistics, requiring a broad sweep of data across the entire system. Such an example is the computation of sales by product, which ordinarily requires evaluation of the entire database.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Queries that support comprehensive reports, such as listings of all individual customers that purchased a given product in the last day, week or month.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Avoidance of cross-shard joins.&lt;/em&gt;&amp;nbsp;In a sharded system, queries or other statements that use inner-joins that span shards are highly inefficient and difficult to perform. In the majority of cases, it has been found that such inner-joins are not actually required by an application, so long as the correct techniques are applied. The primary technique is the replication of Global Tables, the relatively static lookup tables that are common utilized when joining to much larger primary tables. Tables containing values as Status Codes, Countries, Types, and even Products fall into this category. What is required is an automated replication mechanism that ensures values for Global Tables are in synch across all shards, minimizing or eliminating the need for cross-shard joins.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Auto-increment key management.&lt;/em&gt;&amp;nbsp;Typical auto-increment functionality provided by database management systems generate a sequential key for each new row inserted into the database. This is fine for a single database application, but when using Database Sharding, keys must be managed across all shards in a coordinated fashion. The requirement here is to provide a seamless, automated method of key generation to the application, one that operates across all shards, ensuring that keys are unique across the entire system.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;em style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Support for multiple Shard Schemes.&lt;/em&gt;&amp;nbsp;It is important to note that Database Sharding is effective because it offers an application specific technique for massive scalability and performance improvements. In fact it can be said that the degree of effectiveness is directly related to how well the sharding algorithms themselves are tailored to the application problem at hand. What is required is a set of multiple, flexible shard schemes, each designed to address a specific type of application problem. Each scheme has inherent performance and/or application characteristics and advantages when applied to a specific problem domain. In fact, using the wrong shard scheme can actually inhibit performance and the very results you are trying to obtain. It is also not uncommon for a single application to use more than one shard scheme, each applied to a specific portion of the application to achieve optimum results. Here is a list of some common shard schemes:&lt;/li&gt;
&lt;ul style=&quot;border: 0px; font-family: inherit; font-size: 10px; font-style: inherit; line-height: 1.5em; list-style-image: initial; list-style-position: initial; margin: 0px 0px 0px 25px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Session-based sharding, where each individual user or process interacts with a specific shard for the duration of the user or process session. This is the simplest technique to implement, and adds virtually zero overhead to overall performance, since the sharding decision is made only once per session. Applications which can benefit from this approach are often customer-centric, where all data for a given customer is contained in a single shard, and that is all the data that the customer requires.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Transaction-based sharding determines the shard by examining the first SQL Statement in a given database transaction. This is normally done by evaluating the &quot;shard key&quot; value used in the statement (such as an Order Number), and then directing all other statements in the transaction to the same shard.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Statement-based sharding is the most process intensive of all types, evaluating each individual SQL Statement to determine the appropriate shard to direct it to. Again, evaluation of the shard key value is required. This option is often desirable on high-volume, granular transactions, such as recording phone call records.&lt;/li&gt;
&lt;/ul&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Determine the optimum method for sharding the data. This is another area that is highly variable, change from application to application. It is closely tied with the selection of the Database Shard Scheme described above. There are numerous methods for deciding how to shard your data, and its important to understand your transaction rates, table volumes, key distribution, and other characteristics of your application. This data is required to determine the optimum sharding strategy:&lt;/li&gt;
&lt;ul style=&quot;border: 0px; font-family: inherit; font-size: 10px; font-style: inherit; line-height: 1.5em; list-style-image: initial; list-style-position: initial; margin: 0px 0px 0px 25px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Shard by a primary key on a table. This is the most straightforward option, and easiest to map to a given application. However, this is only effective if your data is reasonably well distributed. For example, if you elected to shard by Customer ID (and this is a sequential numeric value), and most of your transactions are for new customers, very little if anything will be gained by sharding your database. On the other hand, if you can select a key that does adequately and naturally distribute your transactions, great benefits can be realized.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Shard by the modulus of a key value. This option works in a vast number of cases, by applying the modulus function to the key value, and distributing transactions based on the calculated value. In essence you can predetermine any number of shards, and the modulus function effectively distributes across your shards on a “round-robin” basis, creating a very even distribution of new key values.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Maintain a master shard index table. This technique involves using a single master table that maps various values to specific shards. It is very flexible, and meets a wide variety of application situations. However, this option often delivers lower performance as it requires an extra lookup for each sharded SQL Statement.&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
As you can see, there are many things to consider and many capabilities required in order to ensure that a Database Sharding implementation is successful and effective, delivering on its objectives of providing new levels of scalability and performance in a cost-effective manner.&lt;/div&gt;
&lt;h2 style=&quot;background-color: white; border: 0px; clear: both; color: #444444; font-family: Verdana, sans-serif; font-size: 18px; font-weight: normal; margin: 10px 0px 4px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
When Database Sharding is Appropriate&lt;/h2&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Database Sharding is an excellent fit for many types of business applications, those with general purpose database requirements. It can also be used effectively for Data Warehousing applications, and as there are many available products and technologies to accomplish this, we will not focus on this element here.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The general purpose database requirements that are a fit for sharding include:&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.5em; list-style: circle; margin: 0px 0px 0px 25px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;High-transaction database applications&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Mixed workload database usage&lt;ul style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: 1.5em; list-style-image: initial; list-style-position: initial; margin: 0px 0px 0px 25px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Frequent reads, including complex queries and joins&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Write-intensive transactions (CRUD statements, including INSERT, UPDATE, DELETE)&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Contention for common tables and/or rows&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;General Business Reporting&lt;ul style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: 1.5em; list-style-image: initial; list-style-position: initial; margin: 0px 0px 0px 25px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Typical &quot;repeating segment&quot; report generation&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Some data analysis (mixed with other workloads)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
To determine if Database Sharding is applicable to your specific application or environment, the most important thing to evaluate is how well your database schema lends itself to sharding. In essence, Database Sharding is a method of “horizontal” portioning, meaning that database rows (as opposed to columns) for a single schema table are distributed across multiple shards. To understand the characteristics of how well sharding fits a given situation, here are the important things to determine:&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.5em; list-style: circle; margin: 0px 0px 0px 25px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Identify all transaction-intensive tables in your schema.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Determine the transaction volume your database is currently handling (or is expected to handle).&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Identify all common SQL statements (SELECT, INSERT, UPDATE, DELETE), and the volumes associated with each.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Develop an understanding of your &quot;table hierarchy&quot; contained in your schema; in other words the main parent-child relationships.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Determine the &quot;key distribution&quot; for transactions on high-volume tables, to determine if they are evenly spread or are concentrated in narrow ranges.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
With this information, you can rapidly gain an assessment of the value and applicability of sharding to your application. As an example, here is a simple Bookstore schema showing how the data can be sharded:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8etGhCLloItGWQ_Cplj2q5CrnDRxJh-Fx1iH1w0RCKtJrRTYhW4j122zcu1Gt6HL3yicIXw4yme0QdgtpPmW1oL77QrPIvFKhYKozsvuXzwncxtUFX-8Xvw6uO0ttF0_DdsoOCE7CWGI/s1600/dbs-bookstoreschema.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8etGhCLloItGWQ_Cplj2q5CrnDRxJh-Fx1iH1w0RCKtJrRTYhW4j122zcu1Gt6HL3yicIXw4yme0QdgtpPmW1oL77QrPIvFKhYKozsvuXzwncxtUFX-8Xvw6uO0ttF0_DdsoOCE7CWGI/s1600/dbs-bookstoreschema.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;imgdesc&quot; style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; font-style: italic; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Figure 3. Example Bookstore schema showing how data is sharded.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
In the Bookstore example, the Primary Shard Table is the &#39;customer&#39; entity. This is the table that is used to shard the data. The &#39;customer&#39; table is the parent of the shard hierarchy, with the &#39;customer_order&#39; and &#39;order_item&#39; entities as child tables. The data is sharded by the &#39;customer.id&#39; attribute, and all related rows in the child tables associated with a given &#39;customer.id&#39; are sharded as well. The Global Tables are the common lookup tables, which have relatively low activity, and these tables are replicated to all shards to avoid cross-shard joins.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #444444; font-family: Verdana, sans-serif; font-size: 13px; line-height: 1.4em; margin-bottom: 15px; margin-top: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
While this example is very basic, it does provide the basic considerations for determining how to shard a given database application. By using this evaluation approach, you can determine if sharding is applicable to your particular environment, and what benefits can be realized by implementing Database Sharding.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/805894799372326035/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/805894799372326035' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/805894799372326035'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/805894799372326035'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2013/10/database-sharding.html' title='Database Sharding'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOELmIVE9kRnUfKsuxpG6cICpNyxpwX-14vrMFWFceZH7dvihyphenhyphenRHQfV7_eTPP3ugLR8a79KamIadxWsdymfVuRWjy-wj9eguy2mIuTA7KTR2avDPU1ofegdV2qpNoIa4f5nBzX5NkX780/s72-c/dbshards-graph.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-6298001707492891318</id><published>2012-11-22T18:15:00.000+05:30</published><updated>2012-11-22T18:15:10.496+05:30</updated><title type='text'>Create VHD using DISKPART</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;color: #6fa8dc; font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;Create Virtual Harddisk Using DISKPART&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #424a4e; line-height: 20px; margin: 0in 0in 0pt;&quot;&gt;
&lt;div class=&quot;&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Open the&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://windows7support247.blogspot.com/2010/11/how-to-open-elevated-command-prompt-in.html&quot; style=&quot;color: #fa6104; font-family: Arial, Helvetica, sans-serif; outline: none; text-decoration: initial;&quot;&gt;Elevated Command Prompt&lt;/a&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;with Administrator Privileges and type the following commands:&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #424a4e; line-height: 20px; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #424a4e; line-height: 20px; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;DISKPART&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;CREATE VDISK FILE=&quot;c:\win7\win7.vhd&quot; MAXIMUM=20000&lt;br /&gt;SELECT VDISK FILE=&quot;c:\win7\win7.vhd&quot;&lt;br /&gt;ATTACH VDISK&lt;br /&gt;CREATE PARTITION PRIMARY&lt;br /&gt;ASSIGN LETTER=X&lt;br /&gt;FORMAT QUICK LABEL=Windows7&lt;br /&gt;EXIT&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;
&lt;span style=&quot;background-color: white; color: #424a4e; font-family: Arial, Helvetica, sans-serif; line-height: 20px;&quot;&gt;This will create the&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://windows7support247.blogspot.com/2011/01/creating-vhd-in-windows-7.html&quot; style=&quot;background-color: white; color: #fa6104; font-family: Arial, Helvetica, sans-serif; line-height: 20px; outline: none; text-decoration: initial;&quot;&gt;VHD&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #424a4e; font-family: Arial, Helvetica, sans-serif; line-height: 20px;&quot;&gt;&amp;nbsp;file of primary partition. You will see the newly attached disk in Disk Management with Drive Letter X:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-color: white; color: #424a4e; font-size: 12px; line-height: 20px;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-color: white; color: #424a4e; font-size: 12px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-color: white; color: #424a4e; font-size: 12px; line-height: 20px;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-color: white; color: #424a4e; font-size: 12px; line-height: 20px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-color: white; color: #424a4e; font-size: 12px; line-height: 20px;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQaoeusnMtds7uCd2wMWK0cYWD6sLzA9asJmDbTHjhHnDy26kDtKpQmJlVjifcjRpelhCCqUD9LTTevOGxBJvWmwnhPcIB__CaZj1OJzYjgnbhAq_K-MwBZDAqgbVNjsUNdexIBpegy78/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQaoeusnMtds7uCd2wMWK0cYWD6sLzA9asJmDbTHjhHnDy26kDtKpQmJlVjifcjRpelhCCqUD9LTTevOGxBJvWmwnhPcIB__CaZj1OJzYjgnbhAq_K-MwBZDAqgbVNjsUNdexIBpegy78/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-color: white; color: #424a4e; font-size: 12px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-color: white; color: #424a4e; line-height: 20px;&quot;&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin: 0in 0in 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;b&gt;Attaching and Detaching VHD in&amp;nbsp;&lt;a href=&quot;http://windows7support247.blogspot.com/&quot; style=&quot;color: #fa6104; outline: none; text-decoration: initial;&quot;&gt;Windows 7&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin: 0in 0in 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin: 0in 0in 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;Right Click&lt;/b&gt;&amp;nbsp;on My Computer and Click &#39;&lt;b&gt;Manage&lt;/b&gt;&#39; that will open up&amp;nbsp;&lt;b&gt;Computer Management&lt;/b&gt;, in that click on&amp;nbsp;&lt;b&gt;Disk Management&lt;/b&gt;. Just like previous part.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin: 0in 0in 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin: 0in 0in 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;Then Right Click on Disk Management and select&amp;nbsp;&lt;b&gt;&#39;Attach VHD&#39;.&lt;/b&gt;&amp;nbsp;This will open new windows&amp;nbsp;&lt;b&gt;&#39;Attach&lt;a href=&quot;http://windows7support247.blogspot.com/2011/01/creating-vhd-in-windows-7.html&quot; style=&quot;color: #fa6104; outline: none; text-decoration: initial;&quot;&gt;Virtual Hard Disk&lt;/a&gt;&#39;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin: 0in 0in 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 12px; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin: 0in 0in 0pt;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAmYYE3Ly9_wR_gLuRwcxYlISxTak2WpXYpkIqeXuseXa9SEh-1Sxc1ix0LIUi0IB01VhyhyI_ZMOZvNepjzf-g45vKvqii4Nc0lH4eh_6hW3D2M2THJ9p0EPMPlE7evoE5AGrFnW-YWg/s1600/2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;458&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAmYYE3Ly9_wR_gLuRwcxYlISxTak2WpXYpkIqeXuseXa9SEh-1Sxc1ix0LIUi0IB01VhyhyI_ZMOZvNepjzf-g45vKvqii4Nc0lH4eh_6hW3D2M2THJ9p0EPMPlE7evoE5AGrFnW-YWg/s640/2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin: 0in 0in 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin: 0in 0in 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;Click on&amp;nbsp;&lt;b&gt;OK&lt;/b&gt;&amp;nbsp;and that will attach the existing Virtual Hard Disk. Now, if you don&#39;t want to make write anything on the VHD, we will select the&amp;nbsp;&lt;b&gt;&#39;Read-only&#39;&lt;/b&gt;&amp;nbsp;check box.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-size: 12px; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQVjqBuKkKFlqbmsR8_mHJdS1Kh0BX-52QZALPk9RCmQu8tcPZDk9dZaucLj-9Vopw8W_yqzf1JPX7HicekCDP9VqUXnKHj6TkVmUgTOPgX6wIcuIkq1jGCRAYZJlVBMnqZL4kZeQbqOU/s1600/3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;458&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQVjqBuKkKFlqbmsR8_mHJdS1Kh0BX-52QZALPk9RCmQu8tcPZDk9dZaucLj-9Vopw8W_yqzf1JPX7HicekCDP9VqUXnKHj6TkVmUgTOPgX6wIcuIkq1jGCRAYZJlVBMnqZL4kZeQbqOU/s640/3.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 12px;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-color: white; color: #424a4e; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12px;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;And subsequently we will have the attached VHD in explorer.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;
&lt;span style=&quot;color: #424a4e; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ5kRT0eph4aEy-YnZwApai7vA56ZpFHD0bpao6-h5lHscjrBv9nntlhKvfsBNMyLVQY2WqsfyX8etEnUZqhenU7SBYlTCmftCPYqcQARDIfXb6hMzxJo8yntAcJy9DkiSMm068MxMKsY/s1600/4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ5kRT0eph4aEy-YnZwApai7vA56ZpFHD0bpao6-h5lHscjrBv9nntlhKvfsBNMyLVQY2WqsfyX8etEnUZqhenU7SBYlTCmftCPYqcQARDIfXb6hMzxJo8yntAcJy9DkiSMm068MxMKsY/s1600/4.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-color: white; color: #424a4e; line-height: 20px;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;background-color: white; color: #424a4e; font-family: Arial, Helvetica, sans-serif; font-size: 12pt; line-height: 20px;&quot;&gt;How to Detach&amp;nbsp;VHD?&lt;/b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-color: white; color: #424a4e; line-height: 20px;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin: 0in 0in 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin: 0in 0in 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;To detach the VHD simply Right Click on the&amp;nbsp;&lt;b&gt;&#39;Disk 1&#39;&lt;/b&gt;&amp;nbsp;(Blue Color) and select&amp;nbsp;&lt;b&gt;&#39;Detach VHD&#39;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-xKxq_jaWzn4QGX0q0K2AUjRfGJaP274KqXOLNMN4jyIbPSBqseTBcs3XsrMFBz9YErIPHNLAmmw2s4JK3u7OhGQ-tSLZJcEnfVjk_K0MW4GdpkATPC5mGu_vQNKBRHeg0rRT7mlNR8E/s1600/5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;460&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-xKxq_jaWzn4QGX0q0K2AUjRfGJaP274KqXOLNMN4jyIbPSBqseTBcs3XsrMFBz9YErIPHNLAmmw2s4JK3u7OhGQ-tSLZJcEnfVjk_K0MW4GdpkATPC5mGu_vQNKBRHeg0rRT7mlNR8E/s640/5.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin: 0in 0in 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;After clicking on&amp;nbsp;&lt;b&gt;&#39;Detach VHD&#39;&lt;/b&gt;&amp;nbsp;you will be prompt you with&lt;b&gt;&amp;nbsp;&#39;Detach Virtual Hard Disk&#39;&amp;nbsp;&lt;/b&gt;message. Click on&amp;nbsp;&lt;b&gt;OK&amp;nbsp;&lt;/b&gt;to detach. Also, if you want delete the VHD permanently you can select the Checkbox.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi23qUFryhPrrGxe3CftU_tFmOwjKKdx9rQBfagGTw3au9iuyxM6amAuaDMueRqT-D1VVZC6xZqHFFOFJ4-xptXonHbmbqDrnyP3qk8G1P7Gh-uyIIYmP3lG73FeHrmtUJKf6bha88lvv0/s1600/6.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;458&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi23qUFryhPrrGxe3CftU_tFmOwjKKdx9rQBfagGTw3au9iuyxM6amAuaDMueRqT-D1VVZC6xZqHFFOFJ4-xptXonHbmbqDrnyP3qk8G1P7Gh-uyIIYmP3lG73FeHrmtUJKf6bha88lvv0/s640/6.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin: 0in 0in 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12pt;&quot;&gt;This way we have seen how can we create new VHDs, attach/detach existing VHDs using Disk Management and Diskpart utility.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/6298001707492891318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/6298001707492891318' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/6298001707492891318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/6298001707492891318'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2012/11/create-vhd-using-diskpart.html' title='Create VHD using DISKPART'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQaoeusnMtds7uCd2wMWK0cYWD6sLzA9asJmDbTHjhHnDy26kDtKpQmJlVjifcjRpelhCCqUD9LTTevOGxBJvWmwnhPcIB__CaZj1OJzYjgnbhAq_K-MwBZDAqgbVNjsUNdexIBpegy78/s72-c/1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-5557321457557637570</id><published>2012-10-06T15:11:00.005+05:30</published><updated>2012-10-06T15:19:17.472+05:30</updated><title type='text'>Factory Method Design Pattern</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h2 style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 16.0pt; line-height: 150%;&quot;&gt;Factory Method&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h3 style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Intent&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Define an interface for
creating an object, but let subclasses decide which class to instantiate.
Factory Method lets a class defer instantiation to subclasses.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h3 style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Also Known As&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Virtual Constructor&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h3 style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Motivation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Frameworks use abstract
classes to define and maintain relationships between objects. A framework is
often responsible for creating these objects as well.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Consider a framework for
applications that can present multiple documents to the user. Two key
abstractions in this framework are the classes Application and Document. Both
classes are abstract, and clients have to subclass them to realize their
application-specific implementations. To create a drawing application, for
example, we define the classes DrawingApplication and DrawingDocument. The
Application class is responsible for managing Documents and will create them as
required—when the user selects Open or New from a menu, for example.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Because the particular
Document subclass to instantiate is application-specific, the Application class
can&#39;t predict the subclass of Document to instantiate—the Application class
only knows &lt;em&gt;when&lt;/em&gt;
a new document should be created, not &lt;em&gt;what
kind&lt;/em&gt; of Document to create. This creates a dilemma: The framework
must instantiate classes, but it only knows about abstract classes, which it
cannot instantiate.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;The Factory Method pattern
offers a solution. It encapsulates the knowledge of which Document subclass to
create and moves this knowledge out of the framework.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjOXCcia3q5rHdmEcVnfs5ty7Nk5XGsXGqYwOkCz3DwNf2TAKYWzGwjPBsrYYUeaCOVBZGMkVbZDkBD2akm6n9SgOl8iMw6GrQVrszRp5rI1jqkoOCpYOErMN7i2MU786fNILjgeRMg4A/s1600/fm1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;246&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjOXCcia3q5rHdmEcVnfs5ty7Nk5XGsXGqYwOkCz3DwNf2TAKYWzGwjPBsrYYUeaCOVBZGMkVbZDkBD2akm6n9SgOl8iMw6GrQVrszRp5rI1jqkoOCpYOErMN7i2MU786fNILjgeRMg4A/s640/fm1.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%;&quot;&gt;Application subclasses
redefine an abstract CreateDocument operation on Application to return the
appropriate Document subclass. Once an Application subclass is instantiated, it
can then instantiate application-specific Documents without knowing their
class. We call CreateDocument a &lt;/span&gt;&lt;strong style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%;&quot;&gt;factory
method&lt;/strong&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%;&quot;&gt; because it&#39;s responsible for &quot;manufacturing&quot;
an object.&lt;/span&gt;&lt;/div&gt;
&lt;h3 style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Applicability&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Use the Factory Method
pattern when&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;a class can&#39;t
     anticipate the class of objects it must create. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;a class wants
     its subclasses to specify the objects it creates. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;classes delegate
     responsibility to one of several helper subclasses, and you want to
     localize the knowledge of which helper subclass is the delegate.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Structure&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO80g03lNk4nI9wDsLtBa51QCqz-UIZKPUts59mscerS-m5SFxJH1lKaO6jGzW9irK-ODBQ5sQTWEK7N4CdFfOLnPkoIi5kyBX5wspyBpBYPSA_YLO2XYwZ7PnLEoCpEUmBDsITTJZw9Q/s1600/fm2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;214&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO80g03lNk4nI9wDsLtBa51QCqz-UIZKPUts59mscerS-m5SFxJH1lKaO6jGzW9irK-ODBQ5sQTWEK7N4CdFfOLnPkoIi5kyBX5wspyBpBYPSA_YLO2XYwZ7PnLEoCpEUmBDsITTJZw9Q/s640/fm2.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt;&lt;b&gt;Participants&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Product&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt; (Document) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ul type=&quot;circle&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;defines
      the interface of objects the factory method creates.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;ConcreteProduct&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt; (MyDocument) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ul type=&quot;circle&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;implements
      the Product interface.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Creator&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt; (Application) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ul type=&quot;circle&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;declares
      the factory method, which returns an object of type Product. Creator may
      also define a default implementation of the factory method that returns a
      default ConcreteProduct object. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;&lt;!-- extra space --&gt;may
      call the factory method to create a Product object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;ConcreteCreator&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt; (MyApplication) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ul type=&quot;circle&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l2 level2 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 1.0in; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;overrides
      the factory method to return an instance of a ConcreteProduct.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Collaborations&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;ul type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l0 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Creator relies
     on its subclasses to define the factory method so that it returns an
     instance of the appropriate ConcreteProduct.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Consequences&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Factory methods eliminate
the need to bind application-specific classes into your code. The code only
deals with the Product interface; therefore it can work with any user-defined
ConcreteProduct classes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;A potential disadvantage of
factory methods is that clients might have to subclass the Creator class just
to create a particular ConcreteProduct object. Subclassing is fine when the
client has to subclass the Creator class anyway, but otherwise the client now
must deal with another point of evolution.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Here are two additional
consequences of the Factory Method pattern:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ol start=&quot;1&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l4 level1 lfo4; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Provides
     hooks for subclasses.&lt;/span&gt;&lt;/em&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;
     Creating objects inside a class with a factory method is always more
     flexible than creating an object directly. Factory Method gives subclasses
     a hook for providing an extended version of an object. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;In
the Document example, the Document class could define a factory method called
CreateFileDialog that creates a default file dialog object for opening an
existing document. A Document subclass can define an application-specific file
dialog by overriding this factory method. In this case the factory method is
not abstract but provides a reasonable default implementation. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ol start=&quot;2&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l4 level1 lfo4; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Connects
     parallel class hierarchies.&lt;/span&gt;&lt;/em&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;
     In the examples we&#39;ve considered so far, the factory method is only called
     by Creators. But this doesn&#39;t have to be the case; clients can find
     factory methods useful, especially in the case of parallel class
     hierarchies. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Parallel
class hierarchies result when a class delegates some of its responsibilities to
a separate class. Consider graphical figures that can be manipulated
interactively; that is, they can be stretched, moved, or rotated using the
mouse. Implementing such interactions isn&#39;t always easy. It often requires
storing and updating information that records the state of the manipulation at
a given time. This state is needed only during manipulation; therefore it
needn&#39;t be kept in the figure object. Moreover, different figures behave differently
when the user manipulates them. For example, stretching a line figure might
have the effect of moving an endpoint, whereas stretching a text figure may
change its line spacing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;With
these constraints, it&#39;s better to use a separate Manipulator object that
implements the interaction and keeps track of any manipulation-specific state
that&#39;s needed. Different figures will use different Manipulator subclasses to
handle particular interactions. The resulting Manipulator class hierarchy
parallels (at least partially) the Figure class hierarchy:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYNq81cO9Js9yCWtG2_ogf7g9nJJbdy_PNdhIvX9PvlY45oG2O12YephbPxwbP7ItXgGUkbED7iiPTN7_OaDDeBCjbfg9AWMyau4sai-y_rtgK_DKV3CbVmmubE77CRV_iwxXgBYlvpek/s1600/fm3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;line-height: normal; margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;256&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYNq81cO9Js9yCWtG2_ogf7g9nJJbdy_PNdhIvX9PvlY45oG2O12YephbPxwbP7ItXgGUkbED7iiPTN7_OaDDeBCjbfg9AWMyau4sai-y_rtgK_DKV3CbVmmubE77CRV_iwxXgBYlvpek/s640/fm3.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;!--[if mso &amp; !supportInlineShapes &amp; supportFields]&gt;&lt;span
style=&#39;mso-element:field-begin;mso-field-lock:yes&#39;&gt;&lt;/span&gt;&lt;span
style=&#39;mso-spacerun:yes&#39;&gt; &lt;/span&gt;SHAPE &lt;span
style=&#39;mso-spacerun:yes&#39;&gt; &lt;/span&gt;\* MERGEFORMAT &lt;span style=&#39;mso-element:field-separator&#39;&gt;&lt;/span&gt;&lt;![endif]--&gt;&lt;!--[if gte vml 1]&gt;&lt;v:rect
 id=&quot;Rectangle_x0020_6&quot; o:spid=&quot;_x0000_s1026&quot; alt=&quot;Description: mk:@MSITStore:E:\MyWorld\Books\Patterns\Design%20Patterns%20-%20Elements%20Of%20Reusable%20Object%20Oriented%20Software.chm::/Pictures/fmeth048.gif&quot;
 style=&#39;width:24pt;height:24pt;visibility:visible;mso-wrap-style:square;
 mso-left-percent:-10001;mso-top-percent:-10001;mso-position-horizontal:absolute;
 mso-position-horizontal-relative:char;mso-position-vertical:absolute;
 mso-position-vertical-relative:line;mso-left-percent:-10001;mso-top-percent:-10001;
 v-text-anchor:top&#39; o:gfxdata=&quot;UEsDBBQABgAIAAAAIQC75UiUBQEAAB4CAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbKSRvU7DMBSF
dyTewfKKEqcMCKEmHfgZgaE8wMW+SSwc27JvS/v23KTJgkoXFsu+P+c7Ol5vDoMTe0zZBl/LVVlJ
gV4HY31Xy4/tS3EvRSbwBlzwWMsjZrlprq/W22PELHjb51r2RPFBqax7HCCXIaLnThvSAMTP1KkI
+gs6VLdVdad08ISeCho1ZLN+whZ2jsTzgcsnJwldluLxNDiyagkxOquB2Knae/OLUsyEkjenmdzb
mG/YhlRnCWPnb8C898bRJGtQvEOiVxjYhtLOxs8AySiT4JuDystlVV4WPeM6tK3VaILeDZxIOSsu
ti/jidNGNZ3/J08yC1dNv9v8AAAA//8DAFBLAwQUAAYACAAAACEArTA/8cEAAAAyAQAACwAAAF9y
ZWxzLy5yZWxzhI/NCsIwEITvgu8Q9m7TehCRpr2I4FX0AdZk2wbbJGTj39ubi6AgeJtl2G9m6vYx
jeJGka13CqqiBEFOe2Ndr+B03C3WIDihMzh6RwqexNA281l9oBFTfuLBBhaZ4ljBkFLYSMl6oAm5
8IFcdjofJ0z5jL0MqC/Yk1yW5UrGTwY0X0yxNwri3lQgjs+Qk/+zfddZTVuvrxO59CNCmoj3vCwj
MfaUFOjRhrPHaN4Wv0VV5OYgm1p+LW1eAAAA//8DAFBLAwQUAAYACAAAACEAJwpGik4DAAAUBwAA
HwAAAGNsaXBib2FyZC9kcmF3aW5ncy9kcmF3aW5nMS54bWykVctu2zoQ3RfoPxAEupQlubJjCVXa
xI8iQNIacYu7yYamKIkNRaok/WrRf79DSq6d5OIuWgGWZ4bDwzMv6t37fSPQlmnDlcxxPIgwYpKq
gssqx1+/LIIJRsYSWRChJMvxgRn8/vL1q3ckqzRpa04RIEiTkRzX1rZZGBpas4aYgWqZhLVS6YZY
UHUVFprsALkR4TCKxmFDuMSXJ6gZsQRtNP8DKKHoIyumRG6JAUhBs3NLz1HQv0cmmdx+1O2qXWrH
nH7aLjXiRY4hc5I0kCIc9gu9G6jhs13VCWBf6sb5q7JEe49ycG+PwfYWUTC+jZJJBPgUlnq5O6P+
/B+7aD3/331ApjsUhDMipnU05PZlZONjZPeMQitUgiEwFcxQnePmMftwt7r5srJKs2yePdwd/lFa
FA/XSj2ahyWxlmlpHmbM8Eq+GUZHC4gB/OaCNUxaA+LnEl73bGPIWjCnr7/BgU7QHFxYAeJKlXZH
NBvQusmycMmp3WhmwrJhtoY0DSpe/i7AMRTT3kJ7GCTVtAb+7Mq0AAztDoEdTVqrXc1IYZy5KxnU
tkPw5TuBQcHXuztVQK3JxirfwX9ext/lIFmrjf3IVIOckGMNJD042d4a23E6uvhaqQUXwneCkE8M
gNlZoINgq1tzveRH62capfPJfJIEyXA8D5JoNguuFtMkGC/ii9Hs7Ww6ncW/3LlxktW8KJh0xxzH
PE5ezFDDqVYGCjOgqgmhkTllx1GHQY+j06AbJXjh4Bwlo6v1VGi0JSLHC//0mT9zC5/S8LMEsTwL
KR4m0fUwDRbjyUWQLJJRkF5EkyCK0+t0HCVpMls8DemWS/b3IaFdjtPRcOSrdEb6WWyRf17GRrKG
w3QgwZscw4TD0/Wua8S5LHxpLeGik89S4eifUgHlPhYaRNNfTXa/8iNt99eqOLiEreEfmlcraC64
TuDaB6FW+gdGO7jMc2y+b2C2MBI3EuYgjZME3KxXktHFEBR9vrI+XyGSAlSOLUadOLWgwZZNq3lV
w0mxT5NUVzA0Je8buuPk2AljV/YgmI/aM2eyWBJN7oGzgLnNMZPB11WfR/CAYE/BbQxbte6G6gal
i96nAxyffQ/81v775T465/rlvwAAAP//AwBQSwMEFAAGAAgAAAAhAJxOXiHiBgAAOhwAABoAAABj
bGlwYm9hcmQvdGhlbWUvdGhlbWUxLnhtbOxZT28bRRS/I/EdRntv4/+NozpV7NgNtGmj2C3qcbwe
704zu7OaGSf1DbVHJCREQRyoxI0DAiq1EpfyaQJFUKR+Bd7M7K534jVJ2wgqaA7x7tvfvP/vzZvd
y1fuRQwdEiEpjzte9WLFQyT2+YTGQce7NRpcWPeQVDieYMZj0vHmRHpXNt9/7zLe8BlNxhyLySgk
EUHAKJYbuOOFSiUba2vSBzKWF3lCYng25SLCCm5FsDYR+AgERGytVqm01iJMY28TOCrNqM/gX6yk
JvhMDDUbgmIcgfSb0yn1icFODqoaIeeyxwQ6xKzjAc8JPxqRe8pDDEsFDzpexfx5a5uX1/BGuoip
FWsL6wbmL12XLpgc1IxMEYxzodVBo31pO+dvAEwt4/r9fq9fzfkZAPZ9sNTqUuTZGKxXuxnPAshe
LvPuVZqVhosv8K8v6dzudrvNdqqLZWpA9rKxhF+vtBpbNQdvQBbfXMI3ulu9XsvBG5DFt5bwg0vt
VsPFG1DIaHywhNYBHQxS7jlkytlOKXwd4OuVFL5AQTbk2aVFTHmsVuVahO9yMQCABjKsaIzUPCFT
7ENO9nA0FhRrAXiD4MITS/LlEknLQtIXNFEd78MEx14B8vLZ9y+fPUHH958e3//p+MGD4/s/WkbO
qh0cB8VVL7797M9HH6M/nnzz4uEX5XhZxP/6wye//Px5ORDKZ2He8y8f//b08fOvPv39u4cl8C2B
x0X4iEZEohvkCO3zCAwzXnE1J2PxaitGIabFFVtxIHGMtZQS/n0VOugbc8zS6Dh6dInrwdsC2kcZ
8OrsrqPwMBQzRUskXwsjB7jLOetyUeqFa1pWwc2jWRyUCxezIm4f48My2T0cO/HtzxLom1laOob3
QuKoucdwrHBAYqKQfsYPCCmx7g6ljl93qS+45FOF7lDUxbTUJSM6drJpsWiHRhCXeZnNEG/HN7u3
UZezMqu3yaGLhKrArET5EWGOG6/imcJRGcsRjljR4dexCsuUHM6FX8T1pYJIB4Rx1J8QKcvW3BRg
byHo1zB0rNKw77J55CKFogdlPK9jzovIbX7QC3GUlGGHNA6L2A/kAaQoRntclcF3uVsh+h7igOOV
4b5NiRPu07vBLRo4Ki0SRD+ZiZJYXiXcyd/hnE0xMa0GmrrTqyMa/13jZhQ6t5Vwfo0bWuXzrx+V
6P22tuwt2L3KambnRKNehTvZnntcTOjb35238SzeI1AQy1vUu+b8rjl7//nmvKqez78lL7owNGg9
i9hB24zd0cqpe0oZG6o5I9elGbwl7D2TARD1OnO6JPkpLAnhUlcyCHBwgcBmDRJcfURVOAxxAkN7
1dNMApmyDiRKuITDoiGX8tZ4GPyVPWo29SHEdg6J1S6fWHJdk7OzRs7GaBWYA20mqK4ZnFVY/VLK
FGx7HWFVrdSZpVWNaqYpOtJyk7WLzaEcXJ6bBsTcmzDUIBiFwMstON9r0XDYwYxMtN9tjLKwmCic
Z4hkiCckjZG2ezlGVROkLFeWDNF22GTQB8dTvFaQ1tZs30DaWYJUFNdYIS6L3ptEKcvgRZSA28ly
ZHGxOFmMjjpeu1lresjHScebwjkZLqMEoi71HIlZAG+YfCVs2p9azKbKF9FsZ4a5RVCFVx/W70sG
O30gEVJtYxna1DCP0hRgsZZk9a81wa3nZUBJNzqbFvV1SIZ/TQvwoxtaMp0SXxWDXaBo39nbtJXy
mSJiGE6O0JjNxD6G8OtUBXsmVMLrDtMR9A28m9PeNo/c5pwWXfGNmMFZOmZJiNN2q0s0q2QLNw0p
18HcFdQD20p1N8a9uimm5M/JlGIa/89M0fsJvH2oT3QEfHjRKzDSldLxuFAhhy6UhNQfCBgcTO+A
bIH3u/AYkgreSptfQQ71r605y8OUNRwi1T4NkKCwH6lQELIHbclk3ynMquneZVmylJHJqIK6MrFq
j8khYSPdA1t6b/dQCKluuknaBgzuZP6592kFjQM95BTrzelk+d5ra+CfnnxsMYNRbh82A03m/1zF
fDxY7Kp2vVme7b1FQ/SDxZjVyKoChBW2gnZa9q+pwitutbZjLVlca2bKQRSXLQZiPhAl8A4J6X+w
/1HhM/sFQ2+oI74PvRXBxwvNDNIGsvqCHTyQbpCWOIbByRJtMmlW1rXp6KS9lm3W5zzp5nJPOFtr
dpZ4v6Kz8+HMFefU4nk6O/Ww42tLW+lqiOzJEgXSNDvImMCUfcnaxQkaB9WOB1+TIND34Aq+R3lA
q2laTdPgCj4ywbBkvwx1vPQio8BzS8kx9YxSzzCNjNLIKM2MAsNZ+g0mo7SgU+nPJvDZTv94KPtC
AhNc+kUla6rO577NvwAAAP//AwBQSwMEFAAGAAgAAAAhAJxmRkG7AAAAJAEAACoAAABjbGlwYm9h
cmQvZHJhd2luZ3MvX3JlbHMvZHJhd2luZzEueG1sLnJlbHOEj80KwjAQhO+C7xD2btJ6EJEmvYjQ
q9QHCMk2LTY/JFHs2xvoRUHwsjCz7DezTfuyM3liTJN3HGpaAUGnvJ6c4XDrL7sjkJSl03L2Djks
mKAV201zxVnmcpTGKSRSKC5xGHMOJ8aSGtHKRH1AVzaDj1bmIqNhQaq7NMj2VXVg8ZMB4otJOs0h
droG0i+hJP9n+2GYFJ69elh0+UcEy6UXFqCMBjMHSldnnTUtXYGJhn39Jt4AAAD//wMAUEsBAi0A
FAAGAAgAAAAhALvlSJQFAQAAHgIAABMAAAAAAAAAAAAAAAAAAAAAAFtDb250ZW50X1R5cGVzXS54
bWxQSwECLQAUAAYACAAAACEArTA/8cEAAAAyAQAACwAAAAAAAAAAAAAAAAA2AQAAX3JlbHMvLnJl
bHNQSwECLQAUAAYACAAAACEAJwpGik4DAAAUBwAAHwAAAAAAAAAAAAAAAAAgAgAAY2xpcGJvYXJk
L2RyYXdpbmdzL2RyYXdpbmcxLnhtbFBLAQItABQABgAIAAAAIQCcTl4h4gYAADocAAAaAAAAAAAA
AAAAAAAAAKsFAABjbGlwYm9hcmQvdGhlbWUvdGhlbWUxLnhtbFBLAQItABQABgAIAAAAIQCcZkZB
uwAAACQBAAAqAAAAAAAAAAAAAAAAAMUMAABjbGlwYm9hcmQvZHJhd2luZ3MvX3JlbHMvZHJhd2lu
ZzEueG1sLnJlbHNQSwUGAAAAAAUABQBnAQAAyA0AAAAA
&quot; filled=&quot;f&quot; stroked=&quot;f&quot;&gt;
 &lt;o:lock v:ext=&quot;edit&quot; aspectratio=&quot;t&quot;/&gt;
 &lt;w:wrap type=&quot;none&quot;/&gt;
 &lt;w:anchorlock/&gt;
&lt;/v:rect&gt;&lt;![endif]--&gt;&lt;!--[if mso &amp; !supportInlineShapes &amp; supportFields]&gt;&lt;v:shape
 id=&quot;_x0000_i1025&quot; type=&quot;#_x0000_t75&quot; style=&#39;width:24pt;height:24pt&#39;&gt;
 &lt;v:imagedata croptop=&quot;-65520f&quot; cropbottom=&quot;65520f&quot;/&gt;
&lt;/v:shape&gt;&lt;span style=&#39;mso-element:field-end&#39;&gt;&lt;/span&gt;&lt;![endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;The
Figure class provides a CreateManipulator factory method that lets clients
create a Figure&#39;s corresponding Manipulator. Figure subclasses override this
method to return an instance of the Manipulator subclass that&#39;s right for them.
Alternatively, the Figure class may implement CreateManipulator to return a
default Manipulator instance, and Figure subclasses may simply inherit that
default. The Figure classes that do so need no corresponding Manipulator
subclass—hence the hierarchies are only partially parallel.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Notice
how the factory method defines the connection between the two class
hierarchies. It localizes knowledge of which classes belong together.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h3 style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Implementation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Consider the following
issues when applying the Factory Method pattern:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ol start=&quot;1&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l3 level1 lfo5; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Two major
     varieties.&lt;/span&gt;&lt;/em&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt; The
     two main variations of the Factory Method pattern are (1) the case when
     the Creator class is an abstract class and does not provide an
     implementation for the factory method it declares, and (2) the case when
     the Creator is a concrete class and provides a default implementation for
     the factory method. It&#39;s also possible to have an abstract class that
     defines a default implementation, but this is less common. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;The
first case &lt;em&gt;requires&lt;/em&gt;
subclasses to define an implementation, because there&#39;s no reasonable default.
It gets around the dilemma of having to instantiate unforeseeable classes. In
the second case, the concrete Creator uses the factory method primarily for
flexibility. It&#39;s following a rule that says, &quot;Create objects in a
separate operation so that subclasses can override the way they&#39;re
created.&quot; This rule ensures that designers of subclasses can change the
class of objects their parent class instantiates if necessary. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ol start=&quot;2&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l3 level1 lfo5; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Parameterized
     factory methods.&lt;/span&gt;&lt;/em&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;
     Another variation on the pattern lets the factory method create &lt;em&gt;multiple&lt;/em&gt; kinds of
     products. The factory method takes a parameter that identifies the kind of
     object to create. All objects the factory method creates will share the
     Product interface. In the Document example, Application might support
     different kinds of Documents. You pass CreateDocument an extra parameter
     to specify the kind of document to create. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;The
Unidraw graphical editing framework [VL90] uses this approach for
reconstructing objects saved on disk. Unidraw defines a &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Creator&lt;/span&gt;&lt;/tt&gt; class with a factory
method &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Create&lt;/span&gt;&lt;/tt&gt; that
takes a class identifier as an argument. The class identifier specifies the
class to instantiate. When Unidraw saves an object to disk, it writes out the
class identifier first and then its instance variables. When it reconstructs
the object from disk, it reads the class identifier first.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Once
the class identifier is read, the framework calls &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Create&lt;/span&gt;&lt;/tt&gt;,
passing the identifier as the parameter. &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Create&lt;/span&gt;&lt;/tt&gt;
looks up the constructor for the corresponding class and uses it to instantiate
the object. Last, &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Create&lt;/span&gt;&lt;/tt&gt;
calls the object&#39;s &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Read&lt;/span&gt;&lt;/tt&gt;
operation, which reads the remaining information on the disk and initializes
the object&#39;s instance variables.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;A
parameterized factory method has the following general form, where &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;MyProduct&lt;/span&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;YourProduct&lt;/span&gt;&lt;/tt&gt; are subclasses of &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Product&lt;/span&gt;&lt;/tt&gt;: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;class
Creator&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;public:&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual Product* Create(ProductId);&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;};&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;Product*
Creator::Create (ProductId id) {&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (id == MINE)&amp;nbsp; return new MyProduct;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (id == YOURS) return new YourProduct;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // repeat for remaining products...&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Overriding
a parameterized factory method lets you easily and selectively extend or change
the products that a Creator produces. You can introduce new identifiers for new
kinds of products, or you can associate existing identifiers with different
products.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;For
example, a subclass &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;MyCreator&lt;/span&gt;&lt;/tt&gt;
could swap MyProduct and YourProduct and support a new &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;TheirProduct&lt;/span&gt;&lt;/tt&gt; subclass:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Product*
MyCreator::Create (ProductId id) {&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (id == YOURS)&amp;nbsp; return new MyProduct;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (id == MINE)&amp;nbsp;&amp;nbsp; return new YourProduct;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // N.B.: switched YOURS and MINE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (id == THEIRS) return new TheirProduct;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Creator::Create(id); // called if
all others fail&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;}&lt;/span&gt;&lt;/blockquote&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt;Notice
that the last thing this operation does is call &lt;/span&gt;&lt;tt style=&quot;font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Create&lt;/span&gt;&lt;/tt&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt;
on the parent class. That&#39;s because &lt;/span&gt;&lt;tt style=&quot;font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;MyCreator::Create&lt;/span&gt;&lt;/tt&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt;
handles only &lt;/span&gt;&lt;tt style=&quot;font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;YOURS&lt;/span&gt;&lt;/tt&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt;, &lt;/span&gt;&lt;tt style=&quot;font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;MINE&lt;/span&gt;&lt;/tt&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt;, and &lt;/span&gt;&lt;tt style=&quot;font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;THEIRS&lt;/span&gt;&lt;/tt&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt; differently than the
parent class. It isn&#39;t interested in other classes. Hence &lt;/span&gt;&lt;tt style=&quot;font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;MyCreator&lt;/span&gt;&lt;/tt&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt; &lt;/span&gt;&lt;em style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt;extends&lt;/em&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%; text-align: justify;&quot;&gt; the kinds of
products created, and it defers responsibility for creating all but a few
products to its parent.&lt;/span&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;ol start=&quot;3&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l3 level1 lfo5; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Language-specific
     variants and issues.&lt;/span&gt;&lt;/em&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;
     Different languages lend themselves to other interesting variations and
     caveats. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Smalltalk
programs often use a method that returns the class of the object to be
instantiated. A Creator factory method can use this value to create a product,
and a ConcreteCreator may store or even compute this value. The result is an
even later binding for the type of ConcreteProduct to be instantiated.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;A
Smalltalk version of the Document example can define a &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;documentClass&lt;/span&gt;&lt;/tt&gt; method on &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Application&lt;/span&gt;&lt;/tt&gt;. The &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;documentClass&lt;/span&gt;&lt;/tt&gt; method returns the
proper &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Document&lt;/span&gt;&lt;/tt&gt; class
for instantiating documents. The implementation of &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;documentClass&lt;/span&gt;&lt;/tt&gt;
in &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;MyApplication&lt;/span&gt;&lt;/tt&gt;
returns the &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;MyDocument&lt;/span&gt;&lt;/tt&gt;
class. Thus in class &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Application&lt;/span&gt;&lt;/tt&gt;
we have&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;line-height: 100%; margin-left: .5in; text-align: justify;&quot;&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;clientMethod&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; document := self documentClass new.&lt;/span&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;documentClass&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;documentClass&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-US;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self subclassResponsibility&lt;/span&gt;&lt;/blockquote&gt;
&lt;/pre&gt;
&lt;div style=&quot;line-height: 100%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%;&quot;&gt;In
class &lt;/span&gt;&lt;tt style=&quot;font-size: 11pt; line-height: 150%;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;MyApplication&lt;/span&gt;&lt;/tt&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%;&quot;&gt; we
have&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;documentClass&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt; line-height: 115%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt; line-height: 115%;&quot;&gt;^ &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt; line-height: 115%;&quot;&gt;MyDocument&lt;/span&gt;&lt;/blockquote&gt;
&lt;/pre&gt;
&lt;div style=&quot;line-height: 100%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;which
returns the class &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;MyDocument&lt;/span&gt;&lt;/tt&gt;
to be instantiated to &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Application&lt;/span&gt;&lt;/tt&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 100%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 100%;&quot;&gt;An
even more flexible approach akin to parameterized factory methods is to store
the class to be created as a class variable of &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Application&lt;/span&gt;&lt;/tt&gt;.
That way you don&#39;t have to subclass &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Application&lt;/span&gt;&lt;/tt&gt;
to vary the product.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Factory
methods in C++ are always virtual functions and are often pure virtual. Just be
careful not to call factory methods in the Creator&#39;s constructor—the factory
method in the ConcreteCreator won&#39;t be available yet.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;You
can avoid this by being careful to access products solely through accessor
operations that create the product on demand. Instead of creating the concrete
product in the constructor, the constructor merely initializes it to 0. The
accessor returns the product. But first it checks to make sure the product
exists, and if it doesn&#39;t, the accessor creates it. This technique is sometimes
called &lt;strong&gt;lazy
initialization&lt;/strong&gt;. The following code shows a typical
implementation:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;class
Creator {&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;public:&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Product* GetProduct();&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;protected:&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual Product* CreateProduct();&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;private:&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Product* _product;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;};&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Product*
Creator::GetProduct () {&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (_product == 0) {&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _product = CreateProduct();&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return _product;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;line-height: 150%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;ol start=&quot;4&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l3 level1 lfo5; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Using
     templates to avoid subclassing.&lt;/span&gt;&lt;/em&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;
     As we&#39;ve mentioned, another potential problem with factory methods is that
     they might force you to subclass just to create the appropriate Product
     objects. Another way to get around this in C++ is to provide a template
     subclass of Creator that&#39;s parameterized by the Product class:&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;pre style=&quot;line-height: 150%; margin-left: .5in; mso-list: l3 level1 lfo5; text-align: justify; text-indent: -.25in;&quot;&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;class&lt;/span&gt;&lt;br /&gt;
&lt;blockquote&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Creator {&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;public:&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual Product* CreateProduct() = 0;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;};&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;template &lt;class theproduct=&quot;theproduct&quot;&gt;
&lt;/class&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;template &lt;class theproduct=&quot;theproduct&quot;&gt;
&lt;/class&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;class StandardCreator: public Creator {&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;public:&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual Product* CreateProduct();&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;};&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;template &lt;class theproduct=&quot;theproduct&quot;&gt;
&lt;/class&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;template &lt;class theproduct=&quot;theproduct&quot;&gt;
&lt;/class&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Product* StandardCreator&lt;theproduct&gt;::CreateProduct () {&lt;/theproduct&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new TheProduct;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;}&lt;/span&gt;&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;/pre&gt;
&lt;div style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;With
this template, the client supplies just the product class—no subclassing of
Creator is required.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;line-height: 150%; margin-left: .5in; text-align: justify;&quot;&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;class MyProduct : public Product {&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;public:&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyProduct();&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ...&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;};&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;StandardCreator&lt;myproduct&gt; myCreator;&lt;/myproduct&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;StandardCreator&lt;myproduct&gt; myCreator;&lt;/myproduct&gt;&lt;/span&gt;&lt;/blockquote&gt;
&lt;/pre&gt;
&lt;ol start=&quot;20&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-list: l3 level1 lfo5; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Naming
     conventions.&lt;/span&gt;&lt;/em&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;
     It&#39;s good practice to use naming conventions that make it clear you&#39;re
     using factory methods. For example, the MacApp Macintosh application
     framework [App89] always declares the abstract operation that defines the
     factory method as &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;&quot;&gt;Class* DoMakeClass()&lt;/span&gt;&lt;/tt&gt;,
     where &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;&quot;&gt;Class&lt;/span&gt;&lt;/tt&gt; is the
     Product class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=4670920447169706502&quot; name=&quot;samplecode&quot;&gt;&lt;/a&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Sample
Code&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;The function &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;CreateMaze&lt;/span&gt;&lt;/tt&gt; () builds and returns
a maze. One problem with this function is that it hard-codes the classes of
maze, rooms, doors, and walls. We&#39;ll introduce factory methods to let
subclasses choose these components.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;First we&#39;ll define factory
methods in &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;MazeGame&lt;/span&gt;&lt;/tt&gt; for
creating the maze, room, wall, and door objects:&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;line-height: 100%; text-align: justify;&quot;&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;
class MazeGame {
public:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Maze* CreateMaze();
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;// factory methods:
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual Maze* MakeMaze() const
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { return new Maze; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual Room* MakeRoom(int n) const
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { return new Room(n); }
&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual Wall* MakeWall() const
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { return new Wall; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual Door* MakeDoor(Room* r1, Room* r2) const
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{ return new Door(r1, r2); }
};&lt;/blockquote&gt;
&lt;/pre&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%;&quot;&gt;Each factory method returns
a maze component of a given type. &lt;/span&gt;&lt;tt style=&quot;font-size: 11pt; line-height: 150%;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;MazeGame&lt;/span&gt;&lt;/tt&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 11pt; line-height: 150%;&quot;&gt;
provides default implementations that return the simplest kinds of maze, rooms,
walls, and doors.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Now we can rewrite &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;CreateMaze&lt;/span&gt;&lt;/tt&gt; to use these factory
methods:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;
Maze* MazeGame::CreateMaze () {
    Maze* aMaze = MakeMaze();
    Room* r1 = MakeRoom(1);
    Room* r2 = MakeRoom(2);
    Door* theDoor = MakeDoor(r1, r2);
    aMaze-&amp;gt;AddRoom(r1);
    aMaze-&amp;gt;AddRoom(r2);
    r1-&amp;gt;SetSide(North, MakeWall());
    r1-&amp;gt;SetSide(East, theDoor);
    r1-&amp;gt;SetSide(South, MakeWall());
    r1-&amp;gt;SetSide(West, MakeWall());
    r2-&amp;gt;SetSide(North, MakeWall());
    r2-&amp;gt;SetSide(East, MakeWall());
    r2-&amp;gt;SetSide(South, MakeWall());
    r2-&amp;gt;SetSide(West, theDoor);
    return aMaze;
}&lt;/blockquote&gt;
&lt;/pre&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Different games can subclass
&lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;MazeGame&lt;/span&gt;&lt;/tt&gt; to
specialize parts of the maze. &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;MazeGame&lt;/span&gt;&lt;/tt&gt;
subclasses can redefine some or all of the factory methods to specify
variations in products. For example, a &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;BombedMazeGame&lt;/span&gt;&lt;/tt&gt;
can redefine the &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Room&lt;/span&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;Wall&lt;/span&gt;&lt;/tt&gt; products to return the
bombed varieties:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;
class BombedMazeGame : public MazeGame {
public:
    BombedMazeGame();
    virtual Wall* MakeWall() const
        { return new BombedWall; }
    virtual Room* MakeRoom(int n) const
        { return new RoomWithABomb(n); }
};&lt;/blockquote&gt;
&lt;/pre&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;An &lt;tt&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 150%; mso-ansi-font-size: 11.0pt; mso-bidi-font-size: 11.0pt;&quot;&gt;EnchantedMazeGame&lt;/span&gt;&lt;/tt&gt; variant might
be defined like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;
class EnchantedMazeGame : public MazeGame {
public:
    EnchantedMazeGame();
    virtual Room* MakeRoom(int n) const
        { return new EnchantedRoom(n, CastSpell()); }
    virtual Door* MakeDoor(Room* r1, Room* r2) const
        { return new DoorNeedingSpell(r1, r2); }
protected:
    Spell* CastSpell() const;
};&lt;/blockquote&gt;
&lt;/pre&gt;
&lt;h3 style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=4670920447169706502&quot; name=&quot;knownuses&quot;&gt;&lt;/a&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Known
Uses&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Factory methods pervade
toolkits and frameworks. The preceding document example is a typical use in
MacApp and ET++ [WGM88]. The manipulator example is from Unidraw.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Class View in the
Smalltalk-80 Model/View/Controller framework has a method defaultController
that creates a controller, and this might appear to be a factory method
[Par90]. But subclasses of View specify the class of their default controller
by defining defaultControllerClass, which returns the class from which
defaultController creates instances. So defaultControllerClass is the real
factory method, that is, the method that subclasses should override.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;A more esoteric example in
Smalltalk-80 is the factory method parserClass defined by Behavior (a
superclass of all objects representing classes). This enables a class to use a
customized parser for its source code. For example, a client can define a class
SQLParser to analyze the source code of a class with embedded SQL statements.
The Behavior class implements parserClass to return the standard Smalltalk
Parser class. A class that includes embedded SQL statements overrides this
method (as a class method) and returns the SQLParser class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;The Orbix ORB system from
IONA Technologies [ION94] uses Factory Method to generate an appropriate type
of proxy (see Proxy ) when an object requests a reference to a remote object.
Factory Method makes it easy to replace the default proxy with one that uses
client-side caching, for example.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h3 style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Related Patterns&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Abstract Factory is often
implemented with factory methods. The Motivation example in the Abstract
Factory pattern illustrates Factory Method as well.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Factory methods are usually
called within Template Methods (325). In the document example above, NewDocument
is a template method.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;line-height: 150%; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 150%;&quot;&gt;Prototypes (117) don&#39;t
require subclassing Creator. However, they often require an Initialize
operation on the Product class. Creator uses Initialize to initialize the
object. Factory Method doesn&#39;t require such an operation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/5557321457557637570/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/5557321457557637570' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/5557321457557637570'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/5557321457557637570'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2012/10/factory-method-design-pattern.html' title='Factory Method Design Pattern'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjOXCcia3q5rHdmEcVnfs5ty7Nk5XGsXGqYwOkCz3DwNf2TAKYWzGwjPBsrYYUeaCOVBZGMkVbZDkBD2akm6n9SgOl8iMw6GrQVrszRp5rI1jqkoOCpYOErMN7i2MU786fNILjgeRMg4A/s72-c/fm1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-2993386548119715211</id><published>2012-10-06T14:42:00.001+05:30</published><updated>2012-10-06T14:42:39.715+05:30</updated><title type='text'>Facade Design Pattern</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 18pt; line-height: 150%;&quot;&gt;Facade&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 18pt; line-height: 150%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;Intent&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;Provide a unified
interface to a set of interfaces in a subsystem. Facade defines a higher-level
interface that makes the subsystem easier to use.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;Motivation&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;Structuring a system
into subsystems helps reduce complexity. A common design goal is to minimize
the communication and dependencies between subsystems. One way to achieve this
goal is to introduce a&amp;nbsp;&lt;b&gt;facade&lt;/b&gt;&amp;nbsp;object that provides a single,
simplified interface to the more general facilities of a subsystem.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhppSBAvT6BrdQn3SgXn0laqOQqhZUHr5iXKpwWS8va-hXQT0EbW1kcG719p3tkzniSnNdBaYZY9q9Tlj8tBtf1rzAOO2LWV9LcF2_jAtaMDVVHEJCvY9K2CvgbzKOnljhLAiFkm5HXePc/s1600/q1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;202&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhppSBAvT6BrdQn3SgXn0laqOQqhZUHr5iXKpwWS8va-hXQT0EbW1kcG719p3tkzniSnNdBaYZY9q9Tlj8tBtf1rzAOO2LWV9LcF2_jAtaMDVVHEJCvY9K2CvgbzKOnljhLAiFkm5HXePc/s640/q1.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif; line-height: 150%;&quot;&gt;Consider for example a
programming environment that gives applications access to its compiler
subsystem. This subsystem contains classes such as Scanner, Parser,
ProgramNode, BytecodeStream, and ProgramNodeBuilder that implement the
compiler. Some specialized applications might need to access these classes
directly. But most clients of a compiler generally don&#39;t care about details
like parsing and code generation; they merely want to compile some code. For
them, the powerful but low-level interfaces in the compiler subsystem only
complicate their task.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;To provide a
higher-level interface that can shield clients from these classes, the compiler
subsystem also includes a Compiler class. This class defines a unified
interface to the compiler&#39;s functionality. The Compiler class acts as a facade:
It offers clients a single, simple interface to the compiler subsystem. It glues
together the classes that implement compiler functionality without hiding them
completely. The compiler facade makes life easier for most programmers without
hiding the lower-level functionality from the few that need it.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6GZDSbrqwgrTXrrQnYTMYQc1dmQiQxv5z3vkeb_4LOViYUyppghUbdSAXN_5YCynP-FzuLuUhVNBC3hB1EJZPoDbfMbAVv51QF6_cUo9S1sPSbg-cZ1dNuzbP9iParjt18PipBK7FAf8/s1600/q11.jpg&quot; imageanchor=&quot;1&quot; style=&quot;line-height: normal; margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;420&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6GZDSbrqwgrTXrrQnYTMYQc1dmQiQxv5z3vkeb_4LOViYUyppghUbdSAXN_5YCynP-FzuLuUhVNBC3hB1EJZPoDbfMbAVv51QF6_cUo9S1sPSbg-cZ1dNuzbP9iParjt18PipBK7FAf8/s640/q11.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;Applicability&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;Use the Facade pattern
when&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;you want to provide a simple
     interface to a complex subsystem. Subsystems often get more complex as
     they evolve. Most patterns, when applied, result in more and smaller
     classes. This makes the subsystem more reusable and easier to customize,
     but it also becomes harder to use for clients that don&#39;t need to customize
     it. A facade can provide a simple default view of the subsystem that is
     good enough for most clients. Only clients needing more customizability
     will need to look beyond the facade.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;there are many dependencies
     between clients and the implementation classes of an abstraction.
     Introduce a facade to decouple the subsystem from clients and other
     subsystems, thereby promoting subsystem independence and portability.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;you want to layer your
     subsystems. Use a facade to define an entry point to each subsystem level.
     If subsystems are dependent, then you can simplify the dependencies
     between them by making them communicate with each other solely through
     their facades.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;Structure&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1N1hX0b64QJ80bBk_zsZnDj9HcfM8r1Lr_gpYoRv11mLmdzcejZbE8ZafWMozILXTHa_r0sx65NW-h-MWW3CXiYmP9Zqe5QZfFGgsuPrs0Vhy4P6Bqmg5YNOvHnwEhCNLRCVB4rfFVpw/s1600/q.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;248&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1N1hX0b64QJ80bBk_zsZnDj9HcfM8r1Lr_gpYoRv11mLmdzcejZbE8ZafWMozILXTHa_r0sx65NW-h-MWW3CXiYmP9Zqe5QZfFGgsuPrs0Vhy4P6Bqmg5YNOvHnwEhCNLRCVB4rfFVpw/s640/q.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;Participants&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;ul type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Facade&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;(Compiler)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ul type=&quot;circle&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;knows which subsystem classes
      are responsible for a request.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;delegates client requests to
      appropriate subsystem objects.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;subsystem classes&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;(Scanner,
     Parser, ProgramNode, etc.)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ul type=&quot;circle&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;implement subsystem
      functionality.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;handle work assigned by the
      Facade object.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;have no knowledge of the
      facade; that is, they keep no references to it.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;Collaborations&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;ul type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Clients communicate with the
     subsystem by sending requests to Facade, which forwards them to the
     appropriate subsystem object(s). Although the subsystem objects perform
     the actual work, the facade may have to do work of its own to translate
     its interface to subsystem interfaces.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Clients that use the facade
     don&#39;t have to access its subsystem objects directly.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;Consequences&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;The Facade pattern
offers the following benefits:&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ol start=&quot;1&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;It shields clients from
     subsystem components, thereby reducing the number of objects that clients
     deal with and making the subsystem easier to use.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;It promotes weak coupling
     between the subsystem and its clients. Often the components in a subsystem
     are strongly coupled. Weak coupling lets you vary the components of the
     subsystem without affecting its clients. Facades help layer a system and
     the dependencies between objects. They can eliminate complex or circular
     dependencies. This can be an important consequence when the client and the
     subsystem are implemented independently.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;Reducing compilation dependencies is vital in large software
systems. You want to save time by minimizing recompilation when subsystem
classes change. Reducing compilation dependencies with facades can limit the
recompilation needed for a small change in an important subsystem. A facade can
also simplify porting systems to other platforms, because it&#39;s less likely that
building one subsystem requires building all others.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ol start=&quot;3&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;It doesn&#39;t prevent applications
     from using subsystem classes if they need to. Thus you can choose between
     ease of use and generality.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;Implementation&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;Consider the following
issues when implementing a facade:&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ol start=&quot;1&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Reducing client-subsystem
     coupling.&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;The coupling between
     clients and the subsystem can be reduced even further by making Facade an
     abstract class with concrete subclasses for different implementations of a
     subsystem. Then clients can communicate with the subsystem through the
     interface of the abstract Facade class. This abstract coupling keeps
     clients from knowing which implementation of a subsystem is used.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;An alternative to subclassing is to configure a Facade object with
different subsystem objects. To customize the facade, simply replace one or
more of its subsystem objects.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ol start=&quot;2&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; text-align: justify;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Public versus private subsystem
     classes.&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;A subsystem is analogous
     to a class in that both have interfaces, and both encapsulate something—a
     class encapsulates state and operations, while a subsystem encapsulates
     classes. And just as it&#39;s useful to think of the public and private
     interface of a class, we can think of the public and private interface of
     a subsystem.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;The public interface to a subsystem consists of classes that all
clients can access; the private interface is just for subsystem extenders. The
Facade class is part of the public interface, of course, but it&#39;s not the only
part. Other subsystem classes are usually public as well. For example, the
classes Parser and Scanner in the compiler subsystem are part of the public
interface.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;Making subsystem classes private would be useful, but few
object-oriented languages support it. Both C++ and Smalltalk traditionally have
had a global name space for classes. Recently, however, the C++ standardization
committee added name spaces to the language [Str94], which will let you expose
just the public subsystem classes.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;a href=&quot;&quot; name=&quot;samplecode&quot;&gt;&lt;/a&gt;&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;Sample Code&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;Let&#39;s take a closer look
at how to put a facade on a compiler subsystem.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;The compiler subsystem
defines a {BytecodeStream} class that implements a stream of&amp;nbsp;Bytecode&amp;nbsp;objects.
A&amp;nbsp;Bytecode&amp;nbsp;object encapsulates a bytecode, which can specify machine
instructions. The subsystem also defines a&amp;nbsp;Token&amp;nbsp;class for objects
that encapsulate tokens in the programming language.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;The&amp;nbsp;Scanner&amp;nbsp;class
takes a stream of characters and produces a stream of tokens, one token at a
time.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
class Scanner {&lt;br /&gt;public:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Scanner(istream&amp;amp;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual ~Scanner();&lt;br /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual Token&amp;amp; Scan();&lt;br /&gt;private:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; istream&amp;amp; _inputStream;&lt;br /&gt;};&lt;/blockquote&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;The class&amp;nbsp;Parser&amp;nbsp;uses
a&amp;nbsp;ProgramNodeBuilder&amp;nbsp;to construct a parse tree from a&amp;nbsp;Scanner&#39;s
tokens.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
class Parser {&lt;br /&gt;public:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Parser();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual ~Parser();&lt;br /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual void Parse(Scanner&amp;amp;, ProgramNodeBuilder&amp;amp;);&lt;br /&gt;};&lt;/blockquote&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;Parser&amp;nbsp;calls back
on&amp;nbsp;ProgramNodeBuilder&amp;nbsp;to build the parse tree incrementally. These
classes interact according to the Builder pattern.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre&gt;class ProgramNodeBuilder {&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;public:&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ProgramNodeBuilder();&lt;br /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual ProgramNode* NewVariable(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; const char* variableName&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) const;&lt;br /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual ProgramNode* NewAssignment(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProgramNode* variable, ProgramNode* expression&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) const;&lt;br /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual ProgramNode* NewReturnStatement(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;ProgramNode* value&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) const;&lt;br /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual ProgramNode* NewCondition(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProgramNode* condition,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProgramNode* truePart, ProgramNode* falsePart&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) const;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ...&lt;br /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProgramNode* GetRootNode();&lt;br /&gt;private:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProgramNode* _node;&lt;br /&gt;};&lt;/blockquote&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif; line-height: 150%; text-align: justify;&quot;&gt;The parse tree is made
up of instances of&amp;nbsp;ProgramNode&amp;nbsp;subclasses such as&amp;nbsp;StatementNode,&amp;nbsp;ExpressionNode,
and so forth. The&amp;nbsp;ProgramNode&amp;nbsp;hierarchy is an example of the
Composite pattern.&amp;nbsp;ProgramNode&amp;nbsp;defines an interface for manipulating
the program node and its children, if any.&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;text-align: left;&quot;&gt;class ProgramNode {&lt;/span&gt;public:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // program node manipulation&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual void GetSourcePosition(int&amp;amp; line, int&amp;amp; index);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ...&lt;br /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // child manipulation&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual void Add(ProgramNode*);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual void Remove(ProgramNode*);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ...&lt;br /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual void Traverse(CodeGenerator&amp;amp;);&lt;br /&gt;protected:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProgramNode();&lt;br /&gt;};&lt;/blockquote&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;The&amp;nbsp;Traverse&amp;nbsp;operation
takes a&amp;nbsp;CodeGenerator&amp;nbsp;object.&amp;nbsp;ProgramNode&amp;nbsp;subclasses use
this object to generate machine code in the form of&amp;nbsp;Bytecode&amp;nbsp;objects
on a&amp;nbsp;BytecodeStream. The class&amp;nbsp;CodeGenerator&amp;nbsp;is a visitor (see
Visitor ).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
class CodeGenerator {&lt;br /&gt;public:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual void Visit(StatementNode*);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual void Visit(ExpressionNode*);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ...&lt;br /&gt;protected:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CodeGenerator(BytecodeStream&amp;amp;);&lt;br /&gt;protected:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BytecodeStream&amp;amp; _output;&lt;br /&gt;};&lt;/blockquote&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif; line-height: 150%;&quot;&gt;CodeGenerator has subclasses, for example,
StackMachineCodeGenerator and RISCCodeGenerator, that generate machine code for
different hardware architectures.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;Each subclass of&amp;nbsp;ProgramNode&amp;nbsp;implements&amp;nbsp;Traverse&amp;nbsp;to
call&amp;nbsp;Traverse&amp;nbsp;on its child&amp;nbsp;ProgramNode&amp;nbsp;objects. In turn,
each child does the same for its children, and so on &lt;br /&gt;
recursively. For example,ExpressionNode&amp;nbsp;defines&amp;nbsp;Traverse&amp;nbsp;as
follows:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
void ExpressionNode::Traverse (CodeGenerator&amp;amp; cg) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cg.Visit(this);&lt;br /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ListIterator&lt;programnode&gt; i(_children);&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/programnode&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i.First(); !i.IsDone(); i.Next()) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i.CurrentItem()-&amp;gt;Traverse(cg);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/blockquote&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 11.5pt; line-height: 150%;&quot;&gt;The classes
we&#39;ve discussed so far make up the compiler subsystem. Now we&#39;ll introduce a&amp;nbsp;Compiler&amp;nbsp;class,
a facade that puts all these pieces together.&amp;nbsp;Compiler&amp;nbsp;provides a
simple interface for compiling source and generating code for a particular
machine.&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
class Compiler {&lt;br /&gt;public:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Compiler();&lt;br /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; virtual void Compile(istream&amp;amp;, BytecodeStream&amp;amp;);&lt;br /&gt;};&lt;br /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;void Compiler::Compile (&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; istream&amp;amp; input, BytecodeStream&amp;amp; output&lt;br /&gt;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Scanner scanner(input);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProgramNodeBuilder builder;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Parser parser;&lt;br /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; parser.Parse(scanner, builder);&lt;br /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RISCCodeGenerator generator(output);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProgramNode* parseTree = builder.GetRootNode();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; parseTree-&amp;gt;Traverse(generator);&lt;br /&gt;}&lt;/blockquote&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/pre&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background: white; color: #333333; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;This
implementation hard-codes the type of code generator to use so that programmers
aren&#39;t required to specify the target architecture. That might be reasonable if
there&#39;s only ever one target architecture. If that&#39;s not the case, then we
might want to change the&amp;nbsp;Compiler&amp;nbsp;constructor to take a&amp;nbsp;CodeGenerator&amp;nbsp;parameter.
Then programmers can specify the generator to use when they instantiate&amp;nbsp;Compiler.
The compiler facade can parameterize other participants such as&amp;nbsp;Scanner&amp;nbsp;and&amp;nbsp;ProgramNodeBuilder&amp;nbsp;as
well, which adds flexibility, but it also detracts from the Facade pattern&#39;s
mission, which is to simplify the interface for the common case.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;a href=&quot;&quot; name=&quot;knownuses&quot;&gt;&lt;/a&gt;&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;Known Uses&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background: white; color: #333333; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;The compiler
example in the Sample Code section was inspired by the ObjectWorks\Smalltalk
compiler system [Par90].&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background: white; color: #333333; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background: white; color: #333333; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;In the ET++
application framework [WGM88], an application can have built-in browsing tools
for inspecting its objects at run-time. These browsing tools are implemented in
a separate subsystem that includes a Facade class called
&quot;ProgrammingEnvironment.&quot; This facade defines operations such as
InspectObject and InspectClass for accessing the browsers.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background: white; color: #333333; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background: white; color: #333333; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;An ET++
application can also forgo built-in browsing support. In that case,
ProgrammingEnvironment implements these requests as null operations; that is,
they do nothing. Only the ETProgrammingEnvironment subclass implements these
requests with operations that display the corresponding browsers. The
application has no knowledge of whether a browsing environment is available or
not; there&#39;s abstract coupling between the application and the browsing
subsystem.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background: white; color: #333333; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background: white; color: #333333; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;The Choices
operating system [CIRM93] uses facades to compose many frameworks into one. The
key abstractions in Choices are processes, storage, and address spaces. For
each of these abstractions there is a corresponding subsystem, implemented as a
framework, that supports porting Choices to a variety of different hardware
platforms. Two of these subsystems have a &quot;representative&quot; (i.e.,
facade). These representatives are FileSystemInterface (storage) and Domain
(address spaces).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq3mhDnnZN2TJn4Zy5pIMrt2q_mQIJHIBD0ZaupPBKyQ6rdI3MuLMEyh_8m8QyehDu26dlBY2zSjDLBUhKGrnUtWIK00n4gh2xGcKVTRx0cfsEKxeeNgpwci-94iNp1NFM4fWShsE-UXQ/s1600/q7.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;348&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq3mhDnnZN2TJn4Zy5pIMrt2q_mQIJHIBD0ZaupPBKyQ6rdI3MuLMEyh_8m8QyehDu26dlBY2zSjDLBUhKGrnUtWIK00n4gh2xGcKVTRx0cfsEKxeeNgpwci-94iNp1NFM4fWShsE-UXQ/s640/q7.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 11.5pt; line-height: 150%;&quot;&gt;For example,
the virtual memory framework has Domain as its facade. A Domain represents an
address space. It provides a mapping between virtual addresses and offsets into
memory objects, files, or backing store. The main operations on Domain support
adding a memory object at a particular address, removing a memory object, and
handling a page fault.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background: white; color: #333333; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;As the
preceding diagram shows, the virtual memory subsystem uses the following
components internally:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;color: #333333; line-height: 150%; mso-list: l4 level1 lfo6; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;span style=&quot;background: white; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;MemoryObject represents
     a data store.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;color: #333333; line-height: 150%; text-align: left;&quot;&gt;&lt;span style=&quot;background: white; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;MemoryObjectCache
     caches the data of MemoryObjects in physical memory. MemoryObjectCache is
     actually a Strategy that localizes the caching policy.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;color: #333333; line-height: 150%; mso-list: l4 level1 lfo6; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-align: justify;&quot;&gt;&lt;span style=&quot;background: white; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;AddressTranslation
     encapsulates the address translation hardware.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background: white; color: #333333; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;The
RepairFault operation is called whenever a fault interrupt occurs. The Domain
finds the memory object at the address causing the fault and delegates the
RepairFault operation to the cache associated with that memory object. Domains
can be customized by changing their components.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, sans-serif; font-size: 13.5pt; line-height: 150%;&quot;&gt;Related Patterns&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background: white; color: #333333; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;Abstract
Factory can be used with Facade to provide an interface for creating subsystem
objects in a subsystem-independent way. Abstract Factory can also be used as an
alternative to Facade to hide platform-specific classes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background: white; color: #333333; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;Mediator is similar
to Facade in that it abstracts functionality of existing classes. However,
Mediator&#39;s purpose is to abstract arbitrary communication between colleague
objects, often centralizing functionality that doesn&#39;t belong in any one of
them. A mediator&#39;s colleagues are aware of and communicate with the mediator
instead of communicating with each other directly. In contrast, a facade merely
abstracts the interface to subsystem objects to make them easier to use; it
doesn&#39;t define new functionality, and subsystem classes don&#39;t know about it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;background: white; color: #333333; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.5pt; line-height: 150%;&quot;&gt;Usually only
one Facade object is required. Thus Facade objects are often Singletons.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/2993386548119715211/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/2993386548119715211' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/2993386548119715211'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/2993386548119715211'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2012/10/facade-design-pattern.html' title='Facade Design Pattern'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhppSBAvT6BrdQn3SgXn0laqOQqhZUHr5iXKpwWS8va-hXQT0EbW1kcG719p3tkzniSnNdBaYZY9q9Tlj8tBtf1rzAOO2LWV9LcF2_jAtaMDVVHEJCvY9K2CvgbzKOnljhLAiFkm5HXePc/s72-c/q1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4670920447169706502.post-5193223329114459532</id><published>2012-09-13T15:58:00.000+05:30</published><updated>2012-09-13T16:50:33.205+05:30</updated><title type='text'>HTML5 Browser Compatibility</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Over the past few years,&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://developers.whatwg.org/introduction.html&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;HTML5&lt;/a&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;has gone from mythical creature to vivid reality and has taken its share of hits from skeptics and experts alike as to its readiness and viability. Now, in 2012, HTML5 is ready for use with all modern browsers, including IE9. It has also been developed to gracefully degrade, even without help from JavaScript or CSS resets.&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Even still, you may be concerned about providing full backwards compatibility, or unsure of what will work in one browser and not another. HTML5 has commonly been blamed for the issues presented by jQuery and CSS3, both newer technologies and standards evolving alongside HTML5, but not actually a part of it. To get a grip on HTML5 browser compatibility, you must first understand the way browsers look at each of these languages.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgScYfWObCmy50_sFv0TJFqVs1OeDQOs62sDPdRgQAhDkGnyb5T1YNDQyYDLUiAalS9kXUNqNAKxUDTXgepOJKxc9aHLv2tlTck8KlBWm4x-pif_gmcgKGK0-y6oT_8KD7s4XBvekEh8Xs/s1600/csshtml5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;323&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgScYfWObCmy50_sFv0TJFqVs1OeDQOs62sDPdRgQAhDkGnyb5T1YNDQyYDLUiAalS9kXUNqNAKxUDTXgepOJKxc9aHLv2tlTck8KlBWm4x-pif_gmcgKGK0-y6oT_8KD7s4XBvekEh8Xs/s640/csshtml5.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
HTML5 is a revision of the HTML markup specification, containing several best practices and rules by which browser makers and web developers can find common ground. It was first drafted and accepted by the W3C in 2006, closing in 2009 and deemed ready for use, with full candidate approval likely this year. It contains new layout elements, which you have likely seen, such as &lt;article&gt;, &lt;aside&gt; and &lt;nav&gt;. It removes support for presentational tags and attributes, while introducing support for native browser functionality such as multi-media playback and offline storage.&lt;a href=&quot;http://www.w3.org/TR/css3-selectors/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;CSS3&lt;/a&gt;, on the other hand, is a separate specification that is still in active revision, and as such, not all browsers fully support the new selectors.&lt;/nav&gt;&lt;/aside&gt;&lt;/article&gt;&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Both of these specifications aim to get web development to a more semantic and meaningful place in terms of producing a set of easy to understand standards that are designed to work well with one another. Because HTML5 is not tied to CSS3, it can be used in a wide variety of applications without suffering the compatibility issues some cutting-edge CSS3 selectors may pose.&lt;/div&gt;
&lt;h2 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 24px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 10px 0px; orphans: 2; padding: 15px 0px 5px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Coming to Terms&lt;/h2&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
We’ve all heard the terms several times, but the concept of&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;graceful degradation&lt;/strong&gt;,&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;progressive enhancement&lt;/strong&gt;,&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;strong&gt;backwards compatibility&lt;/strong&gt;&lt;/strong&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;and&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;browser support&lt;/strong&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;can sound like total nonsense if you are new to design or focus on front-end design most of the time. Fortunately, much has been written on these topics and a few very useful tools have been created to make it easier for us to cope. Let’s start with the basics of what these things are.&lt;/div&gt;
&lt;h2 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 24px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 10px 0px; orphans: 2; padding: 15px 0px 5px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Is Browser Compatibility That Important?&lt;/h2&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
I’ve seen designers argue that there is no point in spending unneeded energy supporting outdated browsers. Why bother when modern webkit browsers&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.w3schools.com/browsers/browsers_stats.asp&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot;&gt;account for nearly 75%&lt;/a&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;of all browser usage? Unfortunately, it’s hard to convince clients that want to reach the most viewers possible or support an audience who depend on older technology. A large part of the world still lacks the financial resources or technical ability to upgrade. You must also consider users with accessibility needs. HTML5 and CSS3 solve a huge compatibility gap by attempting to standardize how browsers display the web which, in time, will reduce the additional effort spent on crafting compatibility solutions into design.&lt;/div&gt;
&lt;h2 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 24px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 10px 0px; orphans: 2; padding: 15px 0px 5px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Graceful Degradation vs Progressive Enhancement&lt;/h2&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Opera’s Christian Heilmann&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://dev.opera.com/articles/view/graceful-degradation-progressive-enhancement/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot;&gt;defines graceful degredation&lt;/a&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;as “providing an alternative version of your functionality or making the user aware of shortcomings of a product as a safety measure to ensure that the product is usable.” Put into practice, this would encompass providing fallback support in the form of conditional statements for IE, special JavaScripts or Flash audio and video where new HTML5 elements are used.&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;strong&gt;Backwards Compatibility&lt;/strong&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;is a similar term meaning much the same thing, referring to an older browser’s ability to display your application or website, or accommodate it’s functionality.&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
In comparison,&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;Progressive Enhancement&lt;/strong&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;is a process that starts with a baseline of usable functionality, and then increases the richness of the user experience through various testing methods. Therefore, it is the initiative while graceful degradation is the interim solution.&lt;/div&gt;
&lt;h2 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 24px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 10px 0px; orphans: 2; padding: 15px 0px 5px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Browser Compatibility Now&lt;/h2&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
As previously mentioned, the new HTML5 tags are supported in all modern browsers. Where it gets complicated is when you begin to implement HTML5 native browser features and canvas elements, many of which still need JavaScript to be fully supported. Many CSS3 selectors are also either dependent on JavaScript or not safe for mobile browsers.&lt;/div&gt;
&lt;h4 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 17px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 5px 0px 12px; orphans: 2; padding: 15px 0px 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
HTML5 Elements Support:&lt;/h4&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
Internet Explorer 9 &amp;amp; 10&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
Firefox 7 and higher&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
Chrome 14 and higher&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
Safari 5 and higher&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
Opera 11 and higher&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
Mobile Safari 3.2 and higher&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
Opera Mobile 5 and higher&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
Android 2.1 and higher&lt;/div&gt;
&lt;/li&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;/ul&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Below are a few more resources to help you get an idea of where the web is at with CSS3 and HTML5. Add these to your toolkit to save yourself time and frustration when working on your next HTML5 project.&lt;/div&gt;
&lt;h4 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 17px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 5px 0px 12px; orphans: 2; padding: 15px 0px 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;a href=&quot;http://www.findmebyip.com/litmus/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;FindMeByIP&lt;/a&gt;&lt;/h4&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
HTML5 Canvas shares the same modern browser support for graphic rendering as HTML5 elements, which is great news if you plan to implement a canvas slideshow, text effects or Canvas animations into your app or website. FindMyByIP features a handful of at-a-glance charts for checking specific HTML5 and CSS3 features against various browsers, although it does not offer solutions for what to do if something isn’t supported. If you need to check advanced features, APIs or JavaScript features in addition to HTML5 and CSS3, check out&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.caniuse.com/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;caniuse.com&lt;/a&gt;.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT6L3V5_dq6AWiNBg-zdoL0VxPHnMoee7YePtX_mCqfq_wLxfKC13kuMup-4h-_Rw-4Pq3jy6YwOk7tUOv-Q5tjoC4ZRI2WPBFwjf0VRG4Pj__VP-vfFFGD1h5lwoJMXQBx474jlYht68/s1600/chart1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;356&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT6L3V5_dq6AWiNBg-zdoL0VxPHnMoee7YePtX_mCqfq_wLxfKC13kuMup-4h-_Rw-4Pq3jy6YwOk7tUOv-Q5tjoC4ZRI2WPBFwjf0VRG4Pj__VP-vfFFGD1h5lwoJMXQBx474jlYht68/s640/chart1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcyJcQCPud20guJmMyyzrym9Uz7wU756hFg6fP0wOejwEYFOSZh6oTk60ao4bJ4e11UEp6_23Sxyak6qFpuiW3HDt7IJfAHT9lumX4I2U7kRYfJfAsD89E41nr-7UvRHDouI52A78-qEo/s1600/chart2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;500&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcyJcQCPud20guJmMyyzrym9Uz7wU756hFg6fP0wOejwEYFOSZh6oTk60ao4bJ4e11UEp6_23Sxyak6qFpuiW3HDt7IJfAHT9lumX4I2U7kRYfJfAsD89E41nr-7UvRHDouI52A78-qEo/s640/chart2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;h4 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 17px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 5px 0px 12px; orphans: 2; padding: 15px 0px 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;a href=&quot;http://www.html5please.us/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;HTML5 Please&lt;/a&gt;&lt;/h4&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
After checking the chart at FindMeByIP, or if you have a specific feature in mind, head over to HTML5Please to lookup the element or selector and get straightforward advice on whether you should use it or not, and what can be done to help provide graceful degradation via polyfills (additional scripts).&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdHI2tfdSTgb2gpppyTLtz-g0wMyjjdVS0L_Tjzp5-c7IMnJ3Q90o1KV0ZCrLP6uV_ikfq9RMKpDUeeEQD6j4dOQxtGRZ2eDEuLzsv7yW24MTaoN8EKSVA_dtcEXVcGmuR5ASr0QOer6U/s1600/html5please.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;370&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdHI2tfdSTgb2gpppyTLtz-g0wMyjjdVS0L_Tjzp5-c7IMnJ3Q90o1KV0ZCrLP6uV_ikfq9RMKpDUeeEQD6j4dOQxtGRZ2eDEuLzsv7yW24MTaoN8EKSVA_dtcEXVcGmuR5ASr0QOer6U/s640/html5please.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;h4 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 17px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 5px 0px 12px; orphans: 2; padding: 15px 0px 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;a href=&quot;http://www.browsershots.org/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Browsershots&lt;/a&gt;&lt;/h4&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
This website allows you to test a live website in just about every browser and OS combination possible, giving you a screenshot of each selection to give you an idea of how your site will render in various browsers. Browsershots won’t tell you what markup, scripts or styles are incompatible, but the visual cues allow you to quickly pinpoint problem areas and begin planning for a solution.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWx75KX-bIrbIe0VTzuRB8StJZaMsv7RMY2trfz-Y0DYhG5_M4pW64NNNEA6581eNsoN_zLxLkENpekZSyO_uugBWVxcy7c_SQa79QRlwRUjLVubUXqG1XdqSWiP7GckRmNnoUsPzeqms/s1600/browsershots.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;444&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWx75KX-bIrbIe0VTzuRB8StJZaMsv7RMY2trfz-Y0DYhG5_M4pW64NNNEA6581eNsoN_zLxLkENpekZSyO_uugBWVxcy7c_SQa79QRlwRUjLVubUXqG1XdqSWiP7GckRmNnoUsPzeqms/s640/browsershots.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;h4 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 17px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 5px 0px 12px; orphans: 2; padding: 15px 0px 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;a href=&quot;http://spoon.net/browsers/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Spoon&lt;/a&gt;&lt;/h4&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Similar to Browsershots, Spoon is a free service for testing websites across a wide variety of browsers, including mobile browsers and release candidates such as Firefox Aurora and Chrome 18. Your site is loaded up in a virtual browser rather than returned in a screenshot, so you are better equipped to debug.&lt;/div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCaCFyL7B7jxBBXLeFEv02KzilzPDMChfRHFnxj5_yPMDnPHzXqP8_GeU_g5kmiUH7R5fRiYmQqD1AmqaAl7wnWJKqyxlmxjJYTYwUs6aX57dR0ezZQdjGAotKHYHhbYnZs8BymPiHXPY/s1600/spoon.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;384&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCaCFyL7B7jxBBXLeFEv02KzilzPDMChfRHFnxj5_yPMDnPHzXqP8_GeU_g5kmiUH7R5fRiYmQqD1AmqaAl7wnWJKqyxlmxjJYTYwUs6aX57dR0ezZQdjGAotKHYHhbYnZs8BymPiHXPY/s640/spoon.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 24px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 10px 0px; orphans: 2; padding: 15px 0px 5px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Getting it Together&lt;/h2&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
So now that the difference between HTML5 and CSS3 has been established, and we better understand why compatibility is important and how to test for it, let’s take a look at how to accomplish it.&lt;/div&gt;
&lt;h4 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 17px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 5px 0px 12px; orphans: 2; padding: 15px 0px 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
HTML5 Shiv&lt;/h4&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Taking advantage of the new capabilities of HTML5 and CSS3 can mean sacrificing control over the experience in older&amp;nbsp;browsers.&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/HTML5_Shiv&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;HTML5 shivs&lt;/a&gt;/shims/bims/bams/whatevers are scripts you can use to make up for the lack of feature detection in older browsers, allowing your cutting-edge websites and applications to work exactly right no matter what browser or device your visitors use.&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Implementing one of these scripts into and HTML5 website is pretty easy. All it takes is linking the script in the document head:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font-size-adjust: none; font-stretch: normal; font: 14px/15.38px Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px;&quot;&gt;&amp;lt;script src=&quot;//html5shiv.googlecode.com/svn/trunk/html5.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/blockquote&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;span style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline !important; float: none; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;Note that we no longer need the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #eeeeee; color: #333333; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 22px; orphans: 2; padding: 0px 3px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&quot;type=&quot;&lt;/code&gt;&lt;span style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline !important; float: none; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;attribute, which is depreciated in HTML5.&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline !important; float: none; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;strong&gt;Script Resources:&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline !important; float: none; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;ul style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 14px/normal helvetica; letter-spacing: normal; list-style: none; margin: 0px; orphans: 2; padding: 0px 0px 15px 15px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;li style=&quot;font-size: 15px; line-height: 20px; margin: 0px 0px 0px 15px; padding: 2px 0px 2px 2px;&quot;&gt;&lt;a href=&quot;http://remysharp.com/2009/01/07/html5-enabling-script/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Remy Sharp’s HTML Enabling Script →&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;font-size: 15px; line-height: 20px; margin: 0px 0px 0px 15px; padding: 2px 0px 2px 2px;&quot;&gt;&lt;a href=&quot;http://www.modernizr.com/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Modernizr →&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;font-size: 15px; line-height: 20px; margin: 0px 0px 0px 15px; padding: 2px 0px 2px 2px;&quot;&gt;&lt;a href=&quot;http://paulirish.com/2011/the-history-of-the-html5-shiv/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;The History of the HTML5 Shiv →&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;font-size: 15px; line-height: 20px; margin: 0px 0px 0px 15px; padding: 2px 0px 2px 2px;&quot;&gt;&lt;a href=&quot;http://www.alistapart.com/articles/taking-advantage-of-html5-and-css3-with-modernizr/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Getting Started with Modernizr →&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 17px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 5px 0px 12px; orphans: 2; padding: 15px 0px 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
CSS Reset&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The pioneer of the CSS Reset, Eric Meyer explains,&quot;The goal of a reset stylesheet is to reduce browser inconsistencies in things like default line heights, margins and font sizes of headings, and so on. The general reasoning behind this was&amp;nbsp;&lt;a href=&quot;http://meyerweb.com/eric/thoughts/2007/04/18/reset-reasoning/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot;&gt;discussed in a May 2007 post&lt;/a&gt;, if you’re interested. Reset styles quite often appear in CSS frameworks, and the original “meyerweb reset” found its way into&amp;nbsp;poular CSS frameworks such as&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://code.google.com/p/blueprintcss/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot;&gt;Blueprint&lt;/a&gt;, among others. &quot; Implementing the reset provides fallbacks for styles and selectors that aren’t recognized by older browsers. You can plop them right into the beginning of your main stylesheet, use&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background-color: #eeeeee; padding: 0px 3px;&quot;&gt;@import&lt;/code&gt;, or link them in the document head above your main stylesheet.&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;strong&gt;CSS Reset Resources:&lt;/strong&gt;&lt;/div&gt;
&lt;ul style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 14px/normal helvetica; letter-spacing: normal; list-style: none; margin: 0px; orphans: 2; padding: 0px 0px 15px 15px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;li style=&quot;font-size: 15px; line-height: 20px; margin: 0px 0px 0px 15px; padding: 2px 0px 2px 2px;&quot;&gt;&lt;a href=&quot;http://meyerweb.com/eric/thoughts/2011/01/03/reset-revisited/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Eric Meyer’s CSS Reset →&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;font-size: 15px; line-height: 20px; margin: 0px 0px 0px 15px; padding: 2px 0px 2px 2px;&quot;&gt;&lt;a href=&quot;http://html5reset.org/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;HTML5Reset.org →&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;font-size: 15px; line-height: 20px; margin: 0px 0px 0px 15px; padding: 2px 0px 2px 2px;&quot;&gt;&lt;a href=&quot;http://html5doctor.com/html-5-reset-stylesheet/&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;HTML5 Doctor Reset →&lt;/a&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(Super HTML5ified by Richard Clark)&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 17px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 5px 0px 12px; orphans: 2; padding: 15px 0px 0px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
IE Conditional Tags&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
HTML5 enabling scripts and CSS reset stylesheets are only needed by older browsers, so there is no point in loading them for everyone. Thankfully, Internet Explorer supports conditional tags, which can be used to detect a specific version of IE to feed it a special stylesheet, script or message. For example:&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 14px/normal helvetica; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter  xml&quot; id=&quot;highlighter_582690&quot; style=&quot;background-color: white !important; font-size: 1em !important; margin: 1em 0px !important; overflow-x: auto !important; overflow-y: hidden !important; position: relative !important; width: 650px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-collapse: collapse; border-radius: 0px !important; border-spacing: 0px; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 650px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;gutter&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border-right-color: rgb(108, 226, 108) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border-right-color: rgb(108, 226, 108) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border-right-color: rgb(108, 226, 108) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border-right-color: rgb(108, 226, 108) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border-right-color: rgb(108, 226, 108) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border-right-color: rgb(108, 226, 108) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border-right-color: rgb(108, 226, 108) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
7&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 618px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;xml plain&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; color: black !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;lt;!--[if IE 6]&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;xml plain&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; color: black !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;lt;p&amp;gt;I am truly sorry for your loss of experience.&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;xml plain&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; color: black !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;May you be delivered into the arms of a webkit browser soon.&amp;lt;/p&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;xml plain&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; color: black !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;lt;![endif]--&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;xml plain&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; color: black !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;lt;link rel=&quot;stylesheet&quot; href=&quot;reset.css&quot; /&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;xml plain&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; color: black !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; /&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 14px/normal helvetica; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter  xml&quot; id=&quot;highlighter_905009&quot; style=&quot;background-color: white !important; font-size: 1em !important; margin: 1em 0px !important; overflow-x: auto !important; overflow-y: hidden !important; position: relative !important; width: 650px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-collapse: collapse; border-radius: 0px !important; border-spacing: 0px; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 668px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;gutter&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border-right-color: rgb(108, 226, 108) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border-right-color: rgb(108, 226, 108) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border-right-color: rgb(108, 226, 108) !important; border-right-style: solid !important; border-width: 0px 3px 0px 0px !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 0.5em 0px 1em !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
3&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 636px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;xml plain&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; color: black !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;lt;!--[if lt IE 9]&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;xml plain&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; color: black !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;lt;script src=&quot;js/libs/modernizr-2.0.6.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;xml plain&quot; style=&quot;background-image: none !important; border-radius: 0px !important; border: 0px currentColor !important; bottom: auto !important; box-sizing: content-box !important; color: black !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;lt;![endif]--&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Conditional statements can take a number of operators to fine-tune control. In my above example, &quot;if lt IE 9&quot; means &quot;if less than Internet Explorer 9,&quot; meaning any version of IE lower than 9 will benefit from the script.&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;strong&gt;Learn More:&lt;/strong&gt;&lt;/div&gt;
&lt;ul style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 14px/normal helvetica; letter-spacing: normal; list-style: none; margin: 0px; orphans: 2; padding: 0px 0px 15px 15px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;li style=&quot;font-size: 15px; line-height: 20px; margin: 0px 0px 0px 15px; padding: 2px 0px 2px 2px;&quot;&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;About Conditional Comments (Microsoft) →&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;font-size: 15px; line-height: 20px; margin: 0px 0px 0px 15px; padding: 2px 0px 2px 2px;&quot;&gt;&lt;a href=&quot;http://reference.sitepoint.com/css/conditionalcomments&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;SitePoint: Conditional Comments →&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 24px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 10px 0px; orphans: 2; padding: 15px 0px 5px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Visual Designing with HTML5&lt;/h2&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Browser compatibility is just one of the many complex factors involved in hand-coding your own websites that can be taken care of with the right tools. The new HTML5 Website Builder from Wix is a completely free online tool for designing valid, rich HTML5 websites using a visual drag-and-drop editor, giving you the power of complete creative freedom. It is extremely easy to master and comes with an extensive library of animations, widgets and graphics to get you started designing with HTML5 right now. You can rapidly design and style any layout from the ground up and add HTML5 audio, video, slideshows and more without extensive and time-consuming hand-coding. Check it out &lt;a href=&quot;http://www.wix.com/html5/now-on-wix&quot; style=&quot;color: #5a7a9b; text-decoration: none;&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;
&lt;h2 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; color: #444444; font-family: &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 24px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; margin: 10px 0px; orphans: 2; padding: 15px 0px 5px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Hopefully this introduction to HTML5 and browser compatibility has provided you with a starting outline for designing a better experience for your visitors and clients. The HTMl5 specification is in the home stretch and adoption is expected to grow by leaps and bounds over the next few years, but there will always be a percentage out there somewhere that need consideration. As the web evolves, you can be sure that the need for graceful degradation and progressive enhancement will never go away, the techniques and requirements will simply change.&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/22px &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px 0px 15px; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
Is there something I missed? Tell us about it in the comments!&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://davenaimish.blogspot.com/feeds/5193223329114459532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4670920447169706502/5193223329114459532' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/5193223329114459532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4670920447169706502/posts/default/5193223329114459532'/><link rel='alternate' type='text/html' href='http://davenaimish.blogspot.com/2012/09/getting-to-grips-with-html5-browser.html' title='HTML5 Browser Compatibility'/><author><name>Naimish Dave</name><uri>http://www.blogger.com/profile/06276836027113003737</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPwyQDMDPMU_KuxTYCn6Swdhp_kYWsF6ZcIQCYVLQCEZZLFGSgwLFuNBReHMn8q04bzPLObuSvsEmVly3qctCUhWmNvxkKHjOh_Hso5_qvkKuTZVP8cUwDh5bgoaJgYQ/s220/2016-12-17-20-16-06.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgScYfWObCmy50_sFv0TJFqVs1OeDQOs62sDPdRgQAhDkGnyb5T1YNDQyYDLUiAalS9kXUNqNAKxUDTXgepOJKxc9aHLv2tlTck8KlBWm4x-pif_gmcgKGK0-y6oT_8KD7s4XBvekEh8Xs/s72-c/csshtml5.jpg" height="72" width="72"/><thr:total>0</thr:total></entry></feed>