PhillyNJ Presentation and Code Files on Windows Service Design

Tonight Presentation

Thanks to everyone who braved the bad weather for the PhillyNJ meeting tonight.

I’ve posted the files on my SKYDRIVE at the folder on this link.

https://skydrive.live.com/redir.aspx?cid=79d1d19d50ff06b6&resid=79D1D19D50FF06B6!1069&parid=79D1D19D50FF06B6!106

I hope everyone found something useful from tonight presentation given that a good portion of it is one of the more boring (yet interesting) subjects.

 

Have Fun!

The Ron

ISO Files to USB – The Cheap and Easy Way

(DISCLAIMER: Yes there are lots of more elegant ISO software beside the free Microsoft one I’m about to show. But free is free and it has been tested and works for me for making advance bootable USB drives. That is another story. Look up Windows 8 Developer Preview for that one on BING.)

For those of use that work with new technology all the time we accumulate a lot of ISO files and have to burn them to CD/DVD’s quite often.

But we now have machines without burner in the corporate environment. We have personally Netbooks and light wait highly mobile laptops that do not have DVD burner.

USB ports are all the rage and now we have USB 3.0 which is way faster than the 2.0 we are used to.

Just looking at the technology, space saving and the cost issues alone is a reason to buy these answer to the DVD’s.

So what is special about USB 2.0 and USB 3.0?

USB 2 has a maximum speed of 480 Mbps... (That is Megabits per SECOND!!)

Now look at the storage that we have with USB thumb drives that are now up to 64 GB in size, cell phone and PDAs that have a lots of internal storage built in well above the 16 Gig range.

At the MAX USB 2.0 speed of 480 Mbps a full transfer of data in between devices can take a long time. Time is money right. Every back up a iPhone? Don’t get me started.

So at least the engineers have been planning ahead with USB 3.0 which offers a maximum transfer speed of 4.8 Gbps... (That is Giga bits per SECOND!!)

That speed is almost 10 times faster than USB 2.0 …. We don’t need to do the math on that one do we?

But for now I'm thrilled with USB 2.0 and the fact I can get these little 4 Gig USB drives for $4.00 each at Staples on sale.

ISO_USB_Demo000

Well that is a no brainer don’t you think. But what can you do with them to replace that DVD.

Simply and cheaply put………. THIS!

First let’s get an ISO file like the Visual Studio 2010 Ultimate DVD ISO from MSDN to demonstrate with. I develop on several computers so this is a good choice for me.

So we downloaded the ISO file and put it in a folder somewhere like this.

ISO_USB_Demo001

Next we go download to the Windows 7 USB/DVD Download Tool site and read about the tool. http://www.microsoftstore.com/store/msstore/html/pbPage.Help_Win7_usbdvd_dwnTool

And click this like to get the tool and install it.

ISO_USB_Demo002

Once it is installed you go to the Start, Programs menu, Windows 7 USB DVD Download Tool folder.

ISO_USB_Demo003

And then click the tool to open it up.

ISO_USB_Demo004

As you will see it is a sweet, simple tool that was originally designed to put the ISO for Windows 7 which is designed to be bootable on a USB or DVD for us geeks to play with. It is now being used for the Windows 8 Developer Preview by many developers for that for the same purpose it was built for in the past.

ISO_USB_Demo005

But for now we will use it to put a NON Bootable ISO on a USB. Hey it does the job and I’m reusing a left over program. Why buy the fancy one or a free trial and clutter up my machine.

We will click the BROWSE button and navigate to where we put our ISO file we want to put on the USB drive.

ISO_USB_Demo006

Obviously we are going to click NEXT and continue to select a USB Device (you can guess what the DVD button is for).

ISO_USB_Demo007

Next we select the USB that we have plugged into one of our laptops USB ports.

ISO_USB_Demo008

Then we click the BEGIN COPYING button and the first thing the program does is format our USB drive.

ISO_USB_Demo009

Then it starts copying out files out of the ISO and constructing the USB as if it was a DVD.

ISO_USB_Demo010

So now that the files are copying to the drive I’m going to warn you. We will error out here.

This program was design for bootable ISO’s of which this one is NOT. No problem because what fails it the writing of the bootable data to the drive that isn’t there. No biggie….

ISO_USB_Demo011

Forget the STARTOVER button is even there and click the dialog’s CLOSE button and exit the program.

ISO_USB_Demo012

Now go to Windows Explorer and navigate to the USB Device.

ISO_USB_Demo012a

You can now access everything and even add stuff to the drive. But for me I want to keep this drive for one purpose and that is to install VS2010 on various machines. So the only stuff I’ll add to this is a folder of notes on things on visual studio that I might want to put on other machines I’m installing VS2010 on to.

So that is it. Have a nice day!

The Ron

PhillyNJ - Open XML SDK, Windows Service Design and Other Goodies

For the November PhillyNJ.NET meeting I'll be presenting an early "Proof of Concept" application.


 

PhillyNJ.NET is a .NET Developer Group meeting in the Jersey suburbs of Philadelphia

Register for this Meeting at http://www.phillynj.net/Meeting/Register

Meeting Date: 11/29/2011 6-8pm
 


This meeting will be filled with design discussions around the functioning code that will be demonstrated and explained.

Given the two hour meeting time this will be a HIGH level and Low level mix of information on going about designing and building a practical enterprise level service.

This service has several applications of which this presentation will discuss.

  • Automated Excel Report Generation
  • Batch Processing of incoming data from third parties.
  • Automating BackOffice Systems
  • Etc...

A peek at a running service

IF you every asked yourself any of the following questions then this meeting is for you.

  • What is the Open Office XML SDK?
  • Can I use it on a server to create office document?
  • How to use the Repository pattern with a Generic Repository to create a disposable in memory database?
  • What is cool about Extension Methods and why should I use them? 
  • How do you go about developing a Windows Service?
  • What is the FileSystemWatcher and how can I use it even with it quirks?
  • How do I do basic Multi-Threading in an application?

And YES...  The code demonstrated will be made available to everyone.

So come on out and bring your questions. 

It should be educational on all levels and everyone should walk away having learned something and with a few new ideas.

--The Ron

How often to should you check your email?

Given all the social networking stuff people are going into information overload.

 I myself get 150 to 300 emails a day just at work.  Combine those numbers with one personal email account(s) and you can guess where I'm going.

 So HOW OFTEN should you check your emails.  I've thanks to work have had to do self improvement and time management training over the years. There are several thoughts and you have to combine the various "METHODS" out there.

 TO give you an idea here is the foundation for my current email schedule.

 The 24-Hour Method

 Other people argue that rather than check your emails starting later in the day, you should just check them once per day, in the morning. Among the members of this camp is productivity expert Elizabeth Grace Saunders. She generally clears out her inbox during the first 1-2 hours of her day, and formulates her game plan for the rest of the day after that. After that, she doesn’t generally look at her email again for the rest of the day, allowing her to focus completely on business development and client projects.

 

This is harder, of course, if you are at the bottom of the food chain at your company. But if you are in upper management or you are self-employed, setting this routine can be a great way to boost your productivity.

 When in Doubt, Check the Chart

 Scott Scheper checks his email twice a day, and has created a handy flow chart for helping you to blow through all the unread messages in your inbox.  This is one of my favorites take note.....

 Every time you open a new email, ask yourself 3 basic questions:

  1. Is this relevant?
  2. Can I solve this?
  3. Will it take less than 2 minutes of my time to deal with this?

 By following his handy flow chart, you’ll develop a new way to bust through your inbox more efficiently.

 What am I doing?  Since I'm a virtual Employee (Meaning I work at home)

 Personal.... I check in the mornings.  Later if I get a chance or am expecting something.  Other times on the smartphone if I'm in a car going somewhere and NOT driving.  That isn't very often. I get Twitter, Facebook, News and Text Messages that take up the rest of the personal email gap.  Hence my oldest boy send a text that says "Check your email I just sent you something" quite often.

 Work.... IN the Morning, Mid-Morning, Lunchtime, Twice in Afternoon, After Dinner and even later sometimes.  My company is GLOBAL and I have contacts in at least EIGHT different time zones.

 Add to this we have a corporate Instant Messaging System that PINGS and I have that one from morning till the End Of Day (EOD) before dinner time my time or after the last meeting of the day.

 Somewhere in that time especially these days I've several projects that require me to be HANDS ON and FACE DOWN in SOFTWARE CODE.  It's what pays the bills.

 What does that mean? 

 If you are family...  PING ME (via text) or Facebook it.  That causes my phone to PING getting my attention even if I'm in a meeting. 

 Puzzling thought...  The oldest son gets annoyed that I have my phone's sound on.  Yet says I need to check my phone and email more.  :-)  As are other family members on a different schedule than I am.

 Feel free to comment....  I'm sure we all ore of different views.

 The Ron

 

Working on part 2 of series for PHILLYNJ.NET

Just an update .... I'm currently working on the next presentation in the multi-part of a series on the Applied Design Patterns project called “AdventureWorksDesignPatterns” .

It has been a busy summer both at work and home. 

Summer is "DIY" time at my house as I'm building a 16 by 20 foot raised deck.

Work wise ..... Some of my team and I have been updating some of our "Demonstration" and "Proof Of Concept" applications to test out Microsoft's Windows Azure, SQL Azure and AppFabric

This is turning out to be very interesting and may require some blogs on this subject in the next year after we get AdventureWorksDesignPatterns”  series well underway.

I also want to do a thing on web security.  I'm not sure whether to treat that separately or to mix it into the Applied Design Patterns Series.  Anyone have any thoughts on this?

But my primary goal is to keep the “AdventureWorksDesignPatterns” Project on track, because I think there is really a need to demonstrate how to actually implement design patterns into a useful "Enterprise" application demonstrator for the community.

NOT to mention proving some of us Architects practice what we preach.

(Ha Ha... Yes Bill....  I try to practice what I preach!!)

 

Have a great summer everyone and keep checking back!!

The Ron

 

AdventueWorks Design Patterns Project - Part 1

This is the presentation I did June 29, 2011 at PHILLYNJ.NET. 

It is the first in a multi-part of a series on the Applied Design Patterns. 

 The solution files are working code with design pattern notes in the comment blocks.

After the overview and higher level discussions on Enterprise Design Patterns I reviewed the low level Database Access Library of code.  With walk-throughs of the the code and unint test.

After that we went through the ProductPhotoConsoleTest Application that performed intergration testing of the DBAccess Class with the AdventureWorks ProductPhoto table extracting the photos and writing them to a file folder.

The Demo code and PowerPoint can be obained from this link.

 https://skydrive.live.com/?wa=wsignin1.0&cid=29e34e9a8650bb9e#!/?cid=29e34e9a8650bb9e&sc=documents&id=29E34E9A8650BB9E%21151

Please note that I use Visual Studio 2010 Ultimate.  If you have a lesser version the Modeling projects likely will not work or have limited functionality and you should unload that project to prevent warning.

Enjoy!

--Ron

 

 

Applied Design Patterns Series

Overview of the “AdventureWorksDesignPatterns” Project

(I’ll be posting on this series here. It will be based on the presentations I’m creating for the PhillyNJ.NET user group a subgroup of PhillyDotNet)

This is the start of a long series on “applied design patterns”. The intent to demonstrate design patterns in real code. I am not endorsing or “pushing” any specific methodologies. But I will be stressing various points of views many of which are part of various methodologies you may have heard of.

That said I have specific goals for this series which are.

1.    To write the code implementing the design patterns.

2.    To have the code implementing the pattern be in an actual component as it would be used in a Enterprise level application.

3.    To demonstrate good coding practices

4.    To explain the design patterns in the code

5.    To update tools from my previous versions of my “reusable components” or “toolbox”.

6.    To do this on the AdventureWorks Sample Database.

The Approach

We are going to build a multi layered enterprise grade application demonstrating design patterns in actual use. This is NOT to say what you will be learning is just for “Enterprise” use.

This approach can be use at all levels of applications design …. NOT just the Enterprise. I want to drive that point home.

These are design patterns for ANY professional in the software industry should know and understand. (See my Design Patterns 100 blog series)

In a sense we will sort of be taking the bottom up approach. This is because we have and existing database and reusable components that have been evolving through the years.

Many years as a matter of fact.

The fact is my reusable components are always evolving with some having their basis in my old days of a C programmer working on medical equipment. Through the Visual Basic years, and on into the .NET framework and C#.

One big example is the “DBAccess” library. This name for my personal data access component goes all the way back to the wrapper I put around the B-Tree library called C-Index by Trios Systems in eighties.

So it is safe to say I’m stuck on some naming conventions. But I assure you this version we are working on is “State of My Art”.

The AdventureWorks Database goes back to SQL Server 2005. It was the sample database to replace the PUBS and NORTHWIND we old timers have know to over and hate though the years.

It was built to be robust and to demonstrate the use f the Business Intelligence services in SQL Server. Aside from the Project REAL database there is no other sample database that is as robust and could be used to support any type of Demonstrator” ”Proof of Concept” application. You can find the AdventureWorks database in it’s latest evolution on CodePlex at http://msftdbprodsamples.codeplex.com/releases/view/55926 .

For that fact, if you are interested in SL Server and haven’t seen the community samples you should check out the goodies at this link http://sqlserversamples.codeplex.com/ .

The High Level Solution

To start we have created a project solution in Visual Studio called AdventureWorksDesignPatterns that looks like this.

High Level Solution Image

This will give you and idea of what we are going to do here. Under each of these folders I will build complete projects for the logical layers of an Enterprise application.

These layers can be deployed physically in a number of ways via configuration changes and no rewriting of code.

The plan is to build the following projects in these folders:

01-Presentation Layer

·      MVC 2 Framework projects (Framework 4.0) .

·      Webforms Projects (Framework 4.0) .

·      Windows Presentation Framework (WPF) Projects (Framework 4.0) .

·      Silverlight Project (If I get to it.)

02-ServiceHost Layer

·      IIS Hosting WCF Projects for the Service Layer

·      Windows Service WCF Projects for the Service Layer

·      WCF NamedPipes Project for Service Layer (Compressed WebApp Tier Design)

03-Service Layer

·      Base Service Projects (datacontracts, message design, mapping, service implementations, etc..)

04-Business Layer

·      Business Objects Projects

05-Data Layer

·      Data Access Objects (DAO) and Factory Projects built using my DBAccessLibrary based on ADO.NET

ComponetsFW

·      DBAccessLibrary Projects

·      EncryptionLibrary Projects

·      FileSystemToolsLibrary Projects

·      LoggingToolsLibrary Projects

Database Solutions

·      AdventureWorks2008R2 Project (Scripts of Community Sample)

·      AdventureWoerksDesignPatternsDB Project (Modified AdventureWorks2008R2)

The work will initially begin from the bottom up.

Since we already have the reusable components and the database work will start here. Explain the design, what patterns are used, unit tests, etc..

I will be building a working ServiceHosting layer, Service layer, Business Layer, Data Layer ComponetsFW and Database first.

The idea is to get a working “Business Service” in place explaining all the design patterns to that level and the work that goes into it.

Once that is completed to a certain level, then we start on the presentation layer projects.

It is here that we will build various working “front ends” for our services.

The key points from the design is to have the proper separation of concerns through out the various layers of the design and to minimize maintenance.

In the end the reader will have functional code base, tools and understanding of design patterns.

I hope you decide to join me on this Adventure.

The Ron

 

PhillyNJ.NET short demo on how to view TechEd 2011 Session Videos

PhillyNJ.NET short demo on how to view TechEd 2011 Session Videos and Presentations

In case you missed it you should go check out the free content.  Here is how to get started!!

The presentation was held at http://www.phillynj.net which is a sub group of http://www.phillydotnet.org .

We’ve been meeting at the

Greenwich Township Branch Gloucester County Library System
411 Swedesboro Road Gibbstown, NJ 08027

PHONE: (856) 423-0684

If your looking for talent to employ, or just out to find fellow geeks and learn something new.

Come on out to visit us.

Recruiters and businesses we could always use a sponsor.

Please see the websites for information on events, etc…

http://www.phillynj.net AND http://www.phillydotnet.org

Design Patterns 100–Part5

“Design Patterns 100″ is a prerequisite for .NET Developers.

(Part 5 – Excerpts from July 2010 – PhillyNJ.NET Presentation)

Continuing our discussion from Part-4 we ask.

What are the “Gang of Four” (GoF) Behavioral Patterns and where can we find them in the .NET Framework?

Chain of Responsibility is a way of passing a request between a chain of objects

You can identify a Chain of Responsibility in the Windows event model where each UI control can decide to process an event or let it fall through to the next control in
the event chain.
Occasionally you may run into a Chain of Responsibility implementation in which a chain of objects process a message between a sender and a receiver, in which each object does some processing on the message as it travels through the chain from the sender to the receiver. This is slightly different from the GoF definition in which just one object in a chain decides to handle the request.

The .NET Framework implements this ‘stepwise chain pattern’ in .NET Remoting in which a message between a client and a server passes through one or more so-called message sinks. Message sinks form a chain as each sink has a reference to the next sink in the chain. These sinks implement the IMessageSink interface and one of its members is the NextSink property.

Command Encapsulates a command request as an object

Command in the .NET Framework is hidden in the the source code we can’t see. But I’m fairly sure that many Microsoft’s applications, including Visual Studio .NET, uses the Command pattern to support their menus, toolbars, shortcuts, and associated undo functionality.

We would have expected that the Command pattern would be exposed in .NET as part of WinForms architecture, but they are not. Until recently the Command patterns was not generally used in the .NET Framework. The Introduction of WPF changed that as WPF natively supports Commands in its Command System.

Interpreter is a way to include language elements in a program

I’m not really aware of the Interpreter pattern being used in the .NET Framework libraries. But is valuable for building scripting parsers, but it has limited value to business type applications. This is a highly specialized design pattern.

Iterator Sequentially accesses the elements of a collection

Iterator in the .NET Framework is not only part of the .NET Framework libraries, it is baked into the language itself. The .NET libraries contain numerous classes that implement the IEnumerable and IEnumerator interfaces, such as, Array, ArrayList, AttributesCollection, BaseChannelObjectWithProperties, BaseCollection, BindingsContext, as well as the generic counterparts of these classes.

.NET 3.0 made iteration even more fun and powerful with LINQ (language integrated query) which is a query language built on top of the generic IEnumerable<T> and IEnumerator<T> iterator types.

The foreach (For Each in VB) language construct is an implementation of the Iterator pattern. In fact, LINQ is almost entirely designed around the Iterator pattern.

Mediator Defines simple communication between classes

Mediator in the .NET Framework is not used in the .NET Framework libraries.

Memento Capture and restore and object’s internal state

Memento in the .NET Framework Serialization is the process of converting an object into a linear sequence of bytes for either storage or transmission to another location.

Deserialization is the process of taking in stored information and recreating objects from it. The Memento pattern creates a snapshot of an object’s state and then offers the ability to restore it to its original state.

This is what the serialization architecture of .NET offers and therefore qualifies as an example of Memento in the .NET Framework.

Observer A way of notifying change to a number of classes

Observer in the .NET Framework As mentioned, the .NET event model is implemented with the Observer design pattern and is found throughout the .NET Framework — both in the .NET languages and .NET class libraries.

.NET events and delegates are an implementation of the Observer pattern.

State Alter an object’s behavior when its state changes

State in the .NET Framework is not used in the .NET Framework it self.

The State Pattern, for example, is used when you have clearly defined state transitions, such as a Credit card application process that goes through a sequence of steps.

Strategy encapsulates an algorithm inside a class

An example of the Strategy pattern in .NET is the ArrayList which contains several overloaded Sort methods. These methods sort the elements in the list using a given class that implements the IComparer interface.

IComparer contains a Sort method that compares two objects and returns a value indicating whether one object is greater than, equal to, or less than the other object. Classes that implement the IComparer interface are implementations of the Strategy design pattern.

Template Method Defer the exact steps of an algorithm to a subclass

The Template Method is frequently used in the .NET Framework. It is through this pattern that .NET provides extensibility to the users of its API.

Take a look at custom controls in ASP.NET. Custom controls are created by inheriting from one of the control base classes (Control or WebControl). Also the Control class in the System.Windows.Forms namespace demonstrates usage of the Template Method.

These template methods allow the base class designer controlled extensibility by centralizing these methods as a single virtual method.

Microsoft suffixes these methods with the word “Core”.

Visitor defines a new operation to a class without change

The Visitor pattern is not used in the .NET Framework libraries.

If you discover anymore examples of the base patterns in the .NET Framework please leave a comment on this blog.

Design Patterns 100-Part4

“Design Patterns 100″ is a prerequisite for .NET Developers.

(Part 4 – Excerpts from July 2010 – PhillyNJ.NET Presentation)

Continuing our discussion from Part-3 we ask.

What are the “Gang of Four” (GoF) Structural Patterns and where can we find them in the .NET Framework?

Let’s look at a list of the Strutural Patterns as defined by the GoF.

  • Adapter Pattern – is used to match interfaces of different classes
  • Bridge Pattern – is used to separate an object’s interface from its implementation
  • Composite Pattern – Allows clients to treat individual simple and composite objects uniformly
  • Decorator Pattern – adds responsibilities to objects dynamically and is used for extending the functionality of an existing class
  • Façade Pattern – provides an interface that represents an entire subsystem making it easier to use
  • Flyweight Pattern – is primarily used to support the sharing of a lot fine-grained objects
  • Proxy Pattern – provides an object representing another object to control access to it

The Adapter Pattern is used to match interfaces of different classes

In the .NET Framework the Adapter pattern is used extensively in providing the ability for .NET clients to communicate with legacy COM components. As you know, there are significant differences between COM and .NET. These are handled via Runtime Callable Wrappers (RCW) which are implementations of the Adapter pattern. The Adapter adapts the COM interface to what .NET clients expect

The Bridge Pattern is used to separate an object’s interface from its implementation

The Bridge is a high-level architectural pattern and as such is not exposed by the .NET libraries themselves. But developers are not aware of this, but they use this pattern all the time. If you build an application that uses a driver to communicate with a database, like with ODBC, you’re using the Bridge pattern. ODBC is a standard API for executing SQL statements and represents the interface.

These Bridge design pattern classes are those that implement the API of the ODBC drivers. The ODBC architecture decouples an abstraction from its implementation so that the two can vary independently for the different database.

The Composite Pattern Allows clients to treat individual simple and composite objects uniformly.

The Composite pattern is widely used in the .NET Framework. Control classes are examples of this. The one for Windows apps is in the System.Windows.Forms namespace and the other is for ASP.NET apps in the System.Web.UI namespace. These Control classes support operations that apply to all Controls and their descendants in their respective environments, as well as operations that deal with child controls.

Windows Presentation Framework (WPF) also has many built-in controls that are examples of the Composite Pattern.
The Decorator Pattern adds responsibilities to objects dynamically and is used for extending the functionality of an existing class


Examples of the Decorator in the .NET Framework include a set of classes that are designed around the Stream class. The Stream class which is an abstract class that reads or writes a sequence of bytes from an IO device (disk, sockets, memory, etc). There are various implementations in the framework based on this class like BufferedStream and CryptoStream.

The new .NET Extension Methods are a closely related to the composite pattern as they also offer the ability to add functionality to an existing type. Similarly, attached properties and attached events which are used in WPF, also allow extending classes dynamically without changing the classes themselves.

The Façade Pattern provides and interface that represents an entire subsystem making it easier to use.

In the .NET Framework you’ll find numerous implementations of the Façade design pattern. It is used in scenarios where there is a need to present a simplified view over more complex set of types.
To discuss this properly we need to distinguish high-level architectural Facades and lower level component type facades. Microsoft has introduced its own terminology for the lower level façade types in component-oriented designs; they call these aggregate components.

In reality these are pure façades as they represent a higher level view of multiple lower level types and APIs. A classic example of an aggregate component is System.Diagnostics.EventLog which developers use all the time. Examples of high level include System.Web.Mail.SmtpMail, System.IO.SerialPort, System.Messaging.MessageQueue and System.Net.WebClient which provide simpler interfaces to shield the user from the complexities of the subsystem.

Ultimately the Facade Pattern is used through many design methodologies like Domain Driven Design and other areas of business objects as well as the presentation layer in an applications design.

The Flyweight Pattern is primarily used to support the sharing of a lot fine-grained objects.

It is a highly specialized design pattern. The Flyweight is used internally in the .NET Framework as string management techniques to minimize memory usage for immutable strings. An application example you would see implemented in word processors and graphical editors.

The Proxy Pattern provides an object representing another object to control access to it.

In .NET the Proxy pattern manifests itself in .NET Remoting infrastructure. Whenever an object requires access to an object in a different address space (app domain, process, or machine) a proxy is created that sends the request to the remote object and any data it might need.

Generally with proxies, the client is frequently not even aware that a proxy is at work. Clients applications use proxies to contact Web Services and WCF services which are auto-generated proxy objects.

(NEXT: Design Patterns 100-Part5 – Behavioral Patterns)