Thursday, March 18, 2010

More Details on Microsoft's plans to ruin jQuery

Visual Studio Magazine: "Microsoft is working in a number of directions, including databinding, the script loader and contributing to development of templating functionality as part of the jQuery core."
Oh, no Microsoft! Please, please don't ruin jQuery! Don't make it as insanely overcomplicated as your own AJAX.NET. Don't mix together JavaScript client code with server-side "loaders". Don't you understand that RESTless WEB client is not the same as .NET server or Win desktop?!

Tuesday, February 23, 2010

Squeryl — Introduction

Squeryl — Introduction

"Squeryl is a strongly typed DSL (domain specific language) for SQL databases in which table rows are manipulated as Scala objects via an SQL like language"

I hate the idea. Aren't we already fed up with MS datasets which break n-Tier application structure by bringing excessive and over-complicated database only related properties into a domain layer?
To me it is clear, that there is only three legitimate ways of creating decoupled n-Tier applications:
1) Use hand-made Data Access Layer objects;
2) Use ORM tools like [N]Hibernate;
3) Use object-oriented databases like db4o

Wednesday, January 27, 2010

‘The WebForms Rant’ by karl Seguin


"ASP.NET WebForms is an ugly and messy framework that complicates an otherwise simple thing. ViewState, codebehind, postback, page lifecycle and databinding are things that you have to constantly program against."
"A framework that accepts that HTTP is stateless will always be simpler, cleaner and more powerful that a framework that doesn't."

Wow! Well done :)
I agree completely. Karl probably is a first developer whom I highly respect (as my virtual teacher too) and who is stating the matter straight and without usual 'polites'.

One more important argument against WebForms is that it leads to hard-to-avoid "Web page was expired" problem due to inability to implement Post-Redirect-Get (PRG) pattern.
See http://pro-thoughts.blogspot.com/2009/06/classic-aspnet-improper-abstractions.html

I also really like a classic I Spose I’ll Just Say It: You Should Learn MVC article by Rob Conrey.
Finally, recent MVC or WebForms: It's more about client side vs server side article by Ian Cooper is good too.

Don’t forget to read comments under all those articles!

Thursday, December 17, 2009

My new Android blog

I decided to start a separate blog fully dedicated to Android usage and development. You're very welcome to visit Wonderful Android: Using and Developing.

Tuesday, November 03, 2009

How to install missing LaserJet 4MPlus driver on Windows 7

 

I found on HP forum site the following advice:

The Laserjet 4M drivers (and many others)  are actually available through the Windows Update process.  Try the following:  go to the Printers folder, select Add a Printer, select the appropriate port, then when the "Chose a Printer Model" dialog comes up select "Windows Update". 

Unfortunately, there was one strange Windows feature or probably a bug... as it always happens with Windows. A first bug I discovered in Windows 7, which is actually much better than its predecessors.

When I tried to installed my LaserJet 4MPlus network printer on Win 7 64 bit by clicking Add Printer, as you described above, there was NO Windows Update button visible. Finally, I selected an incorrect printer model and installed that printer driver. After doing it, I right-clicked on a printer, chose Printer Properties => Advanced => New Driver and ... what a miracle: Windows Update button suddenly appeared!

If you ask me how did I find this way, I would answer: a long practice working with a buggy Windows software.

Tuesday, June 02, 2009

Classic ASP.NET: improper abstractions and ruined REST

http://herdingcode.com/?p=183

1. No one ever anywhere answered the simple question: how to avoid POST operations in a classic ASP.NET when GET operations should be used instead according to a common sense and REST.
POST - for changing data, GET - for reading. No one found any decent way to avoid "Web page was expired"  messages resulting from improper usage of POST. No way to PRG.

To me, this fact alone makes “classic” ASP.NET’s Web Forms approach inappropriate.

2. Yes you can find a workaround for anything, but you’re ending up battling against a framework rather than using it most of the time. And maybe even worse: you’re battling against MS tutorials and books which teach you that ASP.NET-in-24-hours-dataset-no-custom-code-monolithic development.

3. It’s pretty obvious to me, that event-driven model moved from Windows desktop development to Web does not correspond to Request/Response nature of Web and makes programming much more complicated, than even with a plain old ASP. I’d be pretty happy to have lain ASP + C# 3.5 + Intellisense, and believe me, my code would be at the same time more user-friendly and better structured than monstrous code-behind of those ugly master/detail ASP.NET pages.

4. I have nothing against Http Modules, Handlers, etc. They are powerful tools.
But I personally hate Web Forms so much, I think that all those words about Web Forms better in one situations and MVC in another is just a precaution: people understand that MVC is better but are afraid to talk.

Finally, everything is already said in this article and all the comments below.

Monday, June 01, 2009

“Mega” menu? Is it like almost unusable Office 2007 menu?

Usability guru Jakob Nielsen thinks that “mega” menus are good. But is it something similar to Office 2007’s “ribbon” menu?

Office 2007 menu is awful. It's a major step back from a standard and simple Office 2003 menu. Really hard to find what you need, you never sure which main menu bar link to click. My daughter told me to uninstall Office 2007 from her machine because she cannot find anything. If "mega" menu is something like that, I strongly disagree with Jakob Nielsen. The less pictures and other unnecessary graphical elements are in a menu - the better it is.

Wednesday, May 06, 2009

Rob Conery: I Suppose I’ll Just Say It: You Should Learn MVC

http://blog.wekeroad.com/blog/i-spose-ill-just-say-it-you-should-learn-mvc/

Comments under this article are as interesting as article itself.
I only hope I’ll be allowed to write my next ASP.NET project in ASP.NET MVC. I already bought Rob’s book.

Wednesday, February 11, 2009

Write deep Clone(). Forget about ICloneable.

I was chatting with my co-worker about implementing Clone() method for our hierarchy of classes. It's not easy to implement interfaces (think about ICloneable) for class hierarchies. Some tips might be found in Implementing Interfaces at C# Online.NET article, in Implementing Interfaces: ICloneable and IComparable article, and in Advantages of ICloneable? discussion.
As Zach said, it's easier just to implement a virtual Clone() method in a base class and to override it in derived classes as necessary.

I started to look for information about ICloneable and found the following quite unequivocal guidelines:

Caution. Avoid implementing ICloneable. As alarming as that sounds, Microsoft is actually making this recommendation. The problem stems from the fact that the contract doesn’t specify whether the copy should be deep or shallow. In fact, as noted in Krzysztof Cwalina and Brad Abrams’ Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries (Boston, MA: Addison-Wesley Professional, 2005), Cwalina searched the entire code base of the .NET Framework and couldn’t find any code that uses ICloneable. Had the Framework designers and developers been using this interface, they probably would have stumbled across the omission in the ICloneable specification and fixed it.
However, this recommendation is not to say that you shouldn’t implement a Clone method if you need one. If your class needs a clone method, you can still implement one on the public contract of the class without actually implementing ICloneable.

Accelerated C# 2008

Because the contract of ICloneable does not specify the type of clone implementation required to satisfy the contract, different classes have different implementations of the interface. Consumers cannot rely on ICloneable to let them know whether an object is deep-copied or not. Therefore, we recommend that ICloneable not be implemented.
The moral of the story is that you should never ship an interface if you don't have both implementations and consumers of the interface. In the case of ICloneable, we did not have consumers when we shipped it. I searched the Framework sources and could not find even one place where we take ICloneable as a parameter.
x DO NOT implement ICloneable.
x DO NOT use ICloneable in public APIs.
x CONSIDER defining the Clone method on types that need a cloning mechanism. Ensure that the documentation clearly states whether it is a deep- or shallow-copy.

Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries

Tuesday, December 30, 2008

Call a method only if a supplied argument is not Null

Suppose you have a C# method which only works correctly if its parameter value is not Null, otherwise it either throws an exception or returns wrong value. Sometimes you cannot guarantee that a parameter value is not Null, because it was passed from outside, was read from DB, etc. Instead of writing your custom code again and again, which checks a parameter value and only calls a method if it is not Null, it may be more convenient to re-use a common helper method. Overloaded CallIfArgumentNotNull() methods shown below are such helpers. I was somehow inspired by reading this article by Jon Skeet (lazy evaluation) .

    // If a first argument of type int? is not Null, a supplied method (second argument)
    // is called with a first argument passed in and its return value is returned.
    // If a first argument is Null, a default(T) is returned
    // (null for reference types, 0 from Integer, etc.)
    public static T CallIfArgumentNotNull<T>(int? arg, Func<int, T> func) {
      return (arg != null) ? func((int)arg) : default(T);
    }
 
    // If a first argument of type int? is not Null, a supplied method (second argument)
    // is called with a first argument passed in and its return value is returned.
    // If a first argument is Null, a third argument value is returned.
    public static T CallIfArgumentNotNull<T>(int? arg, Func<int, T> func, T defResult) {
      return (arg != null) ? func((int)arg) : defResult;
    }
 
    // If a first argument of type A? is not Null, a supplied method (second argument)
    // is called with a first argument passed in and its return value is returned.
    // If a first argument is null, a third argument value is returned.
    public static T CallIfArgumentNotNull<A, T>(Nullable<A> arg, Func<A, T> func, T defResult)
      where A : struct {
      return (arg != null) ? func((A)(arg)) : defResult;
    }

Thursday, November 20, 2008

An easy way to override Chrome bookmarks

It is quite easy to manually override Chrome “Other Bookmarks” with your Firefox bookmarks:
1) In Chrome, click on “Other Bookmarks” and, if you have any, right click on each bookmark and delete it.
2) Use “Import Bookmarks and Settings”, switch to import from Firefox, clear all checkboxes except ‘Bookmarks’ one and hit ‘Import’.
3) This will keep all imported bookmarks in one ‘folder’, which is actually good, because next time when you decide to override Chrome bookmarks, you will need to delete only one Other Bookamrks ‘folder’ by right-clicking on it.

(On WinXP machine Chrome keeps bookamrks in C:\Documents and Settings\-your-name-\Local Settings\Application Data\Google\Chrome\User Data\Default\Bookmarks file. This is a text file which looks similar to XML. )

Thursday, November 13, 2008

Configuring MS DTC on WinXP, Server 2003, and Server 2008 machines

Our N-Tier ASP.NET (C# 2008 / SQL Server)  application uses MS DTC transactions for database integrity. This allows a transaction to embrace several BL or DL method calls without sharing the same database connection.
A usage is simple:

using System.Transactions; 

using (TransactionScope myTransactionScope = new TransactionScope()) {
  // Do any database related work you need: call methods, open and close connections, update multiple tables.
  // Database integrity is preserved  even if one of methods which update database fails.

     myTransactionScope.Complete();
}

To support MS DTC all servers which run our application (including developers' machines) and servers which host a databases were properly configured. (Configuring developers' machines allowed to work properly with your local copy of application and with a remote database.

1) To configure DTC on Windows XP, Windows Server 2003 machine follow these instructions to open Component Services window and configure DTC.
Make sure that "Use local coordinator" check box is checked on MSDTC tab of computer properties window.
Make sure that "Network DTC access" is checked on MSDTC=>Security Configuration window, that both "Allow Inbound" and "Allow Outbound" are checked, and DTC Logon Account is set to "NT AUTHORITY\NetworkService".
2) On Windows Server 2008 machine it's pretty much the same, except that in Component Services window has My Computer -> Distributed Transaction Coordinator -> Local DTC node, on which you'll need to right-click and choose Properties.
3) After configuring DTC restart your machine.
4) Open Control Panel -> Administrative Tools -> Services and make sure that DTC is set to start automatically and is started.




Reference on using DTC with N-Tier application: http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=419

Sunday, November 02, 2008

The best of F# and C# -- Nemerle? Scala? various approaches to mixed OOP - functional languages

Today I was pointed out to yet another mixed OOP and functional language: Nemerle. I looked at the Nemerle features and immediately spotted something very familiar, "Probably the most important feature of Nemerle is the ability to mix object oriented and functional programming styles. The top-level program structure is object oriented, while in the body of methods one can (but is not forced to) use functional style. In some programming problems this is very handy." It sounds exactly the same as what is stated about Scala programming language, "Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages." A main platform for Scala is JVM, but it's CLR variant already exists and is planned to be fully developed.

I think that both C# and Java in their pursuit of simplicity dropped too many functional features which existed in their common parent - C++. I've just blogged about it today. So, both communities felt the need for more functional OOP languages. It looks like that both Scala and Nemerle chose the same approach which creators of Java used: to build up on the base of familiar and wide-spread language in a hope that it gives an immediate advantage of huge number of programmers who are familiar with the syntax and want to try new language. I don't know about Nemerle yet and I still know too little about F#, but Scala language found a very natural and consistent way of combining object oriented and functional features and is even better OOP language than Java.

I think people are absolutely right, when they are saying, that it's hard to catch up with F#, "because the syntax of the ML - derivative languages is just too foreign for those with only imperative language experience". I felt it by myself when I was trying to start learning language using "Expert F#" book, having no prior ML experience.
But there is a flip side: now, when - thanks to an excellent "Real World Functional Programming" book by Tomas Petricek I started to understand both functional concepts and beauty of ML syntax, I feel that more graduate approach taken by Scala (and probably - Nemerle) may in fact postpone real understanding of a functional nature of new languages. It's possible to program in Scala as in "improved Java" and never learn its functional features. And thanks to more steep approach of F# I now better understand and try to pursue functional approach in Scala and better understand ideas behind LINQ...

Learning languages in comparison. How Scala re-introduces what was dropped in C++ to create Java.

An update (30/11/2008): I realize that a title of this post sounds silly. I never tried to say something like "Scala has C++ roots" or so. Scala is "an attempt to come up with a decent statically typed language that is both functional and object-oriented and that interoperates on standard VMs" (Martin Odersky in a comment here). My point is: too much (including some functional features) was dropped when C++ was "simplified" by Java creators. 

Scala allows to pass variable length argument list to a function defined like

def echo(args: String*) =
  for (arg <- args) println(arg)

In "Programming in Scala" authors says that,
'... Thus, the type of args inside the echo function, which is declared as type "String*"  is actually Array[String]'

It immediatelly reminds me C++, which uses similar syntax of passing array arguments. I'm pretty sure Martin Odersky chose asterisk, because it is used in C/C++, although in C/C++ it allows to pass array parameters, not a variable length argument list, and denotes a pointer to a first element of array.

There is definitely a feel, that C++ is more functional language than Java, for example a name of a function is a pointer (reference) variable pointing to a function itself, which allows to pass a function to another function as parameter and return as return value. First-class functions, isn't it?
So, Scala feels partly as a consistent attempt to re-introduce to Java functional features which were dropped when Java creators used C++ to produce new [over?]simplified language.

Personally, I always loved when authors of books described new languages in comparison to existing ones, like Trey Nash is doing in his "Accelerated C# 2008", comparing C# to C++, like David Flanagan is doing in "JavaScript. The Definite Guide", comparing JavaScript to C/C++, and like Bruce Eckel is doing in "Thinking in Java", comparing it to... C++ again. (By the way, Bruce is considering Scala as a next "big" language, which will gradually and partially replace Java the same way Java did to C++.) One fresh and excellent example is "Real World Functional programming in .NET" by Tomas Petricek. This book introduces F# language (a merge of OCaml and .NET platform) and functional concepts in constant comparison to limited functional features of C# 3.0. It helps a lot to understand both F# and functional features of C#. It even helps to understand Scala, because functional concepts are the same in both F# and Scala.
To learn programming languages in comparison is not an easy task. But it is, in my opinion, a most powerful way to obtain real understanding of languages. Footnotes or special text blocks, describing similarities and diffrence between languages make a programming book shine.

Friday, September 12, 2008

How to decoratively set an attribute of a server-side control to some public property/value?

Have you ever tried to decoratively set an attribute of a server-side control to some public property/value defined in code-behind code (or in a Business Layer)? Here's a simple example:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPage.aspx.cs"
 Inherits="TestPage" %>
 
<!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 runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:TextBox ID="TextBox1" runat="server" Text="<%=hitest %>" />
    </div>
    </form>
</body>
</html>

And in a code-behind file:

public partial class TestPage : System.Web.UI.Page {
 
  public string hitest = "Hello";

This example doesn't work, ASP.NET engine does not process hitest and displays a text box with <%=hitest %> inside.

I know, I'm doing something stupid and show everybody that I understand nothing about ASP.NET, but here's a reasoning behind my attempts:
In our application we use AjaxControlToolkit, and in particular - MaskedEditExtender. There is a complicated WebForm with a ListView and numerous text boxes for entering phones, there were millions of MaskEditExtenders with identical masks set to @"(9{3}) 9{3}-9{4}". (The same story for emails.) I don't like clattering a code with "magic" strings and numbers, so I decided to declare constants and toplace them into our common class sitting in App_Code:

namespace CoTs.Partners.Common {
  public static class Util {
    public const string MailRegEx = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
    public const string PhoneMask = @"(9{3}) 9{3}-9{4}";
Then, I thought, I would set
<cc1:MaskedEditExtender Mask="<%#CoTs.Partners.Common.Util.PhoneMask %>"
- and voila. For some reason it worked fine for a ListView's "Edit", but bombed with an empty Mask in "Add". I started to investigate and decided that using of <%# is probably incorrect, because <%# implies data binding. But, as I said, <%= doesn't work either. Sure, I can assign values to Maks properties programmatically in code-behind file, but it sounds crazy, given the fact that MaskEditExtender controls are scattered inside many other controls in a complicated page.

So, again: is there a way to decoratively set an attribute of a server-side control to some public property/value (defined in code-behind code or in a Business Layer)?
Suprizingly, I couldn't find any information on a Web....

Thursday, September 04, 2008

Custom ViewState storage and multiple browser tabs/windows

I'm thinking about implementing a custom ViewState storage, most likely - in a database, like it is described in this article. It may do several good things: make pages more lightweight, together with Cross Page Post Back allow for implementing Post/Redirect/Get (PRG) pattern in ASP.NET application, maybe even allow for some custom history / breadcrumb solutions for application / page lifecycle...

However, I have one concern: having multiple browser's Tabs or windows. When you work in Internet Explorer, you can open a new tab and have it to work with the same ASP.NET application, it will share session. With Firefox, you can even open a new window and it will share session. Now, if we use links (GET operation) to go from page to page, GUID is not passed between pages, and custom history / breadcrumb cannot work correctly with multiple Tabs. The only (ugly) solution I see is to modify every link on ASP.NET page to include GUID.

Tuesday, August 19, 2008

Delegates and events. What does `event` keyword actually mean in C#

In a very interesting "Accelerated C# 2008" book, its author Trey Nash described the role of C# events (page 262):
"... .NET runtime designers were so generous as to define a formalized built-in event mechanism. When you declare an event within a class, internally the compiler implements some hidden methods that allow you to register and unregister delegates, which are called when a specific event is raised. In essence, an event is a shortcut that saves you the time of having to write the register and unregister methods that manage a delegate chain yourself."
Then, on a page 265 he is saying:
"... events are ideal for implementing a publish/subscribe design pattern, where many listeners are registering for notification (publication) of an event. Similarly, you can use .NET events to implement a form of the Observer pattern, where various entities register to receive notifications that some other entity has changed."

Often, when some material is not clear to me, I try to read another book to clarify a matter. So, I found the following description of events in "C# 3.0 in a Nutshell" book (page 112:
"When using delegates, two emergent roles commonly appear: broadcaster and subscriber.
The broadcaster is a type that contains a delegate field. The broadcaster decides when to broadcast, by invoking the delegate.
The subscribers are the method target recipients. A subscriber decides when to start and stop listening, by calling += and -= on the broadcaster's delegate. A subscriber does not know about, or interfere with, other subscribers.
Events are a language feature that formalizes this pattern. An event is a wrapper for a delegate that exposes just the subset of delegate features required for the broadcaster/subscriber model. The main purpose of events is to prevent subscribers from interfering with each other."

This is quite opposite to what Trey said about events! They are introduced to prevent subscribers from interfering with each other, not as a shortcut that saves you the time of having to write the register and unregister methods.
+= and -= operators are defined for non-event delegates as well as for event delegates, while non-event delegates also expose assignment (=) operator and GetInvocationList() method which are too dangerous for subscribers. They allow a particular subscriber to investigate which other classes also subscribed to the same delegate and even allow to remove other independent subscribers. That's exactly what we prevent by adding an `event` keyword to a delegate.

Here's a modified code snippet from "C# 3.0 in a Nutshell" which proves what I said above (note, that it does not use famous EventHandler<TEventArgs> delegates; events could actually be used with any delegates):


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace Chp04_events {
 
  internal delegate void PriceChangedHandler( decimal oldPrice, decimal newPrice );
 
  /// <summary>
  /// "Broadcaster" class
  /// </summary>
  internal class Stock {
    string _symbol;
    decimal _price;
 
    public Stock( string symbol ) { this._symbol = symbol; }
 
    // If you comment out this line and uncomment next line,  "myStock.PriceChanged = ..." and "Delegate[] chain = " statements
    // below in public void SetStockToWatch( Stock myStock ) methods would become legal, compromising an independence of event subscribers.
    // That's why we use an `event` keyword, rather than simpli a delegate.
    public event PriceChangedHandler PriceChanged;
    //public PriceChangedHandler PriceChanged;
 
    public decimal Price {
      get { return _price; }
      set {
        if (_price == value) return;
        if (PriceChanged != null) {
          // Code within the Broadcaster type has full access to event and can treat it as delegate:
          Delegate[] chain = PriceChanged.GetInvocationList();
          Console.WriteLine( "There is/are {0} subscribers watching for event I'm broadcsting", chain.Length );
          Console.WriteLine( "The first subscriber has a type of {0}", chain[0].Target.GetType() );
          if (chain.Length > 1) {
            Console.WriteLine( "The second subscriber has a type of {0}", chain[1].Target.GetType() );
          }
 
          PriceChanged( _price, value );
        }
        _price = value;
      }
    }
  }
 
  /// <summary>
  /// "Subscriber" class
  /// </summary>
  internal class StockWatcher {
    protected string _watcherName = String.Empty;
 
    public StockWatcher( string watcherName ) {
      this._watcherName = watcherName;
    }
 
    public string WatcherName {
      get { return _watcherName; }
    }
 
    public void SetStockToWatch( Stock myStock ) {
      myStock.PriceChanged += new PriceChangedHandler( myStock_PriceChanged );
      // Code outside the Broadcaster type can only perform += an -=. "Subscriber" does not know about other "subscribers".
      // The following line of code won't compile: 
      // Error: The event 'Chp04_events.Stock.PriceChanged' can only appear on the left hand side of += or -=
      // (except when used from within the type 'Chp04_events.Stock')
      myStock.PriceChanged = new PriceChangedHandler( myStock_PriceChanged );
      // The same error:
      Delegate[] chain = myStock.PriceChanged.GetInvocationList();
    }
 
    public void myStock_PriceChanged( decimal oldPrice, decimal newPrice ) {
      Console.WriteLine( "{0}: Stock price was changed from {1} to {2}", WatcherName, oldPrice, newPrice );
    }
  }
 
  internal class NewStockWatcher : StockWatcher {
    public NewStockWatcher( string watcherName ) : base( watcherName ) { }
  }
 
  class Program {
    static void Main( string[] args ) {
      decimal myDecPrice;
 
      var myStock = new Stock( "Napster" );
      var myStockWatcher1 = new StockWatcher( "First Watcher" );
      var myStockWatcher2 = new NewStockWatcher( "Second Watcher" );
 
      myStockWatcher1.SetStockToWatch( myStock );
      myStockWatcher2.SetStockToWatch( myStock );
 
      while (1 == 1) {
        Console.WriteLine( "Please enter new stock price:" );
        string newStockPrice = Console.ReadLine();
        if (newStockPrice == String.Empty) break;
        if (Decimal.TryParse( newStockPrice, out myDecPrice ))
          myStock.Price = myDecPrice;
      }
    }
  }
}

Friday, August 15, 2008

"ASP.NET gets no Respect" by Rick Strahl

There is a good ASP.NET gets no Respect article just posted by well-known ASP.NET developer Rick Strahl. Read it! I commented there too :)

Thursday, August 14, 2008

A novice Scala programmer: Eclipse vs. IntelliJ IDEA vs. Netbeans. Debugger and for () yield {}

I continue my Scala IDE mini series I described my experience with installation of Eclipse, IntelliJ IDEA, and Netbeans applications and installation of Scala plugins in those environments.

The following simple code (from Programming in Scala, chapter 7) poses certain challendges to Scala debuggers. Some debuggers cannot stop on breakpoint placed, for example, on "val prod = (i * j).toString" line.
As Alexander Podkhalyuzin from JetBRAINS/Intellij IDEA Scala Plugin team said, "This problem goes to Java debugger problem with anonymous classes, because it's compile in different class file. So, we must to understand what name of this class files, and to set to each line, line in this class file. In Eclipse developers do this work, we have not implemented this yet, but you must be sure, it will be, because it is not convenient to work without for debugger."

As of today, Eclipse Scala plugin debugger can stop, the latest Intellij IDEA Scala Plugin debugger can stop as well. Both go even to a library Seq.class; Eclipse shows its code, IntelliJ IDEA shows interface, saying that it is "IntelliJ API Decompiler stub source generated from a class file. Implementation of methods is not available".
The latest and greatly improved NetBeans Scala plugin debugger still cannot stop here.


package chp7multitable
object Main {
/**
* @param args the command line arguments
*/
def main(args: Array[String]) = {
val multi = {
val table = for (i <- 1 to 10) yield {
val row = for (j <- 1 to 10) yield {
° val prod = (i * j).toString
String.format("%4s", Array(prod))
}
row.mkString + "\n"
}
table.mkString
}
println(multi)
}
}



1. Eclipse vs. IntelliJ IDEA vs. Netbeans. Installation.
2. Eclipse vs. IntelliJ IDEA vs. Netbeans. Creating and running Scala project with Eclipse.
3. Eclipse vs. IntelliJ IDEA vs. Netbeans. Creating and running Scala project with IntelliJ IDEA.
4. Eclipse vs. IntelliJ IDEA vs. Netbeans. Creating and running Scala project with Netbeans.
5. A novice Scala programmer: Eclipse vs. IntelliJ IDEA vs. Netbeans.
6. A novice Scala programmer: Eclipse vs. IntelliJ IDEA vs. Netbeans. Debugger and for () yield {}.

Thursday, August 07, 2008

Effective Java Programming

Here's an interesting speech by Joshua Bloch (the author of Effective Java) on YouTube.

(I use ScribeFire with Firefox to post on Blogger. Unfortunately, ScribeFire always posts as Draft, regardless of me selecting or un-selecting post-to-draft option.)