Archive for the ‘Uncategorized’ Category

h1

Web Service Contract First Design

April 14, 2008

Today I was asked to finish off an implementation of a web service for my current engagement. When I opened up the solution I noticed that there was a LOT of classes that had some comments at the start of them that said “auto generated by wscf”. After doing some research I found out that when building enterprise web services you can either build them by “code first” or you can take a “contract first” approach. Learn more about it here

h1

Visual Studio Project Templates Missing

April 9, 2008

So today I installed Visual Studio 2005 Team system onto my machine that already had Visual Studio 2008 Professional edition on it and when I opened up VS2005 I was missing all my project templates

Basically I didn’t have that little expansion cross next to Visual C# or Visual Basic at all. I ran across this blog and left a thankful message as he has saved me a lot of grief in time wasted reinstalling the solution.

h1

Changing Jobs!

April 9, 2008

I start a new job! This Friday is my last day and the coming Monday I will be contracting at Carlson Marketing for a 3 month engagement. I am super excited because they have visual studio team system! Unfortunately it’s 2005 and they do not have the license for 2008 but it’s not always that you get the luxury of working with team system. Maybe this is something Microsoft should look into making cheaper in order to dominate the market more?

h1

WCF Service Software Factory thoughts…

March 24, 2008

Today, I completed a hands on lab from codeplex that shows off the features of what the service factory can do. The reason why I did this tutorial is that I have decided to strengthen my career with WCF and SOA and to also try and strengthen my architect skills. The reason why I picked the service software factory for part of my studies is a few reasons:

  • It’s new to me. I have been too scared to use it in production environments because of my lack of knowledge about it
  • It’s Guidance automation packages are extensible and are very focused for the decision makers/architects
  • It provides a lot of code generation and task automation of some of the monotonous things that programming in WCF can sometimes make you feel. i.e. it will probably take you 2+ hours to just THINK about how many projects you will have, what to call them, and how to layout your solution in general.

So after I have finished it I am now left with a question in my head. I do not have anyone that works with me currently that is at a very high architect’s level or works with one so I cannot ask the question to colleagues. My question is: How realistic is the use of the software factory to create production systems. Sure it’s enterprise level but how easy would it be to make code changes to already generated files? Yes it can be done, but then you can no longer re-generate the file with the software factory or else your changes get overwritten. How stable are these tools when code files start to hit the hundred’s and dependency complexity between files and projects increases? I understand the code is open source and that any potentially blocking issues could theoretically be fixed but that’s beside the point. I would love to know how many architects/senior developers actually produce production code for large projects (by large I mean enterprise level, million dollar plus projects). My personal view on this is split in two. On one hand I love the fact that I’m no longer writing the word ‘public <return type> <method Name>{//blab la };’ constantly and that it is automatically generated for me. It makes me feel very productive. I love the fact that I can just click on a Guidance Automation Task project type and know that I am adhering to “best practises” without having to think about structuring my solution myself ( I know that one should always consider each scenario individually and that these projects can be modified via recipes etc). I become worried when thinking about what happens when you need to modify the automatically generated code. I become worried when I think about the readability and quality of generated code. I also worry about how reliable these automation tools are. Finally I worry about the fact that I’m not sure how many senior developers out there actually use the software factory. In my limited 6 years of developing I have only come across one developer that has used it and he wasn’t a developer, he was actually an architect/senior consultant.

 

I will be taking the safer option for now by continuously trying to improve my WCF skills and knowledge without worrying too much about learning about the software factory until I meet some more senior architects that can swear by it and maybe even visually show me some implementations on some projects and how it positively affected productivity.

h1

LinQ to SQL Bad Performance?

February 13, 2008

This blog is about a recent finding I had with a readify colleague the other day on a fairly large asp.net project we have been working on for 6 months now and have come towards the end of the scrum iterations and into the “Security and Performance Review” sprint.

On a dual core 2.16ghz laptop running vista 64 bit with 4 gig of ram and a 7200rpm hard drive the results were about 5 to 8 requests per second with the CPU being the obvious bottle neck spiking to 100%. The Load Testing was performed through visual studio 2008 on the same laptop so part of the performance is partially blamed there. We tried running the asp.net application on a server and running the load tests and web tests on a different machine but got more or less the same results.

We created some Data Priming Harness to insert multiple rows into each of our tables before the test so that we could have some data in the database and the inserts were happening at an extremely slow rate with again to CPU being shot up to 100%.

 

We ran SQL Profiler and found that on pages like our home page where we list a list of countries and cultures that there were 800 hits to the database. This could have been done with 1 database hit by just doing a select * from country and joining on Culture where country.CultureID = culture.ID. Obviously we have done something seriously wrong to cause 800 hits to the database just to load the homepage of our project once and do nothing more than display a list of countries and cultures right? So We look at the aspx page and see our repeater control on it. The repeater control has some in line code blocks in it like this:

repeater 

and now the drum roll…. ready for what the code behind looks like?

codeBehind 

 

Okay. So it’s not the most complicated stuff in the world. So the question still remains. Why does SQL Profiler show there are 800 hits to the database? Well. The answer is:

You need to use Data Transfer Objects to stop the calls from going to the database and instead retrieve it from memory. The line of code

<%# Eval(“Name”) %> in the Repeater is causing a hit to the database for each row!

To stop this create a class to hold your data froSQLql, maybe something like this:

public class ContentManagementLink

{

public int ID { get; set; }

public int SortOrder { get; set; }

public string Url { get; set; }

public string Description{ get; set; }

public int Name { get; set; }

}

 

and basically from youdata sourcece library you would do something like this:

 

private static List<ContentManagementLink> GetLinksOfSubPages(int sectionID, int cultureID)

{

PageManager pageManager = new PageManager();

var pages = (from page in pageManager.GetPagesBySectionID(sectionID, cultureID)

where page.PublishStatusID == (int)PublishStatusID.Online

select page).ToList();

var formattedPages = (from page in pages

select new ContentManagementLink

{

Url = LinkService.GetPageLink(sectionID, page.ID, cultureID),

Text = page.Title,

SortOrder = page.SortOrder,

ID = page.ID,

Name = page.Name,

EntityType = EntityType.Page

}).ToList();

return formattedPages;

}

 

What I have learned from this is that ORM’s can be easy to use the wrong way and that it’s very easy to forget that a call to an object’s property may very well be resulting in a database call.

 

I am still not certain as to why the CPU is getting spiked to 100% by aspnet_wp rather than sql hogging the hard drive and creating the application to be I/O bound. My guess is that linq to sql query generation can be expesive.

 

So I guess at the end of the day I haven’t solved the solution completely but I have found that there is something fundementally wrong with the way we have implemented LinQ and that it is more myself to blame then LinQ.

 

More to come on this topic. I would appreicate any feed back on similair experiences other people may have had.

h1

My plans for 2008

January 13, 2008

Okay so this blog entry is about 14 days old now but hey, better late than never right?

Firstly, I would like to say while I had a rough mental idea of what I wanted accomplished in 2007 I had never actually thought about listing them out as such but in general I wanted to sell my car, pay off my credit card and save up a decent amount of money. Well I got two thirds of the way. I sold my car, I paid off my credit card and I saved up a bit but no where near the amount I had planned. Those were the financial side of things, the learning/studying side of things was to learn asp.net 3.5 and to learn . I am coming along nicely with both.

Okay enough about last year and more about this year. I will break up my goals into two parts ,short term (1 to 3 months) and long term (1 year to 3 years).

Short Term:

*Make a decision on investment properties or aMichelle’ss pattisserie franchise

*Get my MCTS

*Write at least one of my ideas in myone notee “Programs to write” tab

*Get my motor bike license

*Buy a motorbike.

 

Long Term:

*Learn Chinese mandarin well enough to the point where I can communicate up to 70% to my girlfriends parents

*Become financially ready to have buy a business (depending on my short term decision about business vs property)

*Take up a senior role at a bank or any very large company

*Buy a Tablet PC

 

I have a generally solid idea about how I will accomplish each of these but some of them require some more thought and in the interest of keeping any potential readers of this blog interested, I will not bore you of these details (unless requested 😉 )

Technorati Tags:

h1

Hello world!

December 24, 2007

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

h1

LINQ Repository

December 11, 2007

Today I did some very fun refactoring at work. I am using a LINQ Repository interface with generics to get some free functionality.
Currently the project I’m working on at work is an asp.net 3.5 project and has 3 projects that make up the solution.
The first is a DB Pro project that has all the sql scripts inside it. The “middle” project is named core and it holds all the business and data layer logic, and lastly the asp.net project. In the core project I would have all my entities that are partial classes and call upon LINQ functionality for my CRUD operaions. And Lastly the asp.net project. From the asp.net project I would call upon the core project’s partial entity classes for my operations. For example.
I want to bind a product to my listview, so the code might look something like this.

ListView1.DataSource = Product.Get(productID);
ListView1.DataBind();

and within Product.Get(int ProductID) you may have something along the lines of:

return Product.SingleOrDefault(x => x.ID = ProductID);

Pretty standard stuff right. Now with the new “LINQ Repository” I would call

Repository.Get(productID);

and there wouldn’t be any code within the Product class other than

class Product : IRepository

and I would get all my CRUD operations for free!

Here is the code for an example of IRepository (Note, none of this code is compiled and tested, I am doing this in the blogger’s WYSIWYG)

public interface IRepository
where T : IIdentifiable
{
int Count();
int Count(Expression<func> expression);

void Add(T entity);
void Remove(T entity);
void Save(T entity);

T FindOne(int id);
T FindOne(Expression<func> expression);

bool TryFindOne(Expression<func> expression, out T entity);

IList FindAll();
IList FindAll(Expression<func> expression);

IQueryable Find();
IQueryable Find(int id);
IQueryable Find(Expression<func> expression);
}

h1

Prototyping Microsoft Live Maps Finished!

October 14, 2007

So Tonight I finished my prototype for work. Our client had this flash app and it was a map of the earth with all their locations mapped on it and you could do some basic filtering on the view of the earth to see the different offices (visually just blue dots) the client had around the world.

wait… back track. For some background information, they have an existing classic asp website and my job is to recreate it, extend it and make it generally better in the latest technology .net 3.5. The requierment was just to build it bigger and better in .net but since 3.5 is going to be launching by the end of this year, we (the senior consultant) thought that since the project is going get delivered in february that it would make sense to start building it in 3.5. We probably wont build it with sql 2008 tho because that misses the launch date by 1 week, but this decision may change.

Incase you were too lazy to click on the ‘we’ link I, I’ll explain that I have been lucky enough to have the privlage of working with one of australia’s best .net guys Mitch Denny from Readify!

So anyway back to my prototype. I used microsft live maps as the technology for viewing the globe and was looking through the API to see how to do some basic things that the business would need like plotting thumbnails on the map to represent locations, limiting zoom for the interenet facing site (security reasons) and also obfuscating (did I spell it correctly?) the x,y points so that it’s not hackable by going view source or something like that .

That was all well and good and didn’t take much more than copy pasting some methods from the live maps API. Something any monkey could do, and is not what I wanted to blog about.

What I learnt today was that AJAX lets you create scriptable web methods. (Not new I know, but just not something I’ve had to do until today)

What I did was make a webservice that provides a GetAllPoints() method which returned a List. I had to create the CoOrdinates struct myself because the .net Point class only takes int, not doubles. Once I decorated my class with the clientscript decloration, I then used LINQ to easily pull the data from my locations table.

The linq looked something like this…

So There you have it, I have easily replaced the flash app (which cost them something like $15000) with one days worth of code. Obviously leveraging heavily off live maps, ajax and LINQ. Sometimes I feel that the learning curve for new technologies is very costly but it’s nights like these that I realise, it’s VERY well worht it in the end and that infact it’s much more expensive not to utilize the latest programming solutions and technologies.

I’m tired now and have a WCF Course to attend to tomorrow hosted by Juval Lowe! woooooooo lucky me =-] I’m not ready for it so I’ve gotta quickly brush up before bed.

Night all!

h1

My First Blog Post!

October 8, 2007

Aha! So this is what it’s all about eh?
Hi Folks, This is the start of my first and hopefully many to come posts about my everyday life thoughts, my working career (programming) and maybe some other weird random things as I see fit.

That’s all for my first post folks, it’s back to c# 3.0 specification specs for me now… (jsut some light bed time reading)