Wednesday, September 08, 2010

I have a Right Vs. Right Thing to Do

I try to not get political in my blog. As many of my friends know I will speak my mind about many political issues, but I decided I didn't want my blog to really be political. I wanted it to be more a place to go to learn about technology or see my views on sports and movies. That said I am taking a little detour today.

This is a post I have been wanting to write about since the 4Th of July but held off on. Now however with two major stories in the news that touch on this subject and a third story I witnessed when walking to my car after a wedding on the 4Th of July I decided it was time.

It has to do with the rights granted to us versus what is the right thing to do. Currently in the news are talks about this crazy church that wants to burn the Islamic holy book of the Quran. Also in the news an Islamic group of people who want to build a temple near the world trade towers site. Both groups have come across protesters against what they want to do. Both groups claim they have every right to do what they want to do. Thus it comes down to I have a right versus what is right.

Before I go further I want to share my story. I was walking back to my car after a wonderful wedding ceremony and reception. It was held at the Discovery World Museum here in Milwaukee, and it so happens that it is right next to the Summerfest grounds. Summerfest is a huge music festival that runs two weeks. Well the 4Th of July happened to be the last night of Summerfest. So I left the reception about the time Summerfest was winding down so obviously as I walked I got mixed into those leaving Summerfest and also heading back their cars. In front of me were these two younger women, I would guess early to mid twenties. As you walk back to the parking areas around the lakefront you sort of get funneled down one path so you will see people their selling water or food as you walk buy. Along this route there was a man standing off to the side holding a sign that read "Jesus Saves". Every so often he could be heard saying "Get home safe", or "Drive Safely". As we were passing this man, one of the two "ladies" in front of me shouted at him, "Keep your religion off me you Jesus freak". I started thinking to myself this being the day our nation celebrates independence why would she say such a rude/crass thing. I know she has a right of freedom to speech as did that man, but was it really the right thing to say or the right way to say it. Just like the pastor has a right to burn the Quran, a holy book to millions, is it really the right way to get your message out? Or, is building an Islamic temple right next to a site where extreme islamists, in the name of Allah, flew two airliners into the towers killing thousands the right way to get your message out about peace and Islam?

These are tough questions and I think that if you try more on doing what is right instead of what you have a right to do, you can make a lasting message that would be more open to debate and conversation. By acting in ways that close off thought or by being rude or inflammatory only causes more hate and more misguided acts.

It is important as a society to have these rights and to fight to protect these rights, but it is just as important for society to use our rights in a responsible way.

I know, I know, I can hear it now who made me the keeper of right and wrong, and my answer is quite simple no one. However I believe that in all three of these cases the use of common sense along with what my Mom and Dad taught me about what is right and what is wrong is a very powerful baseline for judging how all three of these situations could have been and still could be handled better.

For example maybe instead of burning the Quaran you could hold a prayer service for those who currently are fighting so that they may stay safe and for those who lost family members on 9/11 that they may find peace. Perhaps at this service you could also pray for peace in the world. A simple solution for the Islamic temple would be to build it somewhere else in NYC. It could still be used for prayer, and to teach Islam just as well somewhere else. It does not have to be blocks from one of the site of one of the worst attacks on America. Finally in the case of the young lady who disagreed with the man holding the sign, she could have simply said thank you for the well wishes but I don't believe in God or that Jesus saves (her thought not mine).

To wrap up this long winded post as 9/11 comes and goes I want to thank those who fight for us and also those who pray for us. I also want to remember those lost and those who risked it all to try and save those in towers, at the pentagon and on flight 93.

Now that I exercised my right to free speech feel free to exercise yours in the comments section.

Friday, August 13, 2010

This and That

I know I haven't posted anything in a long time. It is not for lack of topics but really the things I wanted to post really didn't have much depth, so this post will have three mini posts in it.

1) lucene.net
2) My new Zune HD
3) Airline travel

So first....

I love lucene.net. In today's world of ever changing technology, it is great when a product like lucene can stand the test of time.

Lucene is a search and indexing framework. In the DotNet world Lucene is a direct port from it's Java brother. I have now used lucene.net on three different projects and it always works like a champ. It is very simple to setup and program against. There is a lot of online documentation to help you through the rough spots. Oh and it has a really cool tool called luke that actually lets you see inside the index and how lucene is parsing your documents and the tokens that come out of the parse. There is another tool I have not used but looks promising called Link To Lucene.

Next....
I recently purchased a Zune HD 64. Why a zune and not an Ipod? well honestly it was because I could not stand fighting the ITunes interface anymore. I also like the idea of the Zune Pass subscription model. I know, I know there are 1000's of more apps and things for an Ipod touch, but lets be honest. I need my mp3 player to play music (both digital and radio stations), video, and sync nicely with my Windows PC. I dont need an app for anything else on my mp3 player.

That is why a Zune HD. Now how do I like it? I love it because right now it just works. I can easily use the Zune software on my pc to find music and create playlists, and everything syncs as it should nicely to the player.

Finally Air travel
I am so tired of airlines cheeping out. I remember when I could fly non-stop get a soda and a meal, sit in comfort, check a bag, and not have to pay additional fees.

I just booked a round trip flight with an airlines I have flown with for over ten years. I am fed up with them. One of the destinations I fly to used to have 3 non stop flight offerings a day. Now it is down to one. Some might think the destination is not that popular, well I am pretty sure Las Vegas is still a popular retreat. I am also tired of having to pay fees for additional services. $20 to check a bag, $10 for a meal, $10 to pick your seat, then add on all the taxes and security fees. Sure your ticket might be advertised for $150, but once it is all said and done you are paying way more. Add to the fact that there is no room to move on a play since you are packed in tight as can be. I was one of the few who was happier paying extra for extra room in the seat and better service. You get what you pay for could not be any truer than in the airline industry.

Well there it is. My rant of the day. Apple fan boys please don't flame me I really dont want to know why ITunes and the IPod are superior to the zune. If you work for an airline please please suggest to your bosses to make things better, and if you worked on Lucene, thank you.

Monday, May 17, 2010

Jim Henson

So the twentieth anniversary of Jim Henson's passing was just recently. I wouldn't have know except I stumbled across another blog post. I started thinking about how Jim Henson and his characters impacted my life.

I remember watching the Muppet show reruns with my Dad, Sister and Grandma Walber. Dad would stop to pick us up from work and we would beg him to let stay longer so we could finish watching the episode. I am not sure if I had a favorite show or character but I did enjoy the songs and how some of the skits made me laugh.

My Sister and I also had a few books and albums. we would read them or dance and sing to the music. I remember dad reading one of the books and he would change his voice to try to match the way the Muppet's sounded. We had the movies on tape, and I must have watched the Muppet Movie a million times. I did not watch the Great Muppet Caper or The Muppets take Manhattan as often, not because they were bad, but because I just thought the first one was the best.

I also watched Sesame Street. I did have a favorite on that show. It was Cookie Monster. I think he was my favorite for three reasons. One blue was my favorite color. Two I like cookies too. Three was because my name also began with the letter C. Although he was my favorite, Oscar was second. He made me laugh at how grouchy he was.

I can remember Merry D. taking me to see Sesame Street on Ice as a kid. Seeing all the characters singing and dancing and performing on ice. I really enjoyed seeing all the characters.

Then there was Fraggle Rock and the Muppet Babies. I did watch both as a kid and even watched the Fraggles on netfilx once or twice. These shows were ok but for some reason did not capture me like the others.

I wish Jim Henson would have lived longer, I can only imagine what he might have done with todays technology. I do know this though... What ever it was it would have been great time spent watching with my family.

Wednesday, April 28, 2010

NCommon Repository, and Unit of Work

This will continue my talks on NCommon.

One reason I like NCommon is it implements some patterns I like. One of my favorite patterns is Unit of Work.

From Martin Fowler:
A Unit of Work keeps track of everything you do during a business transaction that can affect the database. When you're done, it figures out everything that needs to be done to alter the database as a result of your work.

So lets say you want to insert/update/delete a person and that persons address in your model. The pattern will basically wrap all the database operations into one transaction automatically for you.

NCommon implements Unit of Work for use again with the three provided ORMs (Linq 2 SQL, NHibernate, and EF). To use it your code is simple basiclly it will look something like this...




using (var scope = new UnitOfWorkScope())
{
//Your real work here
Person p = GetPerson(1);
p.FirstName = "Bob";
p.Address.State = "WI";
scope.Commit();
}



What this will do will wrap the person update and the Address update into one transaction and execute them both. If one fails both are rolled back. You get all of that free of charge so to speak. NOTE: Nothing is free in this world, but what is meant is just by using the using statement for unit of work, I get all of the goodies of transactions and model change discovery.

Another pattern I am trying to use more is the Repository patter. Again from Martin Fowler:
A Repository mediates between the domain and data mapping layers, acting like an in-memory domain object collection. Client objects construct query specifications declaratively and submit them to Repository for satisfaction. Objects can be added to and removed from the Repository, as they can from a simple collection of objects, and the mapping code encapsulated by the Repository will carry out the appropriate operations behind the scenes. Conceptually, a Repository encapsulates the set of objects persisted in a data store and the operations performed over them, providing a more object-oriented view of the persistence layer. Repository also supports the objective of achieving a clean separation and one-way dependency between the domain and data mapping layers.

So what is accomplished with repository is you abstract out the database code. what I mean is your model queries the repository in a way that is understandable and the repository handles the query. The repository handles the calls to whatever system is being used for persistence, be is SQL Server, Oracle, FlatFile, or whatever. NCommon doesn't exactly hide the ORM from the model since you need to use one of the three Repository classes, but it is simple enough to abstract this away with your own domain specific wrappers.

I was going to show some code on how to use the repository , but since it really is pretty simple, I will leave it out. If you are interested download the NCommon code and take a look in the unit tests. There you will see a very basic example on how to use them. I might do a follow up post with how I implemented my repositories with NCommon as well.

I am not sure if I will go into any more detail about the other pieces of NCommon (BusinessRules /Validation, Specifications, Guard, or Store) I do use some of them, and find them useful, but think there are also many good ways to solve the problems they address. If you would like more please let me know and maybe I could whip something up.

Friday, April 09, 2010

NCommon Setup

Today I finally get to a post my friend Dan has been riding me to do for some time. How to setup NCommon and StructureMap with Asp.Net MVC.

Before I get started I want to talk a little about what NCommon is. Simply put, NCommon is a library of commonly used design patterns when developing applications. I took that right from the project website. It was developed by Ritesh Rao. The code can be found at google code. The patterns it implements are as follows...
  1. Unit of Work
  2. Repository using Linq
  3. Validation and business rules
  4. Specification using expressions
  5. Guard class
  6. Utility class
This post wont talk to much about these patterns but future posts will talk about some of them.

So Lets get started.

I will be focusing on the following versions...
ASP.Net MVC version 1.0
StructureMap version 2.5.3
StructureMap Adapter version 1.0
NCommon version 1.0

I plan on updating all version once VS2010 comes out. So there will possibly some differences with the setup if running a later version of ASP.Net MVC.

So my project uses Linq 2 Sql as the backend interface to the database, I could have went with Entity Framework or NHibernate as well since NCommon also supports those as well. While I am at it I did not have to use StructureMap either I could have went with Windsow or Spring or Unity. I just chose StructureMap since I like it best. In the future I might switch to EF 4 or NHibernate with fluent NH but for now I am sticking to Linq 2SQL and StructureMap.

So the first thing you need to do is set up you StructureMap Container and store it in the NCommon.Storage.Store.

In the container setup you need to register some things.


public static Container BuildContainer()
{
Container container = new Container(x =>
{
//ncommon
x.ForRequestedType().CacheBy(InstanceScope.Hybrid).TheDefaultIsConcreteType();
x.ForRequestedType(typeof(IRepository<>)).CacheBy(InstanceScope.Hybrid).TheDefaultIsConcreteType(typeof(LinqToSqlRepository<>));
x.ForRequestedType().CacheBy(InstanceScope.Hybrid).TheDefault.Is.ConstructedBy(
() => new DataModelDataContext(ConfigurationManager.ConnectionStrings["ConnectionStringNameFromWeb.Config"].ConnectionString));


//Other project items here.....
});

container.AssertConfigurationIsValid();
return container;
}


So what is going on here... We create a new StructureMap container and tell it how to create objects when asked for a certain object. the first line we tell the container when asked for IUnitOfWorkFactory we want it to return LinqToSqlUnitOfWorkFactory since I am using Linq2Sql. If I was using EF I would have set it up to return EFUnitOfWorkFactory. The same goes for typeof(Irepository<>) we have it return typeof(LinqToSqlRepository). Finally we tell the container how to create our DataContext.

So How do we call this method. Well in the global.asax.cs file is how.

protected void Application_Start()
{
ConfigureContainer();
RegisterRoutes(RouteTable.Routes);
ControllerBuilder.Current.SetControllerFactory(new IocControllerFactory());
LinqToSqlUnitOfWorkFactory.SetDataContextProvider(GetDataContext);
}

private void ConfigureContainer()
{
Container container = StructureMapBootStrapper.BuildContainer();

Store.Application.Set("ApplicationContainer", container);

ServiceLocator.SetLocatorProvider
(
() => new StructureMapServiceLocator(Store.Application.Get ("ApplicationContainer"))
);

}


So as you can see on the app startup we call ConfigureContainer and that method calls our build container and then sets the container on the Store. We then use the ServiceLocator and tell it how to find our newly created container. BTW.... the Service locator is part of the Common Service Locator Library from Microsoft using the StructureMap Adapter.

The Next important thing we need to do is tell MVC how to inject our controllers. If you see in the code above ControllerBuilder.Current.SetControllerFactory(new IocControllerFactory()); This code tells MVC to use a ControllerFactory I created instead of the default. Note the following code will not work in MVC 2.0.


public class IocControllerFactory : DefaultControllerFactory
{
protected override IController GetControllerInstance(Type controllerType)
{
IController result = null;
if (controllerType != null)
{
try
{
IContainer container = Store.Application.Get("ApplicationContainer");
result = container.GetInstance(controllerType) as Controller;

//result = ObjectFactory.GetInstance(controllerType) as Controller;
}
catch (StructureMapException)
{
System.Diagnostics.Debug.WriteLine(ObjectFactory.WhatDoIHave());
throw;

}
}

return result;
}
}


As you can see what we are doing is we are asking the Store for our container and trying to find the requested controller. StructurMap is smart in that if we did not define it in the registry it will try to create it itself using the greasiest constructor.

Finally the last thing we need to set the DataContext on the LinqToSqlUnitOfWorkFactory. again from teh app startup method in the global.asax.cs file we do this LinqToSqlUnitOfWorkFactory.SetDataContextProvider(GetDataContext); where GetDataContext is a property that looks like this


private DataContext GetDataContext()
{
return (DataContext)Store.Application.Get("ApplicationContainer").GetInstance(typeof (DataContext));
}


All it does is ask the store for our container and ask it for the DataContext.

That was how I set up my application to use NCommon. In the next post I will talk more about NCommon and some of the patterns. Stay tuned.

Friday, March 12, 2010

Rackspace Cloud Sites

So in a previous post I talked about cloud computing and what is offered by Rackspace. This post will talk more about their Cloud Sites Product.

Before I do I again want to point out, that I am not being payed by rackspace for this post, and I do not currently use any of these products personally although I have had clients who have used rackspace in the past. I do plan to use this product in the future.

Also Rackspace is only one of many who offer cloud services. Please don't flame me with X does this too and costs this much or have you seen y.

So Cloud Sites.....

Overview
When you sign up and host your website on cloud sites, it is just like hosting in a shared, virtual or dedicated environment except, load balancing, clustering, and redundant storage are all inherited by your application automatically, without any effort.

So as your web presence grows your site scales automatically, without having to rent, buy or lease new hardware ahead of time.

So what is the catch...
The catch is simple your monthly fee you pay is flat but as you start to use more ram, processor and bandwidth, you are charged an extra fee. It is like a cellphone pay as you go plan. The cool thing is that if you start using less resources the extra fees are not charged. The flat fee price includes cpu cycles, bandwidth and storage already, you only pay extra if you go over the allotted amount.

What technologies do they support...
As you can tell from my blog I focus in the .Net world. So yes you can run your .Net web apps, both MVC and Webforms. They use IIS 7, .Net 3.5 and lower, Windows Sever 2008 and Sql Server 2008.

They also have Linux path that runs Debian + Red Hat, Apache, MySQl, php, Perl and what not. I cant speak to these choice since I do not know enough about this path.

How do I get my app out there....
Setup is a process of walking through a wizard that guides you to deployment of your application. Reading through the FAQ it seems that your site is very customizable.

I was going to provide pricing information however they removed that section from their site and force you to talk to a person to get it. I do have some of the old pricing though so this would be more of a guideline than what is most accurate.

149.00 per month
0.22 per gb of bandwidth first 500 free
0.01 per cpu cycle first 10000 free (they had a stat that this number was able to host an average website or a small data intensive site)
5.00 per 100mb sql server file size
I don't have the cost for hd storage and what is included. :(





Friday, March 05, 2010

Floating on a Cloud

In a previous post I discussed some topics I would like to explore and share. Today I am going to share my thoughts about The Rack Space Cloud Products. I want to point out, that I am not being payed by rackspace for this post, and I do not currently use any of these products personally although I have had clients who have used rackspace in the past. I also plan on using every product I am about to discuss in the future.

First I want to talk about what is the cloud, and what is cloud hosting. Wikipedia says
"Cloud computing is a way of computing, via the Internet, that broadly shares computer resources instead of using software or storage on a local PC."
What this means is imagine having an infinite amount of computer resources (RAM, Bandwidth, CPU, and storage) as long as you have enough money to pay for it. The key though is you only have to pay for what you use. This is great because now when Slashdot, or any other news media talks about a website you don't have to worry about if you hardware will scale to the new huge demand, and once that demand tappers down in a month or two you are not stuck with a bunch of servers you no longer need. The concept is pay as you go so to speak.

Here is a list of some key features of the cloud. (again borrowed from wikipedia)

  • Agility improves with users' ability to rapidly and inexpensively re-provision technological infrastructure resources.
  • Cost is claimed to be greatly reduced and capital expenditure is converted to operational expenditure. This ostensibly lowers barriers to entry, as infrastructure is typically provided by a third-party and does not need to be purchased for one-time or infrequent intensive computing tasks. Pricing on a utility computing basis is fine-grained with usage-based options and fewer IT skills are required for implementation (in-house).
  • Device and location independence enable users to access systems using a web browser regardless of their location or what device they are using (e.g., PC, mobile). As infrastructure is off-site (typically provided by a third-party) and accessed via the Internet, users can connect from anywhere.
  • Multi-tenancy enables sharing of resources and costs across a large pool of users thus allowing for: Centralization of infrastructure in locations with lower costs (such as real estate, electricity, etc.), Peak-load capacity increases (users need not engineer for highest possible load-levels), and Utilization and efficiency improvements for systems that are often only 10–20% utilized.
  • Reliability improves through the use of multiple redundant sites, which makes cloud computing suitable for business continuity and disaster recovery. Nonetheless, many major cloud computing services have suffered outages, and IT and business managers can at times do little when they are affected.
  • Scalability via dynamic ("on-demand") provisioning of resources on a fine-grained, self-service basis near real-time, without users having to engineer for peak loads. Performance is monitored, and consistent and loosely-coupled architectures are constructed using web services as the system interface. One of the most important new methods for overcoming performance bottlenecks for a large class of applications is data parallel programming on a distributed data grid.
  • Security could improve due to centralization of data, increased security-focused resources, etc., but concerns can persist about loss of control over certain sensitive data, and the lack of security for stored kernels. Security is often as good as or better than under traditional systems, in part because providers are able to devote resources to solving security issues that many customers cannot afford. Providers typically log accesses, but accessing the audit logs themselves can be difficult or impossible. Furthermore, the complexity of security is greatly increased when data is distributed over a wider area and / or number of devices.
  • Maintenance cloud computing applications are easier to maintain, since they don't have to be installed on each user's computer. They are easier to support and to improve since the changes reach the clients instantly.
  • Metering cloud computing resources usage should be measurable and should be metered per client and application on daily, weekly, monthly, and annual basis. This will enable clients on choosing the vendor cloud on cost and reliability (QoS).

So that sums up what cloud computing is. Now lets get to RackSpace.

RackSpace offers three different cloud products.
  1. Cloud Servers
  2. Cloud Sites
  3. Cloud Files
Cloud Servers
Cloud Servers are scalable, affordable, and cloud-driven platform of virtualized servers. Customize and spin up new instances in minutes, or take them down, all with root access, easy-to-use management tools and, of course, our Fanatical Support. You only pay for what's provisioned.

Cloud Sites
Cloud Sites are robust, fast, and easy to use web hosting platform. With built-in redundancy, clustering, and the power of cloud computing, your websites are ready to grow with your business.

Cloud files
Cloud files are simple, scalable, and cost-effective online storage solution that leverages the power of the Cloud. Whether your storage needs are modest—or monumental—you enjoy built-in redundancy, an easy-to-use control panel, and Fanatical Support from day one.

My next posts will discuss Cloud Sites and Cloud files in more detail. These are the two products I see myself using in the coming months.

Thursday, February 25, 2010

Bad Blogger

I have been a bad blogger. I have not updated or posted anything in a long time. Well I am going to change all that. Hopefully.

In the coming blog posts I am going to discuss what I have been doing in the world of computers. Below is a list of some of the things I want to blog about int the next few blog posts. Some of the items might be multiple posts. So in no particular order here goes.

Hope you all stay tuned for the start of the NCommon posts. They will discus what NCommon is and how to intergrate it into an asp.net mvc application.

Wednesday, January 06, 2010

New Year

I first would like to wish everyone a happy new year. I have not blogged in a while so this post will be somewhat of a catch up.

Last week my good friends Josh and Jess got married. Their wedding was so much fun. One of the best weddings I have been too and part of. I know they will have a long and happy life together.

Last month we lost to dear people.

One was Evelyn Simono. She lived a long and happy life. I remember when I was young we would play cards together on cold winter days. She lived over 100 years. That is impressive.

The other was Kartik. He was one of the best software developers I ever got to work with. He really could solve the tough challenges we face. He was an even better person. I remember how much fun we all had at the brewer game, and I go a friend of mine who works fro the brewers to put a welcome message on the big score board for him. He will be missed.

In happier news, the Packers had a nice season and made the playoffs. I hope they can make a super bowl run but it will be tough.

The Badger football team finished the season strong by winning their bowl game against Miami. The expectations for next year will be high because they are returning lots of good players.

Well that is it for now. I will try to blog more regularly this year. I might even blog some tech stuff as well.