# Tuesday, August 11, 2009
A jQuery library quickly emerging really popular - and for a reason. I think it is one of the best JavaScript frameworks. You can do fancy stuff really fast and clean.

You can start a Getting Started with jQuery. On the jQuery homepage you can find a lot of nice tutorials. If you have not try jQuery, please do. You will be amazed.

Bassically what jQuery brings to web delopement is that it separates HTML and behaviour. Similarly what CSS brought: separation of presentation and HTML.

There are a great tool named Firebug, which really helps with web development. This tool surely demand a separate post. You can inspect a web page, play with CSS on the fly, debug, use a console ... Here it comes a jQuery. You can write a jQuery instruction right into the console, and it will be applied on the fly. Amazing. All you have to do is to "jQuerify" a web page.

Another great thing to know when you work with jQuery is what the selector will actually select. You can try a SelectorGadget tool which shows the most appropriate selector for the selected element(s). This tool is so great also because all you have to do to run it, just click a "link" when you are on the desired page to be check. Great!

More on Firebug and jQuery in the great video:

posted on Tuesday, August 11, 2009 7:20:20 AM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Saturday, August 08, 2009
I have implemented a very simple validation site. You just put an XML and XSD to it and it tells you if your XML document is valid. Simple.

Just vist XML Validation site and try your XML against XSD. Please notice that it is version 0.01 so I presume you know what that means. :)

When and if it will be updated is depended on the planet polarization.


Related:
http://blog.stegnar.com/2009/06/03/SimpleXMLValidationWithNET35.aspx

posted on Saturday, August 08, 2009 9:30:32 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Wednesday, July 08, 2009
A very nice thinking came by me from Rockford Lhotka. It is about future of OS. I quite agree with him. Soon we will have just thin client and everything will be in cloud.

http://www.lhotka.net/weblog/OSEvolution.aspx

Just think how many "cloud" things are you already using? A lot. Today is totally possible to have installed just a browser in you machine, and you can do (almost) everything.

posted on Wednesday, July 08, 2009 8:53:17 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Friday, June 12, 2009
I am looking for the clean, elegant and smart solution to remove namespaces from all XML elements. How would function to do that look like?

I have used StackOverflow. If you do not know this site, I can describe it as a really smart Q&A site, dedicated for programmers.

So I was searching for really great solution for removement of namespaces in XML. Based on one programmer answer I have created a solution which I really likes. You can clearly see, when you have to deal with tree data structure (which XML for sure is) recursion is simply the best approach to do anything with it:
private static XElement RemoveAllNamespaces(XElement xmlDocument)
{
    if (!xmlDocument.HasElements)
    {
        XElement xElement = new XElement(xmlDocument.Name.LocalName);
        xElement.Value = xmlDocument.Value;
        return xElement;
    }
    return new XElement(xmlDocument.Name.LocalName, 
xmlDocument.Elements().Select(el => RemoveAllNamespaces(el))); }
Do you likes? I love it. :)

I was totally convinced that exists some more smart .NET framework function, with which I could help. But I was wrong. The best .NET can do is something like this:
XmlDocument doc = new XmlDocument()
doc.Load(ms);
doc.DocumentElement.Attributes.RemoveAll();
All this function do, is to remove all attributes on root element only ... You could repeat this on every node with help of XPath, but since those selected nodes are immutable, this is little help.

posted on Friday, June 12, 2009 9:12:44 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Friday, June 05, 2009
Usually the explanation of object reference or pointer goes it is an address which reference something. Well in high level overview we can simplify this to that explanation, but today we well look the difference between the object reference and pointer and we well see why reference in not nearly the same thing as pointer.

Address
First we will look what the address is. Every data cell in memory have address, as every person have home address, basically that simple it is. Address just happen to be a property of some specific memory implementation, we could just have other way to access it.

Reference
Reference is really simple programming concept. It just reference to something. You have NO control over it. You can just reference and dereference it.

Pointer
Pointer is an abstract programming concept, which points somewhere and supports arithmetic operations. Strictly looking, pointer "per se" have no information, it just know where can find it. And you have control over it (arithmetic operations). What is connection between pointer and address? Well Pointer is not an address. Pointer is just implemented with address, because it just perfectly suits to what Pointer needs. To summarize, Pointer can do everything what can Reference plus more.

To better understanding I have made some simple diagrams, how looks those two concept in .NET:



posted on Friday, June 05, 2009 1:29:52 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Wednesday, June 03, 2009
I know, .NET 3.5 framework will soon became "old" framework, because .NET 4.0 is due to release. Anyway it is still the latest, and today we will look how to validate good old XML document with a given XML schema.

It the old days a XML validation took quite some code. For better understanding what I mean, look an XML validation article on CodeProject.

Now just look at this beauty:
        public bool CheckXmlAgainstGivenSchema(XmlHolder xmlHolder)
        {
            XDocument xmlDocument = XDocument.Parse(xmlHolder.XmlDocument);

            XmlSchemaSet xmlSchemaSet = new XmlSchemaSet();
            xmlSchemaSet.Add("myNamespace", XmlReader.Create(new StringReader(xmlHolder.XmlSchema)));

            bool isValid = true;
            xmlDocument.Validate(xmlSchemaSet, (obj, eventArgs) => { isValid = false; });

            return isValid;
        }
It is interesting that this small code snippet represent a lot of .NET 3.5 technology (LINQ to XML, Extension methods and Lamda expressions). This just show us how useful are those "new" concepts.

First we use XML manipulation class "XDocument", which allow us a really nice and smooth XML manipulation, compare to old XmlDocument. XDocument class have nice feature called "Validate", which turns out that this is just we have needed. :)

Validate method in an framework extension method and all it need is XML Schema, as you would expect of course and an event handler, which handle the situation if XML validation is failed.

We pass XML Schema as "XmlSchemaSet", this type is some kind of collection of the schemas. Validator just looks for a proper schema based on proper namespace and XML document elements. A passing delegate is nicely solved with lambda expression. Instead of it we could declare event handler and pass just a method reference (delegate).

posted on Wednesday, June 03, 2009 6:05:08 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Tuesday, June 02, 2009
I have added a Twitter counter for all you Twetties out there. If you would like to be informed about new blog posts, you will find there announcements, among other.

If you wish to be even more up to date, you can subscribe to the RSS feed. I have created one on the Feedburner is spite my blog already provide one (with feedburner you get nice counter and more control over feeds). RSS feed is a nice approach of reading blogs, since computer do the checking work for new content insted of reader.

UPDATE: Oh yeah, my home site, have been completely renewed over weekend. You can check it out. Currently is more or less boring, because it contains almost no content, really. But I have plans. :) I will not revel them completely, you can already see now I will have more "open" blog (not just about software development) on it. When it will something interesting happen, I will post it. Then I (will) have picture gallery, same applies here as for personal blog. And more (I hope). Stay tuned. :)

posted on Tuesday, June 02, 2009 9:54:15 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
Have you ever asked yourself, why C# string type works somehow different than other reference types?
  • First, when you declare them, you don't have to use a reserved word, which is used for reference type initialization - "new". You can also easily "overwrite"* them.
  • Second, when it is passed as a parameter to method, it does not reflect possible changes of this parameter inside a method (as reference types would normally do).
So what this animal really is? To explain string behaviour in deep, you have to know all about:
- immutability
- value type vs. reference types
- parameter passing
- C# reserved word "implicit"
- ...

All these interesting topic I will cover in the following days.

*As straight forwards as it may seems, we will see this is not really true.

posted on Tuesday, June 02, 2009 1:09:08 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Wednesday, May 27, 2009
I always wish to have my own e-mail domain space. You know, something like yourName@yourDomain. It just rulez. :)

Well a lot of things is nice to have, but you have to ask yourself is it feasible? Optimal? The right question about having your own e-mail domain is: Is this optimal?

If you think about it, you will figure out that even nearly is not. First you have to have a server that's mean the hardware (even in virtual machine it demand some hardware resources), a fail safe one. It demands power, power costs ... And this is just beginning. Then you have to install and configure SMTP server, anti virus, anti spam software ... And all of this you have to maintain, backup ... If you sum up, despite if you are an computer geek. You do not want your own email server at home. It just takes too much resources and it is just too unreliable. Period.

But we still want our "own e-mail". What to do? Well it turns out that Google have an answer (as almost always). You surely hear about Google apps. It perfectly solve our problem. It provide e-mail address with our domain on well tested Gmail infrastructure. All you have to to is to play a little with CNAME settings at your domain provider and that's it.

It is perfect example of cloud computing service. It is personalized and it persist in internet realm, somewhere.

From now on I am officially in the cloud, you can reach me at peter@stegnar.com.

PS: You can start here. You can choose two account types. For normal usage, standard version will do.

posted on Wednesday, May 27, 2009 6:46:19 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Tuesday, May 12, 2009
It just come out - Stack Overflow DevDays conference will be held in couple of cities:

October 19 San Francisco
October 21 Seattle
October 23 Toronto
October 26 Washington, DC
October 28 London

We Europeans have only one choice- London. I have already make a reservation and so should you! I believe this will be great conference.

Right now about 2h after Joel's announcement are 231 and 14 tickets available of 300. In less then one day there will be none, when it seeds out (what I am actually doing right now).

posted on Tuesday, May 12, 2009 9:52:31 PM (Central European Daylight Time, UTC+02:00)  #    Comments [1] Trackback