<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.developerdotstar.com/community" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>developer.* Blogs - How to Configure Asynchronous COM+ Loosely Coupled Events - Comments</title>
 <link>http://www.developerdotstar.com/community/node/141</link>
 <description>Comments for &quot;How to Configure Asynchronous COM+ Loosely Coupled Events&quot;</description>
 <language>en</language>
<item>
 <title>Objects, languages and thanks!</title>
 <link>http://www.developerdotstar.com/community/node/141#comment-3895</link>
 <description>&lt;p&gt;I don&#039;t want to pollute these fine posts with RTFM-kind of questions, or some &quot;below the level&quot; comments.  I just have to say that people (hopefully developers) should have (and read) discussions like these more often.  Objects are objects, no matter what.  They should all follow the same rules (yes, rules instead of standards) across languages and technologies, if we are hoping for a better “programming world”.  A silly VB6 programmer like my self some times lingers over these kind of topics, and is refreshing to know that all-programming-languages/techniques literates some times ask the same questions that I do.  The big difference is they actually conclude to something useful for us all.&lt;/p&gt;
&lt;p&gt;A while ago I was talking to a colleague about useless conversations.  &quot;You always know when you had one of those&quot;, she said &quot;You walk away feeling a little bit dumber&quot;.  I came here looking for some guidance on MSMQ and atomic transactions, and I walk away feeling a little bit smarter.  So, Daniel and Edward, in the name of us “grasshoppers”, my deepest thanks to you guys, for sharing your knowledge and experiences.&lt;/p&gt;
</description>
 <pubDate>Fri, 26 Jan 2007 14:52:38 -0800</pubDate>
 <dc:creator>Vino</dc:creator>
 <guid isPermaLink="false">comment 3895 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>_INTsequence</title>
 <link>http://www.developerdotstar.com/community/node/141#comment-255</link>
 <description>&lt;p&gt;The Shared variable _INTsequence appears throughout the code of Build Your Own as a simple sequence number identifying the order of appearance of the object within the Windows process.&lt;/p&gt;
&lt;p&gt;It starts with an underscore to show it is Shared: its Hungarian prefix is upper case because its name scope is object-wide (I apologize for using &quot;module level&quot; in the previous comment: it were a brain fart: it is VB-6 terminology: VB.Net files consist of classes).&lt;/p&gt;
&lt;p&gt;Since in practice multiple &quot;coding standards&quot; are the default, and because a Structuralist consistency is more important than any one coding standard I document my standards in Build Your Own without any implication they are Great. (Structuralist in the literal sense: a program is best understood not as a set of fixed referents but as a structure of identity and difference: understanding a program as the former creates unmaintainable code).&lt;/p&gt;
&lt;p&gt;Whereas when altering another programmer&#039;s code, I attempt to determine his coding standards and follow them exactly. This is because over and above ethnocentric wars, the consistency of the code is very important.&lt;/p&gt;
&lt;p&gt;But in following my own standards I never deviate in an almost autistic sense. This is because if they are good standards then they should be followed (this is &quot;obvious, profound, stupid, or all three&quot;).&lt;/p&gt;
</description>
 <pubDate>Sat, 05 Mar 2005 01:43:48 -0800</pubDate>
 <dc:creator>Edward G Nilges</dc:creator>
 <guid isPermaLink="false">comment 255 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>A flurry of answers for Daniel</title>
 <link>http://www.developerdotstar.com/community/node/141#comment-254</link>
 <description>&lt;p&gt;&quot;Stateless&quot; means that there are no variables preserved between method calls so it means, I think, the same thing a static. Because of VB&#039;s sloppiness, you can &quot;instantiate&quot; a class with no state in this sense, whereas in cleaner languages you can&#039;t, and static is a reminder that you can&#039;t.&lt;/p&gt;
&lt;p&gt;Being able to instantiate a class with no &quot;state&quot; has no application, of course, except as a zero operation to see if it can be done while testing the compiler.&lt;/p&gt;
&lt;p&gt;The actual objects in Build Your Own .Net Language and Compiler have in fact a read-only Usable property and a separate mkUnusable() method. The Usable property can be examined to see whether it is OK to use the object, but it can&#039;t be written because user code should not tell an Unusable object from the outside, &quot;you, Unusable object, are in fact Usable&quot;. There is no application for this and it violates common sense security.&lt;/p&gt;
&lt;p&gt;But the reverse operation is allowed through mkUnusable() if a user object senses abnormal behavior. This might be a security hole in that a bad user object can mark all objects it sees as Unusable, and disable a process thereby. I decided to implement it in the objects in Build Your Own because it biases the system to not proceeding in possibly erroneous situations, of which a &quot;bad user object&quot; is one: at worst, it stops the other objects from proceeding.&lt;/p&gt;
&lt;p&gt;The Hungarian notation is explained in Build Your Own. Module-level &quot;state&quot; variables that are not Structure or Class members have upper case Hungarian prefixes, while local and Static variables have lower case prefixes. This visually reveals the lifetime of each to the reader of the code.&lt;/p&gt;
&lt;p&gt;I can see NO good reason AT ALL for this postmodern rejection of Hungarian notation. No one programmer is at once so verbally facile and knowledgeable about his possible readership to choose the &quot;most meaningful&quot; non-Hungarian name: indeed, the very idea of &quot;most meaningful&quot; is at once introspective in a malign sense: an appeal to the mob: ethnocentric: and statistically, meaningless. &lt;/p&gt;
&lt;p&gt;The all-important selection of type is therefore a valuable addendum to the &quot;hopefully, most meaningful&quot; name. This is because the selection of type is an important forensic decision (in the sense of a decision with moral and business consequences) that needs to be relatively immoveable, and performed when the variable is created.&lt;/p&gt;
&lt;p&gt;A great programmer knows or discovers the range of values a variable can have: a lousy programmer randomly changes data type, while debugging.&lt;/p&gt;
&lt;p&gt;As such the variable type may be compared to human gender, which identifies people on documents because of its fixity, and in most cases its determination at birth. Which isn&#039;t to say, of course, that gender, or variable type cannot change.&lt;/p&gt;
&lt;p&gt;I conclude that the abandonment of Hungarian notation was performed as an Oedipal gesture of revolt.&lt;/p&gt;
&lt;p&gt;Finally, what I meant in the last comment was that in C, a complex data structure is often best implemented with auxiliary routines to check its validity and print it out, but these routines are extra work to write and maintain, and can cause bugs when not packaged with the original data structure.&lt;/p&gt;
&lt;p&gt;Whereas in OO, the &quot;complex data structure&quot; CONTAINS methods like inspect() and toString(), bound to its core &quot;with hoops of steel&quot;.&lt;/p&gt;
&lt;p&gt;I shall endeavor to be clear in the future.&lt;/p&gt;
</description>
 <pubDate>Sat, 05 Mar 2005 01:33:31 -0800</pubDate>
 <dc:creator>Edward G Nilges</dc:creator>
 <guid isPermaLink="false">comment 254 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>A Flurry of Questions for Edward</title>
 <link>http://www.developerdotstar.com/community/node/141#comment-253</link>
 <description>&lt;p&gt;Hi Edward,&lt;/p&gt;
&lt;p&gt;Thanks for taking the time to write and post that code. I&#039;ve been having fun studying it and your comments.&lt;/p&gt;
&lt;p&gt;I had suspected from your earlier post that you and I had two different ideas in mind while using the same word: &quot;stateless.&quot; I see now that you were thinking of statelessness as meaning &quot;instanceless,&quot; aka &quot;static.&quot; My concept of a stateless comes more from a COM+ context: objects are instantiated and participate in DTC transactions, but do not retain any state between method calls because COM+ in the background is actually destroying the objects between calls. In this sense there is a conceptual similarity to the notion of &quot;static.&quot; (And do they really think so poorly of VB programmers that they have to dumb down &quot;static&quot; to &quot;shared&quot;?)&lt;/p&gt;
&lt;p&gt;Given this disconnect I was having trouble from your original post in connecting the stateless concept to threading issues. But now, having read this latest post, I see that connection.&lt;/p&gt;
&lt;p&gt;Can you tell me more about _INTsequence? Is this just something you&#039;re using as an example to demonstrate the threading issues, or is this something you do in practice for production code? If it is standard practice for you, what is the utility of _INTsequence?&lt;/p&gt;
&lt;p&gt;[quote=&quot;Edward Nilges&quot;]Note, in the above, that I talk about the moral responsibilities of objects. This is because computing has, in my view, a forensic dimension, in which the &quot;mere&quot; coder remains responsible for his objects, which as entities are his proxies.[/quote]&lt;/p&gt;
&lt;p&gt;I like very much this idea of our code being our proxies in the world. It adds a whole new dimension to the concept of personal and professional responsibility for our work.&lt;/p&gt;
&lt;p&gt;Regarding your &quot;usable&quot; varaible: I notice you don&#039;t expose this as a property in the public interface. How then would client code instantiating an object from this class know whether or not the object is usable--that is, whether the constructor was successful? And would every public method, like tellmeSweetieWhatsMyName(), check BOOusable before doing anything? And would it be better for tellmeSweetieWhatsMyName() to raise an exception in the case that BOOusable is False?&lt;/p&gt;
&lt;p&gt;I&#039;m also curious about your use of an all-caps Hungarian convention. I take it you&#039;re not in agreement with the movement within the .NET world to eradicate Hungarian? And why all caps?&lt;/p&gt;
&lt;p&gt;[quote=&quot;Edward Nilges&quot;]In non-object code, the &quot;virtual&quot; constructs that appear are epiphenonemnal as regards the lines of code and only a first-rate computing imagination can fully retain a vision of the entities so supported. But a first-rate, or overactive, or merely caffeinated computing imagination is thereby like to generate many extra functions and subroutines for managing the virtual object that textually are only weakly linked.[/quote]&lt;/p&gt;
&lt;p&gt;Edward, you gotta help us mere mortals (the ones without philosophy degrees anyway) with this one. :-)&lt;/p&gt;
&lt;p&gt;I&#039;m looking forward to the promised type (3) code example.&lt;/p&gt;
&lt;p&gt;Dan&lt;/p&gt;
</description>
 <pubDate>Fri, 04 Mar 2005 08:48:58 -0800</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">comment 253 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Example of thread taxonomy</title>
 <link>http://www.developerdotstar.com/community/node/141#comment-239</link>
 <description>&lt;p&gt;Caution, the code is extempore. I discuss two thread models, the two most useful: stateless objects and serially threadable objects with a shared variable managed through interlocking. In a subsequent post IO shall provide code examples of objects that have state yet can fully thread.&lt;/p&gt;
&lt;div class=&quot;codeblock&quot;&gt;
&lt;pre&gt;Public Class stateless&lt;br /&gt;&lt;br /&gt;&amp;#039; A &amp;quot;stateless&amp;quot; class consists of no global data (other than&lt;br /&gt;&amp;#039; constants and type declarations). It can return constant&lt;br /&gt;&amp;#039; information and evaluate functions as black boxes based on&lt;br /&gt;&amp;#039; parameters only. It is free to declare local variables other&lt;br /&gt;&amp;#039; than static variables.&lt;br /&gt;&amp;#039;&lt;br /&gt;&amp;#039; Stateless classes have Shared methods exclusively and you don&amp;#039;t&lt;br /&gt;&amp;#039; need to (and stylistically should not) declare an instance using&lt;br /&gt;&amp;#039; a new() constructor when using a stateless class. Just use the&lt;br /&gt;&amp;#039; class name and think of the stateless class as ectomorphic or&lt;br /&gt;&amp;#039; transparent as compared with all other classes in this taxonomy.&lt;br /&gt;&amp;#039;&lt;br /&gt;&amp;#039; C# sharpies call these classes Static.&lt;br /&gt;&amp;#039;&lt;br /&gt;&amp;#039; The other classes must exist &amp;quot;concretely&amp;quot; in the world of things,&lt;br /&gt;&amp;#039; but stateless classes are the pure or fixed Idea of one or more&lt;br /&gt;&amp;#039; pure (reinen) procedures.&lt;br /&gt;&amp;#039;&lt;br /&gt;&amp;#039; As such, stateless classes are an excellent choice for tools &lt;br /&gt;&amp;#039; libraries written in the highest form of &amp;quot;functional&amp;quot; binding.&lt;br /&gt;&amp;#039; They are also very efficient. But like angels in theology they&lt;br /&gt;&amp;#039; lack the ability to interact with the world of men.&lt;br /&gt;&lt;br /&gt;     Public Shared ReadOnly Property ClassName()&lt;br /&gt;         Get&lt;br /&gt;             Return &amp;quot;stateless&amp;quot;&lt;br /&gt;         End Get&lt;br /&gt;     End Property&lt;br /&gt;&lt;br /&gt;     Public Shared Function returnLog(ByVal dblN As Double)&lt;br /&gt;            As Double&lt;br /&gt;          Return Math.Log(dblN)&lt;br /&gt;     End Function&lt;br /&gt;&lt;br /&gt;End Class&lt;br /&gt;&lt;br /&gt;Public Class seriallyThreadable&lt;br /&gt; &lt;br /&gt;&amp;#039; A &amp;quot;serially threadable&amp;quot; class can run simultaneously in more&lt;br /&gt;&amp;#039; than one competing thread, but only as distinct object&lt;br /&gt;&amp;#039; instance for each thread. The only variables shared by this&lt;br /&gt;&amp;#039; type of class are Shared variables which live in an area &lt;br /&gt;&amp;#039; associated with the class and not with the object instance.&lt;br /&gt;&amp;#039;&lt;br /&gt;&amp;#039; Serially threadable classes, or classes that need to be seen as&lt;br /&gt;&amp;#039; such, are probably the most common type of class. Multiple&lt;br /&gt;&amp;#039; instances can run but must work on separate data and communicate&lt;br /&gt;&amp;#039; only via their caller.&lt;br /&gt;&amp;#039;&lt;br /&gt;&amp;#039; If our image of a stateless class is that of an immaterial Angel&lt;br /&gt;&amp;#039; which does not exist in the world of men, a stateless class may&lt;br /&gt;&amp;#039; be thought of as a gentleman able to keep his paws off other&lt;br /&gt;&amp;#039; people&amp;#039;s data, but who insists on a right of property.&lt;br /&gt;&lt;br /&gt;     &amp;#039; --- Here is the object instance sequence number. I have&lt;br /&gt;     &amp;#039; --- prefixed it with an underscore as a notational&lt;br /&gt;     &amp;#039; --- convention. It is Private, considered as a name, for&lt;br /&gt;     &amp;#039; --- each object refers, using its own Private ID, to&lt;br /&gt;     &amp;#039; --- ONE location in Shared class data.&lt;br /&gt;     Private Shared _INTsequence As Integer&lt;br /&gt;&lt;br /&gt;     &amp;#039; --- Unlike a stateless class, this object has state, and&lt;br /&gt;     &amp;#039; --- notice how I slide from saying, stateless CLASS to&lt;br /&gt;     &amp;#039; --- &amp;quot;stateful&amp;quot; or &amp;quot;state-ridden&amp;quot; OBJECT. A CLASS is pure&lt;br /&gt;     &amp;#039; --- (reinen) code. An object is a mortal being with a &lt;br /&gt;     &amp;#039; --- soul of code, and its &amp;quot;sins&amp;quot; and other dross in state.&lt;br /&gt;     Private BOOusable As Boolean&lt;br /&gt;     Private STRname As String&lt;br /&gt;     Private COLcollection As Collection&lt;br /&gt;&lt;br /&gt;     Public Sub new()&lt;br /&gt;          &amp;#039; A REAL new() constructor should, in my opinion, take&lt;br /&gt;          &amp;#039; responsibility for its own success. When it creates a&lt;br /&gt;          &amp;#039; reference object, it should check for success. On&lt;br /&gt;          &amp;#039; failure, it needs to recognize that it is &amp;quot;deformed,&lt;br /&gt;          &amp;#039; unfinished, scarce half made up&amp;quot; and mark itself&lt;br /&gt;          &amp;#039; Not Usable.&lt;br /&gt;          STRname = CType(Interlocked.Increment(_INTsequence), _&lt;br /&gt;                          String)&lt;br /&gt;          Try&lt;br /&gt;              COLcollection = New Collection&lt;br /&gt;          Catch&lt;br /&gt;              &amp;#039; Dammit, I needed that collection. Although I&lt;br /&gt;              &amp;#039; (speaking as the Object Instance) need to&lt;br /&gt;              &amp;#039; enter the world, I know I am no good. Therefore&lt;br /&gt;              &amp;#039; I shall exit before marking myself Usable&lt;br /&gt;              &amp;#039;&lt;br /&gt;              &amp;#039; (No, I do not want to &amp;quot;set myself to Nothing&amp;quot;).&lt;br /&gt;              &amp;#039; With centralized garbage collection, this isn&amp;#039;t&lt;br /&gt;              &amp;#039; possible. As a damaged Object, I nonetheless have&lt;br /&gt;              &amp;#039; an ethical responsibility to .Net to Act Right&lt;br /&gt;              &amp;#039; until they come and take me away!&lt;br /&gt;              Return &lt;br /&gt;          End If &lt;br /&gt;          BOOusable = True    &lt;br /&gt;     End Sub&lt;br /&gt;&lt;br /&gt;     Public Function tellmeSweetieWhatsMyName() As String    &lt;br /&gt;         If Not BOOusable Then&lt;br /&gt;              &amp;#039; If the constructor failed, or a serious internal&lt;br /&gt;              &amp;#039; error occured elsewhere, I need here to record&lt;br /&gt;              &amp;#039; an error and return a suitable default. Here in&lt;br /&gt;              &amp;#039; this example I shall just return a simple default.&lt;br /&gt;              &amp;#039;&lt;br /&gt;              &amp;#039; In this particular example, I won&amp;#039;t say my name&lt;br /&gt;              &amp;#039; if I have been disposed, if my constructor failed,&lt;br /&gt;              &amp;#039; or somewhere else in a real solution, a serious&lt;br /&gt;              &amp;#039; error occured. In practice, one might make an&lt;br /&gt;              &amp;#039; exception for a simple Name, and other methods&lt;br /&gt;              &amp;#039; that do not need, for example, Heap data that may&lt;br /&gt;              &amp;#039; not exist.&lt;br /&gt;              Return &amp;quot;&amp;quot;&lt;br /&gt;         End If&lt;br /&gt;         Return strName&lt;br /&gt;     End Function&lt;br /&gt;&lt;br /&gt;     Public Function dispose() As Boolean&lt;br /&gt;         &amp;#039; Here, I need to get rid of the collection, and mark&lt;br /&gt;         &amp;#039; myself unusable. Getting rid of reference objects  &lt;br /&gt;         &amp;#039; created by the object instance that are in state is&lt;br /&gt;         &amp;#039; VERY important since otherwise they clutter the .Net&lt;br /&gt;         &amp;#039; heap with dead soldiers with nonzero reference counts,&lt;br /&gt;         &amp;#039; that the garbage collector does not see, to cart away,&lt;br /&gt;         &amp;#039; from off the field of glory.&lt;br /&gt;         &amp;#039;&lt;br /&gt;         &amp;#039; But I also must mark meself Not Usable since I don&amp;#039;t&lt;br /&gt;         &amp;#039; have the needed reference object.  &lt;br /&gt;         colCollection = Nothing&lt;br /&gt;         BOOusable = False&lt;br /&gt;    End Function&lt;br /&gt;&lt;br /&gt;End Class&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note, in the above, that I talk about the moral responsibilities of objects. This is because computing has, in my view, a forensic dimension, in which the &quot;mere&quot; coder remains responsible for his objects, which as entities are his proxies.&lt;/p&gt;
&lt;p&gt;In non-object code, the &quot;virtual&quot; constructs that appear are epiphenonemnal as regards the lines of code and only a first-rate computing imagination can fully retain a vision of the entities so supported. But a first-rate, or overactive, or merely caffeinated computing imagination is thereby like to generate many extra functions and subroutines for managing the virtual object that textually are only weakly linked.&lt;/p&gt;
&lt;p&gt;The notion of object construction and garbage collection, by clarifying object lifetime (its mortality along with its &quot;soul&quot; of immortal code), makes the object &quot;like&quot; a person with rights and responsibilities to a community which is proxy for the moral community of programmers, users, and managers.&lt;/p&gt;
&lt;p&gt;For this reason, it makes no sense to allow a constructor to finish in situations where you can detect failure, such as the failure to construct a needed reference object. But, the ONLY entity that you can terminate is the object itself; the glory days of yesteryear, where a single mainframe program could bring down the entire computer in a Wagnerian finale, are gone.&lt;/p&gt;
&lt;p&gt;In fact, if the object contains more than one reference object, and in the constructor some objects are created successfully but then an object is not, and the constructor returns without marking the object instance Usable, the object itself should dispose() itself, and the dispose() routine needs to test each reference object that it either Sets to Nothing or disposes for Nothinghood.&lt;/p&gt;
&lt;p&gt;Otherwise, a &quot;leakage&quot; of the successfully created objects will occur such that we have to trust the object user to execute dispose() on the Unusable object.&lt;/p&gt;
&lt;p&gt;The only foolproof solution is to dispose() in any case of Unusability, taking care in dispose() to check that you are not disposing Nothing in the form of a reference object in state that hasn&#039;t been created.&lt;/p&gt;
&lt;p&gt;I believe that there is a solution to these considerations in the form of a new programming language with a &quot;rich&quot; object (as opposed to the thin Object of .Net, a thing with only GetType and no properties).&lt;/p&gt;
&lt;p&gt;The RichObject, the top level object in my Language, would have properties including Usable, Name and whether it can be instantiated in the first place. Furthermore in my Language, one could compare disimilar objects for their list and types of properties would be &quot;first class&quot; properties of the object itself. &lt;/p&gt;
&lt;p&gt;But all that is More Fun Work.&lt;/p&gt;
&lt;p&gt;A further note. It is easy to violate thread taxonomy when your code accesses the functions of MS-DOS.&lt;/p&gt;
&lt;p&gt;Suppose two competing threads read a file. If it&#039;s the same file, they need separate internal locks (using Interlocked) on that file.&lt;/p&gt;
&lt;p&gt;Where do you put the lock?&lt;/p&gt;
&lt;p&gt;It can&#039;t be an MS-DOS facility, such as a file or a Registry entry, for this creates infinite regress: you have to lock, access to the lock.&lt;/p&gt;
&lt;p&gt;It has to be in Shared variables associated with the class, but even here there is, I think, a danger. If a Windows PROCESS invokes .Net to create multiple THREADS, they all see the Shared lock which controls access to MS-DOS.&lt;/p&gt;
&lt;p&gt;But two PROCESSES might run the same class!&lt;/p&gt;
&lt;p&gt;I&#039;m pretty certain this is a real danger and I need to check it out. I will report on my results in the next comment along with presenting a fully threadable class with state as simple extempore code.&lt;/p&gt;
</description>
 <pubDate>Wed, 02 Mar 2005 05:16:38 -0800</pubDate>
 <dc:creator>Edward G Nilges</dc:creator>
 <guid isPermaLink="false">comment 239 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>The Fwizz Factor</title>
 <link>http://www.developerdotstar.com/community/node/141#comment-230</link>
 <description>&lt;p&gt;Great stuff, Edward. Can you provide a concrete example of your (1), (2), and (3) types?&lt;/p&gt;
&lt;p&gt;In my day-to-day working on high volume, highly scalable, transaction-oriented, web-based systems (with much of my code residing in COM+), I deal mainly with plain stateless classes (your type (1)). In this situation, the &quot;objects&quot; themselves are much less object oriented in the traditional sense. They tend to be much more structured in nature. This tends to happen because cross-process and cross-machine marshalling becomes a big factor when you have multiple tiers running statelessly on farms of web and application servers. Class interfaces must be designed to optimize marshalling and reducing the number of calls required to perform a given operation. So the most outward-facing methods in the business tier tend to be very use case oriented, with things becoming more generalized, abstract, and granular as you go down layer by layer.&lt;/p&gt;
&lt;p&gt;[quote=&quot;Edward Nilges&quot;]Some programmers delight in code that seems to work, code that demands their employment, code which cannot be spoken of except gnomically, and code that results in perverted vigils as the team gapes dully at screens at 3:00 AM. I do not.[/quote]&lt;/p&gt;
&lt;p&gt;This reminds me of my favorite Dilbert cartoon (someone needs to write a Dilbert search engine so I can find the cartoons I want when I need them).&lt;/p&gt;
&lt;p&gt;Wally and Dilbert are in a conference room with another guy we don&#039;t know. Wally or Dilbert says to this guy &quot;What&#039;s your secret? You come and go as you please, take long lunches, and walk around like you own the place. What gives?&quot;&lt;/p&gt;
&lt;p&gt;The guy replies, &quot;Fifteen years ago I wrote 15,000 lines of spaghetti that runs the entire payroll system.&quot;&lt;/p&gt;
&lt;p&gt;Wally and Dilbert genuflect: &quot;The Holy Grail! We&#039;re not worthy!&quot;&lt;/p&gt;
&lt;p&gt;The guy winks at them and says &quot;You boys will see a little extra in your checks this month.&quot;&lt;/p&gt;
&lt;p&gt;Dan&lt;/p&gt;
</description>
 <pubDate>Tue, 01 Mar 2005 11:39:28 -0800</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">comment 230 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>A note from Dr. Rotwang!</title>
 <link>http://www.developerdotstar.com/community/node/141#comment-228</link>
 <description>&lt;p&gt;You are a braver man than I am, Dan. I took one look at com multiprocessing above the level of DoEvents and decided not to use threads in COM at all. But in VB.Net beta, I could see that a clear semaphore model was in use and supports clear notions of atomic state transitions, etc.&lt;/p&gt;
&lt;p&gt;There are of course gotchas in VB.Net threading, the major one being that the atomicity isn&#039;t at the level of the VB.Net statement but at the level of the CLR instruction. But overall it&#039;s much clearer than in COM+.&lt;/p&gt;
&lt;p&gt;In dealing with .Net threads, I theorized early on that as far as I was concerned there are four distinct types of classes:&lt;/p&gt;
&lt;p&gt;(1) Stateless classes&lt;/p&gt;
&lt;p&gt;(2) Stateful classes fully threadable, both in the sense that ONE INSTANCE of the stateful class could run procedure code in competing simultaneous threads and in the sense that MULTIPLE INSTANCES of the stateful class could run in competing simultaneous threads.&lt;/p&gt;
&lt;p&gt;(3) Stateful classes serially threadable, in the sense that the second condition in (2) is met, and these classes may run multiple instances in competing threads.&lt;/p&gt;
&lt;p&gt;(4) Everything else, for if a class has state (in the sense of global variables that occupy storage at run time) and cannot be proven stateful(2) or stateful(3) it is assumed &quot;fully not threadable&quot;.&lt;/p&gt;
&lt;p&gt;Making a class type (1) is easy. Just don&#039;t have state. Of course, this severely limits what the class can do. Classes forced (by managerial ukase and preference for popular buzzwords such as &quot;stateless&quot;) into statelessness wind up in my experience generating secret &quot;scapegoat&quot; classes that in ugly fashion hold state, and pass it just in time (just in time, that is, to create confusion) to the &quot;stateless&quot; class as a series of ugly and confusing parameters.&lt;/p&gt;
&lt;p&gt;Making a class type (2) is almost as easy and nearly all classes in a straightforward environment can be type (2), such that multiple instances may simultaneously run: just make sure all Shared variables are read and changed through a lock, whether an Interlocked method in the case of value objects or a Synclock in the case of reference objects.&lt;/p&gt;
&lt;p&gt;Most of the classes in Build Your Own .Net Language and Compiler are type (3). They mostly have a single Shared variable, _INTsequence, which keeps track of the number of instances created in the current process and which is atomically incremented, and used to form the default instance name as   .&lt;/p&gt;
&lt;p&gt;About the only problem is that in forming the default instance name, I had to remember to both READ and CHANGE the variable in one call to Interlocked.Increment.&lt;/p&gt;
&lt;p&gt;This psychologically violates &quot;structured&quot; programming in a minor key, for ideally you would do one thing at a time, but my early assembler experience with a strange set of IO instructions came to my rescue: my first CPU featured an instruction that would both print a line and read a card, and since this was cool I would structure assembler code loops around its use, thereby replacing dull and literally noisy code with fast and quieter code: literally, ka-chung, ka-clank was replaced by a more atomic ta-pocketa as the results for one punched card were printed out while the next was read.&lt;/p&gt;
&lt;p&gt;This, and modern .Net threads, are what I call the fwizz factor in computing!&lt;/p&gt;
&lt;p&gt;Type (2) is harder to develop though not, as far as I can tell, as hard as using threads in COM. Here my experience is that you need to code a dispatch() method which knows the names of all Public procedures, and dispatches to private implementations of the Public functionality inside a lock.&lt;/p&gt;
&lt;p&gt;For simple type (2) objects, the complete state can be wrapped into a Class (that to keep things simple violates the rule that its Public members should not be variables). The dispatcher can then Synclock the class.&lt;/p&gt;
&lt;p&gt;But there are cases (such as one I am currently working on at my day job) where locking the complete state is not the answer, at all, and creates *de facto* nonthreading in the sense that instances simply form a one-dimensional queue, and execute the one after the other as the synclocks are released...meaning you did all that code for nothing!&lt;/p&gt;
&lt;p&gt;Here, my current praxis is not to throw up my hands and get random. It is to instead &quot;minimally partition&quot; the original state into a small number of separate &quot;states&quot;, and, correspondingly, document the rules as to what Public procedures can multithread.&lt;/p&gt;
&lt;p&gt;The process is &quot;documentation driven&quot; in the sense that any praxis has to conform either to the taxonomy described above, or else to overriding rules in the object reference manual. This is because in my experience, just as soon as you start using multiple threads without being to describe in clear and natural languages what it is you are doing, you are in a heap of trouble.&lt;/p&gt;
&lt;p&gt;Some programmers delight in code that seems to work, code that demands their employment, code which cannot be spoken of except gnomically, and code that results in perverted vigils as the team gapes dully at screens at 3:00 AM. I do not.  &lt;/p&gt;
&lt;p&gt;My method is used in qbGUI as published last year, but I am not completely happy with it; it is only that I am less happy with the various alternatives. The graphical user interface of the quickBasicEngine does support availability of the form while code is running and a Stop button using Type(2) threading but the Stop button does not work crisply. &lt;/p&gt;
&lt;p&gt;Also, a user (Randy Howard, apparently of Austin TX) encountered an error possibly related to this feature on a high-end multiple CPU system. Unfortunately, this individual&#039;s conduct on the Net, and the way he reported the error, means that I cannot interact with him collegialy to find out what&#039;s going on in his system.&lt;/p&gt;
&lt;p&gt;Nonetheless I am working on the Stop button feature in the next (and much delayed) edition of the compiler and will try to get access to a high end multiple processor system.&lt;/p&gt;
&lt;p&gt;I am tempted to add a fork statement to my optional set of Quickbasic extensions thereby giving anybody who&#039;s damnfool enough to use my stuff to code real code the ability to use .Net threads through &quot;my&quot; compiler and interpreter. But as I remark in my book, the programmer must realize that at times objects take on a life of their own, and, like Frankenstein, demand to exist.&lt;/p&gt;
&lt;p&gt;&quot;I was working in lab late one night, when my eyes beheld a weary sight: my monster from the slab began to rise, and to my surprise he did the Mash, he did the Monster Mash.&quot;&lt;/p&gt;
&lt;p&gt;You get the picture: the mad scientist is possessed by objects outside himself and must reflect on the fate of Dr. Frankenstein, or Rotwang in Fritz Lang&#039;s Metropolis: being overcome by an explicit reification of Objective Spirit. Or something like that.&lt;/p&gt;
&lt;p&gt;Multiprocessing and multithreading seems to bring out the worst in people owing to the difficulty of its bugs, and the attractions of the apparent something for nothing, the apparent fool&#039;s gold, the ectomorphic Cold Fusion: something (computing time) for nothing (ha! to think one is getting something for nothing, after hours of work, means that you have low self esteem, Dr. Rotwang!) &lt;/p&gt;
&lt;p&gt;Multiple threads create mental suffering of a high order, and in programmers (mostly male) socialized not to feel their own or other&#039;s pain, unlike Clinton, it creates authoritarian pathology.&lt;/p&gt;
&lt;p&gt;[Down, Ygor, down!]&lt;/p&gt;
&lt;p&gt;In the 1960s, highly placed Big Science managers at MIT&#039;s Multics project promised Mister Bigs that Multics would use multiprocessing to get blindingly fast answers. But so many issues were unresearched that the problems caused severe delays in the Multics project (although ultimately it was delivered). The response, by some folks at Princeton and Bell Labs, was the very name of unix, which was based on uniprocessing apart from its simple fork primitive and represented a strategic retreat from the fox to the hedgehog&#039;s way.&lt;/p&gt;
&lt;p&gt;As far as I can tell from the record, the history of thought about multiprocessing divides into Before Dijkstra and After Dijkstra, although Dijkstra had no truck with unix per se. It was only when Dijkstra directed his formidable intellect and dedication to truth at the problem was any progress made. My understanding is that he may have been the first to capture the essence of the problem and its solution in the idea of a completely atomic event.&lt;/p&gt;
&lt;p&gt;It was a philosophical rather than technical solution in that it is creative ontology to declare that what we need is a &quot;semaphore&quot; rather than bemoan or workaround its absence.&lt;/p&gt;
&lt;p&gt;In my own experience, I have usually seen philosophical computing ontology rejected. Instead of stepping back, and seeing if we can develop that which we all know is missing, &quot;teams&quot; are instead told by managers (in the ugly pose of the high school football coach) to persist in developing the solution as initially specified by noncoders, and this pathology is especially prevelant in multithread efforts.&lt;/p&gt;
&lt;p&gt;.Net threads are in this sense post-Dijkstra because they give you a simple answer: Interlocked and Synclock.&lt;/p&gt;
&lt;p&gt;Which isn&#039;t to say that you cannot get into trouble with these constructs, of course. By default qbGUI doesn&#039;t expose the Stop button and its own multithread capability has not been integrated with its constituent objects, which are all type (3).&lt;/p&gt;
&lt;p&gt;Finally, a comment about type (4). It&#039;s an epistemological category because the standard declares that if you cannot PROVE your object to be of types 1, 2, or 3, then it IS type 4. Better safe, than sorry.&lt;/p&gt;
&lt;p&gt;[Are we not men? Yes, Ygor.]&lt;/p&gt;
</description>
 <pubDate>Mon, 28 Feb 2005 19:22:32 -0800</pubDate>
 <dc:creator>Edward G Nilges</dc:creator>
 <guid isPermaLink="false">comment 228 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>How to Configure Asynchronous COM+ Loosely Coupled Events</title>
 <link>http://www.developerdotstar.com/community/node/141</link>
 <description>&lt;p&gt;A two-in-one special: the main post goes into great detail about exactly what the topic describes, but the attached comments go into a whole other discussion that should be of interest even to those with no interest in COM+.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.developerdotstar.com/community/node/141&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://www.developerdotstar.com/community/node/141#comment</comments>
 <category domain="http://www.developerdotstar.com/community/taxonomy/term/9">Windows</category>
 <pubDate>Mon, 28 Feb 2005 09:11:34 -0800</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">141 at http://www.developerdotstar.com/community</guid>
</item>
</channel>
</rss>
