Where are my Visual Stuido templates?

On both my Work and home PC recently i have lost all of my VS 2005 file templates. These are the template that dump all the default stuff intot he file when you click “add new… class” or “add new… web control” etc
As i install new stuff all the time, mainly just to kick the tyres, it is hard to point the finger at anything in particular…so iwont, either way it has pissed me off.

Any way if you find you have this issue:

devenv /installvstemplates

is the command to get you back on track.

This seems to happen when new templates have been added (ie you have added a new framework, just as a .net upgrade, or new test framwork etc

Python… the beginning

So I bought me a Python book and download Python*. That was all pretty painless.

The book is so far pretty good, well written, no junk I don’t care about and to the point.

The language seems pretty easy to pick up.. kinda fits with the “convention over config” line of thoughts with its white space approach… I guess if we are going to have white space why not make it part of the language?

Its scripty and OO-ish.. I can already see where this will fit into my development plans, and can see where Ayende has gone with Boo. These languages are great for file/text manipulation especially on the fly.

One mistake I made was paying for the book… well not really, it was cheap and I can read it on the tube, but for those who don’t like paying for stuff the latest version of Dive Into Python can be found here

Also if you are a CLR junkie then have a look at IronPython

2.0 should be released soon, till then I’ll stick with the correct release version of 1.1.1 (for now)

*IronPython… not real Python 😉

New strings to the bow…

For awhile now I have been umming and arrghing and generally weighing whether to learn a dynamic styled language and which one to learn… Well I have been fluffing around for too long.

I am going to learn Python (OMG not ruby!).

Why:

  • It is supported on the CLR/DLR
  • It is similar in syntax to Boo
  • I want to learn Boo and be able to follow Ayendes post of DSLs
  • Ayende uses Boo and he is smarter than me. I try to follow people that are leaders in their fields.
  • I want a language to manipulate text that is better than c# or xslt… K

I am hoping that learning one will make it easier to learn others. I can jump between Java, VB and C# but the are all C based and basic just different dialect/syntax, hardly wildly different languages (well Fowler kinda agrees with me)

So time to get off my bum and do it. Any book recommendations?

Time to Refactor

Good sign you need to Refactor: Boxing and Unboxing making a prominent appearance… yuck.

With the use of generics and properly implemented interfaces this has been pretty much completely removed from one of our projects… my question is why was it there in the first place?

NHibernate errors: 101

We seem to be having a bit of trouble with NHibernate of late. Below are some basic check and strategies to get the most out of the ORM. This document is very basic but covers 90% of the issues I have had to fix with NHibernate on this project. For some background i believe I am the only one to have work with NHibernate previously and had come in well after the DAL had taken shape, so some basic mistake have been uncovered as part of our learning process.

Basic checks
Check Mapping files are embedded resources (right click the file in VS and select Properties. Ensure the build action is Embedded Resource)

Check the class is marked as Serializable

[Serializable]
public class Customer : DomainEntity<int>, ICustomer
{…}

Check the properties are Virtual

public virtual Orders Orders
{
get
{
return this._orders;
}
set
{
this.orders = value;
}
}

Lazy loading exceptions

Check the object loaded is occurring in a session correctly and the session is being properly closed & committed
Check the mapping for the object and the children you are trying to load. If the Mappings are set to lazy=true, you will have to explicitly load them or access a property on the object to hydrate the object graph to the next lazy node down the object graph.
Check your session is not closing prematurely, either by code or by an internal error such as DB timeouts. Nested session will all be committed at the committing of the upper most transaction. Be wary of overly nested transaction as this may lead to time out and a possible “number of connection/cursor” exceptions throw from the database or it drivers.

Concurrency Issues
NHibernate is finicky with objects being loaded multiple times and associated in different sessions. This (in my cases) has usually come down to poorly factored code. E.g. Make sure you are not trying to put the same object in to a collection twice from 2 different sessions etc. I don’t have any great advice here as this is usually handled on a case by case basis, but is a good sign you need to rethink your design.

Rules of thumb
Reference data should be cached, immutable and eager loaded. This makes the pretty basic assumption that no relationships exist off to other objects (i.e. no children or other mapped entities)
Complex domain data should generally be lazy loaded, immutable and not cached. You can set up lazy/eager loading strategies on a per property basis. Eager loading simple types is fine, be careful with complex relationships as you should be catering for the most minimal requirements. Excessive use of eager loading will severely affect performance.
Again, be careful with eager loading. If you eager load a child there may be any number levels of eager loading down the object graph. Eager loading should generally be avoided unless there is a business reason to do so. Instead explicitly load each object or object collection explicitly in the business code that deals with the situation, ie

//this occurs with in a session to get all the Orders of the given customer

this.TheOrderDao.Initialize(customer.Orders); //Using NHibernateUtil.Initialize

Preferentially walk the object graph as opposed to using find by id or overly simple HQL. I.e. to get the customer orders use customer.Orders as opposed to a query that looks for order based on a customer ID. NB: This must be done in-session if objects are marked as lazy.
Use ICriterion styled searches to do simple object searches, ie: Find all customers with city location of London
Use HQL queries to get type objects back from queries. These are general object based queries where a collection of a mapped type is returned but may need other joined tables for querying purposes. Ie return all the product categories for all the orders of customer x for the last 365 days. These queries can usually be though of as follow the format select customer.* from customer inner join….
Only use stored procs for set based queries to
aid in speed if walking the object graph would be extraneous or load too much redundant data
to return streamlined DTO/DataSet for non type queries or queries that would otherwise return overly large object graphs when only a small portion of the graph is required. (These are the exception rather than the norm.)

HTH

Rhys

Greenfields project

I am setting up a Greenfields ASP.Net service based app for a “friend”. It is not completely a self less act. The work I do on a day to day basis bores me to tears so this is an opportunity for me to play with new tools, frameworks ideas etc and stop me hating being a coder.

Also as a contractor I often come in after the initial set up has occurred, which means I suck at setting up solutions. I am using the TreeSurgeon project and Mike Roberts article to guide into best practise here. So have a single batch file to call a single NAnt build script to build and test all my stuff. As there are a bunch of empty projects and empty tests this is pretty bloody fast!!! LOL

So straight off the bat I have in my Development IDE

  • VS2005 (waiting form my copy of 2008)
  • TestDriven.Net
  • Ghost Doc
  • ReSharper (old but still happy with it as i am not 3.5 yet)

.Net aspects I am using

  • WCF
  • Old Skool Asp.net WebForms. the first Web layer will probably be throw away especially as it uses AP.Net Security which doesn’t suit the requirements. I may move to MVC later, but I honestly have never had issues with WebForms mainly because everything I usually kept very simple. Plus i wasn’t TDD last time i did a web app, certainly not in the web projects at least.
  • SQL 2005

Frameworks I am using

  • Castle stack for IOC & AOP
  • NHibernate 2.0 (alpha)
  • MBUnit (because i haven’t used it)
  • Rhino Mocks (because i am yet to use it properly), possibly TypeMock too for odd stuff
  • Nlog/Log4net… who cares some sort of logging… actually probably L4N as it is in other assemblies already.

Deployment and source control

  • NAnt 0.86
  • SVN
  • CC.Net or Team City. Not set up yet.
  • Assembla.com for svn and project management

Quality Control Tools

  • FX Cop
  • NDepend
  • NCover
  • Sandcastle

and would like to use Spec# but its too much of a hassle to have it in “real” code.
I think that pretty much covers it.
Thoughts?

I am keen to discuss lot of the architectural side of things in weeks to come. I am probably going post a few of the questions on the altdotnet list (yahoo group) too.

Rhys

Alt.net Lessons for ‘tards

What I learned:
-TDD is not as simple as it seems. There are many approaches, frameworks, & schools of thought. MBUnit, TypeMock, MoQ need a decent looking at by yours truly and delve a bit deeper into RhinoMock and NSpec.
-There are some real smart in this movement. The Distributed Domain Driven Design session with the likes of Udi, Martin, Greg, Drew and Alan(?) etc. was awesome.
-Understanding other languages helps you understand the benefits and limitations of “your” language that much better. I really need to play more with Ruby, Python, F#… just something… anything!
-Spec# should not be know as Spec# it should just be C#. This, IMO is f*&king ridiculous. These guys are working hard to help us improve the the code at design, compile and runtime… why would we all not want this? IF this can be pushed into the C# 3.5 then just make it part of .Net 4.0…..Anders: Make it so!!!!!
-Hansleman is not only a sharp witted & entertaining guy but is smarter than a lot of his podcasts let on. (Are you dumbing this down for us Scott? 😉 )
-We need to bottle the water in Israel and Austin TX and combine it and include it in your MSDN subscription… they are hubs for smart dudes.
-Everyone was a lot nicer than I expected.. even Bellware (jokes!)… I hope this continues as it was a big nice warm fuzzy environment :).
-Special note goes to Glenn Block from Patterns and Practices. Kudos for jumping in the firing line and being prepared to take flack… even if the products are well before his time. I hope that very open and receptive attitude continue amongst the PnP team 🙂

*Oh.. the tard is me

Post Alt.Net

Well I have arrived pretty late in London after delayed flights and nasty Heathrow.. so going to work is off the cards… sorry John…

I just wanted to say a quick thanks to everyone involved in organising the event and a special thank to the people who took the time out to share knowledge with me, debate and talk about the virtues of a diet high in salt sugar fat and volume…
particularly: Ian, Tim, Chris(es), Jarod, Jason, Ray(s), Roy, Scott(s), Udi, Martin, Greg, Dru et al
Thanks for everything hope to see you all in the near(ish) future; keep in touch!

For those that didn’t attend, you missed out. The stuff learned was the stuff you needed to learn. the people you meet are the people you need to meet. This is better than Tech-Ed because you are the … if only we got free stuff… actually we did! Cheers Roy!