<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>CppDepend</title>
	<atom:link href="http://cppdepend.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://cppdepend.wordpress.com</link>
	<description>CppDepend Cases Studies</description>
	<lastBuildDate>Wed, 26 Oct 2011 15:43:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='cppdepend.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>CppDepend</title>
		<link>http://cppdepend.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://cppdepend.wordpress.com/osd.xml" title="CppDepend" />
	<atom:link rel='hub' href='http://cppdepend.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Concurrency Runtime: Task Scheduler</title>
		<link>http://cppdepend.wordpress.com/2010/09/14/concurrency-runtime-task-scheduler/</link>
		<comments>http://cppdepend.wordpress.com/2010/09/14/concurrency-runtime-task-scheduler/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 15:56:03 +0000</pubDate>
		<dc:creator>cppdepend</dc:creator>
				<category><![CDATA[CodeProject]]></category>

		<guid isPermaLink="false">http://cppdepend.wordpress.com/?p=416</guid>
		<description><![CDATA[The Task Scheduler schedules and coordinates tasks at run time. A task is a unit of work that performs a specific job. The Task Scheduler manages the details that are related to efficiently scheduling tasks on computers that have multiple computing resources. Windows OS provides a preemptive kernel-mode scheduler,it&#8217;s a round-robin, priority-based mechanism that gives [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=416&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The Task Scheduler schedules and coordinates tasks at run time. A task is a unit of work that performs a specific job. The Task Scheduler manages the details that are related to efficiently scheduling tasks on computers that have multiple computing resources.</p>
<p>Windows OS provides a preemptive kernel-mode scheduler,it&#8217;s a round-robin, priority-based mechanism that gives every task exclusive access to a computing resource for a given time period, and then switches to another task.Although this mechanism provides fairness (every thread makes forward progress), it comes at some cost of efficiency.For example, many computation-intensive algorithms do not require fairness. Instead, it is important that related tasks finish in the least overall time. Cooperative scheduling enables an application to more efficiently schedule work.<br />
<span id="more-416"></span><br />
Cooperative scheduling is a mechanism that gives every task exclusive access to a computing resource until the task finishes or until the task yields its access to the resource.</p>
<p>The user-mode cooperative scheduler enables application code to make its own scheduling decisions. Because cooperative scheduling enables many scheduling decisions to be made by the application, it reduces much of the overhead that is associated with kernel-mode synchronization.</p>
<p>The Concurrency Runtime uses cooperative scheduling together with the preemptive scheduler of the operating system to achieve maximum usage of processing resources.</p>
<p>In this article we will discuss the Task Scheduler design and examine how it works internally. To do so, <a href="http://www.cppdepend.com">CppDepend</a> is ued to analyse the concurrency runtime code source.</p>
<p><span style="font-weight:bold;">Scheduler Design</span></p>
<p>The concurrency runtime provides the interface <span style="font-weight:bold;">Scheduler</span> to implement a specific scheduler adapted to application needs.</p>
<p>Let&#8217;s discover classes implementing this inerface:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt113.png"><img class="alignnone size-full wp-image-450" title="crt1" src="http://cppdepend.files.wordpress.com/2010/09/crt113.png?w=300&#038;h=256" alt="" width="300" height="256" /></a></div>
<p>
The concurrency runtime provides two implementations of the scheduler, <span style="font-weight:bold;">ThreadScheduler </span>and <span style="font-weight:bold;">UMSThreadScheduler</span>, and as shown in the dependency graph the <span style="font-weight:bold;">SchedulerBase</span> contains all common behavior of these two classes.</p>
<p>Is the Scheduler flexible? a good indicator of flexiblity is to search for all abstract classes used by the scheduler.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt104.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt104.png?w=600&#038;h=370" alt="" title="crt10" width="600" height="370" class="alignnone size-full wp-image-450" /></a>
</div>
<p>As shown in the dependency graph the Scheduler use many abstract classes,it enforces the low coupling, and make the scheduler  more flexible, so adapting it to other needs will be easy.</p>
<p>To explain  the role of each absract class used by the scheduler we will discuss its responsabilities.</p>
<p>There are three major responsabilities assigned to the Task Scheduler:</p>
<p><span style="font-weight:bold;">1) Getting Resources(Processors,Cores,Memory): </span></p>
<p>When the scheduler is created it ask for resources from runtime resource manager as explained in this <a href="http://www.drdobbs.com/windows/227300348">article</a>.</p>
<p>The scheduler communicate with resource manager using <span style="font-weight:bold;">IResourceManager</span>, <span style="font-weight:bold;">ISchedulerProxy</span> and <span style="font-weight:bold;">IScheduler </span>interfaces.</p>
<p>Resources given by resource manager use scheduler policy to allocate resources to the scheduler.<br />
The policy as shown in this dependency graph is assigned when the scheduler is created.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt25.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt25.png?w=600&#038;h=194" alt="" title="crt2" width="600" height="194" class="alignnone size-full wp-image-451" /></a></div>
<p>The concurrency runtime create a default scheduler if no scheduler exists by invocking GetDefaultScheduler method, and a default policy is used.<br />
The Task Scheduler enables applications to use one or more <span class="parameter">scheduler instances</span> to schedule work, and an application can invoke Scheduler::Create to add another scheduler that uses a specific policy.</p>
<p>The Concurrency::PolicyElementKey enumeration defines the policy keys that are associated with the Task Scheduler.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt83.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt83.png?w=261&#038;h=186" alt="" title="crt8" width="261" height="186" class="alignnone size-full wp-image-452" /></a>
</div>
<p>Here&#8217;s an <a href="http://help.outlook.com/en-us/140/ff829269.aspx">article </a>explaining the utility of each policy key, and the default value of each key.</p>
<p>The following  collaborations between the scheduler and resource manager shows the role of each interface concerned by the allocation.</p>
<p>- Ask for resource allocation:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt133.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt133.png?w=587&#038;h=154" alt="" title="crt13" width="587" height="154" class="alignnone size-full wp-image-453" /></a>
</div>
<p>- Getting resources from resource manager:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt143.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt143.png?w=597&#038;h=83" alt="" title="crt14" width="597" height="83" class="alignnone size-full wp-image-454" /></a></div>
<p><span style="font-weight:bold;">2)Manage Task Queues:</span></p>
<p>When Schedeluer is created, tasks could be assigned to it to be executed, the Scheduler store tasks into queues.to enforce the cohesion of classes, the queues are not managed directly by the ThreadScheduler class but by ScheduleGroupBase class.</p>
<p>A schedule group affinitizes, or groups, related tasks together. Every scheduler has one or more schedule groups. Use schedule groups when you require a high degree of locality among tasks, for example, when a group of related tasks benefit from executing on the same processor node.</p>
<p>As shown in the following graph, the runtime provides two kind of ScheduleGroup: <span style="font-weight:bold;">FairScheduleGroup</span> and <span style="font-weight:bold;">CacheLocalScheduleGroup</span>, choosing between those two groups as it will be explained later impact the algorithm of choosing the next task to execute by the scheduler.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt43.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt43.png?w=478&#038;h=230" alt="" title="crt4" width="478" height="230" class="alignnone size-full wp-image-455" /></a>
</div>
<p>Every <strong>Scheduler</strong> has a default schedule group for every scheduling node.The runtime creates one  scheduling node for every processor package or Non-Uniform Memory  Architecture (NUMA) node. If you do not  explicitly associate a task with a schedule group, the scheduler chooses  which group to add the task to.</p>
<p>As shown in the following dependency graph ,The schedulingRing is responsable of managing Scheduler Groups, it contains a list of groups and create them.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt51.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt51.png?w=600&#038;h=200" alt="" title="crt5" width="600" height="200" class="alignnone size-full wp-image-450" /></a></div>
<p>The  Schedule group contains three kind of queues:</p>
<p><span style="font-style:italic;">1) FIFO Queue</span></p>
<p>This queue contains lightweight tasks,a lightweight task resembles the function that you provide to the Windows API <span style="font-weight:bold;">CreateThread</span> function. Therefore, lightweight tasks are useful when you adapt  existing code to use the scheduling functionality of the Concurrency  Runtime.</p>
<p>A lighweight task is represented by <span style="font-weight:bold;">RealizedChore</span> class, and the FIFO queue of the schedule group is represented by the field m_realizedChores.</p>
<p>Let&#8217;s search all methods using directly this queue:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt63.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt63.png?w=342&#038;h=173" alt="" title="crt6" width="342" height="173" class="alignnone size-full wp-image-457" /></a>
</div>
<p>So we can add a lightweight task to the group by invoking ScheduleGroupBase::ScheduleTask  or Scheduler::ScheduleTask.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt123.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt123.png?w=600&#038;h=94" alt="" title="crt12" width="600" height="94" class="alignnone size-full wp-image-458" /></a></div>
<p>Here&#8217;s an interesting <a href="http://help.outlook.com/en-us/140/ff829270.aspx">article</a> talking about  lighweight tasks.</p>
<p><span style="font-style:italic;">2)Work Stealing queue:</span></p>
<p>There&#8217;s only one FIFO queue associated to the schedule group, but the schedule group reference a list of work sealing queues, for each worker thread there&#8217;s a local queue associated to it.</p>
<p>A thread that is attached to a scheduler is known as an <span class="parameter">execution context</span>, or just <span class="parameter">context</span>, so actually this local queue is associated to <span style="font-weight:bold;">Context </span>class.</p>
<p>The <span style="font-weight:bold;">Context </span>class provides a programming abstraction for an execution context and offer  the ability to cooperatively block,  unblock, and yield the current context.</p>
<p>And to be sure that only Context create this kind of queue, let&#8217;s search of method accessing directly to m_workQueues field.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt153.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt153.png?w=300&#038;h=195" alt="" title="crt15" width="300" height="195" class="aligncenter size-medium wp-image-459" /></a>
</div>
<p>So the context is responsable of creating this queue, and for each context there&#8217;s a local work stealing queue associated to it.</p>
<p>To illustrate the behavior of the work-stealing algorithm ,let&#8217;s imagine that we have two worker thread allocated to the scheduler.</p>
<p>As explained before for each worker thread there&#8217;s a local queue associated with it.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt164.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt164.png?w=360&#038;h=203" alt="" title="crt16" width="360" height="203" class="alignnone size-full wp-image-460" /></a>
</div>
<p>Imagine that we have <span class="longtext">three tasks in the queue of the Worker Thread 1, tasks 3 and 4 are waiting to be executed while the 5 is running.</span></p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt173.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt173.png?w=355&#038;h=201" alt="" title="crt17" width="355" height="201" class="alignnone size-full wp-image-461" /></a>
</div>
<p><span class="longtext">The Dispatch method finds that there is nothing in the queue, so  the task 3 is moved, or &#8220;stolen&#8221; from its original queue, to be distributed <span style="background:none repeat scroll 0 0 white;">the worker thread available.</span></span></p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt183.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt183.png?w=351&#038;h=199" alt="" title="crt18" width="351" height="199" class="alignnone size-full wp-image-462" /></a>
</div>
<p>How we can create a task managed by work stealing queue ?</p>
<p>To answer this question  let&#8217;s search for methods indirectly invocking the CreateWorkQueue method.</p>
<p>As shown in this dependency graph, this kind of task could be created by using task_group class.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt193.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt193.png?w=600&#038;h=200" alt="" title="crt19" width="600" height="200" class="alignnone size-full wp-image-450" /></a>
</div>
<p>Using task_group to add new task is more better than using Sheduler::ScheduleTask to create lighweight task, indeed the work stealing algorithm optimize better the using of virtual processors allocated to the scheduler.</p>
<p>However ScheduleTask could be better to migrate easilly from the existing code using CreateThread API.</p>
<p><span style="font-style:italic;">3)Unblocqued Context queue:</span></p>
<p>The <strong>Context</strong> class lets you block or yield the  current execution context. Blocking or yielding is useful when the  current context cannot continue because a resource is not available.<br />
The Context::Block method blocks the current context. A context that is blocked yields its  processing resources so that the runtime can perform other tasks. The  Context::Unblock method unblocks a blocked context.</p>
<p>When a context is unblocked and it&#8217;s available to be executed , it&#8217;s added to runnable context queue, this queue is represented by the field m_runnableContexts.</p>
<p>Here&#8217;s a dependency graph showing some cases where the context is added to runnable queue:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt291.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt291.png?w=600&#038;h=171" alt="" title="crt29" width="600" height="171" class="alignnone size-full wp-image-464" /></a>
</div>
<p>So the context is added to the queue when it&#8217;s unblocked or a virtual processor is retired from the scheduler.</p>
<p><span style="font-weight:bold;">3)Dispatching Tasks:</span></p>
<p>The scheduler try to search for work to execute, a work could be:</p>
<p>- Unblocked context.<br />
- Lightweight task.<br />
- Task  in work stealing queues.</p>
<p>And  as explained before all these works are stored in queues managed by  Schedule groups, and each group is managed by a scheduling ring.</p>
<p>When a virtual processor is allocated to the scheduler a ThreadProxy class is created and associated to this processor. and after the creation the Dispatch method of the ThreadProxy is invoked.<br />
As shown in the following dependency graph and as explained before the concurrency runtime use abstract classes to enforces low coupling, and the real dispatch invoked depends of the implementation choosed by the runtime, this choice is given by the scheduler policy.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt312.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt312.png?w=409&#038;h=162" alt="" title="crt31" width="409" height="162" class="alignnone size-full wp-image-465" /></a>
</div>
<p>The concrete implementation of Dispatch invoke Dispatch Method of the execution context.</p>
<p>Here&#8217;s a dependec graph showing  methods invocked by concrete implementation of Context::Dispatch method:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt203.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt203.png?w=600&#038;h=91" alt="" title="crt20" width="600" height="91" class="alignnone size-full wp-image-466" /></a></div>
<p>So the algorithm of searching the next work to execute is implemented by<span style="font-weight:bold;"> </span><span style="font-weight:bold;">WorkSearchContext</span> class.</p>
<p>Let&#8217;s discover all classes used directly by WorkSearchContext to achieve its responsability:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt232.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt232.png?w=544&#038;h=260" alt="" title="crt23" width="544" height="260" class="alignnone size-full wp-image-467" /></a>
</div>
<p>The responsability of WorkSearchContext is to give us a <span style="font-weight:bold;">WorkItem</span> to execute, it could be InternalContextBase, RealizedChore or _UnrealizedChore.</p>
<p>To understand better the collaboration between these classes , let&#8217;s search for methods used directly by WorkSearchContext:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt301.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt301.png?w=348&#038;h=488" alt="" title="crt30" width="348" height="488" class="alignnone size-full wp-image-468" /></a>
</div>
<p>So the WorkSearchContext iterate on <span style="font-weight:bold;">SchedulingRing </span>and <span style="font-weight:bold;">SheduleGroup </span>classes by using SchedulerBase methods.</p>
<p>And for each ScheduleBase we search for RunnableContext, realizedChore or UnrealizedChore.</p>
<p>The WorkSearchContext class is created by the <span style="font-weight:bold;">VirtualProcessor </span>class, and as shown in the following dependency graph, the algorithm used is specified when the VirtualProcessor is initialized, and for that it ask the Scheduler for the <span style="font-weight:bold;">SchedulingProtocol</span> which describe the scheduling algorithm that will be utilized for the scheduler.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt213.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt213.png?w=420&#038;h=219" alt="" title="crt21" width="420" height="219" class="alignnone size-full wp-image-469" /></a>
</div>
<p>The WorkSearchContext will be notified by the algorithm to use by passing it a value from Algorithm enum.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt281.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt281.png?w=243&#038;h=66" alt="" title="crt28" width="243" height="66" class="alignnone size-full wp-image-470" /></a>
</div>
<p>So two algorithmes are implemented by this class to find a work:</p>
<p>- Cache Local algorithm:</p>
<p>This algorithm will look for runnables context within the current schedule group,then realized chores and unrealized chores, if there&#8217;s no more work in the curent schedule group it looks for the next group in the same shedule ring, and when it finishes all works in the current schedule ring it looks in the next schedule ring.</p>
<p>So the scheduler prefers to continue to work on tasks within the current schedule group before moving to another schedule group.</p>
<p>This algorithm is implemented by WorkSearchContext::SearchCacheLocal method, and as show by this dependency graph, this method search invoke other methods to search for runnable contexts, RealizedChore or _UnrealizedChore.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt261.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt261.png?w=600&#038;h=176" alt="" title="crt26" width="600" height="176" class="alignnone size-full wp-image-471" /></a>
</div>
<p>Another specificity of this algorithm is that the unblocked contexts are cached per virtual-processor and are typically scheduled in a last-in first-out (LIFO) fashion by the virtual processor which unblocked them.</p>
<p>And to verify this behavior, here&#8217;s a dependency graph of methods invocked when searching for runnable context:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt242.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt242.png?w=600&#038;h=76" alt="" title="crt24" width="600" height="76" class="alignnone size-full wp-image-472" /></a></div>
<p>This algorithm is the default algorithm choosen by the scheduler if no one is specified.</p>
<p>- Fair algorithm:</p>
<p>In this case the scheduler prefers to round-robin through schedule groups after  executing each task. Unblocked contexts are typically scheduled in a  first-in-first-out (FIFO) fashion. Virtual processors do not cache  unblocked contexts.</p>
<p>This algorithm is implemented by WorkSearchContext::SearchFair  method, and as show by this dependency graph, this method search invoke  other methods to search for runnable contexts, RealizedChore or  _UnrealizedChore.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt271.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt271.png?w=575&#038;h=232" alt="" title="crt27" width="575" height="232" class="alignnone size-full wp-image-473" /></a>
</div>
<p>After this analysis we can say that The concurrent runtime task scheduler is well designed , it&#8217;s characterized by a high cohesion and very low copling, it&#8217;s very flexible and provides by default an optimized algorithm to exploit better hardware resources.</p>
<br />Filed under: <a href='http://cppdepend.wordpress.com/category/codeproject/'>CodeProject</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppdepend.wordpress.com/416/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppdepend.wordpress.com/416/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppdepend.wordpress.com/416/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppdepend.wordpress.com/416/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppdepend.wordpress.com/416/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppdepend.wordpress.com/416/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppdepend.wordpress.com/416/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppdepend.wordpress.com/416/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppdepend.wordpress.com/416/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppdepend.wordpress.com/416/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppdepend.wordpress.com/416/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppdepend.wordpress.com/416/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppdepend.wordpress.com/416/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppdepend.wordpress.com/416/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=416&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppdepend.wordpress.com/2010/09/14/concurrency-runtime-task-scheduler/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/92d6551df2d319e31f6d7f0af63ddce4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cppdepend</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt113.png?w=300" medium="image">
			<media:title type="html">crt1</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt104.png" medium="image">
			<media:title type="html">crt10</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt25.png" medium="image">
			<media:title type="html">crt2</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt83.png" medium="image">
			<media:title type="html">crt8</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt133.png" medium="image">
			<media:title type="html">crt13</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt143.png" medium="image">
			<media:title type="html">crt14</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt43.png" medium="image">
			<media:title type="html">crt4</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt51.png?w=300" medium="image">
			<media:title type="html">crt5</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt63.png" medium="image">
			<media:title type="html">crt6</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt123.png" medium="image">
			<media:title type="html">crt12</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt153.png?w=300" medium="image">
			<media:title type="html">crt15</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt164.png" medium="image">
			<media:title type="html">crt16</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt173.png" medium="image">
			<media:title type="html">crt17</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt183.png" medium="image">
			<media:title type="html">crt18</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt193.png?w=300" medium="image">
			<media:title type="html">crt19</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt291.png" medium="image">
			<media:title type="html">crt29</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt312.png" medium="image">
			<media:title type="html">crt31</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt203.png" medium="image">
			<media:title type="html">crt20</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt232.png" medium="image">
			<media:title type="html">crt23</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt301.png" medium="image">
			<media:title type="html">crt30</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt213.png" medium="image">
			<media:title type="html">crt21</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt281.png" medium="image">
			<media:title type="html">crt28</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt261.png" medium="image">
			<media:title type="html">crt26</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt242.png" medium="image">
			<media:title type="html">crt24</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt271.png" medium="image">
			<media:title type="html">crt27</media:title>
		</media:content>
	</item>
		<item>
		<title>CRT Concurrency Runtime: Resource Manager</title>
		<link>http://cppdepend.wordpress.com/2010/09/04/crt-concurrency-runtime-resource-manager/</link>
		<comments>http://cppdepend.wordpress.com/2010/09/04/crt-concurrency-runtime-resource-manager/#comments</comments>
		<pubDate>Sat, 04 Sep 2010 18:32:19 +0000</pubDate>
		<dc:creator>cppdepend</dc:creator>
				<category><![CDATA[CodeProject]]></category>

		<guid isPermaLink="false">http://cppdepend.wordpress.com/?p=356</guid>
		<description><![CDATA[Visual C++ 2010 comes with interesting new features and enhancements to simplify more native programming. The Concurrency Runtime is an added framework to simplify parallel programming and helps you write robust, scalable, and responsive parallel applications. The Concurrency Runtime raises the level of abstraction so that you do not have to manage the infrastructure details [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=356&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Visual C++ 2010 comes with interesting new features and enhancements to simplify more native programming. The Concurrency Runtime is an added framework to simplify parallel programming and helps you write robust, scalable, and responsive parallel applications.</p>
<p>The Concurrency Runtime raises the level of abstraction so that you do not have to manage the infrastructure details that are related to concurrency. The Concurrency Runtime also enables you to specify scheduling policies that meet the quality of service demands of your applications.<br />
<span id="more-356"></span></p>
<p>Here’s the architecture of Concurrent Runtime Framework:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt10.png"><img style="cursor:pointer;width:296px;height:270px;" src="http://cppdepend.files.wordpress.com/2010/09/crt10.png?w=296" alt="" border="0" /></a>
</div>
<p>And to have more information’s about this framework, here’s a good <a href="http://blogs.msdn.com/b/nativeconcurrency/archive/2009/01/12/an-introduction-to-native-concurrency-in-visual-studio-2010.aspx">introduction </a>about it.</p>
<p>In this article we will discuss the Resource Manager layer, and try to discover how it works internally.For that <a href="http://www.cppdepend.com/">CppDepend</a> is used to analyse CRT Concurrency Runtime code source.</p>
<p>Before reading this article it&#8217;s better to take a look at these interesting articles about ResourceManager:<br />
</p>
<ul>
<li><a href="http://blogs.msdn.com/b/nativeconcurrency/archive/2009/03/10/resource-management-in-the-concurrency-runtime-part-1.aspx">Resource Management in Concurrency Runtime &#8211; Part 1</a>
</li>
<li><a href="http://blogs.msdn.com/b/nativeconcurrency/archive/2009/07/21/resource-management-in-concurrency-runtime-part-2.aspx">Resource Management in Concurrency Runtime &#8211; Part 2 </a>
</li>
<li><a href="http://blogs.msdn.com/b/nativeconcurrency/archive/2009/11/13/resource-management-in-concurrency-runtime-part-3.aspx">Resource Management in Concurrency Runtime &#8211; Part 3</a>
</li>
</ul>
<p><span style="font-weight:bold;color:rgb(51,102,255);"><br />
ResourceManager Design</span></p>
<p><span style="font-style:italic;color:rgb(51,102,255);">Which classes are used by ResourceManager to achieve its responsibility?</span></p>
<p><span style="color:rgb(51,51,255);">SELECT TYPES WHERE</span> IsDirectlyUsedBy &#8220;<span style="color:rgb(255,0,0);">Concurrency.details.ResourceManager</span>&#8220;</p>
<p><a href="http://cppdepend.files.wordpress.com/2010/09/crt110.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt110.png?w=600&#038;h=377" alt="" title="crt1" width="600" height="377" class="alignnone size-full wp-image-389" /></a></p>
<p>The first remark about this design is that it enforces the:</p>
<p>- High Cohesion: Many classes and structs are used by resource manager, each one has a specific responsability, it makes the design very clear.<span style="color:rgb(0,0,0);">The single responsibility  principle states that a class should have more than one reason to  change. Such a class is said to be cohesive.</span><span style="color:rgb(0,0,0);"> A high LCOM value generally  pinpoints a poorly cohesive class. There are several LCOM metrics. The  LCOM takes its values in the range [0-1]. The LCOMHS (HS stands for  Henderson-Sellers) takes its values in the range [0-2]. Note that the  LCOMHS metric is often considered as more efficient to detect  non-cohesive types.</span></p>
<p>LCOMHS value higher than 1 should be considered alarming.</p>
<p><span style="color:rgb(51,51,255);"><br />
WARN IF</span> Count &gt; 0 <span style="color:rgb(51,51,255);">IN SELECT</span> TYPES <span style="color:rgb(51,51,255);">WHERE </span>LCOMHS &gt; 1 <span style="color:rgb(51,51,255);">AND </span>NbFields &gt; 10            <span style="color:rgb(51,51,255);"><br />
                          AND       </span>NbMethods &gt;10 <span style="color:rgb(51,51,255);">AND </span>!IsGlobal <span style="color:rgb(51,51,255);">ORDER BY </span>LCOMHS DESC</p>
<div style="text-align:center;">
<a href="http://cppdepend.files.wordpress.com/2010/09/crt141.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt141.png?w=482&#038;h=132" alt="" title="crt14" width="482" height="132" class="alignnone size-full wp-image-391" /></a>
</div>
<p>So among classes used by ResourceManager, only UMS is considered as class with a  poor cohesion.</p>
<p>- Low Coupling:Many interfaces and proxies are used to isolate ResourceManager from other components.<br />
The Scheduler communicate with ResourceManager but there&#8217;s no direct link between Two components, so how the scheduler communicate with ResourceManager?</p>
<p>To answer to this question let&#8217;s discover classes using ResourceManager:</p>
<p><span style="color:rgb(51,102,255);">SELECT TYPES WHERE</span> IsDirectlyUsing &#8220;<span style="color:rgb(255,0,0);">Concurrency.details.ResourceManager</span>&#8220;</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt71.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt71.png?w=600&#038;h=216" alt="" title="crt7" width="600" height="216" class="alignnone size-full wp-image-392" /></a>
</div>
<p>Only these classes use the ResourceManager, and the Scheduler doesnt know the ResourceManager directly , so how it interact with it? let&#8217;s add to dependency graph the scheduler and interfaces used by it.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt81.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt81.png?w=600&#038;h=272" alt="" title="crt8" width="600" height="272" class="alignnone size-full wp-image-393" /></a>
</div>
<p>As shown in the dependency graph the Scheduler communicate with ResourceManager using interfaces IResourceManager,ISchedulere and ISchedulerProxy.</p>
<p><span style="font-style:italic;color:rgb(51,102,255);">Where the ResourceManager is created?</span><br />
<br />
<span style="color:rgb(51,102,255);">SELECT METHODS WHERE</span> DepthOfCreateA &#8220;<span style="color:rgb(255,0,0);">Concurrency.details.ResourceManager</span>&#8221; == 1</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt162.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt162.png?w=362&#038;h=140" alt="" title="crt16" width="362" height="140" class="alignnone size-full wp-image-395" /></a>
</div>
<p>Only ResourceManager create an instance, and it&#8217;s a singleton so only one ResourceManager exist for the whole process.</p>
<p><span style="font-weight:bold;color:rgb(51,102,255);">Workflow of resource allocation:</span></p>
<p><span style="font-style:italic;color:rgb(51,102,255);">Step 1: Get resources information&#8217;s from system</span><br />
<br />
The Resource manager need all physical information’s concerning processors and cores to use them when allocating resources for schedulers.Let&#8217;s discover all data manipulated by this component.</p>
<p><span style="color:rgb(51,102,255);">SELECT FIELDS WHERE</span> IsDirectlyUsedBy &#8220;<span style="color:rgb(255,0,0);">Concurrency.details.ResourceManager</span>&#8220;</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt23.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt23.png?w=360&#038;h=378" alt="" title="crt2" width="360" height="378" class="alignnone size-full wp-image-396" /></a>
</div>
<p>These structs represent all data needed by ResourceManager, the basic ones are ProcessorCore and ProcessorNode representing information&#8217;s about physical resources.</p>
<p>Other structs contains some scheduler data needed for the allocation algorithm.</p>
<p>The good news is that ResourceManager didnt directly access to fields of other logical classes used by it.</p>
<p>Let&#8217;s search where Resourcemanager get basic information&#8217;s about physical resources, for that we can search for methods using GetLogicalProcessorInformation.</p>
<p><span style="color:rgb(51,102,255);">SELECT METHODS WHERE</span> IsDirectlyUsing &#8220;<span style="color:rgb(255,0,0);">WindowsAPIGlobalMembers.GetLogicalProcessorInformation(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION,PDWORD)</span>&#8220;</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt41.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt41.png?w=336&#038;h=147" alt="" title="crt4" width="336" height="147" class="alignnone size-full wp-image-397" /></a>
</div>
<p>Only ResourceManager::InitializeSystemInformation use this method, to get information&#8217;s from system, but it&#8217;s this method responsible of populating ProcessorCore and ProcessorNode?</p>
<p>For that we can search for methods assigning a fields of ProcessorCore:<br />
<span style="color:rgb(51,102,255);">SELECT METHODS WHERE</span> IsDirectlyWritingField &#8220;<span style="color:rgb(255,0,0);">Concurrency.details.ProcessorCore.m_processorNumber</span>&#8220;</p>
<div style="text-align:center;">
<a href="http://cppdepend.files.wordpress.com/2010/09/crt31.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt31.png?w=340&#038;h=169" alt="" title="crt3" width="340" height="169" class="alignnone size-full wp-image-398" /></a>
</div>
<p>So ResourceManager invoke DetermineTopology method to populate data into structs.<br />
<br />
And here&#8217;s a dependency graph showing methods concerned by getting nodes and cores information&#8217;s.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt151.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt151.png?w=592&#038;h=388" alt="" title="crt15" width="592" height="388" class="alignnone size-full wp-image-399" /></a>
</div>
<p><span style="color:rgb(51,102,255);font-style:italic;">Step2: Scheduler ask for resource allocation</span><br />
<br />
After ResourceManager get all data needed for allocation algorithm, a  scheduler can ask it to allocate ressources.</p>
<p>When the Scheduler is created it ask for a ResourceManager and invoke  CreateResourceManager to get the singleton, after that it invokes  IResourceManager::RegisterScheduler to register it self with the resource manager, and get a pointer to ISchedulerProxy, and with this interface the Scheduler will interact with the resource manager.<br />
<br />
After that the Scheduler is ready to ask for resources allocation by invocking RequestInitialVirtualProcessors.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt171.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt171.png?w=525&#038;h=240" alt="" title="crt17" width="525" height="240" class="alignnone size-full wp-image-400" /></a>
</div>
<p>And as explained before the Scheduler communicate with resource manager using IScheduleProxy interface to enforces low coupling, and the concrete implemenatation of this interface invoke ResourceManager::RequestInitialVirtualprocessors.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt181.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt181.png?w=401&#038;h=127" alt="" title="crt18" width="401" height="127" class="alignnone size-full wp-image-401" /></a>
</div>
<p><span style="color:rgb(51,102,255);font-style:italic;">Step3: Resources allocation</span><br />
<br />
The resource Manager have to give resources to schedulers when schedulers are created.It will do the  allocation depending on the policies and taking into account the other  schedulers in the process. Eventually the resources will be provided to  the scheduler in need.</p>
<p>The entry point of allocating request is RequestInitialVirtualProcessors, and here&#8217;s a dependency graph showing methods used to acheive allocation.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt61.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt61.png?w=600&#038;h=619" alt="" title="crt6" width="600" height="619" class="alignnone size-full wp-image-402" /></a>
</div>
<p>PerformAllocation method implements the allocation logic, it ask for Scheduler policies from SchedulerProxy, and invoke AllocateCores method to perform allocation.</p>
<p>Here&#8217;s some characteristics of PerformAllocation and AllocateCores:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt121.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt121.png?w=355&#038;h=145" alt="" title="crt12" width="355" height="145" class="alignnone size-full wp-image-403" /></a>
</div>
<p></p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt111.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt111.png?w=352&#038;h=153" alt="" title="crt11" width="352" height="153" class="alignnone size-full wp-image-404" /></a>
</div>
<p>Thoses methods are very well documented and the cyclomatic complexity is not high, and it&#8217;s a good indicator that the algorithm of initial allocation is not very complicated.</p>
<p><span style="font-style:italic;color:rgb(51,102,255);">Step4: giving resources to Scheduler</span><br />
<br />
After ResourceManager allocate Resources , the scheduler is notified with resources allocated, for that the resource manager invoke GrantAllocation method.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt131.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt131.png?w=600&#038;h=323" alt="" title="crt13" width="600" height="323" class="alignnone size-full wp-image-405" /></a>
</div>
<p><span style="font-style:italic;color:rgb(51,51,255);">What resources the ResourceManager have to give to Scheduler?</span><br />
<br />
As described in msdn articles mentioned below related to resource manager, the resource is a virtual processor associated to a specific thread and runing in a specific core.<br />
<br />
But as shown in the dependency graph the resource manager dont give VirtualProcessors to SchedulerProxy but an array of SchedulerNodes, the SchedulerProxy create VirtualProcessorRoot classes, VirtualProcessorRoot represent an abstraction for a hardware thread on which a thread proxy can execute.</p>
<p><span style="font-style:italic;color:rgb(51,102,255);">Who is creating VirtualProcessor?</span><br />
<br />
Before answering to this question let&#8217;s search for classes that represent a Virtual Processor, so let&#8217;s search for classes inheriting from this one.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt191.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt191.png?w=418&#038;h=136" alt="" title="crt19" width="418" height="136" class="alignnone size-full wp-image-406" /></a>
</div>
<p>So VirtualProcessor could concern a simple thread or an UMS Thread.<br />
<br />
User-mode scheduling (UMS) is a light-weight mechanism introduced in Windows7 and Windows server 2008 R2, that applications  can use to schedule their own threads. For more information, see <a href="http://msdn.microsoft.com/en-us/library/dd627187%28v=VS.85%29.aspx">User-Mode Scheduling</a>.</p>
<p>Let&#8217;s search for methods creating ThreadVirtualProcessor.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt201.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt201.png?w=384&#038;h=140" alt="" title="crt20" width="384" height="140" class="alignnone size-full wp-image-407" /></a>
</div>
<p>So the Scheduler is the responsible of creating VirtualProcessors, and all information&#8217;s needed to create it are given by manager.</p>
<p><span style="font-style:italic;color:rgb(51,102,255);">Step5:Dynamic managing resources</span><br />
<br />
After the initial allocation of resources, the second main responsability of resource manager is to Constantly monitoring utilization of resources by schedulers, and dynamically migrating resources between schedulers.</p>
<p>And as shown in the following graph the resource manager create DynamicRM Thread,This worker thread wakes up at fixed intervals and load balances resources among schedulers.<br />
</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt211.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt211.png?w=600&#038;h=94" alt="" title="crt21" width="600" height="94" class="alignnone size-full wp-image-408" /></a>
</div>
<p>And here&#8217;s the dependency graph of DynamicResourceManager:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt102.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt102.png?w=588&#038;h=574" alt="" title="crt10" width="588" height="574" class="alignnone size-full wp-image-410" /></a>
</div>
<p><span style="font-weight:bold;color:rgb(51,51,255);">Is ResourceManager customizable?</span><br />
<br />
ResourceManager is well designed and is decoupled from other Concurrency Runtime framework by using interfaces, but it&#8217;s possible to customize the allocation behavior of resource manager.</p>
<p>For that let&#8217;s search for ResourceManager virtual methods:</p>
<p><span style="color:rgb(51,102,255);">SELECT METHODS FROM TYPES</span>  &#8220;<span style="color:rgb(255,0,0);">Concurrency.details.ResourceManager</span>&#8221; <span style="color:rgb(51,102,255);">WHERE</span> IsVirtual</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/09/crt221.png"><img src="http://cppdepend.files.wordpress.com/2010/09/crt221.png?w=364&#038;h=158" alt="" title="crt22" width="364" height="158" class="alignnone size-full wp-image-409" /></a>
</div>
<p>Only these methods are virtual and they implements the IResourceManager methods,so it&#8217;s not possible to overload allocation resource manager logic and customize it.</p>
<br />Filed under: <a href='http://cppdepend.wordpress.com/category/codeproject/'>CodeProject</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppdepend.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppdepend.wordpress.com/356/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppdepend.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppdepend.wordpress.com/356/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppdepend.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppdepend.wordpress.com/356/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppdepend.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppdepend.wordpress.com/356/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppdepend.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppdepend.wordpress.com/356/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppdepend.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppdepend.wordpress.com/356/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppdepend.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppdepend.wordpress.com/356/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=356&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppdepend.wordpress.com/2010/09/04/crt-concurrency-runtime-resource-manager/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/92d6551df2d319e31f6d7f0af63ddce4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cppdepend</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt10.png?w=296" medium="image" />

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt110.png" medium="image">
			<media:title type="html">crt1</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt141.png" medium="image">
			<media:title type="html">crt14</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt71.png" medium="image">
			<media:title type="html">crt7</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt81.png" medium="image">
			<media:title type="html">crt8</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt162.png" medium="image">
			<media:title type="html">crt16</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt23.png" medium="image">
			<media:title type="html">crt2</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt41.png" medium="image">
			<media:title type="html">crt4</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt31.png" medium="image">
			<media:title type="html">crt3</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt151.png" medium="image">
			<media:title type="html">crt15</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt171.png" medium="image">
			<media:title type="html">crt17</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt181.png" medium="image">
			<media:title type="html">crt18</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt61.png" medium="image">
			<media:title type="html">crt6</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt121.png" medium="image">
			<media:title type="html">crt12</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt111.png" medium="image">
			<media:title type="html">crt11</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt131.png" medium="image">
			<media:title type="html">crt13</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt191.png" medium="image">
			<media:title type="html">crt19</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt201.png" medium="image">
			<media:title type="html">crt20</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt211.png" medium="image">
			<media:title type="html">crt21</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt102.png" medium="image">
			<media:title type="html">crt10</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/09/crt221.png" medium="image">
			<media:title type="html">crt22</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual C++ 2010: What’s new for MFC library?</title>
		<link>http://cppdepend.wordpress.com/2010/08/29/visual-c-2010-what%e2%80%99s-new-for-mfc-library/</link>
		<comments>http://cppdepend.wordpress.com/2010/08/29/visual-c-2010-what%e2%80%99s-new-for-mfc-library/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 16:23:04 +0000</pubDate>
		<dc:creator>cppdepend</dc:creator>
				<category><![CDATA[CodeProject]]></category>

		<guid isPermaLink="false">http://cppdepend.wordpress.com/?p=282</guid>
		<description><![CDATA[Some years ago I thought that MFC will be obsolete, and no new features will be added, but I was wrong, VS2008 added many features and enhancements, and with VS 2010 I discovered new improvements. So what&#8217;s new in MFC 10? to answer to this question I tried to compare the two versions MFC 9 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=282&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Some years ago I thought that MFC will be obsolete, and no new features will be added, but I was wrong, VS2008 added many features and enhancements, and with VS 2010 I discovered new improvements.</p>
<p>So what&#8217;s new in MFC 10? to answer to this question I tried to compare the two versions MFC 9 and MFC 10 using <a href="http://www.cppdepend.com/">CppDepend</a>.</p>
<p><span id="more-282"></span><br />
<span style="font-weight:bold;color:rgb(51,102,255);">Removed classes:</span></p>
<p>Let&#8217;s begin with breaking changes and search for removed classes:</p>
<p><span style="color:rgb(51,102,255);">SELECT TYPES WHERE</span> WasRemoved</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc110.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc110.png?w=382&#038;h=236" alt="" title="mfcc1" width="382" height="236" class="alignnone size-full wp-image-321" /></a>
</div>
<p>
<span style="color:rgb(51,102,255);">     </span><br />
<br />
It was very strange that this class is removed , and to be sure I searched in the code source and I found it inside #ifdef ENABLE_RIBBON_LAUNCH_BUTTON statement.</p>
<p>The only resource I found in the web talking about this change is <a href="http://social.msdn.microsoft.com/Forums/en/vcmfcatl/thread/29ad2859-6341-4ffb-85c2-f5f056a6ca48">here</a> , and I dont know if<br />
adding #define ENABLE_RIBBON_LAUNCH_BUTTON is suficient to compile without problem.</p>
<p><span style="font-weight:bold;color:rgb(51,102,255);">Added Classes:</span></p>
<p><span style="color:rgb(51,102,255);">SELECT TYPES WHERE</span> WasAdded <span style="color:rgb(51,102,255);">AND </span>isClass</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc22.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc22.png?w=382&#038;h=435" alt="" title="mfcc2" width="382" height="435" class="alignnone size-full wp-image-323" /></a>
</div>
<p>
<span style="color:rgb(51,102,255);">     </span><br />
<br />
What&#8217;s the new features added by these classes?</p>
<p><span style="font-weight:bold;">CMFCRibbonCollector,CMFCRibbonConstructor,CMFCRibbonInfo</span>:<br />
When I searched in MSDN the utility of these classes , I didnt found any useful informations, so I searched for methods using CMFCRibbonInfo.</p>
<p><span style="color:rgb(51,102,255);">SELECT METHODS WHERE</span> IsDirectlyUsing &#8220;<span style="color:rgb(255,102,102);">CMFCRibbonInfo</span>&#8220;</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc32.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc32.png?w=359&#038;h=268" alt="" title="mfcc3" width="359" height="268" class="alignnone size-full wp-image-324" /></a>
</div>
<p>
<span style="color:rgb(51,102,255);">     </span><br />
<br />
The RibbonBar class use CMFCRibbonInfo to save it to xml or load  it.</p>
<p><span style="font-weight:bold;">CJumpList,CAppDestinations:</span><br />
Jump list is a new useful Window7 feature, it adds a new way of interaction between user and application.<br />
here&#8217;s a good <a href="http://www.codeguru.com/columns/kate/article.php/c17089/Adding-Windows-7-Jump-Lists-to-Visual-C-Applications.htm">article </a>to add JumpList feature with MFC.</p>
<p><span style="font-weight:bold;">CMFCControlContainer:</span></p>
<p>This class provides a CWnd support for MFC Control containment of Feature Pack controls.</p>
<p>And to know which controls can be contained inside this container, let&#8217;s search for classes used by CMFCControlContainer::CreateDlgControl.</p>
<p>Here&#8217;s the result:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc20.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc20.png?w=393&#038;h=339" alt="" title="mfcc20" width="393" height="339" class="alignnone size-full wp-image-349" /></a>
</div>
<p>So only these  MFC feature pack controls are concerned by this container.</p>
<p><span style="font-weight:bold;">CDocument::CDocumentAdapter</span>:</p>
<p>This class implements ATL::IDocument interface required for &#8220;Search and Organize&#8221; feature.<br />
My first impression when I discovered this implemention was &#8221; WOW, MFC use now interfaces to enforce low coupling&#8221;.</p>
<p>Let&#8217;s see the impact of using this interface, for that let&#8217;s search for classes using CDocumentAdapter :</p>
<p><span style="color:rgb(51,102,255);">SELECT TYPES WHERE </span> IsDirectlyUsing &#8220;<span style="color:rgb(255,0,0);">CDocument+CDocumentAdapter</span>&#8220;</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc211.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc211.png?w=338&#038;h=135" alt="" title="mfcc21" width="338" height="135" class="alignnone size-full wp-image-350" /></a>
</div>
<p>Only CDocument use directly this class.</p>
<p>However IDocument is used by other classes like the new class CMFCPreviewCtrlImpl,  so this class can work with CDocumentAdapter and also others classes implementing this interface.</p>
<p>And as explained in the  comment of CDocumentAdapter code source:</p>
<p>&#8220;Search and Organize handlers are implemented in ATL DLLs, which can be MFC or not-MFC based.Internally handlers refer to IDocument interface, whose implementation in the common case should be supplied by a developer. CDocumentAdapter provides this implementation for MFC and basically calls the appropriate methods of the parent CDocument.&#8221;</p>
<p><span style="font-weight:bold;">CDataRecoveryHandler</span>:<br />
This class autosaves documents and restores them if an application unexpectedly exits, it&#8217;s used by Restart Manager feature, here&#8217;s an interesting <a href="http://blogs.msdn.com/b/vcblog/archive/2009/02/18/mfc-restart-manager.aspx">article </a>talking about it.</p>
<p>Let&#8217;s search for classes used by CDataRecoveryHandler:</p>
<p><span style="color:rgb(51,102,255);">SELECT TYPES WHERE</span> IsDirectlyUsedBy &#8220;<span style="color:rgb(255,0,0);">CDataRecoveryHandler</span>&#8220;</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc152.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc152.png?w=600&#038;h=296" alt="" title="mfcc15" width="600" height="296" class="alignnone size-full wp-image-325" /></a>
</div>
<p>CDataRecoveryHandler is highly coupled with other MFC classes like CDocument, CWinApp, CWnd.</p>
<p>Which MFC classes use the recovery feature?</p>
<p><span style="color:rgb(51,102,255);">SELECT TYPES WHERE</span> IsDirectlyUsing &#8220;<span style="color:rgb(255,0,0);">CDataRecoveryHandler</span>&#8220;</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc81.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc81.png?w=323&#038;h=215" alt="" title="mfcc8" width="323" height="215" class="alignnone size-full wp-image-327" /></a>
</div>
<p><span style="color:rgb(51,102,255);">     </span><br />
So all these classes benefit of this new feature especially CDocument.</p>
<p><span style="font-weight:bold;">CTaskDialog:</span><br />
A pop-up dialog box that functions like a message box but can display additional information to the user.<br />
here&#8217;s an interesting <a href="http://www.nuonsoft.com/blog/2009/06/10/ctaskdialog-in-mfc-in-visual-c-2010/">article </a>talking about this feature.</p>
<p><span style="font-weight:bold;">CMFCVisualManagerVS2008,CMFCVisualManagerWindows7:</span><br />
Gives an application the apparence of a VS2008 or Windows 7 application.</p>
<p><span style="font-weight:bold;">CGestureConfig:<br />
</span>Used for touch feature.</p>
<p><span style="font-weight:bold;">CFolderPickerDialog:</span><br />
CFolderPickerDialog class implements CFileDialog in the folder picker mode.</p>
<p><span style="font-weight:bold;">CXMLParser,CXMLParserCollection,CXMLParserRoot: </span><br />
when I dsicovered these classes, I thought that is concerning xml parsing but when I searched for methods using them, I discovered that only CMFCRibbonInfo use them to save or load its description to xml files.</p>
<p><span style="color:rgb(51,102,255);">SELECT METHODS WHERE</span> IsDirectlyUsing &#8220;<span style="color:rgb(255,0,0);">CXMLParserRoot</span>&#8220;</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc41.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc41.png?w=362&#038;h=220" alt="" title="mfcc4" width="362" height="220" class="alignnone size-full wp-image-328" /></a>
</div>
<p><span style="color:rgb(51,102,255);">     </span><br />
<span style="font-weight:bold;">CMFCZoomKernel,CMFCScanliner, CMFCScanlinerBitmap :</span><br />
Not yet documented in MSDN, let&#8217;s discover which classes use them.</p>
<p><span style="color:rgb(51,102,255);">SELECT TYPES WHERE</span> IsDirectlyUsing &#8220;<span style="color:rgb(255,0,0);">CMFCZoomKernel</span>&#8220;</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc181.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc181.png?w=316&#038;h=134" alt="" title="mfcc18" width="316" height="134" class="alignnone size-full wp-image-329" /></a>
</div>
<p><span style="color:rgb(51,102,255);">     </span><br />
And we have the same result for the two other classes.</p>
<p><span style="font-weight:bold;color:rgb(51,102,255);">Methods Removed:</span></p>
<p><span style="color:rgb(51,102,255);">SELECT METHODS WHERE</span> WasRemoved</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc51.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc51.png?w=363&#038;h=377" alt="" title="mfcc5" width="363" height="377" class="alignnone size-full wp-image-330" /></a>
</div>
<p><span style="color:rgb(51,102,255);">     </span><br />
Almost all these methodes are not removed but only the signature is changed , and some optional parameters are added, however some methods are removed like CCommandManager::ResetAllImages or CPanelDialog::ClipPaint, and  one method was renamed from CMFCRibbonBar::GetTabTrancateRatio to CMFCRibbonBar::GetTabTruncateRatio.</p>
<p><span style="font-weight:bold;color:rgb(51,102,255);">Methods Added:</span></p>
<p>Let&#8217;s search for all methods added to MFC10</p>
<p><span style="color:rgb(51,102,255);">SELECT METHODS WHERE</span> WasAdded</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc61.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc61.png?w=365&#038;h=403" alt="" title="mfcc6" width="365" height="403" class="alignnone size-full wp-image-331" /></a>
</div>
<p><span style="color:rgb(51,102,255);">     </span><br />
Which features are added by these new methods?</p>
<p>For that we will focus only in the most used classes.</p>
<p><span style="font-weight:bold;">CWnd:</span></p>
<p>Here&#8217;s the methods added for CWnd, and almost all methods added concern touch feature and touch gestures.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc71.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc71.png?w=367&#038;h=432" alt="" title="mfcc7" width="367" height="432" class="alignnone size-full wp-image-332" /></a>
</div>
<p><span style="color:rgb(51,102,255);">     </span><br />
<span style="font-weight:bold;">CFile,CStdioFile,CFileFind:</span><br />
Many methods of these classes add  CAtlTransactionmanager as optional parameter.</p>
<p>Transactional File System is a new technology first introduced in Windows Vista. It enables you to roll back operations made on the file system and registry.</p>
<p>here&#8217;s a good <a href="http://blogs.msdn.com/b/vcblog/archive/2010/02/02/atl-support-for-transaction-file-system.aspx">article </a>about this feature.</p>
<p><span style="font-weight:bold;">CRecentFileList</span>:<br />
<a href="http://cppdepend.files.wordpress.com/2010/08/mfcc91.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc91.png?w=371&#038;h=87" alt="" title="mfcc9" width="371" height="87" class="alignnone size-full wp-image-333" /></a><br />
<span style="color:rgb(51,102,255);">     </span><br />
New possibilities to add item to recent file list are now available.</p>
<p><span style="font-weight:bold;">CDocument:</span><br />
Here&#8217;s the methods added by CDocument:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc171.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc171.png?w=418&#038;h=470" alt="" title="mfcc17" width="418" height="470" class="alignnone size-full wp-image-334" /></a>
</div>
<p><span style="color:rgb(51,102,255);">     </span><br />
Two new features concern methods added :</p>
<p>-Supporting Windows Search with MFC<br />
-Rich Preview</p>
<p>Let&#8217;s discover the changes concerning dependency of CDocument to other MFC classes,and which additional dependencies are added in MFC10, for that Dependency Matrix can be useful, and the sign &#8220;+&#8221; in the cell representing the dependency indicate  that this dependency is new.<br />
<a href="http://cppdepend.files.wordpress.com/2010/08/mfcc161.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc161.png?w=600&#038;h=206" alt="" title="mfcc16" width="600" height="206" class="alignnone size-full wp-image-335" /></a><br />
<span style="color:rgb(51,102,255);">     </span><br />
So many dependencies are added, especially with new classes added to MFC10 like CDataRecoveryHandler,and also some other inner classes added to CDocument.</p>
<p><span style="font-weight:bold;">CFileDialog:</span><br />
Here&#8217;s the methods added by CFileDialog:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc101.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc101.png?w=495&#038;h=470" alt="" title="mfcc10" width="495" height="470" class="alignnone size-full wp-image-336" /></a>
</div>
<p><span style="color:rgb(51,102,255);">     </span><br />
A good news is we can now customize CFileDialog by adding what we want in the dialog.</p>
<p><span style="font-weight:bold;"><br />
CMDIChildWndEx:<br />
</span>Here&#8217;s the methods added by CMDIChildWndEx:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc111.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc111.png?w=495&#038;h=446" alt="" title="mfcc11" width="495" height="446" class="alignnone size-full wp-image-337" /></a>
</div>
<p><span style="color:rgb(51,102,255);">     </span><br />
Windows7  add a new interesting features like:taskbar Tabs,Taskbar thumbnails and thumbnail previews, and almost all methods added to CMDIChildWndEx concern these features.</p>
<p><span style="font-weight:bold;">CFrameWnd: </span></p>
<p>Windows 7 add also some useful features like OverlayIcon and progressbar in the taskbar, and the methods added to CFrameWnd concern these features.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc121.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc121.png?w=453&#038;h=115" alt="" title="mfcc12" width="453" height="115" class="alignnone size-full wp-image-338" /></a>
</div>
<p><span style="color:rgb(51,102,255);">     </span></p>
<p><span style="font-weight:bold;">CWinApp</span>:</p>
<p>Almost all methods added to CWinApp concern the ApplicationRecovery support.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc131.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc131.png?w=490&#038;h=445" alt="" title="mfcc13" width="490" height="445" class="alignnone size-full wp-image-339" /></a>
</div>
<p><span style="color:rgb(51,102,255);">     </span></p>
<p>Other useful methods are added like CMFCControlRenderer::SmoothResize and CDrawingmanager::DrawRotated.</p>
<p><span style="font-weight:bold;color:rgb(51,102,255);">Methods where visibility was changed:</span></p>
<p><span style="color:rgb(51,102,255);">SELECT METHODS WHERE</span> VisibilityWasChanged</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc141.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc141.png?w=418&#038;h=311" alt="" title="mfcc14" width="418" height="311" class="alignnone size-full wp-image-340" /></a>
</div>
<p><span style="color:rgb(51,102,255);">     </span><br />
Almost the visibility of all CMFCRibbonTab methods is changed from private to public.</p>
<p>But when I checked the code source the only modification in the class declaration is the adding of DECLARE_DYNAMIC(CMFCRibbonTab) , this macro include &#8220;public:&#8221; , so I wonder if this visibility changes is only a side effect of adding this macro.</p>
<p><span style="color:rgb(51,51,255);font-weight:bold;">Methods Not Used Anymore:</span></p>
<p>Some methods become obsolete when upgrading framework version, did MFC10 not use anymore some methods?</p>
<p>To answer to this question let&#8217;s execute the query :</p>
<p><span style="color:rgb(51,51,255);">SELECT METHODS WHERE</span> IsNotUsedAnymore</p>
<p>here&#8217;s the result:</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/08/mfcc191.png"><img src="http://cppdepend.files.wordpress.com/2010/08/mfcc191.png?w=420&#038;h=84" alt="" title="mfcc19" width="420" height="84" class="alignnone size-full wp-image-344" /></a></p>
</div>
<p>These methods were declared before in multimon.h , the origin of this file goes back to Windows 98 to let compatibility with Windows 95 in the case of multi monitor, here&#8217;s an interesting <a href="http://blogs.msdn.com/b/oldnewthing/archive/2009/12/07/9933241.aspx">article </a>talking about it.<br />
In MFC10 this file is no longer included in mfc files. and MFC10 use directly GetSystemMetrics instead of xGetSystemMetrics.</p>
<br />Filed under: <a href='http://cppdepend.wordpress.com/category/codeproject/'>CodeProject</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppdepend.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppdepend.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppdepend.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppdepend.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppdepend.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppdepend.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppdepend.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppdepend.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppdepend.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppdepend.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppdepend.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppdepend.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppdepend.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppdepend.wordpress.com/282/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=282&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppdepend.wordpress.com/2010/08/29/visual-c-2010-what%e2%80%99s-new-for-mfc-library/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/92d6551df2d319e31f6d7f0af63ddce4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cppdepend</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc110.png" medium="image">
			<media:title type="html">mfcc1</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc22.png" medium="image">
			<media:title type="html">mfcc2</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc32.png" medium="image">
			<media:title type="html">mfcc3</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc20.png" medium="image">
			<media:title type="html">mfcc20</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc211.png" medium="image">
			<media:title type="html">mfcc21</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc152.png" medium="image">
			<media:title type="html">mfcc15</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc81.png" medium="image">
			<media:title type="html">mfcc8</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc41.png" medium="image">
			<media:title type="html">mfcc4</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc181.png" medium="image">
			<media:title type="html">mfcc18</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc51.png" medium="image">
			<media:title type="html">mfcc5</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc61.png" medium="image">
			<media:title type="html">mfcc6</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc71.png" medium="image">
			<media:title type="html">mfcc7</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc91.png" medium="image">
			<media:title type="html">mfcc9</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc171.png" medium="image">
			<media:title type="html">mfcc17</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc161.png" medium="image">
			<media:title type="html">mfcc16</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc101.png" medium="image">
			<media:title type="html">mfcc10</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc111.png" medium="image">
			<media:title type="html">mfcc11</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc121.png" medium="image">
			<media:title type="html">mfcc12</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc131.png" medium="image">
			<media:title type="html">mfcc13</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc141.png" medium="image">
			<media:title type="html">mfcc14</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfcc191.png" medium="image">
			<media:title type="html">mfcc19</media:title>
		</media:content>
	</item>
		<item>
		<title>Where&#8217;s the model for MFC Doc/View Design?</title>
		<link>http://cppdepend.wordpress.com/2010/08/18/wheres-the-model-for-mfc-docview-design/</link>
		<comments>http://cppdepend.wordpress.com/2010/08/18/wheres-the-model-for-mfc-docview-design/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 16:27:11 +0000</pubDate>
		<dc:creator>cppdepend</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[MFC]]></category>

		<guid isPermaLink="false">http://cppdepend.wordpress.com/?p=265</guid>
		<description><![CDATA[MFC is a good library that wraps Windows API, and it’s also a framework so it provides a structure for your application and influent the design. We have to be careful when using frameworks, because it impact also the design, and accepting the structure imposed by a specific framework without understanding its impact could be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=265&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>MFC is a good library that wraps Windows API, and it’s also a framework so it provides a structure for your application and influent the design.<br />
<br />
We have to be careful when using frameworks, because it impact also the design, and accepting the structure imposed by a specific framework without understanding its impact could be dangerous.<br />
<span id="more-265"></span></p>
<p>Let’s take a look into Doc/View architecture proposed by MFC and discuss how MVC pattern could be implemented.
</p>
<p>
<B>Did CDocument/CView implements MVC pattern?</B></p>
<p>Doc/View architecture as described by many articles is implementing MVC pattern, but where’s the Model, the controller and the view?</p>
<p>Here’s a description from  msdn article:<br />
<br />
“The Document-View variant recognizes all three roles of Model-View-Controller but merges the controller into the view. The document corresponds to the model role in MVC. This variant is present in many existing GUI platforms. An excellent example of Document-View is the Microsoft Foundation Class Library (MFC) in the Microsoft Visual C++ environment. The tradeoff of using this variant is that the view and the controller are more tightly coupled.”</p>
<p>So the CDocument is the model and CView merge the view and controller.</p>
<p><a href="http://cppdepend.files.wordpress.com/2010/08/mfc2.png"><img style="cursor:hand;width:400px;height:204px;" src="http://cppdepend.files.wordpress.com/2010/08/mfc2.png?w=300" border="0" /></a></p>
<p>But actually the CDocument is not representing only the model , and to proof it  let’s discover some CDocument design and methods:</p>
<p>CDocument derives from CCmdTarget to receive events and commands and contains the following methods :  AddView, GetFirstViewPosition,GetNextView,UpdateAllViews.</p>
<p>So this class treats events,refresh and manage views, so it have some  controller responsability.</p>
<p><a href="http://cppdepend.files.wordpress.com/2010/08/mfc3.png"><img style="cursor:hand;width:400px;height:204px;" src="http://cppdepend.files.wordpress.com/2010/08/mfc3.png?w=300" border="0" /></a><br />
</p>
<h2>Why CDocument is not the good candidate to be the model?</h2>
<p>As described below the CDocument contains controller logic, and considering it also as model impact a lot the cohesion of classes, each classe must have a specific responsibility; it makes the design more flexible. </p>
<p>The model must be independent of any framework used, if it can be a <a href="http://en.wikipedia.org/wiki/Plain_Old_C%2B%2B_Object">POCO</a> classes it will be wonderful, the question is why coupling the model with a specific framework? </p>
<p>high coupling  makes the design more rigid, and any evolution or changes will be very difficult, for example if some client ask  to provides also webservices, and if our model is highly coupled with CDocument , this evolution will cost a lot, on the other side if it’s independent to CDocument it can be developed more easily.</p>
<p><a href="http://cppdepend.files.wordpress.com/2010/08/mfc1.png"><img style="cursor:hand;width:400px;height:311px;" src="http://cppdepend.files.wordpress.com/2010/08/mfc1.png?w=300" border="0" /></a></p>
<p><B>What’s the conclusion of this story?</B><br />
</p>
<ul>
<li>High cohesion and low coupling are two powerful concepts that assist your design, but their benefits are more visible only if evolutions or changes are needed.
<li>Be careful when using external frameworks, and not understanding the design provided by the framework could impact a lot the design quality of your application.
</ul>
<br />Filed under: <a href='http://cppdepend.wordpress.com/category/c/'>C++</a>, <a href='http://cppdepend.wordpress.com/category/mfc/'>MFC</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppdepend.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppdepend.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppdepend.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppdepend.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppdepend.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppdepend.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppdepend.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppdepend.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppdepend.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppdepend.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppdepend.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppdepend.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppdepend.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppdepend.wordpress.com/265/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=265&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppdepend.wordpress.com/2010/08/18/wheres-the-model-for-mfc-docview-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/92d6551df2d319e31f6d7f0af63ddce4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cppdepend</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfc2.png?w=300" medium="image" />

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfc3.png?w=300" medium="image" />

		<media:content url="http://cppdepend.files.wordpress.com/2010/08/mfc1.png?w=300" medium="image" />
	</item>
		<item>
		<title>PVS-Studio a tool complementing CppDepend</title>
		<link>http://cppdepend.wordpress.com/2010/06/28/pvs-studio-a-tool-complementing-cppdepend/</link>
		<comments>http://cppdepend.wordpress.com/2010/06/28/pvs-studio-a-tool-complementing-cppdepend/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 22:35:24 +0000</pubDate>
		<dc:creator>cppdepend</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cppdepend.wordpress.com/?p=229</guid>
		<description><![CDATA[CppDepend is a tool that simplifies managing a complex C\C++ code base. Architects and developers can analyze code structure, specify design rules, do effective code reviews and master evolution by comparing different versions of the code. CppDepend focus more on design analysis to understand the structure of existing code, and many times we ask us [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=229&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>CppDepend is a tool that simplifies managing a complex C\C++ code base. Architects and developers can analyze code structure, specify design rules, do effective code reviews and master evolution by comparing different versions of the code.</p>
<p>CppDepend focus more on design analysis to understand the structure of existing code, and many times we ask us if CppDepend can detect implementation problems, like variables not initialized, 64 bits and parallel issues.<br />
<span id="more-229"></span><br />
For that there are other tools that complements CppDepend to detect this kind of issues and we recommend <a href="http://www.viva64.com/pvs-studio">PVS-Studio</a>.</p>
<p><a href="http://www.viva64.com/pvs-studio">PVS-Studio</a> is a static code analyzer intended for developers of modern resource-intensive C and C++ applications. By modern applications we understand 64-bit and/or parallel applications. Development of such programs involves some difficulties different from the problems you face when developing conventional programs. For besides usual errors known to everybody like uninitialized pointers, which are detected by any compiler, there are new types of problems.</p>
<p>We speak about the errors in programs which occur when porting 32-bit applications on 64-bit platforms or paralleling the code to provide support of multi-processor or multi-core mode. It is rather difficult to develop such applications because of lack of tools which could simplify creation of 64-bit and parallel programs. PVS-Studio analyzer is quite a tool for this purpose!</p>
<p>Though PVS-Studio code analyzer user interface is rather simple, still, to use the tool most efficiently, you should understand the principles and technology of static code analysis. After reading this article and examining the examples described in it, you will be able to use PVS-Studio in your everyday work.<br />
Purpose, abilities and system requirements of PVS-Studio.</p>
<p>The static code analyzer PVS-Studio is intended for developers of modern resource-intensive C and C++ applications. At present, PVS-Studio includes two units:</p>
<p>•	Viva64 is a subsystem of diagnosing errors characteristic of 64-bit systems;<br />
•	VivaMP is a subsystem of diagnosing errors in parallel programs built on OpenMP technology.<br />
With the help of these two units PVS-Studio allows you to detect in the source code of C and C++ programs the following types of defects:<br />
•	errors of migration of 32-bit applications on 64-bit systems;<br />
•	errors occurring when developing new 64-bit applications;<br />
•	non-optimal use of memory in 64-bit programs due to alignment peculiarities;<br />
•	errors in parallel programs relating to insufficient knowledge of OpenMP directives&#8217; syntax;<br />
•	errors in parallel programs relating to insufficient knowledge of the principles of paralleling code using OpenMP technology;<br />
•	errors of incorrect memory operation in parallel code (unprotected main memory access, absence of synchronization, incorrect mode of access to variables etc).<br />
PVS-Studio analyzer is intended for working on Windows-platform. It integrates into Microsoft Visual Studio 2005/2008/2010 development environment. The system requirements to the analyzer coincide with the requirements to Microsoft Visual Studio:<br />
•	Operation System: Windows 2000/XP/2003/Vista/2008 x86 or x64. Attention: to analyze 64-bit applications it is not necessary to have a 64-bit operation system.<br />
•	Development environment: Microsoft Visual Studio 2005/2008/2010 (Standard Edition, Professional Edition, Team Systems). To analyze 64-bit applications you must have a component of Visual Studio &#8220;X64 Compilers and Tools&#8221; installed. It is included into all the listed versions of Visual Studio and can be installed through Visual Studio Setup. Pay attention that PVS-Studio cannot operate Visual C++ Express Edition for this system does not support extension units.<br />
•	Hardware: PVS-Studio operates on systems with no less than 1 Gb of main memory (it is recommended that you have 2 Gb and more); the analyzer can work at several cores (the more cores, the faster code analysis).</p>
<h2>Getting acquainted with PVS-Studio</h2>
<p>After installing the examples PortSample and ParallelSample you can start examining PVS-Studio. Open PortSample  project in Microsoft Visual Studio.</p>
<p><a href="http://cppdepend.files.wordpress.com/2010/06/viva1.png"><img src="http://cppdepend.files.wordpress.com/2010/06/viva1.png?w=300&#038;h=150" alt="" title="viva1" width="300" height="150" class="alignnone size-medium wp-image-233" /></a></p>
<p>Figure 1 &#8211; Selection of PortSample demo-project </p>
<p>You should begin working with PVS-Studio with one of our demo-projects due to some reasons:</p>
<p>•	firstly, they cover all the code defects diagnosed by PVS-Studio;<br />
•	secondly, you can watch behavior of an application with an error in a real example;<br />
•	thirdly, PVS-Studio demo-version shows location only of some of the defects and errors in the code (although it detects them all). But for PortSample and ParallelSample we have made an exception &#8211; for them all the defects are shown.</p>
<p>So, open PortSample project, select 64-bit configuration x64 to check presence of defects in 64-bit code, with the help of PVS-Studio command bar select analysis of 64-bit problems &#8211; Viva64 unit &#8220;64-bit issues (Viva64)&#8221; and launch analysis of the whole solution by the command &#8220;Check Solution&#8221;. All this is shown on Figure 2.</p>
<p><a href="http://cppdepend.files.wordpress.com/2010/06/viva2.png"><img src="http://cppdepend.files.wordpress.com/2010/06/viva2.png?w=590&#038;h=590" alt="" title="viva2" width="590" height="590" class="alignleft size-full wp-image-234" /></a></p>
<p>Figure 2 &#8211; Check of PortSample solution on presence of 64-bit problems </p>
<p>x64 configuration is chosen deliberately. You can check only the 64-bit configuration on 64-bit code problems. The point is that the project&#8217;s settings in the 64-bit configuration are different from those of the 32-bit one. So you cannot perform check of 64-bit code in the 32-bit configuration.</p>
<p>After launching analysis, you will see a progress indicator with Pause (pause analysis) and Stop (stop analysis) buttons on the screen. Potentially unsafe constructions detected during analysis will be printed in the window of detected defects (Figure 3).</p>
<p><a href="http://cppdepend.files.wordpress.com/2010/06/viva3.png"><img src="http://cppdepend.files.wordpress.com/2010/06/viva3.png?w=590&#038;h=593" alt="" title="viva3" width="590" height="593" class="alignnone size-full wp-image-237" /></a></p>
<p>Figure 3 &#8211; Analysis of the project &#8211; problems detected in the code are printed in the window at once </p>
<p>The term &#8220;potentially unsafe construction&#8221; means that the analyzer considered some particular code line a defect. But only the programmer who knows the application can determine if this line is really a defect of the application or not. This principle of working with code analyzers must be understood correctly. </p>
<p>Generally, no tool can replace a programmer completely when solving the task of correcting errors in programs. Only a programmer can do it relying on his knowledge. But a tool can and must help the programmer in this task. That&#8217;s why a code analyzer&#8217;s task is to reduce the number of places in the code which the programmer must look through and investigate.</p>
<p>But let&#8217;s return to PVS-Studio analyzer. Analysis of the whole code is complete and now you can start looking through the messages. By the way, if you have a multi-core processor analysis will be performed faster for all the cores will be used.</p>
<h2>Correction of errors </h2>
<p>After getting a list of diagnostic warnings from the code analyzer, you can study it. Let&#8217;s consider the first<br />
error:<br />
V101: Implicit assignment type conversion to memsize type. v1xx.cpp 34</p>
<p>Here is its code:</p>
<p>  size_t bufferSize = imageWidth * imageHeght *<br />
                      bytePerPixel * maxFrameCountInBuffer;</p>
<p>The problem here is that the resulting size of the buffer (bufferSize variable) has the right size size_t but the variables participating in the expression (imageWidth, imageHeight, bytePerPixel and maxFrameCountInBuffer) have int type. The result of multiplication of these variables has also int type. It is not crucial for values less than 2 Gb for type conversion takes place. But if you get a result more than 2 Gb it will be cut to 2 Gb despite that bufferSize variable has a right type. To correct this error you should change the type of the variables participating in the expression. You can do this in a preciding code section. Instead of:</p>
<p>  unsigned imageWidth = 1000;<br />
  unsigned imageHeght = 1000;<br />
  unsigned bytePerPixel = 3;<br />
  unsigned maxFrameCountInBuffer;</p>
<p>let&#8217;s write:</p>
<p>  size_t imageWidth = 1000;<br />
  size_t imageHeght = 1000;<br />
  size_t bytePerPixel = 3;<br />
  size_t maxFrameCountInBuffer;</p>
<p>You can learn about this correction from the Help system. After pressing Alt+H (with mouse or F4 button) when studying a new error, the online help page will open with the description of the error:</p>
<p><a href="http://cppdepend.files.wordpress.com/2010/06/viva4.png"><img src="http://cppdepend.files.wordpress.com/2010/06/viva4.png?w=600&#038;h=479" alt="" title="viva4" width="600" height="479" class="alignnone size-full wp-image-238" /></a> </p>
<p>Figure 4 &#8211; Detailed description of the error and the ways to correct it are given in online help </p>
<p>After correcting the used data types let&#8217;s relaunch analysis. You will see that the number of diagnostic warnings is less in one. It means that the problem is corrected. In the same way you should deal with all the diagnostic warnings and correct those places in the code where there are possible problems.</p>
<h2>Working with the list of diagnostic warnings </h2>
<p>Of course, in large real projects there will be not some tens of diagnostic warnings, but hundreds or even thousands of them. And looking through all of them is not a simple task. To simplify it PVS-Studio has several mechanisms. The first is filtration of warnings by the code of an error. The second is filtration by the content of the text of a diagnostic warning. The third is filtration by the paths to files. Let&#8217;s consider the examples of using filtration systems.</p>
<p>Suppose you be sure that diagnostic messages with V112 code (using magic numbers) are not relevant to your application. In this case you may turn off showing of these diagnostic warnings with the help of the code analyzer&#8217;s settings:</p>
<p><a href="http://cppdepend.files.wordpress.com/2010/06/viva5.png"><img src="http://cppdepend.files.wordpress.com/2010/06/viva5.png?w=590&#038;h=341" alt="" title="viva5" width="590" height="341" class="alignnone size-full wp-image-240" /></a></p>
<p>Figure 5 &#8211; Turning off some diagnostic warnings by the code </p>
<p>After that all the warnings with V112 code will disappear from the list of warnings. And you do not need to relaunch analysis for this. If you turn on these warnings they will appear in the list again without relaunching analysis.</p>
<p>Now let&#8217;s consider another variant of filtration on the basis of the text of diagnostic warnings. Let&#8217;s get back to PortSample example. One of the errors in this example is access to the array &#8220;array&#8221; using an index of int type:</p>
<p>V108: Incorrect index type for &#8220;array&#8221;. Use memsize type instead.  v1xx.cpp 183</p>
<p>Here is the code:</p>
<p>volatile int index = 0;<br />
  for (size_t i = 0; i != n; ++i) {<br />
    array[index++] = 1; // error<br />
    if (array[i] != 1)<br />
      throw CString(&#8220;x64 portability issues&#8221;);<br />
  }</p>
<p>Of course, you may just change the type of index variable from unsigned to size_t and the problem will disappear. But if there are a lot of code sections with access to array variable and you are sure that there are not more than 2 billions of items in array, you may &#8220;ask&#8221; the code analyzer not to show the warnings whose text contains the word &#8220;array&#8221;. You can do this with the help of the settings on MessageSupression page:</p>
<p><a href="http://cppdepend.files.wordpress.com/2010/06/viva6.png"><img src="http://cppdepend.files.wordpress.com/2010/06/viva6.png?w=590&#038;h=341" alt="" title="viva6" width="590" height="341" class="alignnone size-full wp-image-241" /></a><br />
Figure 6 &#8211; Turning off some diagnostic warnings by the text </p>
<p>After that all the diagnostic warnings whose text contains the word &#8220;array&#8221; will disappear from the list without relaunching the code analyzer. You can get them back by simply removing the word &#8220;array&#8221; from the filter.<br />
The last mechanism of reducing the number of diagnostic warnings is &#8220;Don&#8217;t Check Files&#8221; setting.</p>
<p>You may specify file masks on the tab &#8220;Don&#8217;t Check Files&#8221; to exclude some files from analysis. The analyzer will not check those files that meet the mask&#8217;s conditions.</p>
<p><a href="http://cppdepend.files.wordpress.com/2010/06/viva7.png"><img src="http://cppdepend.files.wordpress.com/2010/06/viva7.png?w=590&#038;h=394" alt="" title="viva7" width="590" height="394" class="alignnone size-full wp-image-242" /></a></p>
<p>Figure 7 &#8211; Setting filtration of messages by files&#8217; names </p>
<p>Using this method, you may, for instance, exclude autogenerated files from analysis. Besides, you may define the files to be excluded from analysis by the name of the folder they are situated in.<br />
A mask is defined with the help of wild card match types like in MS-DOS. The following wild cards can be used:<br />
•	? &#8211; any character;<br />
•	- any number of any characters;<br />
The case of characters does not matter.</p>
<p>If a mask is specified without a full path (i.e. without the characters &#8220;:&#8221; and &#8220;\&#8221;), the check is performed ONLY by the file name. For instance, the mask &#8220;V*.CPP&#8221; covers the files c:\test\V1111.cpp and d:\project\V1111.cpp. But if you define the mask as c:\*.cpp, the file d:\project\V1111.cpp will not fall under it.</p>
<p>Here are some examples:<br />
*ex.c &#8211; all the files whose names end with &#8220;ex&#8221; and which have the extension &#8220;c&#8221; will be excluded from analysis.<br />
c:\Libs\*.cpp &#8211; all the files with the extension &#8220;cpp&#8221; in the folders c:\Libs\XX, c:\Libs\XX\YY, c:\Libs\ZZ, etc. will be excluded.<br />
If you change a mask, you will need to relaunch the analyzer.</p>
<p>In PVS-Studio, there is a possibility called &#8220;Mark as False Alarm&#8221;. Due to it, it is possible to mark those lines in the source code, in which false alarm of the code analyzer occurs. After the marking, the analyzer will not produce diagnostic messages for such code any more. This allows to use the analyzer constantly with more convenience in the process of software development for verifying new code.<br />
Thus, in the following example, the output of the diagnostic message with code V104 is disabled:</p>
<p>size_t n = 100;<br />
  for (unsigned i = 0;<br />
       i &lt; n; //-V104<br />
       i++)<br />
  {<br />
      // &#8230;<br />
  }</p>
<p>This feature is described thoroughly and in detail in the article &quot;PVS-Studio: use of &quot;Mark as False Alarm&quot; function&quot;.<br />
There are also many other means to handle diagnostic warnings to be shown by setting the code analyzer but they lay beyond consideration in this document. We recommend that you refer to the documentation on the code analyzer&#039;s settings.</p>
<h2>Should all the potential errors detected by the analyzer be corrected? </h3>
<p>Having looked through all the warnings shown by the code analyzer you will find both real errors in programs and constructions that are not errors. The point is that the analyzer cannot detect all the errors in programs 100% accurately without the so called &quot;false responses&quot;. Only the programmer who knows and understands the program can determine if there is an error in a particular place. The code analyzer can only significantly reduce the number of sections which must be looked through by the developer.</p>
<p>Thus, of course, there is no sense in trying to correct all the potential problems detected by the code analyzer.</p>
<p>But you should try to correct as many code sections as you can. It is especially relevant when the static analyzer is used not once just to verify an application when, for example, porting it on a 64-bit system, but regularly with the purpose to detect new errors and insufficient constructions. In this case correction of sections which are actually not errors, and also setting of the analyzer to suppress some types of errors will allow you to significantly save on time when using the analyzer next time.</p>
<br />Filed under: <a href='http://cppdepend.wordpress.com/category/uncategorized/'>Uncategorized</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppdepend.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppdepend.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppdepend.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppdepend.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppdepend.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppdepend.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppdepend.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppdepend.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppdepend.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppdepend.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppdepend.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppdepend.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppdepend.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppdepend.wordpress.com/229/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=229&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppdepend.wordpress.com/2010/06/28/pvs-studio-a-tool-complementing-cppdepend/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/92d6551df2d319e31f6d7f0af63ddce4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cppdepend</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/06/viva1.png?w=300" medium="image">
			<media:title type="html">viva1</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/06/viva2.png" medium="image">
			<media:title type="html">viva2</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/06/viva3.png" medium="image">
			<media:title type="html">viva3</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/06/viva4.png" medium="image">
			<media:title type="html">viva4</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/06/viva5.png" medium="image">
			<media:title type="html">viva5</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/06/viva6.png" medium="image">
			<media:title type="html">viva6</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/06/viva7.png" medium="image">
			<media:title type="html">viva7</media:title>
		</media:content>
	</item>
		<item>
		<title>Could we reuse Garbage collector of V8 javascript engine?</title>
		<link>http://cppdepend.wordpress.com/2010/02/20/could-we-reuse-garbage-collector-of-v8-javascript-engine/</link>
		<comments>http://cppdepend.wordpress.com/2010/02/20/could-we-reuse-garbage-collector-of-v8-javascript-engine/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 00:57:35 +0000</pubDate>
		<dc:creator>cppdepend</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cppdepend.wordpress.com/?p=217</guid>
		<description><![CDATA[V8 javascript engine is well optimized, and use an efficient way to manage memory. And I wonder if I can use the garbage collector easily in other projects? and to answer to this question we have to talk about coupling metrics. There is a whole range of interesting code metrics relative to coupling. The simplest [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=217&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>V8 javascript engine is well optimized, and use an efficient way to manage memory.<br />
And I wonder if I can use  the garbage collector easily in other projects? and to answer to this question we have to talk about coupling metrics.<br />
<span id="more-217"></span><br />
There is a whole range of interesting code metrics relative to coupling. The simplest ones are named <strong>Afferent Coupling (Ca)</strong> and <strong>Efferent Coupling (Ce)</strong>. Basically, the Ca for a code element is the number of code elements that use it and the Ce is the number of code elements that it uses.</p>
<p><img src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/patricksmacchia.CaCe/CaCeIllustration.PNG" alt="" /></p>
<p>You can define Ca and Ce for the graph of projects dependencies, the graph of namespaces dependencies, the graph of types dependencies and the graph of methods dependencies of a code base. You can also define the Ca metric on the fields of a program as the number of methods that access the field. This leads to 9 metrics all supported by the tool CppDepend We precise that when computing Ce.</p>
<p>With <a href="http://www.cppdepend.com/">CppDepend</a>, if you wish to know which methods of your program are massively used you can write the following CQL Query :</p>
<p><span style="color:rgb(51,102,255);">SELECT TOP</span> 10 <span style="color:rgb(51,102,255);">METHODS ORDER BY</span> MethodCa <span style="color:rgb(51,102,255);">DESC</span></p>
<p>Being used a lot is not necessarily a problem. However it is still interesting to know which part of your code base is used a lot.</p>
<p><span style="font-weight:bold;color:rgb(51,102,255);">High Efferent Coupling and design flaws</span></p>
<p>If you wish to know which types of your program are heavy users of other types you just have to write:</p>
<p><span style="color:rgb(51,102,255);">SELECT TOP</span> 10 <span style="color:rgb(51,102,255);">TYPES ORDER BY </span>TypeCe <span style="color:rgb(51,102,255);">DESC</span></p>
<p>High Ce might reveal a design problem. Types with high Ce are entangled with many other implementations. The higher the Ce, the higher the number of responsibilities the type has.</p>
<p><span style="color:rgb(51,102,255);"><br />
What about reusing garbage collector?</span></p>
<p>The class representing the garbage collector is MarkCompactCollector, this class has a TypeCe equal to 34, but how many types this class use indirectly.</p>
<p><span style="color:rgb(51,102,255);">SELECT TYPES WHERE</span> IsUsedBy &#8220;<span style="color:rgb(255,0,0);">v8.internal.MarkCompactCollector</span>&#8220;</p>
<p>And there’s the result</p>
<div style="text-align:center;"><a href="http://2.bp.blogspot.com/_tWDA5bNBNHI/S3-roeUDW2I/AAAAAAAAAbA/Hl8Ig3B7h3w/s1600-h/gc.PNG"><img style="cursor:pointer;width:258px;height:400px;" src="http://2.bp.blogspot.com/_tWDA5bNBNHI/S3-roeUDW2I/AAAAAAAAAbA/Hl8Ig3B7h3w/s800/gc.PNG" alt="" border="0" /></a>
</div>
<p>And the metric view shows better relation between MarkCompactCollector class and other V8 types:</p>
<div style="text-align:center;"><a href="http://3.bp.blogspot.com/_tWDA5bNBNHI/S38xmtNrvZI/AAAAAAAAAaw/TgapdnY0bP4/s1600-h/memory.PNG"><img style="cursor:pointer;width:635px;height:146px;" src="http://3.bp.blogspot.com/_tWDA5bNBNHI/S38xmtNrvZI/AAAAAAAAAaw/TgapdnY0bP4/s800/memory.PNG" alt="" border="0" /></a>
</div>
<p>So it’s very difficult to isolate only the garbage collector mechanism from V8 source code, Maybe in the future the V8 team will isolate this garbage collector, and it will be used in other projects.</p>
<br />Filed under: <a href='http://cppdepend.wordpress.com/category/uncategorized/'>Uncategorized</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppdepend.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppdepend.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppdepend.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppdepend.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppdepend.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppdepend.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppdepend.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppdepend.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppdepend.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppdepend.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppdepend.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppdepend.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppdepend.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppdepend.wordpress.com/217/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=217&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppdepend.wordpress.com/2010/02/20/could-we-reuse-garbage-collector-of-v8-javascript-engine/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/92d6551df2d319e31f6d7f0af63ddce4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cppdepend</media:title>
		</media:content>

		<media:content url="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/patricksmacchia.CaCe/CaCeIllustration.PNG" medium="image" />

		<media:content url="http://2.bp.blogspot.com/_tWDA5bNBNHI/S3-roeUDW2I/AAAAAAAAAbA/Hl8Ig3B7h3w/s800/gc.PNG" medium="image" />

		<media:content url="http://3.bp.blogspot.com/_tWDA5bNBNHI/S38xmtNrvZI/AAAAAAAAAaw/TgapdnY0bP4/s800/memory.PNG" medium="image" />
	</item>
		<item>
		<title>Lessons to take from V8 javascript engine</title>
		<link>http://cppdepend.wordpress.com/2010/02/17/lessons-to-take-from-v8-javascript-engine/</link>
		<comments>http://cppdepend.wordpress.com/2010/02/17/lessons-to-take-from-v8-javascript-engine/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 18:15:31 +0000</pubDate>
		<dc:creator>cppdepend</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cppdepend.wordpress.com/?p=199</guid>
		<description><![CDATA[V8 is Google&#8217;s open source JavaScript engine it&#8217;s written in C++ and is used in Google Chrome, the open source browser from Google. It&#8217;s very interesting to discover how this engine is implemented and what lessons we can take when analyzing it. here&#8217;s some remarks about this engine: Optimization is also a design issue When [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=199&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>V8 is Google&#8217;s open source JavaScript engine it&#8217;s written in C++ and is used in Google Chrome, the open source browser from Google.</p>
<p>It&#8217;s very interesting to discover how this engine is implemented and what lessons we can take when analyzing it.<br />
<span id="more-199"></span><br />
here&#8217;s some remarks about this engine:</p>
<p><span style="color:rgb(51,51,255);font-weight:bold;font-size:130%;">Optimization is also a design issue</span></p>
<p>When I hear that google chromium browser use fast javascript engine, I was sure that it was developed with “C” language like almost all known languages and interpreters (Perl, Python, PHP, Spider Monkey), but when I got the  source code, I was very surprised that‘s developed with C++.</p>
<p>The goal of this engine is to be very fast and the decision of V8 team to choose C++ proof that performance depends also on design choices more than language choice.</p>
<p>There’s some V8 Design Choices:</p>
<p><span style="font-style:italic;color:rgb(51,102,255);">Hidden Class: </span></p>
<p>JavaScript is a dynamic programming language: properties can be added to, and deleted from, objects on the fly. This means an object&#8217;s properties are likely to change.<br />
Javascript has a class concept but there’s a class representing it in  source code?</p>
<p>To answer to this question let’s search in V8 source code all objects kind treated, for that we can execute the following request:</p>
<p><span style="color:rgb(51,51,255);">SELECT TYPES WHERE</span> DeriveFrom &#8220;<span style="color:rgb(255,0,0);">v8.internal.JSObject</span>&#8220;</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/02/vobject.png"><img style="cursor:pointer;width:310px;height:400px;" src="http://cppdepend.files.wordpress.com/2010/02/vobject.png?w=232" alt="" border="0" /></a>
</div>
<p><BR><br />
as we can observe there&#8217;s no class inheriting from JSObject representing a Class like Function or Value, it&#8217;s normal because in any dynamic langage the idea is to create a class in the real time and most JavaScript engines use a dictionary-like data structure as storage for object properties,each property access requires a dynamic lookup to resolve the property&#8217;s location in memory.</p>
<p>This approach makes accessing properties in JavaScript typically much slower than accessing instance variables in programming languages like Java and Smalltalk. In these languages, instance variables are located at fixed offsets determined by the compiler due to the fixed object layout defined by the object&#8217;s class. Access is simply a matter of a memory load or store, often requiring only a single instruction.</p>
<p>V8 use hidden class concept to reduce the time required to access JavaScript properties. V8 does not use dynamic lookup to access properties. Instead, V8 dynamically creates hidden classes behind the scenes as detailled in this <a href="http://code.google.com/intl/fr/apis/v8/design.html">post</a>.</p>
<p><span style="font-style:italic;color:rgb(51,51,255);">Dynamic machine code generation:</span></p>
<p>V8 compiles JavaScript source code directly into machine code when it is first executed. There are no intermediate byte codes, no interpreter. Property access is handled by inline cache code that may be patched with other machine instructions as V8 executes.</p>
<p>let&#8217;s discover the dependency graph for MakeCode function.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/02/makecode.png"><img style="cursor:pointer;width:400px;height:329px;" src="http://cppdepend.files.wordpress.com/2010/02/makecode.png?w=300" alt="" border="0" /></a>
</div>
<p><span style="font-style:italic;color:rgb(51,51,255);"><br />
Garbage collector:</span></p>
<p>V8 use an efficient garbage collector to manage memory, and I was very interested to know if I can use it easily in other C++ projects, for that I have to look if the garbage collector classes are highly coupled with other V8 classes or not.</p>
<p>An interesting question is to know if we can use MarkCompactCollector in other C++ projects.</p>
<p>for that let’s search for indirect dependencies for this class:</p>
<p><span style="color:rgb(51,51,255);">SELECT TYPES WHERE</span> IsUsedBy &#8220;<span style="color:rgb(255,0,0);">v8.internal.MarkCompactCollector</span>&#8220;</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/02/memory.png"><img style="cursor:pointer;width:585px;height:134px;" src="http://cppdepend.files.wordpress.com/2010/02/memory.png?w=300" alt="" border="0" /></a>
</div>
<p>Unfortunately this class is highly coupled with a lot of other V8 classes.</p>
<p><span style="color:rgb(51,51,255);font-weight:bold;font-size:130%;">V8 is optimized and use design patterns:</span></p>
<p>I dont know why many developpers think that using OOP and design patterns can impact a lot the optimization.</p>
<p>V8 is an example of project that use OOP and patterns and in the same time very optimized.</p>
<p>here&#8217;s for example two patterns used:</p>
<p><span style="color:rgb(51,51,255);font-style:italic;font-weight:bold;">Factory:</span></p>
<p>The factoy class create many objects needed and do abstraction of garbage collector invocation, for example let&#8217;s search for methods invoked by Factory::NewJsObject</p>
<p><span style="color:rgb(51,51,255);">SELECT METHODS WHERE</span> IsDirectlyUsedBy &#8220;<span style="color:rgb(255,0,0);">v8.internal.Factory.NewJSObject(Handle,PretenureFlag)</span>&#8220;</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/02/factory.png"><img style="cursor:pointer;width:400px;height:387px;" src="http://cppdepend.files.wordpress.com/2010/02/factory.png?w=300" alt="" border="0" /></a>
</div>
<p>as we can observe this method do some abstraction of memory allocation.</p>
<p><span style="color:rgb(51,51,255);font-style:italic;"><span style="font-weight:bold;">Visitor</span>:</span></p>
<p>V8 contains many classes implementing visitor pattern.</p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2010/02/visitor.png"><img style="cursor:pointer;width:338px;height:477px;" src="http://cppdepend.files.wordpress.com/2010/02/visitor.png?w=211" alt="" border="0" /></a>
</div>
<p><BR><br />
<span style="color:rgb(51,51,255);font-weight:bold;"><span style="font-size:130%;">Make C++ easy to use:</span></p>
<p></span><span style="font-style:italic;color:rgb(51,102,255);">Memory allocation simplified</span></p>
<p>Managing memory and allocating pointers is complicated in C++ Using garbage collector can simplify this task.</p>
<p><span style="font-style:italic;color:rgb(51,102,255);">Avoid multiple inheritance</span></p>
<p>Let&#8217;s search for classes with multiple base classes:</p>
<p><span style="color:rgb(51,51,255);">SELECT TYPES WHERE</span> NbBaseClass &gt;1</p>
<p>and the result of this query is empty so V8 dont use multiple inheritance, it simplify a lot the developement and evolution of application.</p>
<p><span style="color:rgb(51,102,255);font-style:italic;">Use RTTI</span><span style="color:rgb(51,102,255);"> carefully</span></p>
<p>Using RTTI resolve some problems but can be an indicator of a bad design, be sure to no overuse this technique.</p>
<p>Let&#8217;s search if V8 use dynamic_cast:</p>
<p><span style="color:rgb(51,51,255);">SELECT  METHODS WHERE</span> IsDirectlyUsing &#8220;<span style="color:rgb(255,0,0);">Keywords.dynamic_cast</span>&#8220;</p>
<p>the result is empty and it&#8217;s an indicator from others that V8 is well designed.</p>
<p><span style="font-style:italic;color:rgb(51,102,255);">Exceptions</span></p>
<p>Using exceptions is interesting but is not easy that a code be exception safe.<br />
V8 team choose to not use exceptions to simplify the implementation.</p>
<p>we can execute the following CQL request to know if exception is used:</p>
<p><span style="color:rgb(51,51,255);">SELECT METHODS WHERE</span>  IsDirectlyUsing  &#8220;<span style="color:rgb(255,0,0);">Keywords.throw</span>&#8220;</p>
<br />Filed under: <a href='http://cppdepend.wordpress.com/category/uncategorized/'>Uncategorized</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppdepend.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppdepend.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppdepend.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppdepend.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppdepend.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppdepend.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppdepend.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppdepend.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppdepend.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppdepend.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppdepend.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppdepend.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppdepend.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppdepend.wordpress.com/199/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=199&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppdepend.wordpress.com/2010/02/17/lessons-to-take-from-v8-javascript-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/92d6551df2d319e31f6d7f0af63ddce4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cppdepend</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2010/02/vobject.png?w=232" medium="image" />

		<media:content url="http://cppdepend.files.wordpress.com/2010/02/makecode.png?w=300" medium="image" />

		<media:content url="http://cppdepend.files.wordpress.com/2010/02/memory.png?w=300" medium="image" />

		<media:content url="http://cppdepend.files.wordpress.com/2010/02/factory.png?w=300" medium="image" />

		<media:content url="http://cppdepend.files.wordpress.com/2010/02/visitor.png?w=211" medium="image" />
	</item>
		<item>
		<title>Refactoring:What&#8217;s the origin of bad design?</title>
		<link>http://cppdepend.wordpress.com/2009/12/17/refactoringwhats-the-origin-of-bad-design/</link>
		<comments>http://cppdepend.wordpress.com/2009/12/17/refactoringwhats-the-origin-of-bad-design/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 00:56:23 +0000</pubDate>
		<dc:creator>cppdepend</dc:creator>
				<category><![CDATA[CodeProject]]></category>

		<guid isPermaLink="false">http://cppdepend.wordpress.com/?p=173</guid>
		<description><![CDATA[The refactoring is defined as the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure. Refactoring improves the quality of application design and implementation, but unfortunately the expression “If it is working don’t change” is many times used [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=173&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The refactoring is defined as the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure.</p>
<p>Refactoring improves the quality of application design and implementation, but unfortunately the expression “If it is working don’t change” is many times used to bypass it.</p>
<p>We can found in general three cases concerning refactoring:<br />
<span id="more-173"></span><br />
-	<em><span style="color:#3366ff;">Iterative refactoring</span></em>: each application can’t be developed perfectly in the first iteration without any feedbacks, even if the team has the best of the architects, designers and developers. The easy way to do refactoring without investing a lot of money and without wasting time is to integrate it in the development process and do it after each iteration.</p>
<p>-	<em><span style="color:#3366ff;">Refactoring when is necessary</span></em>:  after the application is deployed, there are some feedbacks and bugs, if resolving them take a lot of time or some client needs are very complex to develop and integrate to the existing system, a refactoring can be a good solution to improve the quality of the code base, but in this case it can be very risky and we have to take care to avoid regression in the existing code.</p>
<p>-	<em><span style="color:#3366ff;">Not refactor</span></em>:  sometimes even if there are many problems in the existing application, a refactoring is never began, because the boss not want to invest in this process, and the support team have to manage the stress generated by all bugs and feedbacks.</p>
<p><strong><span style="color:#3366ff;">Which factors can influent the quality of design and implementation?</span></strong></p>
<p>To avoid investing a lot of money and time when refactoring, the good solution is to design well the application, but there are some traps that can influent the code quality:</p>
<p><em><span style="color:#3366ff;">No architect and designers in the team:</span></em></p>
<p>Unfortunately there are some projects initiated with only developers, and no architect is present, the problem is that we can discover this misconduct very early and it can contribute of the project failing.</p>
<p><em><span style="color:#3366ff;">Prototype:</span></em><br />
A prototype typically simulates only a few aspects of the features of the eventual program, and may be completely different from the eventual implementation.</p>
<p>Unfortunately many projects are based on the prototype without any review of architecture, design and implementation, and this trap is due to the rapidity of development and the team thinks that’s a good solution to continue with a prototype to gain time.</p>
<p><em><span style="color:#3366ff;">Frameworks used:</span></em></p>
<p>Some frameworks provide useful classes but can influent also the design, for example MFC or Qt are intrusive frameworks.</p>
<p>Using some bad designed functionalities of such frameworks can influent to complicate the design of project, let’s take as example the Doc/View design provided by MFC, if a designer choose to consider CDocument as the model as encouraged by the MFC documentation, it will be a bad choice.<br />
The model must be independent of MFC to be used in other contexts easily; however CDocument can be used as controller.</p>
<p><em><span style="color:#3366ff;">Technology high coupling:</span></em></p>
<p>Some architects and designers forget the low coupling concept, and propose a high coupled design with the technology or the frameworks used.</p>
<p>For example If CORBA is used for a distributed system, it must be isolated in the communication level, and all other classes must be CORBA independent.</p>
<p>Unfortunately in some projects we can found CORBA types used also in the business classes and it complicate a lot the application.</p>
<p>In my opinion this problem is the most popular  and the very dangerous one; it has an enormous impact especially for C++ projects, indeed currently finding a good C++ developer is not very easy, and finding one who master many technologies and frameworks become very hard, so creating a high coupling application with technology used implies that all the team must know it, but if the application is low coupled with technology, it will facilitate the human resource department  task and they can find easily C++ developers.</p>
<p>Your experience is very interesting to identify the bad design origin, for that you can vote to identify each factor is the most responsible.</p>
<p style="text-align:center;"><a href="http://polldaddy.com/poll/2396476/">View This Poll</a></p>
<br />Posted in CodeProject  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppdepend.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppdepend.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppdepend.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppdepend.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppdepend.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppdepend.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppdepend.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppdepend.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppdepend.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppdepend.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppdepend.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppdepend.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppdepend.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppdepend.wordpress.com/173/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=173&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppdepend.wordpress.com/2009/12/17/refactoringwhats-the-origin-of-bad-design/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/92d6551df2d319e31f6d7f0af63ddce4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cppdepend</media:title>
		</media:content>
	</item>
		<item>
		<title>C vs C++: Linux analysis case</title>
		<link>http://cppdepend.wordpress.com/2009/12/04/c-vs-c-linux-analysis-case/</link>
		<comments>http://cppdepend.wordpress.com/2009/12/04/c-vs-c-linux-analysis-case/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 15:22:54 +0000</pubDate>
		<dc:creator>cppdepend</dc:creator>
				<category><![CDATA[CodeProject]]></category>

		<guid isPermaLink="false">http://cppdepend.wordpress.com/?p=162</guid>
		<description><![CDATA[I think that the debate &#8220;C vs C++&#8221; will end when the two langagues will died, and each one have its advantages and inconvenients, the choice of one instead of another depends on the application context. Recently i read a famous linus torvalds opinion about C++, where he wrote: &#8220;C++ is a horrible language. It&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=162&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I think that the debate &#8220;C vs C++&#8221; will end when the two langagues will died, and each one have its advantages and inconvenients, the choice of one instead of another depends on the application context.</p>
<p>Recently i read a famous linus torvalds <a href="http://community.thinbasic.com/index.php?topic=1214.0">opinion</a> about C++, where he wrote:</p>
<p>&#8220;C++ is a horrible language. It&#8217;s made more horrible by the fact that a lot of substandard programmers use it, to the point where it&#8217;s much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out,that in itself would be a huge reason to use C.&#8221;<br />
<span id="more-162"></span><br />
I decide to do a quick analysis of Linux using <a href="http://www.cppdepend.com/">CppDepend</a> and try to understand the Linus opinion.</p>
<p>CppDepend can analyse Visual Studio projects without any configuration, but if the build process is described by another build processing system like Makefile, SCONS, CMake or others, the solution is to use the ProjectMaker to describe the project to be analyzed.</p>
<p>For Linux we can use ProjectMaker to describe projects to analyze.</p>
<p>Linux code source contains many directories, and to have a clear vision of code source we will associate each directory to a project.</p>
<p><BR></p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2009/12/pm.png"><img style="cursor:pointer;width:260px;height:400px;" src="http://cppdepend.files.wordpress.com/2009/12/pm.png?w=194" alt="" border="0" /></a>
</div>
<p><BR></p>
<p>And for each project we can specify other informations:</p>
<p><BR></p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2009/12/pm2.png"><img style="cursor:pointer;width:400px;height:190px;" src="http://cppdepend.files.wordpress.com/2009/12/pm2.png?w=300" alt="" border="0" /></a>
</div>
<p><BR></p>
<p><span style="font-size:130%;"><span style="color:rgb(51,51,255);font-weight:bold;">C vs C++ comparison</span></span></p>
<p><span style="color:rgb(51,51,255);font-weight:bold;">Modularity:Physical vs Logical</span></p>
<p>Modularity  is a software design technique that increases the extent to which software is composed from separate parts  , you can manage and maintain modular code easily.</p>
<p>We can modularize a project with two approachs:</p>
<p>- physically: by using directories and files, this modularity is provided by the operating system and can be applied to any langague.</p>
<p>- logically: by using namespaces,component,classes,structs and functions, this technique depends on the langague capabilties.</p>
<p>when we develop with C, and to package our code we use essentialy physical modularity, for example for Linux each module is isolated in directory and each file contains structs,variables and methods relative to a specific functionality.</p>
<p>This dependency graph shows relation between some linux directories:</p>
<p><BR></p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2009/12/all.png"><img style="cursor:pointer;width:400px;height:253px;" src="http://cppdepend.files.wordpress.com/2009/12/all.png?w=300" alt="" border="0" /></a>
</div>
<p><BR></p>
<p>C++ instead of C can use namespaces and classes to modularize the code, thoses types are provided by the langague, and for the previous graph we can use namespaces to modularize our code instead of directories.</p>
<p>C++ provide an efficient way to modularize the code base, but why namespaces artifacts are not enough used? for example only some C++ open source projects use it, maybe it&#8217;s due to historical reason or maybe we use &#8220;C with Classes&#8221; where the C habits are all the time present instead of modern C++.</p>
<p>What the difference between the two approachs?</p>
<p><span style="color:rgb(51,51,255);font-style:italic;">Lisibility</span> : the logical approch is better, because we can understand and use easily the code, and we dont need to know the physical emplacement of a code element.</p>
<p><span style="color:rgb(51,51,255);font-style:italic;">Managing changes:</span> a good design need in general many iterations, and for the physical approch the impact of  design changes can be very limited than logical one, indeed we need only to move function or variable from a file to another, or move file from directory to another.</p>
<p>However for C++ it can impact a lot of code because the logical modularity is implemented by the langage artifacts and a code modification is needed.</p>
<p><span style="font-weight:bold;color:rgb(51,51,255);">Encapsulation:Class vs File</span></p>
<p>For C++ the encapsulation is defined as the process of combining data and functions into a single unit called class. Using the method of encapsulation, the programmer cannot directly access the data. Data is only accessible through the functions present inside the class.</p>
<p>For C we can have an encapsulation but using also a physical approach like described in the modularity section, and a class can be a file containing functions and data used by them, and we can limit the accesibility of functions and variables by using &#8220;static&#8221; keyword.</p>
<p>Linux use  this technique to hide functions and variables, to discover that let&#8217;s search for static function:</p>
<p><span style="color:rgb(51,51,255);">SELECT METHODS WHERE</span> IsStatic</p>
<p><BR></p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2009/12/sm.png"><img style="cursor:pointer;width:676px;height:156px;" src="http://cppdepend.files.wordpress.com/2009/12/sm.png?w=300" alt="" border="0" /></a>
</div>
<p><BR></p>
<p>and also we can search for static varibles:<br />
<span style="color:rgb(51,51,255);">SELECT FIELDS WHERE</span> IsStatic</p>
<p><BR></p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2009/12/fs.png"><img style="cursor:pointer;width:326px;height:302px;" src="http://cppdepend.files.wordpress.com/2009/12/fs.png?w=300" alt="" border="0" /></a>
</div>
<p><BR></p>
<p><span style="font-style:italic;color:rgb(51,51,255);">Lisibility:</span>using C++ encapsulation mecanism improve the understanding and lisibility of code, C is low level and use physical approch rather than logical.</p>
<p><span style="color:rgb(51,51,255);font-style:italic;">Managing changes:</span>if we have to change the place where varibale or function are encapsulated, it can very easy for C, but for C++ it can impact a lot of code.</p>
<p><span style="font-weight:bold;color:rgb(51,51,255);">Polymorphism vs Selection idiom</span></p>
<p>Polymorphism means that some code or operations or objects behave differently in different contexts.</p>
<p>This technique is very used in C++ projects, but what about C?</p>
<p>for procedural langages the selection techniques by using the keywords &#8220;switch&#8221;, &#8220;if&#8221; or maybe &#8220;goto&#8221; can simulate the polymorphism behavior, but this technique tend to increase  cyclomatic complexity of code.</p>
<p>Let&#8217;s search for complex function and see if the polymorphism can minimize the complexity.</p>
<p><BR></p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2009/12/cc.png"><img style="cursor:pointer;width:354px;height:284px;" src="http://cppdepend.files.wordpress.com/2009/12/cc.png?w=300" alt="" border="0" /></a>
</div>
<p><BR></p>
<p>the more complex function w9968cf_v41_ioctl use a big switch to differentiate a behavior that depends on a specific command, with C++ we can use polymorphism and command pattern to minimize the complexity of this code.</p>
<p><span style="color:rgb(51,51,255);font-style:italic;">Lisibility</span>: using Polymorphism permit the isolation of a specific behavior to a class, it improve the visibility of the code.</p>
<p><span style="color:rgb(51,51,255);font-style:italic;">Managing changes</span>: adding another behavior with polymorphism can implies the adding of another class, however with selection idiom, you can add only another case under the switch statement.</p>
<p><span style="color:rgb(51,51,255);font-weight:bold;">Inheritance vs Agregation</span></p>
<p>Linux use essentially structs to define data manipulated by functions.</p>
<p>Let&#8217;s search for all structs used:</p>
<p><span style="color:rgb(51,51,255);">SELECT TYPES WHERE</span> IsStructure</p>
<p><BR></p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2009/12/structure.png"><img style="cursor:pointer;width:323px;height:331px;" src="http://cppdepend.files.wordpress.com/2009/12/structure.png?w=292" alt="" border="0" /></a>
</div>
<p><BR><br />
but what happened when struct has a common data as another, for exemple many struct can be considered as &#8220;inode&#8221; with adding some other fields, in this case the agregation is used instead of inheritance, let&#8217;s search for structs using &#8220;inode&#8221;.<br />
<span style="color:rgb(51,51,255);"><br />
SELECT TYPES WHERE</span> IsDirectlyUsing &#8220;<span style="color:rgb(255,0,0);">inode</span>&#8220;</p>
<p><BR></p>
<div style="text-align:center;"><a href="http://cppdepend.files.wordpress.com/2009/12/inode.png"><img style="cursor:pointer;width:356px;height:383px;" src="http://cppdepend.files.wordpress.com/2009/12/inode.png?w=278" alt="" border="0" /></a>
</div>
<p><BR></p>
<p>Some structs using inode can be inherited from it, but the agregation technique is used instead.</p>
<p><span style="color:rgb(51,51,255);">Lisibility:</span> using inheritance can improve the understanding of data, but we have to be carefull whene using it, its used only for the  &#8220;Is&#8221; relation.</p>
<p><span style="color:rgb(51,51,255);">Managing changes:</span> Inheritance implies a high coupling so any changes can impact a lot of code.</p>
<p><span style="color:rgb(51,51,255);font-weight:bold;">Conclusion:</span></p>
<p>C++ provide a better lisibility but any changes or refactoring can be difficult, and Linus talk about this idea of design changes in the same post:</p>
<p>&#8220;inefficient abstracted programming models where two years down the road you notice that some abstraction wasn&#8217;t very efficient, but now all your code depends on all the nice object models around it, and you cannot fix it without rewriting your app.&#8221;</p>
<p>But doing refactoring need to understand the existing code and design before making changes, and C program is very difficult to understand but easy to change, however C++ can be more lisible than C but need some effort when making changes.</p>
<p>How we can limit the impact of changes for C++?</p>
<p>The good solution to limit the impact of changements is to use patterns, specially low coupling concept to isolate changes only in a specific place, Irrlicht as explained in the previous <a href="http://cppdepend.wordpress.com/2009/11/21/irrlichtthe-art-of-using-grasp-patterns/">post</a> is a good example of using low coupling.</p>
<br />Posted in CodeProject  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppdepend.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppdepend.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppdepend.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppdepend.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppdepend.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppdepend.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppdepend.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppdepend.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppdepend.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppdepend.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppdepend.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppdepend.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppdepend.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppdepend.wordpress.com/162/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=162&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppdepend.wordpress.com/2009/12/04/c-vs-c-linux-analysis-case/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/92d6551df2d319e31f6d7f0af63ddce4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cppdepend</media:title>
		</media:content>

		<media:content url="http://cppdepend.files.wordpress.com/2009/12/pm.png?w=194" medium="image" />

		<media:content url="http://cppdepend.files.wordpress.com/2009/12/pm2.png?w=300" medium="image" />

		<media:content url="http://cppdepend.files.wordpress.com/2009/12/all.png?w=300" medium="image" />

		<media:content url="http://cppdepend.files.wordpress.com/2009/12/sm.png?w=300" medium="image" />

		<media:content url="http://cppdepend.files.wordpress.com/2009/12/fs.png?w=300" medium="image" />

		<media:content url="http://cppdepend.files.wordpress.com/2009/12/cc.png?w=300" medium="image" />

		<media:content url="http://cppdepend.files.wordpress.com/2009/12/structure.png?w=292" medium="image" />

		<media:content url="http://cppdepend.files.wordpress.com/2009/12/inode.png?w=278" medium="image" />
	</item>
		<item>
		<title>Irrlicht:The art of using GRASP patterns</title>
		<link>http://cppdepend.wordpress.com/2009/11/21/irrlichtthe-art-of-using-grasp-patterns/</link>
		<comments>http://cppdepend.wordpress.com/2009/11/21/irrlichtthe-art-of-using-grasp-patterns/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 23:06:31 +0000</pubDate>
		<dc:creator>cppdepend</dc:creator>
				<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://cppdepend.wordpress.com/?p=139</guid>
		<description><![CDATA[When we search for design pattern articles, we found essentially documentation concerning &#8220;Gang of Four&#8221; patterns, they are very useful and contribute to well design application. But when i discovered GRASP patterns , i advice any one interested to improve his skills design to look at this patterns, it gives a design fondamental rules. Irrlicht [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=139&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When we search for design pattern articles, we found essentially documentation concerning &#8220;Gang of Four&#8221; patterns, they are very useful and contribute to well design application.</p>
<p>But when i discovered GRASP patterns , i advice any one interested to improve his skills design to look at this patterns, it gives a design fondamental rules.</p>
<p><a href="http://irrlicht.sourceforge.net/">Irrlicht</a> is a 3D engine library that use many GRASP concepts, let&#8217;s discover with <a href="http://www.cppdepend.com">CppDepend</a> the benefits of using this kind of patterns, and to show using of GRASP concepts we will focus on the namespace irr::gui.<br />
<span id="more-139"></span><br />
<span style="font-weight:bold;color:rgb(51,51,255);"><br />
Creator:<br />
</span><br />
To detect with CppDepend  the existence of creator, the easy way is to to use a CQL query like this:</p>
<p><span style="color:rgb(51,51,255);">SELECT METHODS WHERE</span> DepthOfCreateA &#8220;<span style="color:rgb(255,0,0);">irr.gui.CGUISkin</span>&#8221; == 1<br />
<BR></p>
<div style="text-align:center;"><a href="http://4.bp.blogspot.com/_tWDA5bNBNHI/Swf-v-WvUeI/AAAAAAAAAW8/chXhgEKafTM/s1600/factory.PNG"><img style="cursor:pointer;width:316px;height:327px;" src="http://4.bp.blogspot.com/_tWDA5bNBNHI/Swf-v-WvUeI/AAAAAAAAAW8/chXhgEKafTM/s800/factory.PNG" alt="" border="0" /></a>
</div>
<p><BR><br />
So the CGUIEnvironement is the only class that create CGUISkin,</p>
<p>but  what about other GUI elements?</p>
<p>almost all GUIElement are created by CGUIEnvironement class except CGUIButton</p>
<p><span style="color:rgb(51,51,255);">SELECT METHODS WHERE</span> DepthOfCreateA &#8220;<span style="color:rgb(255,0,0);">irr.gui.CGUIButton</span>&#8221; == 1<br />
<BR></p>
<div style="text-align:center;"><a href="http://4.bp.blogspot.com/_tWDA5bNBNHI/Swf_GGdaraI/AAAAAAAAAXM/b5-N_N21qnM/s1600/factory3.PNG"><img style="cursor:pointer;width:397px;height:393px;" src="http://4.bp.blogspot.com/_tWDA5bNBNHI/Swf_GGdaraI/AAAAAAAAAXM/b5-N_N21qnM/s800/factory3.PNG" alt="" border="0" /></a>
</div>
<p><BR><br />
As we observe the CGUIButton is created in three different places, maybe there&#8217;s a reason for this behavior.</p>
<p>So  the CGUIEnvironement class act as creator, but what&#8217;s the role of CDefaultGUIElementFactory  class?</p>
<p>The dependency graph between CDefaultGUIElementFactory  and CGUIEnvironement  shows the relation between them:<br />
<BR></p>
<div style="text-align:center;"><a href="http://1.bp.blogspot.com/_tWDA5bNBNHI/Swf-9SE6ytI/AAAAAAAAAXE/jC2MA25E1cE/s1600/factory2.PNG"><img style="cursor:pointer;width:691px;height:400px;" src="http://1.bp.blogspot.com/_tWDA5bNBNHI/Swf-9SE6ytI/AAAAAAAAAXE/jC2MA25E1cE/s800/factory2.PNG" alt="" border="0" /></a></div>
<p><BR></p>
<p>Adding GUIElement begin with the invocation of CDefaultGUIElementFactory::addGuiElement , and this method invoke the right creation method from CGUIEnvironement, it depends of the type of element to create.</p>
<div style="text-align:left;">Finally the creation responsability and logic for GUI elements is isolated in two classes.
</div>
<p><BR><br />
<span style="font-weight:bold;color:rgb(51,51,255);">Controler</span></p>
<p>The Controler for GUIElements must at least manage event processing,this task is processed by CGuiEnvironement::OnEvent.</p>
<p>Let&#8217;s see which methods are used by OnEvent</p>
<p><span style="color:rgb(51,51,255);">SELECT METHODS WHERE</span> IsUsedBy &#8220;<span style="color:rgb(255,0,0);">irr.gui.CGUIEnvironment.OnEvent(constSEvent&amp;)</span>&#8220;<br />
<BR></p>
<div style="text-align:center;"><a href="http://2.bp.blogspot.com/_tWDA5bNBNHI/SwgAJwHUtPI/AAAAAAAAAXk/7oLf0_wdXJM/s1600/event2.PNG"><img style="cursor:pointer;width:342px;height:310px;" src="http://2.bp.blogspot.com/_tWDA5bNBNHI/SwgAJwHUtPI/AAAAAAAAAXk/7oLf0_wdXJM/s800/event2.PNG" alt="" border="0" /></a>
</div>
<p><BR><br />
So the event fired is processed by a class that implement IEventReceiver.</p>
<p>Which classes implement this abstract class?<br />
<span style="color:rgb(51,51,255);">SELECT TYPES WHERE</span> DeriveFrom &#8220;<span style="color:rgb(255,0,0);">irr.IEventReceiver</span>&#8221; <span style="color:rgb(51,51,255);">ORDER BY </span>DepthOfDeriveFrom</p>
<p><BR></p>
<div style="text-align:center;"><a href="http://1.bp.blogspot.com/_tWDA5bNBNHI/Swf_73wkE8I/AAAAAAAAAXc/nws7K2oFmug/s1600/event.PNG"><img style="cursor:pointer;width:400px;height:384px;" src="http://1.bp.blogspot.com/_tWDA5bNBNHI/Swf_73wkE8I/AAAAAAAAAXc/nws7K2oFmug/s800/event.PNG" alt="" border="0" /></a>
</div>
<p><BR><br />
What&#8217;s the other responsabilities of CGUIEnvironement?</p>
<p>As we have seen before this class create the concrete classes and also manage event processing, and to discove if it do another responsability we can search for methods used by this class:</p>
<p><span style="color:rgb(51,51,255);">SELECT METHODS WHERE</span> IsDirectlyUsedBy &#8220;<span style="color:rgb(255,0,0);">irr.gui.CGUIEnvironment</span>&#8220;<br />
<BR></p>
<div style="text-align:center;"><a href="http://3.bp.blogspot.com/_tWDA5bNBNHI/SwhiXJEYUSI/AAAAAAAAAY0/dg2bAeDpblQ/s1600/controler2.PNG"><img style="cursor:pointer;width:400px;height:345px;" src="http://3.bp.blogspot.com/_tWDA5bNBNHI/SwhiXJEYUSI/AAAAAAAAAY0/dg2bAeDpblQ/s800/controler2.PNG" alt="" border="0" /></a>
</div>
<p><BR><br />
This class use also classes from irr::io namespace to persist and load into xml files , so maybe this class has many responsabilities and it can impact it&#8217;s cohesion, but it still tolerable because this class has all informations needed to persist data so this class follows the &#8220;Information Expert&#8221; principle of GRASP.</p>
<p><span style="font-weight:bold;color:rgb(51,51,255);">Low Coupling</span></p>
<p>Low coupling is desirable because a change in one area of an application will require less changes throughout the entire application. In the long run, this could alleviate a lot of time, effort, and cost associated with modifying and adding new features to an application.</p>
<p>Using abstract classes can improve the low coupling and we can evaluate the abstractness of a defined module by the following metric :</p>
<p>A = Na / Nc</p>
<p>Where:</p>
<p>* A = abstractness of a modulke<br />
   Zero is a completely concrete module. One is a completely abstract module.<br />
* Na = number of abstract classes in the module.<br />
* Nc = number of concrete classes in the module.</p>
<p>The abstractness of Irrlich is equal to  0.1245972, and it contains 125 abstract classes.</p>
<p>And for irr::gui namespaces there&#8217;s 28 abstract classes , for each GUI element there&#8217;s the equivalent interface.</p>
<p><span style="color:rgb(51,51,255);">SELECT TYPES FROM NAMESPACES</span> &#8220;<span style="color:rgb(255,0,0);">irr.gui</span>&#8221;   <span style="color:rgb(51,51,255);">WHERE</span> IsAbstract<br />
<BR></p>
<div style="text-align:center;"><a href="http://2.bp.blogspot.com/_tWDA5bNBNHI/SwgWR5eIiRI/AAAAAAAAAYU/6c5r1CIgUWc/s1600/contracts.PNG"><img style="cursor:pointer;width:300px;height:400px;" src="http://2.bp.blogspot.com/_tWDA5bNBNHI/SwgWR5eIiRI/AAAAAAAAAYU/6c5r1CIgUWc/s800/contracts.PNG" alt="" border="0" /></a>
</div>
<p><BR><br />
CppDepend provide DSM graph, and we can triangularize this matrix to focus under red borders highly  dependent classes, and to detect modules.<br />
<BR></p>
<div style="text-align:center;"><a href="http://2.bp.blogspot.com/_tWDA5bNBNHI/SwgVZBlDfNI/AAAAAAAAAX8/sKHaKeT8ULY/s1600/contracts2.PNG"><img style="cursor:pointer;width:667px;height:314px;" src="http://2.bp.blogspot.com/_tWDA5bNBNHI/SwgVZBlDfNI/AAAAAAAAAX8/sKHaKeT8ULY/s800/contracts2.PNG" alt="" border="0" /></a>
</div>
<p><BR><br />
As we can observe all abstract classes are grouped, so we can consider them as module, so we can isolated them in another namespace or maybe in another project.</p>
<p>And to see the benefit of using abstract class to improve the low coupling, let&#8217;s search for classes that use the concrete class CGUISkin.</p>
<p><span style="color:rgb(51,51,255);">SELECT METHODS WHERE</span> IsDirectlyUsing &#8220;<span style="color:rgb(255,0,0);">irr.gui.CGUISkin</span>&#8220;<br />
<BR></p>
<div style="text-align:center;"><a href="http://4.bp.blogspot.com/_tWDA5bNBNHI/SwgAZ1mqmoI/AAAAAAAAAXs/Z4rwpcHWzjU/s1600/low.PNG"><img style="cursor:pointer;width:321px;height:297px;" src="http://4.bp.blogspot.com/_tWDA5bNBNHI/SwgAZ1mqmoI/AAAAAAAAAXs/Z4rwpcHWzjU/s800/low.PNG" alt="" border="0" /></a>
</div>
<p><BR><br />
So only one class know this class, it&#8217;s his creator.</p>
<p>And what about  IGUISkin:</p>
<p><span style="color:rgb(51,51,255);">SELECT METHODS WHERE</span> IsDirectlyUsing &#8220;<span style="color:rgb(255,0,0);">irr.gui.CGUISkin</span>&#8220;</p>
<p><BR></p>
<div style="text-align:center;"><a href="http://3.bp.blogspot.com/_tWDA5bNBNHI/SwgAgory4wI/AAAAAAAAAX0/fN7M7Haxwkc/s1600/low2.PNG"><img style="cursor:pointer;width:318px;height:400px;" src="http://3.bp.blogspot.com/_tWDA5bNBNHI/SwgAgory4wI/AAAAAAAAAX0/fN7M7Haxwkc/s800/low2.PNG" alt="" border="0" /></a>
</div>
<p><BR><br />
Unlike CGUISkin the IGUISkin class is visible and used by many classes.</p>
<p>What about coupling between namespaces:<br />
<BR><br />
<a href="http://4.bp.blogspot.com/_tWDA5bNBNHI/SwgWustXjEI/AAAAAAAAAYc/uacSid4pjEw/s1600/namespace3.PNG"><img style="cursor:pointer;width:713px;height:454px;" src="http://4.bp.blogspot.com/_tWDA5bNBNHI/SwgWustXjEI/AAAAAAAAAYc/uacSid4pjEw/s800/namespace3.PNG" alt="" border="0" /></a><br />
<BR><br />
A dependency cycle exist between namespaces, having this dependency can be not problematic but avoiding it enforce loose coupling, but what&#8217;s interesting than this dependency cycle is the manner that namespaces interact with each others.</p>
<p>When we choose to work with abstract classes, it&#8217;s recommended to interact between functional namespaces using abstract classes rather than concrete classes, except for namespaces that contains utility classes like irr::core.</p>
<p>Is Irrlich follow this rule?</p>
<p>for that let&#8217;s see what the namespace irr use as classes and methodes.</p>
<p><span style="color:rgb(51,51,255);">SELECT METHODS WHERE</span> IsDirectlyUsedBy &#8220;<span style="color:rgb(255,0,0);">irr</span>&#8220;<br />
<BR></p>
<div style="text-align:center;"><a href="http://2.bp.blogspot.com/_tWDA5bNBNHI/SwgW8xTo6uI/AAAAAAAAAYk/Gmuroydi81Y/s1600/namespace2.PNG"><img style="cursor:pointer;width:375px;height:400px;" src="http://2.bp.blogspot.com/_tWDA5bNBNHI/SwgW8xTo6uI/AAAAAAAAAYk/Gmuroydi81Y/s800/namespace2.PNG" alt="" border="0" /></a>
</div>
<p><BR><br />
As we can see almost all interaction with other namespaces pass by abstract classes, except for irr::video::CVideoModelList and irr::scene::CMeshBuffer.</p>
<p>Let&#8217;s discover the origin of the dependency with irr::video::CVideoModelList, for that we can execute the following CQL query:</p>
<p><span style="color:rgb(51,51,255);">SELECT METHODS OUT OF TYPES</span> &#8220;<span style="color:rgb(255,0,0);">irr.video.CVideoModeList</span>&#8221; <span style="color:rgb(51,51,255);">WHERE</span> IsUsing &#8220;<span style="color:rgb(255,0,0);">irr.video.CVideoModeList</span>&#8220;<br />
<BR></p>
<div style="text-align:center;"><a href="http://1.bp.blogspot.com/_tWDA5bNBNHI/SwhraJd6e8I/AAAAAAAAAY8/N9ZbajDfgIM/s1600/low3.PNG"><img style="cursor:pointer;width:400px;height:240px;" src="http://1.bp.blogspot.com/_tWDA5bNBNHI/SwhraJd6e8I/AAAAAAAAAY8/N9ZbajDfgIM/s800/low3.PNG" alt="" border="0" /></a>
</div>
<p><BR><br />
so the class irr::CIrrDeviceWin32 use it because this class declare a field as video::CVideoModeList instead of video::IVideoModeList.</p>
<p><span style="font-weight:bold;color:rgb(51,51,255);">High cohesion</span></p>
<p>The single responsibility principle states that a class should have more than one reason to change. Such a class is said to be cohesive. A high LCOM value generally pinpoints a poorly cohesive class. There are several LCOM metrics. The LCOM takes its values in the range [0-1]. The LCOMHS (HS stands for Henderson-Sellers) takes its values in the range [0-2]. Note that the LCOMHS metric is often considered as more efficient to detect non-cohesive types.</p>
<p> LCOMHS value higher than 1 should be considered alarming.</p>
<p><span style="color:rgb(51,51,255);">SELECT  TYPES WHERE</span> LCOMHS &gt; 0.95 <span style="color:rgb(51,51,255);">AND </span>NbFields &gt; 10 <span style="color:rgb(51,51,255);">AND </span>NbMethods &gt;10 <span style="color:rgb(51,51,255);">AND</span> !IsGlobal <span style="color:rgb(51,51,255);">ORDER BY</span> LCOMHS DESC</p>
<p><BR></p>
<div style="text-align:center;"><a href="http://1.bp.blogspot.com/_tWDA5bNBNHI/SwgVohcwIzI/AAAAAAAAAYE/MiD8FKKQlR8/s1600/cohesion.PNG"><img style="cursor:pointer;width:396px;height:240px;" src="http://1.bp.blogspot.com/_tWDA5bNBNHI/SwgVohcwIzI/AAAAAAAAAYE/MiD8FKKQlR8/s800/cohesion.PNG" alt="" border="0" /></a>
</div>
<p><BR><br />
Only few classes are considered as no  cohesive.</p>
<p><span style="color:rgb(51,51,255);font-weight:bold;">Conclusion:</span></p>
<p>Irrlicht use namespaces to modularize the code base and absract classes to improve low coupling, so it makes it very easy to understand and maintain.</p>
<p>It&#8217;s a good example to follow if you want to improve your design quality.</p>
<br />Posted in C++  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppdepend.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppdepend.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppdepend.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppdepend.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppdepend.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppdepend.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppdepend.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppdepend.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppdepend.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppdepend.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppdepend.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppdepend.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppdepend.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppdepend.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppdepend.wordpress.com&amp;blog=9544673&amp;post=139&amp;subd=cppdepend&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppdepend.wordpress.com/2009/11/21/irrlichtthe-art-of-using-grasp-patterns/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/92d6551df2d319e31f6d7f0af63ddce4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cppdepend</media:title>
		</media:content>

		<media:content url="http://4.bp.blogspot.com/_tWDA5bNBNHI/Swf-v-WvUeI/AAAAAAAAAW8/chXhgEKafTM/s800/factory.PNG" medium="image" />

		<media:content url="http://4.bp.blogspot.com/_tWDA5bNBNHI/Swf_GGdaraI/AAAAAAAAAXM/b5-N_N21qnM/s800/factory3.PNG" medium="image" />

		<media:content url="http://1.bp.blogspot.com/_tWDA5bNBNHI/Swf-9SE6ytI/AAAAAAAAAXE/jC2MA25E1cE/s800/factory2.PNG" medium="image" />

		<media:content url="http://2.bp.blogspot.com/_tWDA5bNBNHI/SwgAJwHUtPI/AAAAAAAAAXk/7oLf0_wdXJM/s800/event2.PNG" medium="image" />

		<media:content url="http://1.bp.blogspot.com/_tWDA5bNBNHI/Swf_73wkE8I/AAAAAAAAAXc/nws7K2oFmug/s800/event.PNG" medium="image" />

		<media:content url="http://3.bp.blogspot.com/_tWDA5bNBNHI/SwhiXJEYUSI/AAAAAAAAAY0/dg2bAeDpblQ/s800/controler2.PNG" medium="image" />

		<media:content url="http://2.bp.blogspot.com/_tWDA5bNBNHI/SwgWR5eIiRI/AAAAAAAAAYU/6c5r1CIgUWc/s800/contracts.PNG" medium="image" />

		<media:content url="http://2.bp.blogspot.com/_tWDA5bNBNHI/SwgVZBlDfNI/AAAAAAAAAX8/sKHaKeT8ULY/s800/contracts2.PNG" medium="image" />

		<media:content url="http://4.bp.blogspot.com/_tWDA5bNBNHI/SwgAZ1mqmoI/AAAAAAAAAXs/Z4rwpcHWzjU/s800/low.PNG" medium="image" />

		<media:content url="http://3.bp.blogspot.com/_tWDA5bNBNHI/SwgAgory4wI/AAAAAAAAAX0/fN7M7Haxwkc/s800/low2.PNG" medium="image" />

		<media:content url="http://4.bp.blogspot.com/_tWDA5bNBNHI/SwgWustXjEI/AAAAAAAAAYc/uacSid4pjEw/s800/namespace3.PNG" medium="image" />

		<media:content url="http://2.bp.blogspot.com/_tWDA5bNBNHI/SwgW8xTo6uI/AAAAAAAAAYk/Gmuroydi81Y/s800/namespace2.PNG" medium="image" />

		<media:content url="http://1.bp.blogspot.com/_tWDA5bNBNHI/SwhraJd6e8I/AAAAAAAAAY8/N9ZbajDfgIM/s800/low3.PNG" medium="image" />

		<media:content url="http://1.bp.blogspot.com/_tWDA5bNBNHI/SwgVohcwIzI/AAAAAAAAAYE/MiD8FKKQlR8/s800/cohesion.PNG" medium="image" />
	</item>
	</channel>
</rss>
