Hi there! Now that Visual Studio 2010 is almost here, here are some facts about and what's new in Visual Studio 2010.

As you may have known, some of other INDC bloggers have blogged things about VS 2010, and there is a nice prize of blogging competition on this topic. As for me, I just want to tell new interesting facts about VS 2010 especially in Beta 2 release :).

This topic is divided into these series:

  1. First looks of Visual Studio 2010 Beta 2 (you're here)
  2. .NET 4 Beta 2 and the related C# 4.0 and VB 10
  3. New language into Visual Studio: F#
  4. WPF of .NET 4 Beta 2
  5. ASP.NET 4
  6. Team development of Visual Studio 2010 Beta 2
  7. Extending VS 2010 Beta 2

(... and more to come!)

Now, here's the first:

First looks of Visual Studio 2010 Beta 2

Note: For those didn't have Visual Studio 2010 Beta 2, you can download it from this MSDN portal of Visual Studio: http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx

Visual Studio 2010 comes in different editions, and it’s different in editions than in versions before 2010.

Visual Studio 2008 comes in these flavors:

  • Express Edition (free to download and use, but you’ll have to install VB, Visual C#, Visual C++ and Visual Web Developer separately)
  • Standard Edition
  • Professional Edition
  • Team System Developer and Database Edition included (it was initially in a separate edition)
  • Team System Architect
  • Team System Test
  • Team Suite, a you can have it all edition that include Team System Developer, Database, Architect, and Test edition

Quite many, right? Now, for Visual Studio 2010 editions:

  • Express Edition (free and the it is the same as Visual Studio 2008 Express)
  • Professional Edition
  • Premium Edition (this includes features from Team System Developer and Database)
  • Ultimate edition (just like Team Suite of VS 2008, but with additional Architect tools and many more)

At first, after you install the Visual Studio 2010 Beta 2, you’ll see this screen: (I use 1024 x 768 resolution)

image

At first, you’ll notice that it has new first page! Also the Visual Studio logo is also new, although it’s still a Möbius strip, but with a nice touchy bluish theme. But one nice interesting fact is (although you can’t see this directly), Visual Studio 2010 UI is largely developed using WPF 4!

Too bad I can’t use Snoop at first on Visual Studio 2010 running instances to prove this, but you can fix Snoop directly in the code using this tips.

I also downloaded the most “complete” edition of VS 2010, the Ultimate edition. It seems Microsoft wants to sync with Windows Vista and Windows 7 editions, right?

If you select “New Project…” on the right side of the Start Page, you’ll see these project types:

image

image

There you are! You’ll see F# dubbed as Visual F# in the list of templates!

And you’ll also see lots of other new template items, such as Silverlight 3 items.

 

And what about the documentation? It’s not like the previous version of MSDN Library. Visual Studio 2010 has MS Help 3.0, and it’s quite different from the previous versions of MS Help.

You have to install the documentation first by “adding” it to the Help collections as a “local content”.

At first, go to menu “Help” and choose “Manage Help Setting”:

image

Visual Studio will then check existing configuration of MS Help 3.0 for quite some time, then a Help Manager window will come up:

image

Choose find content on disk:

image

Browse to the installation disk and go to “ProductDocumentation” folder and you’ll find:

image

Select the file, and then add the packages. If you have successfully added the collections restart Visual Studio soon. Go to the Manage Help Settings and you’ll see this:

image

Now, back to Visual Studio again. Choose menu Help then “Visual Studio Documentation”. A new browser window will pop up and it will also display the homepage of VS 2010 help:

image

As you see, instead of displaying the MS Help Viewer, the documentation will be displayed directly on a web browser. This is quite useful, since it takes less amount of time and memory compared to previous versions.

But this collections that shipped with VS 2010 Beta 2 is not complete, there will be a bunch of pages or links missing/broken. So, always keep the installation of MSDN Library for VS 2008 SP1, don’t uninstall it.

Now, you’re ready to code! Next: .NET 4 Beta 2 and the related C# 4.0 and VB 10…

kick it on DotNetKicks.com

Share this post: | | | |
Posted by eriawan | 3 comment(s)
Filed under:

Hi guys! Just to refresh my entries about web 2.0 on this intro and then part 2, one of the hype of web 2.0 is semantic web. Now, this semantic is not just talking about the what your page will look, but it’s also what your html (or xhtml) page should be constructed. Meaning that, the source of your web page should be in a context of semantically correct.


Note:

First of all, I’m not a web standards fanatic or advocate! Even though I was once part of the W3C HTML/WG invited participant about 9 years ago.


A very nice example of this is the source of stackoverflow and the most complete sample that I’ve known of, is the website of Tantek Çelik, former Microsoft’s developer of IE 5 for Mac (which is sadly, not further developed).

As we move further and further to XHTML and Semantic Web, the old tags of HTML 3.2 will be considered obsolete or deprecated. W3C itself is moving to more semantically direction.

Web are moving to.. semantic web as semantic in simple linguistic?

Why?

HTML 3.2 and before is:

  • A mixes of style and data/content presentation
  • Ambiguous tree representation of DOM 1
  • Vendor influential (not neutral), for example: APPLET element
  • Focusing on quick deployment of looks and layout instantly (remember FONT element?)
  • Focusing on “tag”, not element. This is because it’s rooted back to the original hyperlink text created by CERN, the original birthplace of web and HTML and no DOM at that time.

HTML 4.01 is:

  • Promoting separation of style and layout (moved into CSS) and content presentation. No FONT element anymore!
  • Focusing on HTML element that’s further sync with DOM’s object.
  • Less ambiguous and in sync with DOM 2, although some ambiguities are still exist. Samples of ambiguities removed: use DIV instead of LAYER, BLINK is completely removed.
  • More neutral and based on very lengthy process of WD-“WD Last Call”-CR-PR-REC that unfortunately can take very long time to wait for finished Recommendation and can be pushed back to WD! Even Microsoft has been struggling with standardization and actively participating since the release of IE 7 Beta (see notes below).
  • A natural transition toward stricter DOM and readable and understandable HTML (geared toward browsers for sight impaired/disabilities), even on the source code level, since your HTML can also be read using a combined implementations of WCAI AAA
  • This natural transition is bringing more focus on content presentation but still allow STYLEs elements
  • Not just have to be understood, the meaning of translated or read HTML has to be meaningful in a sense of semantic linguistic, and therefore semantically correct, not just syntactically valid/correct.

Notes on Microsoft on W3C:

As a result of overwhelming request of IE’s standard conformances, many web developers were leaving IE, even fewer after the release of IE 7. As a matter of fact, IE 8 Beta 2 hasn’t been able to pass ACID2 test.

But Microsoft, especially Microsoft’s employee aren’t just bringing promises. See these promises and “horror” comments of this blog of Chris Wilson, Microsoft IE’s Architect. Also don’t forget to catch up with Chris Wilson’s new blog: cwilso.com.

Curious about latest IE development? Follow IE development on MSDN’s IE Team blog.


XHTML 1.0 is:

  • Based on XML 1.0 (now in 5th edition), Namespaces in XML 1.0
  • Although a transitional DTD is available, the use of case sensitivity is strongly applied since it’s XML based.
  • Can be extended implicitly, although this fact is still debated. But due to the fact of “X” factor in XML is eXtensible, this will welcome new possibilities of applications with other XML related standards at W3C, such as XSL, XSLT, XPath, XForm, XFrame, and others.
  • Promoting discipline over readable and transportable web
  • Focus on more well formed XML and more correct semantic

Where is the semantic factor, actually?

There are way too many aspects of semantic web and I can’t simply put those all in this small blog entry. But I can give you quick samples.

On the HTML side:

Element Semantic HTML Why
<b> <strong> More emphasized and clearer definition. It’s also stated in HTML 4.0, this will be rendered as bold face.
<i> <em> More emphasized and cleaner definition. It’s also stated in HTML 4.0, this will be rendered in italic face.
<font> no longer used Use CSS to specify type faces and sizes. Also promote more separation.
<blockquote> for quotation <q> for quotation Cleaner definition over quote of “q”. There have been numerous disagreements on blockquote on many forums of W3C, since blockquote is not clear and ambiguous.

On the HTML table representation:

  • Table should be used exclusively for tabular data, not for HTML layout
  • Use thead to give table header a real semantic representation of a header of tabular data, and use tbody for data itself.
  • Use fixed width to ease layout calculation for browser rendering, but do this in CSS, not in the HTML source! Hint: use “table-layout: fixed
  • If you need footer or last row summary, use tfoot
  • You want caption? You can use “caption” and use it directly as a child element of the table

This is the sample of a table:

<table>
<thead>
<tr><td>First name</td><td>Last Name</td><td>City</td></tr>
</thead>
<tbody>
<tr>
<td>Eriawan</td>
<td>Kusumawardhono</td>
<td>Surabaya</td>
</tr>
<tr>
<td>Benyamin</td>
<td>Suaib</td>
<td>Jakarta</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Total data:</td>
<td>&nbsp;</td>
<td>2</td>
</tr>
</tfoot>
</table>

With additional formatting, the table will be rendered like this:

formatted_html_table

If you look closely, the IE I use  is IE 8 Beta 2. See the compatibilty button. :)

These are the complete code of the sample:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Semantic web</title>
    <style type="text/css">
    thead
    {
        background-color: #00f;
        color: #fff;
    }
    </style>
</head>
<body>

<h1>Table sample</h1>
<table border="1" cellspacing="0">
<thead>
<tr><td>First name</td><td>Last Name</td><td>City</td></tr>
</thead>
<tbody>
<tr>
<td>Eriawan</td>
<td>Kusumawardhono</td>
<td>Surabaya</td>
</tr>
<tr>
<td>Benyamin</td>
<td>Suaib</td>
<td>Jakarta</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Total data:</td>
<td>&nbsp;</td>
<td>2</td>
</tr>
</tfoot>
</table>

</body>
</html>

 

Are there any help from tools/utilities?

The sad fact is, not many HTML/XHTML editors are aware about these.

Adobe Dreamweaver CS2 and CS3, for example, have acknowledged most of these and it also validates XHTML 1.0 well, but there’s no support for directly inserting thead and tfoot. Dreamweaver CS2 and CS3 also have supports for suggesting the use of “alt” attributes on “img”. Sweet!

I’d like to test Dreamweaver CS4, but the hardware requirements are quite overkill.

Microsoft Expression Web is more lightweight than Dreamweaver CS3, but unfortunately has many XHTML validation consistencies.

Surprisingly, HTML editor of Microsoft Visual Web Developer (of Visual Studio 2008) has valid validation and has “preview mode” that is closer to the current browser used. And it fully respects W3C XHTML 1.0 DTD, not paying respect to IE’s HTML DTD! Although, the suggestion is somehow less cleaner than in Dreamweaver CS2/CS3. Why?

Because Microsoft acknowledges the fact that IE even IE 8 Beta 2 doesn’t explicitly support XHTML 1.0. Only Opera 9.5 (or above), and Firefox 4.0 (yes, 4.0!) support XHTML.

What to see in the near future? I’ll try to continue this humble mumble of semantic web.

 

Comments are welcome! :)

kick it on DotNetKicks.com

Share this post: | | | |
Posted by eriawan | 44 comment(s)
Filed under: , ,

Funny, now the Windows Live applications and services seem to be in one version sync: version 14.

Get the full standalone of 110MB here:

http://download.microsoft.com/download/7/6/E/76EE3260-D212-4D9B-B8D6-79C014B0593B/EN/wlsetup-all.exe

So, what really is this hefty one package? It contains:

  • Windows Live Writer Beta
  • Windows Live Messenger
  • Windows Live Mail Beta
  • Windows Live Toolbar Beta
  • Windows Live Photo Gallery Beta
  • .. and this strange for me, Windows Live Call Beta. I think it's Microsoft's answer to Skype.

… And they all have the same version: version 14.

Here’s the snapshots:

Windows Live Messenger 14:

messenger_14

Windows Live Writer 14:

writer_14

Windows Live Mail 14

livemail_14

If some of you may ask, why do I show Windows XP? I need to inform you that you can still install these damn useful applications on Windows XP SP2, and on Vista of course. I suggest, on Vista though. You already have .NET 2.0 on Vista with added twists of security and reliability. :)

Funny or maybe not finished? The Windows Live Writer editor doesn’t recognize the CSS of my blog. Hope they will fix this.

Ah, by the way, Windows Live Writer needs .NET 2.0 runtime. And if you don’t have it, it’s already included in the standalone installer. Enjoy!

Share this post: | | | |
Posted by eriawan | 2 comment(s)
Filed under: ,

I know, it's quite old but it's still relevant, even today in the world of .NET 2.0, 3.0, and 3.5.

What the C or C++ Programmer Needs to Know About C# and the .NET Framework

Enjoy reading! :)

Share this post: | | | |
Posted by eriawan | 2 comment(s)

Yes. Why do I say many cares? Just a day after I wrote my latest blog entry about the first silent scream, some of my colleagues gave me supports, including many of my colleagues from Indonesian OMG BMI members. Wow! They even offer me many samples of syllables from many Australian universities, for comparison resources.

Some of them were willing to pour some real cash to accelerate this. But not so fast, though. We need to form a specific "organization", since then it's not an initiative from RX Communica anymore. Basically, they agreed. It's also being considered as a non-profit organization, and there should be no hidden agenda at all, no dependency or dominance from a single company.

Ahh, it may sound easy to say than to really form it. At the same time, while my friends and I are still considering many options, those guys that interested in funding approach me. But, they have to agree on stricter term, especially on these fine prints: "non profit, no dependency and dominance". Few of them backed off.

Funny thing is, some of them thought that we were building a promising startup, just like the story behind the fever of startup on the dusk of web 2.0 bubbles.

Simple answer is: No. We are not building a startup. We're not tied as a promising newcomer for many VCs. Yes, we're concerning about software development in general, and our main target is preparing young talents to be aware of the latest software development theory and best practices, also giving them experiences on real projects.

A first, the base camp is on RX Communica. Later when the need (and also funding) are sufficient, we'll have our own base, since we've agreed about no dominance, even for RX Communica and also my friend's company. We don't know yet the name. :)

Many thanks for you guys, especially from Indonesian OMG guys and my silent scream fellows on Kalimantan. Next, since this topic is no longer about .NET, I'll migrate it to a new host, or maybe I'll use any other free blog services for this time being. Or, do any of you, this blog's loyal visitors, want me to report it here? I will, if you want to. But I'm afraid it'll be less .NET content. :)

As Aerosmith sung:

"It's amazing! With a blink of an eye, we finally see the light..."

 

Again, many thanks.

Share this post: | | | |

 

 


Update:

May 147h, 2008: revisiting local type inference and more clarification on VB and C# feature comparison


 

Close view of Lambda Expressions and the journey to LINQ

Now, what's really a lambda?

According to MSDN Library that comes with VS 2008, a lambda expression is "an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types." That's a mouthful description.

First, an anonymous function. Function, in a sense of C# and VB.NET, is simply a method that returns any value. In VB, it's more verbose, it uses keyword Function. It can be seen as a further development of anonymous method, only it's more like syntactic sugar, since it's more expressive.

Before enjoying this journey, C#3.0 and VB 9.0 new features are not LINQ alone. Many new features of C#3.0 and VB 9.0 forms (or compose) LINQ.

These are:

  • Query expression (or query comprehension)
  • Local variable type inference
  • Lambda expression
  • Anonymous types
  • Object initializers
  • Expression tree

Now grab your popcorn, relax and stay sit. :)

Before Lambda expressions, and others, there has been impedance mismatch of data and object

Now, let's see... The roadmap to the query expression of LINQ. Yes, the journey behind it. You can also see the movie about it on LANGNET 2008 website in Talks section. But for those prefer to seek another way to crunch this concept, let me enlighten you. :)

It all starter when these things happened: "impedance mismatch of objects and relational data".

Or, easily put by Anders Hejlsberg and others:

relationaldata != object

Remember XBase family software such as dBASE, FoxBase (then FoxPro and then Visual FoxPro and then "gone")? Yes, they were neat, if you need to access data, it's so simple. You got the feeling that the data was there, integrated with your language you're coding. It's also giving you compile time errors on query (although there were no such thing like Intellisense). They were also fun to use, since you're concerning only on "what" data you want to display, instead of concerning "how". And the database world has grown not just simple query, but it's grown into a standard based SQL, at least ANSI SQL-92.

The separation grew larger, since the difference was more obvious:

  1. Database is relational, object is hierarchical,
  2. Database has nullable types, object didn't have it.
  3. Database has indexes, primary keys, object didn't have it. But this was solved by major ORM, including #1 above, but not #2.

 

The long road to marry data and object

Luckily, in CLR 2.0 (also C# 2.0 and VB 8.0) we have Nullable value type, which can be simply written int? in C# or Integer? in VB. Now, we know then, at least in .NET 2.0, we have matched types from database domain.

What about query in our programming language? It's simply can't match the power of the domain specific language such as SQL. Yet, we still need to work at the heart of our general programming language discipline first, the object itself.

The journey of those thinkers in Microsoft is illustrated below.

Suppose I want to query an arbitrary collection in .NET, and later I want to make it "fluent" and looks like query I used to know. Why? Because basically a table is a collection of rows, and this collection can be a CLR IEnumerable<T>.

Now, let's do a simple query of available processes on my machine, and then print it on console.

In C# 2.0:

IEnumerable<Process> processess = Process.GetProcesses();
 
foreach (Process proc in processess)
{
    Console.WriteLine(proc.ProcessName);
}
Console.ReadLine();

In VB 8.0:

Dim processes As IEnumerable(Of Process) = Process.GetProcesses()
 
For Each proc As Process In processes
    Console.WriteLine(proc.ProcessName)
Next
Console.ReadLine()

 

Oh, what about if I want to know which processes on my machine have size > 50MB? Sure I could add if statement that filter the proc in Processes before I display, like these:

in C# 2.0:

IEnumerable<Process> processess = Process.GetProcesses();
 
foreach (Process proc in processess)
{
    if (proc.WorkingSet64 > (50 * 1024 * 1024))
        Console.WriteLine(proc.ProcessName);
}
Console.ReadLine();

in VB 8.0:

Dim processes As IEnumerable(Of Process) = Process.GetProcesses()
 
For Each proc As Process In processes
    If proc.WorkingSet64 > (50 * 1024 * 1024) Then
        Console.WriteLine(proc.ProcessName)
    End If
Next
Console.ReadLine()

But, this is the query that I want. A query is not like these. I decide to implement Where as a method. But how do I pass expression to be later evaluated and spawned as iterators? Fortunately, C# 2.0 has a new keyword of C# "yield" to have the compiler generates iterators. But sadly enough, VB 8.0 doesn't have it. But you can code it in C# and use it in VB anyway.

Note: This is where the language features of C# and VB seems having unfair advantages: the yield keyword is only available on C#. Why doesn't MS include this in VB? I can't find the reason anywhere, even on MSDN.

After I think for a while, I decide I have to put these into a method with accept generic. Ah, this is a suitable implementation for .NET 2.0 anonymous generic delegate. I think I want a class that contains method that can be called anywhere, and this is definitely a static class.

So, I modified my code to add this class, let's just call it Query. And the method to filter, let's just call it Where. It's perfectly suited for our intent: to filter out elements/items and make new collection with filtered items.

But first, I have to make declaration/definition of the delegate:

public delegate TResult Func<T,TResult>(T arg);

And now, here's the resulting Query class with Where method in C# 2.0:

namespace TrialLINQinNET20
{
    public delegate TResult Func<T,TResult>(T arg);
 
    public static class Query
    {
        public static IEnumerable<T> Where<T>(IEnumerable<T> items,Func<T,bool> predicate)
        {
            foreach (T item in items)
            {
                if (predicate(item))
                    yield return item;
            }
        }
 
 
    }
 
}

Now, my query somehow looks nicer:

In C# 2.0:

IEnumerable<Process> processess = Process.GetProcesses();
 
IEnumerable<Process> listproc = Query.Where(processess, 
    delegate(Process p) { return p.WorkingSet64 > (50 * 1024 * 1024); });
foreach (Process proc in processess)
{
    Console.WriteLine(proc.ProcessName);
}
Console.ReadLine();

In VB 8.0, I can't. It simply doesn't support anonymous functions, and this including anonymous delegate.

Note: This is another aspect of VB 8.0 having unfair advantages: the anonymous delegate/function is only available on C# 2.0. Another "why doesn't MS include this in VB". But in VB 9.0 it's being done as a lambda expression in a more verbose way.

Now, I have created filter or "map" in functional programming terms. I passed the predicate as expressed in delegate.

To tell you the truth, I copy the declaration of Func<T,TResult> delegate from MSDN Library.

What about Select? If you look at the base theory of SQL, it's called a projection. As a matter of fact, projection, filter, and others are essentially part of relational algebra. And it's fun to know that it's part of set theory, which we had in elementary school. :)

Now, let's create a select method. Basically, it projects a collection of type into other collection of type. It can be the same, but it can be different. It looks almost like Where, but I have to change and modify the signature of select method to be able to map IEnumerable<T> to another type.

This is the select method:

public static IEnumerable<U> Select<T, U>(IEnumerable<T> source, Func<T, U> selector)
{
    foreach (T var in source)
    {
        yield return selector(var);
    }
}

Yes. Now, if I want to display (and select) only the ProcessName of the running process that has taken more than 50MB of my precious RAM, the code will be:

IEnumerable<Process> processess = Process.GetProcesses();
 
IEnumerable<Process> listproc = Query.Where(processess, 
    delegate(Process p) { return p.WorkingSet64 > (50 * 1024 * 1024); });
 
IEnumerable<String> procnames = Query.Select<Process, String>(listproc,
    delegate(Process p) { return p.ProcessName; });
foreach (String procname in procnames)
{
    Console.WriteLine(procname);
}
Console.ReadLine();

 

Now... I see the class and the code is simpler to be read. I can map a collection of Process into a collection of String, since I only need to dump the ProcessName.

Please note the sequence here: I need to filter it first, then map it. If I map first and then filter it, I'll loose some information about the data (type metadata) in the collection. So where comes before select! This is different from SQL, since SQL permits select first and then filter it, and then take from a pool of data. In OOP, we have to know from what data we want to use, filter it, and then map it.

SQL seems to cook up structural type before "from" was taken place.

Local type inference revisited...

Hmm... This is somehow satisfactory, but it's full of syntactical noises, where I have to type full type declaration, especially if I have to type long type declaration of generics.

The variable's type on the left side of declaration is already known after I initialized or have been assigned with a value.

Now this is where I begin to use C# 3.0, .NET 3.5, and Visual Studio 2008, since it can infer the type of local variable. Only, it means available only on local variable of method scope. This is why it's simply named "local type inference".

Instead of writing this:

in C# 2.0:

Dictionary<String, List<Int32>> integerdict = new Dictionary<string, List<int>>();

in VB 8.0 it's somehow shorter:

Dim integerdict As New Dictionary(Of String, List(Of Integer))()
And C# 3.0 brings you:
 
var integerdict = new Dictionary<string, List<int>>();

Again, it means give integerdict the type of the right hand assignment or expression has. It's neat, and it's simpler.

It's still statically typed, since by then the type of integerdict is always Dictionary<string, List<int>>. Yes, it looks like dynamic language, but it's not dynamically typed, and it's not the same as Variant in VB or object in Javascript.

Now, in C# 3.0, my little query class and its implementation is:

var processess = Process.GetProcesses();
var listproc = Query.Where(processess, 
    delegate(Process p) { return p.WorkingSet64 > (50 * 1024 * 1024); });
var procnames = Query.Select<Process, String>(listproc, 
    delegate(Process p) { return p.ProcessName; });
foreach (String procname in procnames)
{
    Console.WriteLine(procname);
}
Console.ReadLine(); 

Pretty neat, isn't it? But this is not query. In real query, I just can combine Where and Select. So, the procnames is a select of filtered data of process.WorkingSet64 > 50MB. How do I do this?

Then I decide to just passing the where to my projection:

 

var processess = Process.GetProcesses();
var procnames = Query.
    Select<Process, String>(Query.Where(processess,
    delegate(Process p) { return p.WorkingSet64 > (50 * 1024 * 1024); }),
    delegate(Process p) { return p.ProcessName; });
foreach (String procname in procnames)
{
    Console.WriteLine(procname);
}
Console.ReadLine();

But now it looks confusing. In reality, I should filter it first and then map it. Do where first, and then select it. The execution order is correct, but I can't just make it into a sequences.

I was thinking about extending IEnumerable to be able to do query, something like IQuery but it has to be concrete class, not an interface. But then again, it's not so practical.

But I think it would be nice to have this notion: procname.Where(...).Select(...) instead of having to combine Select and Where just like above. In programming buzzword, this way of thinking is called "fluent", since the data/value passed flows like fluid, although it's still to be arranged in a sequence.

Simple sample of fluent thinking:

String name="Eriawan  ";
String upperstring = name.ToUpper().Trim();
 
See? The string is passed. Now, it's more fluid.

Ahhh, it's "fluent" now

Luckily, there's this feature: method extension in C# 3.0 and VB 9.0. I can just "extend" existing class especially "locked" class or classes which has modifier of sealed in C# or NotInheritable in VB.

How to do this?

In C# 3.0:

  1. Create static class with static methods, with the first parameter is the type you want to add method.
  2. Put "this" keyword in the first parameter of the static method

In VB 9.0:

  1. Create new module
  2. Create method (either Sub or Function) with Public modifier and give the method <Extension()> attribute

And you're on!

So, my Query class in C# 3.0 would be:

 

public static class Query
{
    public static IEnumerable<T> Where<T>(this IEnumerable<T> items, Func<T, bool> predicate)
    {
        foreach (T item in items)
        {
            if (predicate(item))
                yield return item;
        }
    }
 
    public static IEnumerable<U> Select<T, U>(this IEnumerable<T> source, Func<T, U> selector)
    {
        foreach (T item in source)
        {
            yield return selector(item);
        }
        //return source;
    }
}

Now, the implementations will be:

var processess = Process.GetProcesses();
var procnames = processess
    .Where(delegate(Process p) { return p.WorkingSet64 > (50 * 1024 * 1024); })
    .Select(delegate(Process p) { return p.ProcessName; });
foreach (String procname in procnames)
{
    Console.WriteLine(procname);
}
Console.ReadLine();

Yayy! It's more fluent! But... I think it's still noisy. Just look at the delegate syntax on Where and Select. It's simply a function with a parameter and an expression. I want to be more expressive.

Now is the close view of Lambda

Now, this is where Lambda Expression comes to help. Lambda expression, as Norman said in commenting blog entry :), is just basically writing inline function. Lambda expression is just a simple synonym of Lambda Calculus, which is one of the basic of functional programming.

Let's just go down to transform our delegate parameters above, into these:

 

var procnames = processess
    .Where((Process p) => { return p.WorkingSet64 > (50 * 1024 * 1024); })
    .Select((Process p) => { return p.ProcessName; });

The fat arrow "=>" is "goes to". It can be simplified as inline function that has parameter p and then  "p -> p.ProcessName".

Thanks to local type inference, the lambda parameter type can be omitted:

var procnames = processess
    .Where((p) => { return p.WorkingSet64 > (50 * 1024 * 1024); })
    .Select((p) => { return p.ProcessName; });

If the parameter is just one, the parentheses () can be omitted too. Also, since the return value is just a simple expression, I can just make it more expressive and looks more functional instead of writing an imperative return statement.

Now the code above looks like this:

var procnames = processess
    .Where(p => p.WorkingSet64 > (50 * 1024 * 1024))
    .Select(p => p.ProcessName);

Now, the noises are gone. My code looks functional!

But it's still not the query I used to be, I know it's closer. It would be nice to have select and where as keywords, and be integrated into our code.

Now, C# 3.0 and VB 9.0 include this new feature: query comprehension.

Query that is so integrated into our code: Query comprehension

The code before now is transformed using this query comprehension into:

var procnames = from p in processess
                where p.WorkingSet64 > (50 * 1024 * 1024)
                select p.ProcessName;

and in VB 9.0:

Dim procnames = From p As Process In Process.GetProcesses() _
            Where p.WorkingSet64 > (50 * 1024 * 1024) _
            Select p.ProcessName

 

But the LINQ wave doesn't stop here! There are many other discrete cool features in C# 3.0 and VB 9.0 that forms LINQ.

kick it on DotNetKicks.com 

(to be continued...)

Share this post: | | | |
Posted by eriawan | 4 comment(s)

I was in the middle of downloading screencast from Channel9 of MSDN and also finishing my part 2 blog.

To my surprise, the 3G connection went so fast! Many thanks to my XL 3G for this connection:

image

Before this, I always complained to them about how slow it was.

But right after that, I test the real speed using intel bandwidth test:

image

 

It looks like I only have a quick surge of 3G speed. Well.. For this speed, it's still slower thean my ISDN connection at home. But, anyway, it's fun to test the real speed. Also, maybe I should sample more test.

I have tested it again many times, and this is what I got an average of 72kbps out of 5 times testing:

image

So, what I got is a quick surge of 3G speed. Has any of you experienced this phenomenon too?

Share this post: | | | |
Posted by eriawan | 4 comment(s)
Filed under: ,

Yeah. I know. It's quite noisy, either in INDC's mailing list, or in many web that says cool features in VS 2008.

But let me straighthen up first, why I choose LINQ first? It's because becoming hot buzzwords number one. And it can get many wrong views.

 


UPDATE:

27th March, 2008: fixing typos, code samples are now in C# 3.0 and VB 9.0, not just C# 3.0.


 

LINQ views and what comes in a single query of LINQ

Ah. Language INtegrated Query. Everyone has been becoming crowded and many shouting at me, "I know it! Of course I know!" But many don't know, it's not just a new essential features of VS 2008, but it's more like one of new features of .NET 3.5.

I also often heard many mumbles that said, "LINQ is the only way","LINQ is the newest concept from Microsoft's family of programming languages", blah, blah, blah, and many leads to almost false altruism.

It can be a sad fact for us but it's true, LINQ is not all that new! In "C Omega", or Cω, the notion that you can include SQL query such as Select is already available before C# 3.0. The name itself is new. Yes, the term LINQ is new, but the concept behind it it's not new. But why I say, not all? The concept of bringing Lambda expressions to LINQ queries are new. I'll try to explain it after this LINQ views.

LINQ it's not exclusive of .NET 3.5, though. Because it's simply a set of new language features capabilities that built into the fabric of C# 3.0 and VB 9.0 language specifications in terms of new keywords and new syntaxes. Most of all, it's simply a syntactic sugar, to ease all of us writing codes especially when dealing with SQL query language syntaxes. And don't forget one thing, .NET 3.5 is still .NET 2.0 lies beneath. So, .NET 3.5 was built on top of .NET 2.0 added with .NET 3.0. It's not exclusive, right?

Since LINQ is not exclusive of .NET 3.5, it's also implied that you can still can do your hard work in doing querying data. Still, you can do many things in ".NET 2.0 ways". But we, as software developers, tend to be more productive, and can be we're obligated to be always more productive and also more innovative in doing our core responsibilities, solving business problems and coding.

So, I strongly suggest that you use LINQ if you have Visual Studio 2008, and please upgrade to VS 2008 if you have 2005 since your new learning curve is not that new. Why? I'm not a strong opponent of using LINQ. In fact, I (again) strongly suggest you to use LINQ as appropriate and wisely for your development. It's helpful. It's not a must, but it eases our coding, and also promoting easier to read and then to code (can be the other way around).

Why? Because you'll get compile time checking and Intellisense in your query syntaxes! This means less error, more focus to the query logic. Also another why is, it's a way to compose pieces of arcane nested select queries, which can have many side effects. This concept comes from functional programming, and later I'll explain this after LINQ stuffs.

But be prepared to dive the concept behind LINQ uses first. You have to know it. I strongly suiggest you to learn it also. There are some facets of many programming paradigm "hidden" from us!

 

A quick LINQ to SQL

First, easier to code. Why? Let me give you a basic example of LINQ querying a LINQ to SQL (formerly DLINQ)generated class that represents Customers, from our good old sample database of Northwind (it's not installled by default in SQL Server 2005, you can get it here).

These are quick step by step to get your feet wet quickly:

In this sample, I create a LINQ to SQL classes and name it Northwind.dbml

vcsharp2008express_itemtemplate

 

Now let's use this new classes, but please pay attention that you have to understand what really is "LINQ to SQL Classes" is.

Basically LINQ to SQL is a quick "one stop shopping ORM" tool that maps your SQL Server database, tables, relations, and also stored procedures into hierarchical objects and CLR methods.

Your database will be mapped into a DataContext, your table will be mapped to

Just add these tables from Northwind to the Northwind.dbml:

  • Customer
  • Order
  • Order_Detail

Just for fun, add the SalesByCategory stored procedure into Northwind.dbml and you'll see this:

Northwind_dbml

Now... it's quite straightforward, right? But, where's the real LINQ?

Ah, LINQ is not pictures and models. This tool simply helps us visualize this code: (in the Northwind.designer.cs)

 

northwind_designer

 

These are the code that represents Northwind database (also conceptually):

 

    public partial class NorthwindDataContext : System.Data.Linq.DataContext
{

private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();

#region Extensibility Method Definitions
partial void OnCreated();
partial void InsertCustomer(Customer instance);
partial void UpdateCustomer(Customer instance);
partial void DeleteCustomer(Customer instance);
partial void InsertOrder(Order instance);
partial void UpdateOrder(Order instance);
partial void DeleteOrder(Order instance);
partial void InsertOrder_Detail(Order_Detail instance);
partial void UpdateOrder_Detail(Order_Detail instance);
partial void DeleteOrder_Detail(Order_Detail instance);
#endregion

public NorthwindDataContext() :
base(global::WinFormDLinq.Properties.Settings.Default.NORTHWNDConnectionString, mappingSource)
{
OnCreated();
}

public NorthwindDataContext(string connection) :
base(connection, mappingSource)
{
OnCreated();
}

public NorthwindDataContext(System.Data.IDbConnection connection) :
base(connection, mappingSource)
{
OnCreated();
}

public NorthwindDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}

public NorthwindDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}

public System.Data.Linq.Table<Customer> Customers
{
get
{
return this.GetTable<Customer>();
}
}

public System.Data.Linq.Table<Order> Orders
{
get
{
return this.GetTable<Order>();
}
}

public System.Data.Linq.Table<Order_Detail> Order_Details
{
get
{
return this.GetTable<Order_Detail>();
}
}

[Function(Name="dbo.SalesByCategory")]
public ISingleResult<SalesByCategoryResult> SalesByCategory([Parameter(Name="CategoryName", DbType="NVarChar(15)")] string categoryName, [Parameter(Name="OrdYear", DbType="NVarChar(4)")] string ordYear)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), categoryName, ordYear);
return ((ISingleResult<SalesByCategoryResult>)(result.ReturnValue));
}
}

In VB:

 

Again, quite straightforward, eh?

The rest of the code is the declaration of tables.

Now, again, where's the LINQ, or query, or the code thingy?

I simply use the NorthwindDataContext and create a new instance of it. Then, just get Customer table from it! With a hint from Intellisense. Yes.

 

dlinq_intellisense

 

Okay! Now the LINQ!

In this quick sample, I dump the output of the LINQ to SQL of Customer to an IEnumerable and then put it as a DataSource of a Windows Forms GridView:

in C#:

        private void Form1_Load(object sender, EventArgs e)
{
NorthwindDataContext dbnorth = new NorthwindDataContext();
var qry = from c in dbnorth.Customers
select new { c.CustomerID, c.ContactName, c.CompanyName, c.City };
this.dgvCustomer.DataSource = qry;
}

In VB:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dbnorth As NorthwindDataContext = New NorthwindDataContext
Dim qry = From c In dbnorth.Customers _
Select c.CustomerID, c.ContactName, c.CompanyName, c.City
Me.dgvCustomer.DataSource = qry

End Sub

 

Run it, you'll get the same column results from the select query above:

 

image

 

What if I want to filter it? Hmm... Let's just say I want to get data of customers in London.

Change the code above to this:

In C#:

        private void Form1_Load(object sender, EventArgs e)
{
NorthwindDataContext dbnorth = new NorthwindDataContext();
var qry = from c in dbnorth.Customers
where c.City == "London"
select new { c.CustomerID, c.ContactName, c.CompanyName, c.City };
this.dgvCustomer.DataSource = qry;
}

 

In VB:

 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dbnorth As NorthwindDataContext = New NorthwindDataContext
Dim qry = From c In dbnorth.Customers _
Where c.City = "London" _
Select c.CustomerID, c.ContactName, c.CompanyName, c.City
Me.dgvCustomer.DataSource = qry

End Sub

you'll get this:

 

image

Voila!

More productive, right? I just create this sample code less than 5 minutes!

As you see, the "select" is now keyword. So is "where" and "from". But from comes before select, which is different from the original SQL query of SELECT.

Why? Because SQL language is not quite natural in the way the ordinary compiler process. You can't put the "select" first, since you have to know from what kind of set of data you want to manipulate or to select.

The quick notion is: I have to know from what set of data I want to select, then select it. Not the way that SELECT SQL works. Because compiler can't know at first the variables you want to select if you don't define from what data first. Now, enter the world of Declarative Programming!

Why? Because you think what you want to, not how it can be done. Declarative programming is everywhere, from WPF's XAML, to XML Schema, and to quite old domain specific language such as Prolog and our old data centric language (and also domain specific language), SQL query.

Quite funny, isn't it? You've used SQL but you didn't know what kind of taxonomy SQL query was.

But don't be happy soon, C# is not entirely Declarative Programming. It's an imperative programming family member, same as VB.NET.

See? This is why I told you up front, you have to know some concept first. And the depth doesn't stop here. Let's see how the code above is translated into, and I call it, "first phase". But before that, enter another new cool features of C# 3.0 and VB 9.0: type inferencing.

 

Type inferencing

See this:

            var qry = from c in dbnorth.Customers
where c.City == "London"
select new { c.CustomerID, c.ContactName, c.CompanyName, c.City };

You may wonder, is it still type safe? Variable qry has no type defined up front! If you debug and hover your cursor to qry variable, you'll get IEnumerable. Actually, the code above says, "give variable qry the type of the right hand expression has". So, qry has the type of IEnumerable.

I can also create this variable x as Int32 using type inferencing:

            var x = 1;

It's using var and it functions the same as Dim in VB. VB also have it. But var looks like Javascript, and Javascript is dynamic language family member. Enter the world of dynamic language!

But, again, it's up to you to decide whether this is a good or bad news, since C# is not purely dynamic language. For me this fact can be understood perfectly, because C# is intended strongly typed at first, unlike Javascript.

Now, the query code above is translated into this first phase:

            var qry = dbnorth.Customers
.Where(c => c.City == "London")
.Select(c => new { c.CustomerID, c.ContactName, c.CompanyName, c.City });

 

Or in VB:

        Dim qry = dbnorth.Customers _
.Where(Function(c) c.City = "London") _
.Select(Function(c) New With {c.CustomerID, c.ContactName, c.CompanyName, c.City})

 

Have you seen this syntax above before? The "c=>"?

In C#3.0 and VB 9.0, it is called Lambda Expressions. But VB is not taking the same syntax, it's written as new Function which is then translated into Lambda function. VB programmer prefers syntax that's more verbose.

The idea of Lambda Expression itself was taken from a topic of Lambda Calculus, from mathematic foundation. We now turn our journey to the world of exotic Lambda Calculus, but only as an overview in C# or VB view. Now, we're now walking towards new world of Lambda Calculus.

Lambda Calculus (or Lambda Expression in C# 3.0 and VB 9.0)

Now, what is Lambda calculus anyway? It is simply a functional view of expressing your code. But in a deep glass magnifier view, it's a formal system (as in Wikipedia) to investigate function applications and recursion.

In C# and VB, it's a functional way to express delegate and expression tree types.

(To be continued..)

kick it on DotNetKicks.com 

Share this post: | | | |
Posted by eriawan | 3 comment(s)

Yes. It is. I feel dizzy again thinking about what are our youngster wannabe geek doing and thinking today, either they're still studying or being graduated.

I'd experienced many things during my quite long (more than 1 month) silence period. I was doing my coding partially outside Java, the Kalimantan island, while also helping my friends there. My friends are IT lecturers (focusing on software development concepts) from quite a reputable state university and also teaching at other private university as well. Not to mention they have a small software company (call it "micro ISV", just like mine) that sells web solution based on ASP.NET 2.0.

Unspoken yet proven local heroes

Note: I won't mention their company name in here. Also they asked me not to tell their names. But you'll find it on IBM's GSSG website, and they're one of a very rare IBM software development premier partner in Indonesia while also having IBM Rational certifications and MCP certifications in .NET.

I was eager to know many things about educations, especially education IT on Kalimantan. Yes, mostly people of Kalimantan have a warm welcome, comparing to Surabaya. But, I was shocked after visiting and helping them to interview candidates for software developers. Before, they told me, "Don't expect much from fresh graduate locals and from Java graduates." Huh? What's up? They told me that I shouldn't expect graduates to be a good junior software developer to pick.

At first, I didn't believe it. There is should be at least one. Can't find just one? This is impossible.

The truth is more an irony than just a sad fact.

It took almost a week to interview about 30 candidates, but I can only help them for 2 days. Although it's already advertised "looking for C# developer", almost 30% of submitted applicants were failed; they didn't know C# and basic OOP as well.

The rest 70% was quite good at first. They knew basic C# 2.0 and .NET 2.0 concepts, including generics, delegates, using statement (as a deterministic object scope), and collections. But, little they know concepts of .NET CLR. There were fruitful debates at that time, between my friends and me. Finally they agreed to include design pattern and common coding best practices as a requirement. But again, they warned me, "You'll lose many candidates. We won't include that requirement now." Please take note about the word "lose". Lose here doesn't mean that they'll lose good candidates after applying, lose here they'll lose candidates before applying after seeing the fact and yet they mumbled, "What? Design patterns? best practices? no. I don't have that in university".

Ironies

Other ironies comes in again after I met one of candidates at lunch and I was pretending to apply. He told me that most lecturers in his university always giving him doctrines about the best programming language, best OS, and also focusing to learn many programming languages instead of nurturing students to solving business problems, understanding the very basic software development concepts such as DBMS, SDLCs (such as waterfall, iterative, UP), programming paradigms (e.g. imperative programming, functional programming, declarative programming) and many more. He also told me that if he wants to propose .NET 3.0 study as its topic of his final assignment, he'll be out of luck. The majority of his lecturers have rejected him for many non sense reasons such as "We don't use that. What is WPF? No need to learn new things! Just stick to your study and get graduated fast!"

Other candidate that also had lunch with me told me that they somehow got used to think that every concept they've learned from their past universities were enough. No. It's not enough. I calmly told and explained to him that what he'd learned mostly were not conceptual at all. I was having quite painful conversation, since he at first was defensive. After a long persuasion, he realized that he had to learn many basic things that makes a real concepts.

After I discussed this with my friends, they told me that those reasons simply translated to: "I don't know that. Since I don't know WPF and even .NET 3.0 and I won't learn new things since I don't have to. So you as a student simply get back to your chair and just finish your damn study just like others!"

D'uh. I also remembered this bad mentality experience while I was consult my final assignment about 10 years ago. Now still happens.

Heroes and silent screamers

What about my friends as a lecturers? They have gone from "loud scream" to "silent scream". They were known as many bright lecturers and also post graduate students (all of them have at least masters in software engineering and one PhD). Yes, now they're not known from the outside world. But they've been struggling at the university senate level to insert and also assert basic software development concepts while at the same time facing the fact that most of their own colleagues (lecturers, deans) are not willing to shift from programming-language-mastering to instead of conceptual algorithm thinker and problem solver paradigm. They're also always teaching and evangelizing students about the use of best practices, design patterns, and many more. Another best thing: they defend students that have good software developer potentials and have enormous passions of continuous learning and improvements.

Openly against that? Not a chance, they said. Many useless arguments and reasons have been thrown at them. Not to mention threats in form of discipline sanctions because of having against the (bad) habits that have been working for so many years without complaints from students and alumnis.

It's a very fond of them, since my friends love to teach, share, and discuss many things especially about advantages in .NET, software development, and modeling. This is why they're also have quite heroic choices to keep struggling to educate others. Although they don't get paid well by their current universities. They should.

My heart was breaking and I've decided to help them personally and also having helps from friends under my company umbrella, RX Communica.

My proposal to my friends are:

  • Giving additional trainings and workshop about those concepts outside their universities
  • Giving free ebooks such as project Otak as one of first means to accelerate learning programming in Indonesian language while also articulating and exercising other programming paradigms
  • Incubating and sharing some software projects (including their own and jointly developed with RX Communica) to be developed by their potential students
  • Continuously giving constructive critics and suggestion at higher education levels while also giving encouragement to see and understand wider perspective of software developments for almamaters, fellow lecturers, especially IT related lecturers

Closing

What about us? You? Do we care about those who now screaming in silence? Especially for those who keep low profiles and have done many things to make their surroundings and students better.

I do believe we all care. We do care. And by the way, do we have guts to scream in silence in our own local surroundings and our own almamater also? Thanks to them, I do have it now. :)

But I believe we can construct a constructive and intelligent ways to handle this, instead of directly criticize them and hitting their academic pride. Gandhi has proven as one of the best silent screamers. Many other also.

Have any suggestions? Please. you're more than welcome. :)

Share this post: | | | |

Yes, what a shame. I'm too late submitting it (here's my participations on project otak). Many thanks to Agus Kurniawan, for his patience to always reminding me. Also I welcome critics, suggestions, and rants.

Now, I've come home from finishing jobs outside island of Java. I'm ready to participate again in this blog, emails, mailing list.

Guys, please forgive me for my prolonged silence.

Share this post: | | | |
Posted by eriawan | 2 comment(s)

Hi guys!

I know most of you are using VS 2005 (or even VS 2008) and creating best applications. VS 2005 is fun to use and harness, but it has many good best practices in its own code generators. Take for example, the Windows Forms code generator.

 

vs2005_formdesigner

 

It's quite neat, isn't it? Yes, VS 2005 has done this for us. Even since VS 2002, the first VS .NET release.

This idea promotes cleaner and readable code. I bet many of you write code like this:

 

    public partial class FrmUser : csMaintenanceForm
    {

        /// <summary>
        /// Default constructor
        /// </summary>
        public FrmUser()
        {
            this.bizUser = new csUserBusiness();
            this.RegisterPrimaryBizObj(this.bizUser);

            InitializeComponent();
            this.bizUser.LoadAllData();

        }

        protected csUserBusiness bizUser;

        private void SleepForAWhile(int msec)
        {
            System.Threading.Thread.Sleep(msec);
        }
    }

Why don't you reorganize it into this:

 

    public partial class FrmUser : csMaintenanceForm
    {

        #region Constructors

        /// <summary>
        /// Default constructor
        /// </summary>
        public FrmUser()
        {
            this.bizUser = new csUserBusiness();
            this.RegisterPrimaryBizObj(this.bizUser);

            InitializeComponent();
            this.bizUser.LoadAllData();

        }

        #endregion

        protected csUserBusiness bizUser;

        #region Methods

        private void SleepForAWhile(int msec)
        {
            System.Threading.Thread.Sleep(msec);
        }

        #endregion

    }
And make it look like this (after being collapsed by "Ctrl+M,CTRL+O")

vs2005_codereorganized

 

For complex code, I use this arrangement (from first to last):

  • Constructors
  • Properties
  • Methods

Why? These are my reasons/rationales:

  • I put constructors first, since it’s cleaner to know class constructors first and it’s called first time when an object is instantiated.
  • Properties come before methods, because we then want to know what are the object’s attributes are.
    And then what the object do (the object’s operations in OOP terms), and this can mean methods and event handlers.
  • Then, all of the implementation from interfaces is grouped last. This idea comes from VS itself, since VS 2003.

Those rationales come from this simple sequence of job interview questions:

“Hey, I just get to know you. How do I call you? (Constructors) What are your traits and biodata? (Properties) What can you do? (Methods and interfaces implementations)”

Voila! It’s quite simple, in my opinion.

Comments are welcome! :)

 

Eriawan

Share this post: | | | |

Check this out: 

VSIPFactory - A Software Factory for Visual Studio Extensibility - Home

Now, VS SDK has its own software factory too! :)

Don't forget to keep up with this MSDN blog:

Jack Greenfield

Knowing .NET is not enough, knowing VS 2005 and its SDK is quite geeky enough, isn't it? :)

Share this post: | | | |
Posted by eriawan | with no comments
Filed under:

 

C# 3.0: The Evolution Of LINQ And Its Impact On The Design Of C# -- MSDN Magazine, June 2007

 

I know it's rather stale, but see for your self. :)

Share this post: | | | |
Posted by eriawan | with no comments

From all I've read from many web sites (unfortunately not in codeproject), you can make your ASP.NET pages protected from user's misbehavior such as pressing browser's Back button while your data entry is not yet saved, or you want to ensure the security of transactional data, in such as online banking.

But most of them are also giving you confusing or misleading information. Fo example, you have to put the code at the right event to do this. For example, in Page_Load, and this is the safest bet. Also from what I know, some websites give you "Page is expired" message. If you search this using Google, many has just given you example using Response.AppendHeader with Pragma and no-cache parameters, but this sample isn't enough for other browser such as FireFox. After some experiments, I found  a simple one.

This is the code:

        protected void Page_Load(object sender, EventArgs e)
        {
            this.Response.Expires = 0;
            this.Response.AppendHeader("Pragma", "no-cache");
            this.Response.Cache.SetNoStore();
        }

The code above has some drawbacks:

  • It doesn't check whether you should make it expire longer or not. It should be long enough if you predict that not all of your audience has quite fast bandwidth. The fact is, always assume that you have slow bandwidth in Indonesia.
  • The forward button (after pressing back button) will give you the same "Page is expired". This can be quite confusing.

 

Is there any solution better than this? Please let me know. :)

Share this post: | | | |
Posted by eriawan | 2 comment(s)

 

Technorati Tags: ,

 

Have you guys downloaded new build of Windows Live Writer? Although still in Beta stage, I consider it's quite nearly complete and can be more fun and productive to use. Oh, the version and build number at the time of this writing is 1.0 (12.0.1183.516).

 

I admit, I'm still a new user of Windows Live Writer, but I like the ease of use of the UI and I can easily save drafts for later postings. The last feature I mention is my favorite one, since sometimes I can't go directly write and edit blogs directly on this site and on my other Spaces Live blogs. Supports for more blog types (not just Wordpress, Spaces Live, Blogger and Community Server) is added in this release, and they surely fix some nasty Wordpress blog submit bugs.

What also excites me, now I can harness many kinds of Windows Live Writer plugins at Live Gallery. Yup, one of the nice feature is copying source code from Visual Studio IDE and get formatted! Like this one:

 

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello world!");
}
}
}

 

Cool, isn't it? :)

Download the latest Windows Live Writer immediately!

Share this post: | | | |
Posted by eriawan | with no comments
Filed under: ,
More Posts Next page »