Welcome

You have reached the blog of Keith Elder. Thank you for visiting! Feel free to click the twitter icon to the right and follow me on twitter.

Speaking at Lower .Net Alabama User Group

Posted by Keith Elder | Posted in Smart Clients, Speaking | Posted on 28-08-2006

0

Tuesday night I’ll be speaking at the Lower .Net Alabama User Group meeting.  It seems our friend Joe Healy had to cancel due to the tropical storm out in the Gulf.  Through a series of connections and the power of Microsoft Instant Messenger word got back they were looking for someone to speak so I’m stepping in and doing a repeat of the presentation I gave at the Memphis Code Camp on Saturday.  Although presentations are a lot of hard work learning, planning etc., they are very easy to repeat so I don’t mind.  The group is fairly new, only been around for about a year and they haven’t had anyone present on Smart Clients yet so it should be informative for everyone.

Memphis Code Camp Download: Developing Smart Client Applications For The Enterprise

Posted by Keith Elder | Posted in Smart Clients, Speaking | Posted on 26-08-2006

1

Today is Memphis Code Camp day and I was one of the first presenters up this morning.  We talked about Smart Clients until we were blue in the face.  For those that attended the session, thanks for geting up early and coming out!  Also a big thanks to Jerry Dixon for hosting the event.  As promised to those in the session I am making the presentation and code samples available for download.  Feel free to post questions to the blog if you have questions about the material.

Download Memphis Code Camp here.

Tip: ClickOnce Deployment

Posted by Keith Elder | Posted in Smart Clients | Posted on 28-07-2006

0

Julie Lerman posted to her blog about her struggles with ClickOnce deployment. I don’t know all the facts but reading her post really made me go, huh?  I’ve deployed a major CRM app via ClickOnce at work and I haven’t had any of these problems.  Everyone has different ways of getting their apps out to their users based on their environment configurations.  I don’t know what type of environment you are in or how your desktops are managed but here’s how I deploy ClickOnce apps for our Enterprise. 

ClickOnce Catch 22
You’ve wrote your application and you’ve copied it to your web server for ClickOnce deployment.  Question:  How do end users sitting in their cubes know the app is there?  Answer:  They don’t.  The big thing with ClickOnce is you have to jump start the user into launching the application via the URL.  One way would be to just email them the link.  That’s no different than how web sites are passed around today.  But what about tomorrow when a new employee starts.  They didn’t get the email so how do they know what to click on.  To make things somewhat seemless we need to help the users out.  We also want to automate this deployment so if a new computer get’s added to the network, the new employee can just start their computer and launch the app. 

Solution
To make it easy for user’s put an Icon on their desktop.  This icon should be a URL shortcut icon which is a link to the ClickOnce application.  Since the user is always launching the application via the network, auto updates will occur.  Even if your application installs a shortcut menu item for the user, it doesn’t matter which icon they click on.  They are still launching the application via the standard URL.  Depending on your environment, the steps below may be different.  The end result is the same.  To accomplish this:

1.  Make a simple MSI installer which has desktop icon.  The icon is just a shortcut to a URL where the application is deployed.
2.  Deploy the icon.  How you do this will depend on your environment.  At our company the windows engineers can deploy the icon using their whizbang deployment tools where user’s don’t even have to reboot.  I think they use Altiris for this but if you can auto update computers and have software updates installed at boot time, the same thing applies.

After the icon is deployed, the user sees the icon on the desktop and clicks on it.  The first launch it will check to see if it has already been installed and if not, install itself.  If they close the app and then click the icon again, the app checks for updates and then launches.  All subsequent clicks on the app (no matter which version is installed) work.  If they click on the app in the start menu, doesn’t matter, they are still launching it from the network in the right place.

If you think about it, how do user’s know how to find an internal web application or the intranet?  Usually the same thing is done, someone puts an icon on the desktop.

Codesmith and .NetTiers thoughts

Posted by Keith Elder | Posted in .Net, Programming, Smart Clients | Posted on 27-07-2006

2

I was catching up on some blog reading tonight and saw where Daniel had posted about using Codesmith and .NetTiers to generate code.  I’ve been using this for several months myself but hadn’t gotten around to blogging about it.

Quick intro to what it is.  Codesmith is a client app that users templates to generate code.  .NetTiers is an open source projected that provides templates to generate a n-tiered architecture.  If you watched my video cast of building a three tiered architecture in Visual Studio, using these two tools can quickly create the business and datalayer for a project.  Obviously it isn’t going to write business objects for you with all of your validation rules, but it does provide a start (if you think business objects are database records, which I don’t fully agree with).  On the Codesmith site you’ll find a nice 15 minute tutorial which can explain better how they work together.

The thing I use the most with .NetTiers is validating business entities.  Let’s say you have a Contact table in a database.  After .NetTiers runs, it will create a business object called “Contact”.  This object is generated into two partial class files typically called:

  • Contact.cs
  • Contact.generated.cs

The generated file shouldn’t be modified, the other you can modify.  Typically you will add a new method called “AddValidation()” to the Contact.cs object called from the constructor which adds all of your business rules.  For example, FirstName and LastName are required fields.  First and Last name much pass a regular expression validation before saving.  There is a folder in the businesslayer that .NetTiers generates called Validation where there are several generic objects to assist you with common validation rules. You can also add your own.  For example, you could write a method to have the database check to make sure no one else has the first and last name in the database before saving it.  The validation rules use delegates so you can write any method or logic you need to do validation.  Here’s some sample validation code:

    1 Validation.CommonRules.CompareValueRuleArgs<int> schemaValidationArgs =   new Validation.CommonRules.CompareValueRuleArgs<int>(“SchemaValidationId”, 0);

    2             schemaValidationArgs.Description = “Schema Validation is a required field and must be greater than 0.”;

In the example above the property SchemaValidatoinId must be great than 0.   The way the validation in .NetTiers is setup is based on a collection of validation rules.  Once your list of rules is established you simply need to invoke the Validate() on the object.  Validate then processes all of the rules in the list, making calls out to each delegate as it needs to.  What gets created as a result of this is a BrokenRulesList which is a property of your business entity.  Since I don’t have a contact table handy to generate actual code, here is some sudo code as to how things fit together.

    1 using System;

    2 

    3 /// <summary>

    4 /// Summary description for Contact

    5 /// </summary>

    6 public class Contact : ContactBase

    7 {

    8     public Contact():base()

    9     {

   10         AddValidation();

   11     }

   12 

   13     private void AddValidation()

   14     {

   15         Validation.ValidationRuleArgs nameArgs = new ValidationRuleArgs(“FirstName”);

   16         nameArgs.Description = “First Name is a required field.”;

   17         this.ValidationRules.AddRule(Validation.CommonRules.StringRequired, nameArgs);

   18     }

   19 }

   20 

   21 public class Test

   22 {

   23     Test()

   24     {

   25         Contact contact =  new Contact();

   26         contact.Validate();

   27         if (contact.BrokenRulesList.Length > 0)

   28         {

   29             // whoops, you have errors

   30         }

   31     }

   32 }

 

If you are like me and are writing Smart Clients with web services, the BrokenRulesList gives you an easy way to let user’s know what is wrong.  As a typical pattern, I pass the BrokenRulesList (which contains brokenRule objects) as an out parameter on the web service.  This way I can easily display or handle the errors in the Smart Client so it is friendly to the user.

 

Since you know the property in the BrokenRule object that is causing the problem, along with the description of the error, a quick foreach loop through your input controls on your windows form and you can automatically set ErrorProviders on your controls (same could apply for asp.net).  This could all be automated as well with enough time I think too. 

 

One thing I’ve noticed about some developers using .NetTiers is once they start using it, they want to use it for everything!  This is just wrong.  If you think of it from the standpoint of being able to put business rules and validation on information before it hits the database, you’ll be ok.  It isn’t the swiss army knife of developing apps though. 

 

Here is something else to consider about .NetTiers.  What if you only need to display one record with limited data, one or two columns?  This is where .NetTiers doesn’t help at all because given a primary key or a search filter it will always load the entire record.  To my knowledge there is no way to tell it what to load or not to load into the object.  Which logically speaking makes sense because if you updated the information you wouldn’t be able to pass the business rules of the object to save it.  It’s a catch 22 really.  In this case it is easier to just write your own query.  Sometimes you may not care, but in the enterprise where speed counts, you just can’t afford to be lazy.

Speaking at Memphis Code Camp

Posted by Keith Elder | Posted in Smart Clients, Speaking | Posted on 17-07-2006

0

I’ll be speaking at the Memphis Code Camp in August.  I will be covering Smart Clients for the Enterprise.  I’m pretty excited about speaking and have already started preparing in my spare time.  I am planning on covering lots of material.  I could easily turn it into a 8 hour session, there’ just so much stuff to talk about!  I’m looking forward to meeting several other speakers who’s blogs I read such as Wally.  It should be a great time, if you are in the area hopefully you can make it.