Friday, August 29, 2008

Design... Design... Design...

Kintan Brahmbhatt has posted a very good series of articles that make you think about the design process.

In asking “How would you design a kitchen?”, he looks at the design process, and reminds us about what has to be the key tenet of design – making sure that your specify something that is fit for task for the end user.

Kitchen magic starts here: http://www.kintya.com/blog/2008/08/how-would-you-d.html

Freebies are always good -

Yesterday Joe Stagner posted about the free digital release of the first draft of “Data Structures and Algorithms: Annotated Reference with Example”.

It’s not complete, and rather rough in places, but it’s definitely worth a bit of your time to remind yourself about fundamental data structures and the algorithms to manipulate them. In particular, the authors highlight the complexity of each algorithm – and tell you how the algorithm will scale.

Download, Read, Internalise:  http://dotnetslackers.com/projects/Data-Structures-And-Algorithms/

The "evil empire" embraces the source...

Lots of people have blogged about it, including The Moth, but it’s still a remarkable thing to see happen – Microsoft has released the source code to .Net 3.5 (under appropriate licenses) so you can debug into the framework itself.

Why is this important? Well, even in plain-old ASP.Net, the framework can often appear to swallow your code entirely, making it nigh-on impossible to work out why your code is broken.

Now you can trace all the way up and down the stack – and Daniel’s posted a video on how to set up VS2008 to use this to go along with the official blog.

Use the Source: http://www.danielmoth.com/Blog/2008/08/debug-into-fx-35-sp1-source.html

Thursday, August 28, 2008

Ani-XSS - Dang well just use it!

Vineet Batta has posted a great first article on the CISG blog, espousing the virtues of the Anti-XSS library available to ASP.Net developers.

 

What does Anti-XSS do? Well, plenty actually – but in particular Vineet covers how to use the SafeHtml and SafeHtmlFragment methods to sanitise rich text input from a web form. I’m looking forward to his next instalment.

 

Dang well use it!: http://blogs.msdn.com/cisg/archive/2008/08/27/what-does-anti-xss-offer-for-html-sanitization.aspx

Thursday, August 21, 2008

Quick Tip: Getting at the current Page from MasterPage code-behind

I had to work this out today as I wanted to disable functionality on a master page based on the type of page it was attached to.

The MasterPage class is one that sits “beside” the Page class in ASP.Net – specifically, whilst you can access the MasterPage instance from a Page instance, there’s no property on the MasterPage to go back to the current page.

Of course, we can fix this with a helper class – here I’ve coded the sample as an extension method just for fun:

public static class MasterPageExtensions
{
public static Page OwningPage(this MasterPage master)
{
HttpContext context = HttpContext.Current;
Page page = context.Handler as Page;
return Page;
}
}

Now we call access the page from the code-behind of a master page thus:

public partial class MyMasterPage : MasterPage
{
private void DoSomething()
{
Page currentPage = this.OwningPage();
...
}
}

Easy!

Tuesday, August 19, 2008

Nuggets of goodness

Busy day on the MSDN blogs today – as well as Mike Taulty wondering if he’s been blacklisted from TechEd (*G*), we’ve got a posting from Doug about uninstalling .Net Framework 3.5 SP1, but also serves as a very good reminder as to how the .Net framework is layered.

Next, Kirill Osenkov has a good post on understanding generics, Eric White has posts on finding duplicates using LINQ, using Lambda expressions for Event Handlers, and taking a “flat” collection and chunking it into a data structure.

Finally, Ed Glas points to a new version of Fiddler, that apart from anything else has a cool timeline visualiser.

Update: It's not over yet! Vincent Sibal has a great article covering how to use the new WPF DataGrid, and in particular it's templating options, whilst Motley & Maven have an argument about Test Automation.

Silverlight - for or against

The Register has a remarkably balanced article today giving 10 pros and 10 cons for silverlight.

Which side of the fence do you fall on? http://www.theregister.co.uk/2008/08/18/silverlight_pros_and_cons/

New version of FXCop RTMs

Monday, August 18, 2008

Dragging us kicking and screaming to the WPF Grid...

Well, not quite - but today Martin Grayson posted the second part of his Silverlight 2 samples, looking in greater detail at how to build a dragable/dockable/expanding layout.

Also notable is that the first release of the WPF Toolkit – which includes a nice WPF Datagrid. Whether this impacts the commercial offerings will have to be seen.

Drag yourself here to expand your mind:  http://blogs.msdn.com/mgrayson/archive/2008/08/18/silverlight-2-samples-dragging-docking-expanding-panels-part-2.aspx

Get into the Grid here: http://blogs.msdn.com/publicsector/archive/2008/08/18/wpf-datagrid-the-wpf-toolkit.aspx

Streaming via WCF

Nicholas Allen’s posted a nice little article today on how to stream data over a WCF service.

The trick?

binding.TransferMode = TransferMode.StreamedResponse;

Read all about it: http://blogs.msdn.com/drnick/archive/2008/08/18/streaming-web-content.aspx

Friday, August 15, 2008

Reflect on performance

Miguel de Icaza has linked to a couple of interesting articles today.

·         An in-depth explanation of how to improve performance of dynamic invocation

·         A C# port of  Google’s Protocol Buffers.

Read and reflect: http://tirania.org/blog/archive/2008/Aug-14.html

 

Thursday, August 14, 2008

Coupling...

Jeffery Palermo’s got a nice little piece on why Inversion of Control isn’t about testability – but about giving flexibility in how you design your software.

Worth a read: http://jeffreypalermo.com/blog/inversion-of-control-is-not-about-testability/

Silverlight RSS

Returning multiple record sets from Oracle

When you need to retrieve complex data shapes from a database, you traditionally have been restricted to either dealing with multiple (and possibly sparse) rows per entity, or else performing multiple calls to the database and iterating the results to create your object graph.

The former CAN be pretty performant, but is a pain to implement the graph generation state-machine.

The latter suffers from the latency involved in setting up multiple database calls.

What’s needed is the ability to retrieve multiple data sets, but with just ONE database call.

SQL Server trumpets this as a feature, but Oracle’s been able to do this for a while as well. The problem has been that it’s very badly documented how you access the data through ODP.Net. Now I’ll show you how.

Let’s start by creating a stored proc that returns some data from 3 independent tables:

 

    PROCEDURE PRO_GET_MULTIPLE
    (
     p_first OUT SYS_REFCURSOR,
     p_second OUT SYS_REFCURSOR,
     p_third OUT SYS_REFCURSOR
    ) IS
    BEGIN
         OPEN p_ first FOR
              select * from table_one;
         OPEN p_ second FOR
              select * from table_two;

         OPEN p_ third FOR
              select * from table_three;
    END;

 

Easy enough PL./SQL there. Let’s now retrieve the data using ODP.Net:

 

            OracleDatabase db = OracleDatabaseFactory.CreateDatabase ();

 

            OracleCommand cmd = new OracleCommand("MY_PACKAGE.PRO_GET_MULTIPLE", connection);

            cmd.CommandType = CommandType.StoredProcedure;

 

            OracleParameter staffTypeResult = new OracleParameter();

            staffTypeResult.ParameterName = "p_first";

            staffTypeResult.OracleDbType = OracleDbType.RefCursor;

            staffTypeResult.Direction = ParameterDirection.Output;

 

            OracleParameter nameTypeResult = new OracleParameter();

            nameTypeResult.ParameterName = "p_second";

            nameTypeResult.OracleDbType = OracleDbType.RefCursor;

            nameTypeResult.Direction = ParameterDirection.Output;

 

            OracleParameter identifierTypeResult = new OracleParameter();

            identifierTypeResult.ParameterName = "p_third";

            identifierTypeResult.OracleDbType = OracleDbType.RefCursor;

            identifierTypeResult.Direction = ParameterDirection.Output;

 

            cmd.Parameters.Add(staffTypeResult);

            cmd.Parameters.Add(nameTypeResult);

            cmd.Parameters.Add(identifierTypeResult);

 

            //Return the filled Dataset

            DataSet dataset = db.ExecuteDataSet(cmd);

 

Note how we add output parameters for each of the tables the stored procedure returns? This is where the magic lies – the OracleDatabase object knows how to fill a dataset from multiple out-parameters via the ExecuteDataSet command.

Now I should point out that the OracleDatabase type is our customised Enterprise Library Data Access Block provider, so your mileage may vary with other EntLib Oracle providers.

Once you’ve got a DataSet, of course, you can iterate it in the usual manner:

 

            DataTable table = dataset.Tables[tableIndex];

 

            int index = 0;

            foreach (DataRow row in table.Rows)

            {

                Console.Write(string.Format("{0} : {1} {2} {3}",

                    index, row[0], row[1], row[2]));

                Console.WriteLine();

                index++;

            }

 

And that’s all there is too it!

 

Wednesday, August 13, 2008

Yield and prepare to be enumerated!

Raymond Chen has written an illuminating blog post on what *actually* happens when you write an iterator in C#.

This explains clearly what’s going on – essential for getting your head around how to use them, and in particular the yield return and yield break statements.

Start Leeks linked to it as part of his series covering yield.

Syntactic sugar: http://blogs.msdn.com/oldnewthing/archive/2008/08/12/8849519.aspx

Update: Raymond has a posted two follow-up articles.

Top Tip: Don't mix and match in webfarms

Tom details a problem on the ASP.Net Debugging blog about web farms running ASP.Net apps.

Turns out that ViewState is NOT compatible across versions of ASP.Net, or even processor architectures.

Read about it here: http://blogs.msdn.com/tom/archive/2008/08/13/system-indexoutofrangeexception-on-a-webfarm.aspx

 

Tuesday, August 12, 2008

Free ASP.Net and Winforms components

Joe Stagner links to a set of 60 free ASP.Net and Winforms controls now available from DevExpress.

Find them here:  http://www.devexpress.com/Products/Free/WebRegistration60/

Busy day for Microsoft...

It’s clearly a busy day for Microsoft today – just looking at the sheer volume of postings on the MSDN blogs should tell you that something’s up. But what?

Well, today is a major release day for the developer devision:

·         Visual Studio 2008 Service Pack  and the NET Framework 3.5 Service Pack 1 have both been released - good article by Somasegar here.

·         ADO.Net Data Services (formerly known as “Project Astoria” was released today too – see the Project Astoria Team Blog.

·         And finally, the Entity Framework has RTM’d as well. Their Team Blog has plenty of info.

Oh and don’t forget that SQL Server 2008 was released a few days ago as well.

Good times!

 

Thursday, August 07, 2008

Microsoft Sync Framework - RELEASED!

I spotted this on Eric Nelson’s blog first (thanks to his twitter feed) – the Microsoft Sync Framework has finally been released!

Why is this good – well, it SHOULD make things much easier when building occasionally connected applications. Now I just need to work out how to connect it to Oracle via my business services layer. Exciting stuff.

Read all about it: http://blogs.msdn.com/ericnel/archive/2008/08/07/microsoft-sync-framework-released.aspx

Get the goods: http://www.microsoft.com/downloads/details.aspx?FamilyId=C88BA2D1-CEF3-4149-B301-9B056E7FB1E6&displaylang=en

 

Tuesday, August 05, 2008

We're hiring!

We’re looking to hire a .Net developer to work on our next-generation product using the latest Microsoft technologies. Here’s the skinny – and if you’re interested, say you heard about the role from here!


Position

.Net Developer reporting to the Development Manager, based in Altrincham, Cheshire.

Candidate Profile

The development department has a flat structure with small teams formed according to the needs of the developments in question. This means that we do not have fixed team leader roles but allocate responsibility based on experience and skills. An ideal candidate must:

  • Be a self motivator with the drive and enthusiasm to take on new challenges
  • Be flexible and adaptable (but disciplined) when approaching tasks
  • Work well within teams and be able to foster good working relationships
  • Be prepared to take total responsibility for the completion of tasks
  • Be a good communicator, (both written and oral) and be confident making presentations on technical subjects to co-workers
  • Be technical rather than man-management oriented

The candidate must have a minimum of 1-2 years demonstrable experience in a commercial environment developing AJAX style ASP.NET web applications in C#. Experience with Silverlight 2.0 and WPF would be a significant advantage.

Role

To work in a team of analyst/programmers, developing and maintaining the in4tek’s next generation software products including work on customer specific portals, web services, integration projects and web applications using leading edge technologies form Microsoft and Oracle.

Approximately 80% of the time will be spent designing and developing new modules, with the remainder allocated to maintaining and enhancing existing software.

Specific activities within the role include:

  • Assisting with the production and review of User Stories and Functional Specifications
  • Working from Functional Specifications to formulate software designs and create Design Specifications
  • Working from Design Specifications to design and develop coded modules
  • Developing and executing Unit Tests to validate code.
  • Analysing and correcting software deficiencies and coding faults
  • Peer review of specifications, designs and code.

Personal development with the aim of obtaining Microsoft Certification will be encouraged.

Skills/Experience

KEY: R = required, D = desirable

Skill/Experience

Degree level qualification in IT or Business related subject

R

At least 1-2 years commercial .Net experience in C#

R

Demonstrable experience of ASP.Net 2.0/3.5 with AJAX

R

Experience of structured methodologies for software design and UML.

D

Experience of Agile methodologies of Software development

D

Experience of developing within a n-tier architecture

D

Experience of the design of n-tier architectures

D

Commercial Oracle and PL/SQL development experience (or equivalent SQL Server)

D

Database design experience (structure, relationships and triggers)

D

Experience of working to ISO9000 / TickIT standards

D

Knowledge of XML and its use in specifying and implementing software interfaces

D

Experience of Silverlight 2.0 and WPF

D

30 Essential PDF Documents

Rob Caron links to an excellent entry on the positivespace Graphic Design blog that gives “30 (actually more) Essential PDF Documents Every Designer Should Download”.

That’s bedtime reading sorted: http://www.positivespaceblog.com/archives/pdf-documents-designer/

How often do you check in?

Eugene Zakhareyev has an interesting commentary today on how often developers check their code into source control, and the control gates that some organisations can use to ensure quality of the checked in code.

Read it now or else: http://teamfoundation.blogspot.com/2008/08/check-in-your-stuff-now-or-else.html

 

Monday, August 04, 2008

Fun with dragging panels (a.k.a. Silverlight goodness)

Martin Grayson has started blogging about the silverlight controls that the MS CUI team developed for the Patient Journey Demonstrator.

This is really good news, because it gives us an insight into how some of the most compelling UI in the market has been developed (and a leg-up on doing it ourselves).

Silverlight goodness here: http://blogs.msdn.com/mgrayson/archive/2008/08/01/silverlight-2-samples-dragging-docking-expanding-panels-part-1.aspx

 

 

Friday, August 01, 2008