Some interesting XPath queries

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

I heard from people that XPath is not that easy (although I am having trouble believing it… it seems easy enough), so when I wrote a couple of XPath queries last time I chose to blog them to make it easy for some of those people reading this blog.

Here are a couple:

How would you select a parent based on a value of it’s child?

XML:

<a>
    <b>
        <c value=”1″></c>
    </b>
    <b>
        <c value=”2″></c>
    </b>
    <b>
        <c value=”3″></c>
    </b>
</a>

XPath:

//b[descendant::c[@value='3']]

It selects a “b” node based on an attribute value on it’s child “c” node

How would you select a node which has exactly one child node with a given attribute value?

XML:

<a>
    <b>
        <c value=”a”>1</c>
        <c value=”a”>2</c>
        <c value=”v”>2</c>
    </b>
    <b>
        <c value=”c”>2</c>
    </b>
</a>

XPath:

//b[count(c[@value='v']) = 1]

This selects all “b” nodes which have exactly one “c” node with an attribute “value” equal to “v”

 

Hope this helps someone!

Cheers!


Filed under: XML, XPath
Written on: 23 Apr 2008 · No Comments »

Things I mind about Reporting Services in SQL 2005

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

On the MVP summit we had a last day sessions (amongst others) about the new Reporting Services, and while I can’t tell you the details (don’t know what part is NDA and what is not) I can tell you that the guys are going in the right direction and really trying to fix some of the problematic things in the current version of Reporting Services.

On my way home I thought some more what I minded (=missed) about Reporting, so this blog post is an attempt to mention a couple of these things and hopefully someone from MS will read this.

Ok, so in no particular order:

  1. Shared library within a reporting project - on each reporting project we have a number of repeating report functions, it would be great if we could write them in c# classes (and class files), reuse them accross all reports in the project and deploy them as a report solution or as a shared library which is linked to the deployed reports
  2. Code editing - when editing code (functions, expressions, etc…) it would be nice to implement things like syntax highlighting, better intellisense (although that part is ok now mostly) so that in this day and age of modern IDE’s we can also use these features (althoguh every 5th level editor has these now)
  3. Report localization - I work for a company which delivers multilingual solutions as well (often a Dutch company application also needs reports, UI and other things in Belgium for example or even plain English) - it would be nice if engine would support something like ASP.NET does

There are probably more things like these, but:

  1. I can’t remember now
  2. The guys from MS are really working hard and some of the big issues (for me) I’ve already seen as fixed


Cheers!


Filed under: SQL, SQL Reporting Services
Written on: 23 Apr 2008 · No Comments »

Partitioning NHibernate IRepository to achieve better SRP level (hopefully!)

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

As you might know for some time now I’ve been working on my own NHibernate implementation. Largely it is influenced by Ayende’s great Rhino.Commons for NHibernate, but what I like to think is that it took a little bit different direction, and that the details of implementation are what it makes really different (not better or worse… just different).

With this in mind I am working on my own IRepository implementation and have found that it actually has at least 3 reponsibilities it must fullfill:

  1. It must be able to Save/Update/Delete/Query Entities
  2. It must be able to Query for DTO’s (via projections)
  3. It must be able to call Stored procedures

Now, with Ayende’s REALLY great implementation all this is a part of the main IRepository interface, what I’ve decided is that in my implementation they will be split:

  • IEntityRepository
  • IStoredProcedureRepository
  • IProjectionRepository

This allows me to split the responsibilities more accurately over them. Some of the differences:

  • IEntityRepository<EntityT> is full featured - it can both query and save/update/delete mapped entities
  • IStoredProcedureRepository contains only methods to call stored procedures
  • IProjectionRepository also only contains querying possibilities, it can query very similary to Entity repository, difference being that here you define the projections as well and thus tranform the result to a DTO or something else. Also, instead of defining the resulting type on the repository level (IRepository<T>), here you define it on a query level (.Find<T>….)

What do you think of a such idea?

I have to mention that the first two repositories are already made (Entity and Stored procedure), and are fully tested (spec’d out).

Ill describe how the current ones look in a series of upcoming posts, but they do contain some neat things.

Cheers!


Filed under: Akua.Framework, BDD, C#, NHibernate
Written on: 21 Apr 2008 · No Comments »

Alt.Net Croatia? Any takers?

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

As I am really disapointed that I couldn’t attend one more Alt.Net gathering in Seattle (had to fly home) I again started thinking of meeting people from my own region on a similar event.

You can take a look at some videos of how it was in Seattle:

http://www.youtube.com/results?search_query=alt.net&search_type=

Also, to find out more about this type of event and the principles and values that this group charishes, take a look here:

http://altdotnet.org/

http://laribee.com/blog/2007/04/10/altnet/

So… anyone interested? We can start of with Beer-meetups and work our way from there or something… just if there is anyone interested (either for a beer on the same topics or even a small conf)?

Drop me a comment if you are.

 

Cheers!


Filed under: ALT.NET
Written on: 21 Apr 2008 · No Comments »

MVP Summit Seattle

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

So I am back from Seattle. It was great this year… we’ve had 2-3 days of technical discussions and all in all… the future on MS platform looks promising.

I’ve also met a couple of people in person like Oren Eini (Ayende), Scott Hanselman, Phil Haack, Peter Blum and had a chance to speak to the DNN crowd (Cathal, Joe, Shaun, Lee and others). The whole time there I’ve spent mostly in the company of great SQL MVP’s like my friend Dean Vitner, Tomislav Bronzin and Dejan Sarka which made the time spent even more fun! All in all it was great to be there!

Besides the “official” part of the summit I’ve also had a chance to visit the Seattle Aquarium and Seattle Music Museum with it’s sub-museum on Sci-Fi, the first Starbucks shop and other things… Really neat.

You can find some pictures on my Flickr location:
http://www.flickr.com/photos/vladanstrigo/sets/72157604651822126/

Just one really bad part is about British Airways… this is probably the last time I fly with them. When going to Seattle I did not check in over the internet… when I came there to get a boarding pass the lady told me that there are no seats left on the flight (and I payed for my ticket!!!) so she told me to go at the gate and try to get the guy there to find me a seat if someone doesn’t show up. Fortunately he did, and it all went great… but still, I really don’t need this. Especially when I pay my ticket regulary!!!

Cheers!


Filed under: Personal
Written on: 21 Apr 2008 · No Comments »

Thinking about the new preview of MVC…

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

So obviously this is related to actions on a controller returning a value instead of being a void.

As mentioned by ScottGu in his latest blog post on the changes in the next preview of MVC:
http://weblogs.asp.net/scottgu/archive/2008/04/16/asp-net-mvc-source-refresh-preview.aspx

Now generally I have a split opinion on this… from one side it really does seem like a great idea, but from other side somehow it just doesn’t feel right (don’t ask me why… it just doesn’t).

So I’ve been thinking that maybe it’s related to the way it’s written, it’s not that readable (IMHO). So without too much thinking (just throwing an idea out)… what do you think of something like this:

public class HomeController : Controller {

    public ActionResult Index() {

        ValueOfViewData["Title"] = “title”;

        return toView();

    }

    public ActionResult About() {

        return toAction(”Index”);

    }

}

so just trying to express ourselves a little better (method names above are not that good, but should prove a point)?

Cheers!

 


Filed under: ASP.NET MVC
Written on: 18 Apr 2008 · No Comments »

Context driven Fluent interfaces via Chameleon pattern

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Before anyone flames me with bad comments, let me do a little disclaimer:

  • I am not a pattern authority; there is a big chance that this already exists under a different pattern. If so, please let me know and I will start using the original name instead of mine.
  • I am calling it by name so that in future I can easily refer to the beast by name and not be ambiguous about it.

So… let the interface extravaganza begin…

So you want to make a Fluent interface in c#, right? You want your interface to bend and shape itself depending on the how it’s used, right?

A little example; I was lately building my own Repository implementation for NHibernate and for the Find part, I want to build it as a fluent interface instead of having a parameter explosion smell.

I want to be able to do something like:

Repository.Find(when.Customer.Name == “Vladan”)
              .Order(on.Customer.Id)
              .StartFrom(10)
              .LimitTo(20)
              .All();

Let’s dissect requirements for each of the methods (this is only a subset of requirements I’ve put in front of myself when defining this interface)

- Find should be able to chain to Order, StartFrom and All
- Order should be able to chain StartFrom and All
- StartFrom should be able to chain only LimitTo
- LimitTo should be able to chain Order and All

Besides the specified allowed chain, the methods should not allow calls to other methods in the chain (e.g. “StartFrom” should not be allowed to call “All” directly, or “Order” should not be able to chain “LimitTo” directly) – or in other words, our method calls should be presented to us depending on the context of their usage, ok?

How do we implement this? Well, let’s start by defining for each method call above an interface:

public interface IFindQuery
{
}
public interface IFind
{
}
public interface IOrder
{
}
public interface IStartFrom
{
}
public interface ILimitTo
{
}

Now let’s chain them together depending on the allowed chaining requirements:

public interface IFindQuery
{
    IFind Find(…);
}
public interface IFind
{
    IOrder Order(…);
    IStartFrom StartFrom(…);
    List<OfResult> All();
}
public interface IOrder
{
    IStartFrom StartFrom(…);
    List<OfResult> All();
}
public interface IStartFrom
{
    ILimitTo LimitTo(…);
}
public interface ILimitTo
{
    List<OfResult> All();
}

Still with me?

Now, can you see that we’ve defined the context of chaining these methods? By being explicit about it, we were able to limit the context only to those operations we want to allow in a given moment.

How do we implement this?

Well the great thing is that now I can implement the complete Find part of my repository as a single object that implements all these interfaces and acts as a Chameleon – or better said, that changes its (inter)face depending on the situation.

Let’s try it:

public class FindQueryImpl : IFindQuery,
                                       IFind,
                                       IOrder,
                                       IStartFrom,
                                       ILimitTo
{
    public IFind Find(…)
    {
        …do something with it…
        return this;
    }
    IOrder Order(…);
    {
        …do something with it…
        return this;
    }
    IStartFrom StartFrom(…);
    {
        …do something with it…
        return this;
    }
    ILimitTo LimitTo(…);
    {
        …do something with it…
        return this;
    }
    List<OfResult> All()
    {
        …do something with it…
        return some_result;
    }
}

As you can see, by always returning a self reference, only under a different (inter)face we become context driven with a really simple object graph to support it.

And that ladies and gents… makes our chameleon. One object which shows it’s (inter)face based on context.

One thing to note though… this object would probably in very complex scenarios become too big and complex to maintain, so in those cases you should probably try to take it to the next level by partiotioning the chameleon to several smaller ones.

What do you think?


Filed under: C#, Patterns
Written on: 04 Apr 2008 · No Comments »

MVP again!

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

3rd year in a row… must be on a roll…

 

Cheers!


Filed under: Personal
Written on: 01 Apr 2008 · No Comments »

[CodeCamp] Once more it went great!

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Disclaimer: Again, this is a looong report :)

Disclaimer 2: This is also the first post about this years CodeCamp because I’ve been overley busy organizing that I just didn’t have time to post about it here.


This time around event was much dearer to me. Finally I’ve had a chance to do it in my hometown! As we’ve also had great content this time around the attendees reacted in a great manner by showing up on really sunny Saturday day for a full day of technical sessions (which believe me was a challenge concerning how much we like our weekends here, and especially how much we like sunny days).

Content

What LINQ brings to the table?

This was the very first session of the day in which Ivan Šaškor had shown us the perks of using Linq to Sql throughout the new Visual Studio 2008.

As first session of the day, Šaški did a great job warming up the attendees for the upcoming sessions by other speakers.

Has world become a better place now that we have Linq2Sql?

Dean Vitner’s session was the most expected one for me personally, as he is a DBA, his look on Linq to Sql sounded as a view that shouldn’t be missed.

As usual in his casual style Dean welcomed us to a well thought of set of arguments on the benefits as well as flaws of using Linq2Sql (couldn’t believe my own eyes and ears when I heard Dean speak even some good arguments in defense of Linq2Sql).

Ms Sync Framework & ADO.NET Sync Services

In his first time CodeCamp appearance Bernard Katić took us on journey towards the new Microsoft Sync framework and ADO.NET Sync services. In his session Bernard successfully explained to us the differences between some of the previous attempts from Microsoft and the new ones as well as shed a light on all the important aspects, problems and ideas which he had discovered from his use of the new framework.

Overview of new features and possibilities in Visual Studio 2008 with .NET Framework 3.5

Tomislav Bronzin together with young Bruno Kovačić continued on Bernard’s footsteps by talking about the new features for integrated development with the new Visual Studio and the features of the new .NET Framework.

Tomislav gave some great examples on how integration between designers and developers could be done with the new tools like Blend, showing us the direction in which the new toolset is leading us.

Dependency Injection with Windsor

Ivica Munitić decided to show us the perks of using Windsor in our applications, as well as generally employing IoC and DI while developing.

His overview of Windsor DI container had shown the attendees some of the possibilities that we can employ more easily. Although Ivica’s theme was on the more advance side, he made sure that each attendee grasps the big picture more easily and that they have some concrete takeaway’s after the session.

Team Foundation System - In Practice

During the last session of the day, Srđan Njirić talked about his personal experiences with Team Foundation Server in his company. His session quickly turned into a great discussion on the subject of practices and general experiences in guiding projects and was a great way to finish the technical part of the day.

Srđan once again did a great job in guiding our discussion in the right direction.


The day

The day started once again early at 09:30 AM and lasted long till 19:00 hours PM (a WHOLE day of technical talks, discussions and general fun) after which we’ve closed the event with a BIG raffle in which we gave over 20 prizes to some 30 or 40 attendees that survived the packed Saturday day.

Attendees

Over the course of the day we had up to 50 attendees and as the day were ending that count fall only to some 40 persons. Again our approach to attendee registration has triumphed, showing us that only a small part of the registered attendees did not show up (of some 55 registrations, only 2-3 attendees did not make it to event… which is for a free event IMHO a great accomplishment).

Viewing the attendee demographic profiles we’ve had visitors coming from all parts of Croatia… such towns as Dubrovnik, Zadar, Osijek, Zagreb, Split, etc… thus once more uniting our community under one roof.

Contributors

As previous years, the zero-friction-contributor list got even larger, thus helping us to have a sound background to organize such a good event.

We had divided the contributors in three categories, Gold, Silver and Bronze or Swag ones:

Gold contributors this year included: Microsoft, INETA, Telerik and Nevron

Silver contributors were: RedGate and NETmedia Sistemi

Bronze or Swag ones: LLBLGen Pro and Ekobit

We were especially happy this time around to include some of the more successful Croatian companies like NETmedia Sistemi and Ekobit, and thus expanding the reach of CodeCamp even more on the Croatian IT scene.

Because of the great help from our contributors, we were able to organize a big raffle at the end of the event, handling out 2-3 Vista’s, 2-3 Visual Studio/Windows Server/SQL Server 2008 packages donated by Microsoft, 2 Developer licenses of Controls Suite donated by Telerik, 5 licenses of Nevron User interface for .NET professional and 10 licenses of Nevron Chart for .NET Lite donated by Nevron, 2 licenses of .NET Developer Bundle donated by Red Gate, 2 licenses of LLBLGen Pro from LLBLGen Pro, 2 licenses of TeamCompanion and 1 license of TestManager for TeamEdition donated by Ekobit.


People

I would like to thank the people who have helped me organize this with their efforts:

From the community: Tomislav Bronzin, Siniša Dolinac, Siniša Bencetić, Denis Brulić

From Microsoft: Marin Mamić

Speakers: Ivan Šaškor, Dean Vitner, Bernard Katić, Tomislav Bronzin, Bruno Kovačić, Ivica Munitić and Srđan Njirić

Thank you all, without you – it could not have been done!


Recordings and materials from the sessions

With the help of Siniša Dolinac we were able to organize the recording of sessions with his camera. We have videos of each session and when we get the materials from the speakers we will publish it live on our website and thus making It possible to re-view the sessions again or listen to them if you’ve missed them (like I did as I was running around taking care of operational things… can’t wait to see the videos).

This will be done in the following 1-2 weeks pending the editing which will be done by a colleague from my company Siniša Jakelić.
At the same time we will also publish the presentations and other materials from our speakers.

Pictures

As soon as we collect the pictures from the digital cameras (this time around we don’t have that many pictures, but the ones we do together with the videos should help you get a feeling of how good it was J) we will publish them and put the link up.

Final thoughts… I am very proud I was a part of this; hope you’ve had a great time like I did… see you next year!


Cheers!


Filed under: CodeCamp
Written on: 01 Apr 2008 · No Comments »