Reactive Programs and Windows Workflow Ramblings

I’ve started working heavily with Windows Workflow.  It seems this foundation from Microsoft is being heavily undersold in my opinion.  What one can do with this base is massive, at least for enterprise solutions, and in many a case for almost any type of solution.  This type of graphical design of workflow directly mapped to code has been needed for ages, oft promised, mostly just vaporware until now.

This is an entry documenting some of my first flailing through some samples I’ve been tossing together.

Sample 1

First I started a basic Sequential Workflow Console Application from Visual Studio by starting a new project.

Once the application is open I renamed the initial workflow file accordingly, since I have an obsessive compulsive issue with the default filenames and such.

Now that I’ve settled my obsession with things not being “default” I moved on to tossing some cool workflow controls into the SequentialWorkflow.cs file.  The first two I dropped in was a Code Control and a Delay Control.  After dropping these two controls onto the page I ended up with the diagram below.

There was one problem.  I wanted the delay to occur before the Code Control executes.  With the Workflow Extensions Diagramming it is ridiculously easy to change it, by simply dragging and dropping the delay in front of the Code Control I resolved my whole dilemma.

Now that everything in the world was right I tossed some petty Console.Write* code into each of the controls.  The code I entered was super basic for this example.

1 using System;

    2 using System.Workflow.Activities;

    3

    4 namespace WorkflowSampeSequential

    5 {

    6     public sealed partial class SequentialWorkflow : SequentialWorkflowActivity

    7     {

    8         public SequentialWorkflow()

    9         {

   10             InitializeComponent();

   11         }

   12

   13         private void delayFor30Seconds_InitializeTimeoutDuration(object sender, EventArgs e)

   14         {

   15             Console.WriteLine(“Pausing for 30 seconds.”);

   16         }

   17

   18         private void CodeActivityNumeroOne_ExecuteCode(object sender, EventArgs e)

   19         {

   20             Console.Write(“This is the console writing doing a \”Console.Write\”.  “);

   21             Console.WriteLine(“This is the \”Console.WriteLine\”.”);

   22         }

   23     }

   24 }

So with that snippet of code one can see how the example works to step through each part of the Workflow. My next example is going to be a little more elaborate. So now that the simple one is setup, cuz it’s always good to have that simple “working” example, my next workflow related entry will have some real meat to it.

Installing all the .NET Stuff

I’ve really been doing tons of hard core dev work with some of the newer .NET 3.0 technologies lately.  The project that is underway currently has been utilizing the WCF (Windows Communication Foundation) since it was beta and the SCSF (Smart Client Software Factory) since the first real CTP.  Those two foundations I have felt that the real technology utilization of .NET 3.0 was only halfway completed.  That notion being planted in my head, I’ve begun a trek to tie together the other parts of .NET 3.0 such as the WPF (Windows Presentation Foundation) and WF (Windows Workflow).  For that trek I use the following development tools, libs, factories, foundations, etc.

The following items are what I have installed for my development efforts:

  1. ReSharper – ReSharper is one of the, if not the most kick ass product for cleaning up, writing solid, keeping things formatting, intellisense enhancing, beautiful code helper application on the market!  This product is produced and sold by JetBrains.  I highly suggest going on getting this product.
  2. EntLib (Enterprise Library) – Application Blocks baby!!!  These rule.  If you’re building an application for an environment that could even remotely be considered “Enterprise” you should seriously consider using these.  If you aren’t, you’re most likely doing something VERY wrong.
  3. WCSF (Web Client Software Factory) – The WCSF is very helpful when building web applications with dedicated horizontally developing teams.  Check it out, you might find it useful for even non-horizontally aligned teams.
  4. Guidance Automation – The Guidance Automation Toolkits assist with templates and such for things like the Smart Client Software Factory, Web Client Software Factory, and other such foundations.  These can be very helpful to reduce those initial setup of code files for the mentioned foundations.
  5. Cropper – Cropper is a screen shot utility, been around for a while, been pointed out by dozens of developers, very helpful little utility with very little overhead!  This is the way helper applications should work!
  6. dotnetfx3 – Download it, code with it, love it.
  7. WPF & WCF Extensions – WF Extensions and WPF/WCF Extensions are rather vital to modern .NET 3.0 Development.  Download and install these already!
  8. WF Extensions – As mentioned above, WF Extensions are vitally important and awesome!
  9. Easymock.NET – Easymock is an easy dll lib that can be added to projects to do mock testing.  If you aren’t really familiar with mock testing I’ll have some posts on site soon, but until then check out the download and hit up Google with “mock unit tests” and you’ll have a plethora of things to read up on.

For Windows XP vs. Vista CTP releases and compatibilities check out the MSDN Site write up.

Technorati Tags: .NET 3.0, dotnetfx3, SDK, CTP, SCSF, WCSF, Smart Client, WCF, WF, WPF, Windows Presentation Foundation, Windows Workflow, Windows Communication Foundation, Application Blocks, Entlib, Enterprise Library, ReSharper, Jetbrains, Web Client Software Factory, Guidance Automation Toolkits, GAX, Cropper, WF Extensions, WCF Extensions, WPF Extensions, Easymock, Mock Testing, Unit Testing

del.icio.us Tags: .NET 3.0, dotnetfx3, SDK, CTP, SCSF, WCSF, Smart Client, WCF, WF, WPF, Windows Presentation Foundation, Windows Workflow, Windows Communication Foundation, Application Blocks, Entlib, Enterprise Library, ReSharper, Jetbrains, Web Client Software Factory, Guidance Automation Toolkits, GAX, Cropper, WF Extensions, WCF Extensions, WPF Extensions, Easymock, Mock Testing, Unit Testing

kick it on DotNetKicks.com

Law of Demeter :: Tip O' The Day

An important thing to remember when developing software is that readability and reliability are key to the future use and maintenance of the software.  This is especially true in the code.  One of the key laws that applies to this is the “Law of Demeter“.  This key law is simply to assure that object graphs stay reasonable, code is reliable to call, and that friends speak to friends and not strangers.

The Law of Demeter (LoD), or Principle of Least Knowledge is a design guideline for developing software, particularly object-oriented programs. The guideline was invented at Northeastern University in the fall of 1987, and can be succinctly summarized as “Only talk to your immediate friends.” The fundamental notion is that a given object should assume as little as possible about the structure or properties of anything else (including its subcomponents).

It is so named for its origin in the Demeter Project, an adaptive programming and aspect-oriented programming effort. This project was named in honor of Demeter, “distribution-mother” and goddess of agriculture, to signify a bottom-up philosophy of programming which is also embodied in the law itself.

When applied to object-oriented programs, the Law of Demeter can be more precisely called the “Law of Demeter for Functions/Methods” (LoD-F). In this case, an object A can request a service (call a method) of an object instance B, but object A cannot “reach through” object B to access yet another object to request its services. Doing so would mean that object A implicitly requires greater knowledge of object B’s internal structure. Instead, B’s class should be modified if necessary so that object A can simply make the request directly of object B, and then let object B propagate the request to any relevant subcomponents. If the law is followed, only object B knows its internal structure.

More formally, the Law of Demeter for functions requires that a method M of an object O may only invoke the methods of the following kinds of objects:

  1. O itself
  2. M’s parameters
  3. any objects created/instantiated within M
  4. O’s direct component objects

In particular, an object should avoid invoking methods of a member object returned by another method.

Continuing on in the definition points out the obvious advantages and disadvantages:

The advantage of following the Law of Demeter is that the resulting software tends to be more maintainable and adaptable. Since objects are less dependent on the internal structure of other objects, object containers can be changed without reworking their callers.

A disadvantage of the Law of Demeter is that it requires writing a large number of small “wrapper” methods (sometimes referred to as Demeter Transmogrifiers) to propagate method calls to the components – these increase development time, increase space overhead, increase maintenance cost, and decrease performance. Automated tools exist to at least partially counteract these problems.

The advantages in my opinion far outweigh the disadvantages.  Agree?  Disagree?

kick it on DotNetKicks.com

Software Development Testing :: Tip O' The Day

Know your testing definitions!  Knowing what types of tests there are, what they do, and what they’re used for is very important.

Unit Testing from Wikipedia

“In computer programming, unit testing is a procedure used to validate that individual units of source code are working properly. A unit is the smallest testable part of an application. In procedural programming a unit may be an individual program, function, procedure etc, while in object-oriented programming, the smallest unit is always a Class; which may be a base/super class, abstract class or derived/child class. Units are distinguished from modules in that modules are typically made up of units.

Ideally, each test case is independent from the others; mock objects and test harnesses can be used to assist testing a module in isolation. Unit testing is typically done by the developers and not by end-users.

Benefit

The goal of unit testing is to isolate each part of the program and show that the individual parts are correct. A unit test provides a strict, written contract that the piece of code must satisfy. As a result, it affords several benefits.“

Integration Testing from Wikipedia

“Integration testing (sometimes called Integration and Testing, abbreviated I&T) is the phase of software testing in which individual software modules are combined and tested as a group. It follows unit testing and precedes system testing.

Integration testing takes as its input modules that have been unit tested, groups them in larger aggregates, applies tests defined in an integration test plan to those aggregates, and delivers as its output the integrated system ready for system testing.”

System Testing from Wikipedia

“System testing is testing conducted on a complete, integrated system to evaluate the system’s compliance with its specified requirements. System testing falls within the scope of black box testing, and as such, should require no knowledge of the inner design of the code or logic. [1]

As a rule, system testing takes, as its input, all of the “integrated” software components that have successfully passed integration testing and also the software system itself integrated with any applicable hardware system(s). The purpose of integration testing is to detect any inconsistencies between the software units that are integrated together (called assemblages) or between any of the assemblages and the hardware. System testing is a more limiting type of testing; it seeks to detect defects both within the “inter-assemblages” and also within the system as a whole.”

del.icio.us Tags: Integration Test, Unit Test, System Test, Stub Test, Mock Test, Black Box, Test Plan Software Testing

Technorati Tags: Integration Test, Unit Test, System Test, Stub Test, Mock Test, Black Box, Test Plan Software Testing