July 2007 - Posts

Bit/Boolean
21 July 07 07:14 PM | adrian | 4 comment(s)

Yes, that's my favorite data structure. Cahnom and Irwansyah have blogged about their favorites, mine is bit.

Why? Because it's the single most significant thing in computer history. No linked list, no hash table, not even an integer without a single bit.

What's a bit? A bit is a memory state, whether high or low voltage (not zero voltage). It originally came from transistor states, where you supply one port with extra voltage to enable current transfer between the other two ports.

In .NET, a bit is called boolean. Boolean has two states, True or False, mimicking the original bit. Before .NET 2.0, people get confused when combining .NET Boolean with SQL Server Bit. 's because SQL Server Bit has three states; True, False, or Null. But since .NET Generics come to life, we can create a Nullable Boolean to comply with SQL Server Bit.

.NET Boolean has slightly different operations than any other types. .NET Boolean does not allow arithmetic operations (like +, -, *, and /). But nearly in any program, .NET Boolean will always present. That is, anytime you use a logical operation, a .NET Boolean will always used. It's so common that you sometime get mixed up between .NET Boolean as a type or as expression result. The significance of .NET Boolean in any .NET application is definitely unquestionable.

Code sample? Data structure drawing? I don't think anyone need an introduction to a Boolean, right? :D

P.S.: I just read that this was actually a contest held by Risman. I didn't know that until midway writing this article. Hopefully I can get the Cormen book... :D

Share this post: | | | |
Filed under:
C# 3.0: Anonymous Type
21 July 07 09:45 AM | adrian | with no comments

So earlier this week I've blogged about the auto-implemented property. A thing it uses is anonymous type. WTH is it?

C# 2.0 seen anonymous method as a way of defining a method (for delegates) without requiring it to have a method name (hence, it'll only be called from one point, the delegate). Anonymous type does the same thing. You can create a type (a.k.a. class) without requiring it to be a full blown type declaration (has a name, namespace, methods, etc.).

To use (not declare) an anonymous type, you can just use this:

var p1 = new {Name = "A", Price = 3};

There goes a new type. You can then access it's properties just like a common type:

Console.WriteLine(p1.Name);
Console.WriteLine(p1.Price);

Behind the scenes, when the above code is compiled, the compiler will autogenerate a class (that means you can access it via Reflector or System.Reflection, for instance) with private fields and public getter/setter property, plus a constructor assigning given values (in this case "A" and 3) to the appropriate fields.

Next question is, when do we use this anonymous type and auto-implemented property? That's next.

Share this post: | | | |
Filed under:
C# 3.0: Auto-Implemented Property
17 July 07 09:22 PM | adrian | 4 comment(s)

Tired of writing this?

private int id;
public int Id
{
 
get
 
{
   
return this.id;
  }
  set
  {
   
this.id = value;
 
}
}

Fear not! C# 3.0 will give way to a new structure for simple getter setter. The above code will become...

public string Test { get; set; }

Amazing!

Behind the scene, the compiler will generate an anonymous type as the backing field, and create getter/setter code as usual. Now what's anonymous type? Well, that's another question for another day!

Share this post: | | | |
Filed under:
Creating a Sortable Membership
12 July 07 08:54 AM | adrian | with no comments

I was trying to display a list of ASP.NET members using GridView and ObjectDataSource control. Apparently, the System.Web.Security.Membership class doesn't support paging with GridView natively. It does have GetAllUsers() with paging parameters, but incompatible with GridView control.

For this solution to work, the Membership class has to be changed. The easiest way is to create a subclass. But sadly, Membership is sealed, that means you can't subclass it. So the next available solution is through wrapper class. A wrapper class uses Adapter design pattern. A wrapper class is where you provide new methods, without changing existing code at all.

ObjectDataSource control needs several methods to make paging work. First it requires a select method with two (or more, but not recommended) parameters. Next it requires a count method to calculate total number of pages. All of them are summed up below:

[DataObject()]
public class PageableMembership
{
  [DataObjectMethod(DataObjectMethodType.Select)]
  public MembershipUserCollection GetAllUsers()
  {
    return GetAllUsers(0, GetAllUsersCount());
  }

  [DataObjectMethod(DataObjectMethodType.Select)]
  public MembershipUserCollection GetAllUsers(int pageIndex, int pageSize)
  {
    int totalRecords;
    return Membership.GetAllUsers((int)pageIndex / pageSize, pageSize, out totalRecords);
  }

  public int GetAllUsersCount()
  {
    return Membership.GetAllUsers().Count;
  }
}

I've also added extra attributes to simplify method choice in the Configure Data Source wizard.

Share this post: | | | |
Filed under:
It's Official, Visual Studio 2008 is out in, well, 2008!
11 July 07 09:33 PM | adrian | with no comments

Microsoft Windows Server 2008 (aka Longhorn Server), Visual Studio 2008 (aka Orcas), and Microsoft SQL Server 2008 (aka Katmai) is going on worldwide launch on Feb 27, 2008. Beta 2 is also coming soon enough. So prep your Virtual PCs now!

Source: http://www.microsoft.com/presspass/press/2007/jul07/07-10WPCDay1PartnersPR.mspx

Share this post: | | | |
Software Venture Business
10 July 07 09:58 PM | adrian | with no comments

Lately I've been involved in a venture business dealing with a software. So, you might be wondering, why?

Well, for me a venture business means innovation. Nobody innovates more than a venture business. Venture business doesn't have anything to start with other than idea. I love innovating over computer system. Imagine using the latest technology like AJAX and Silverlight, and getting paid for doing it!

But there are problem that's relevant with most venture businesses. Venture businesses that failed to survive usually lack of differentiating factor or long time-to-market on their products. The two aren't mutually exclusive either, long time-to-market will enable rivals create a better product first, thus making our product looks obsolete (reducing its differentiation) even before it's launched.

Now, what I've always avoided from a venture business is red tape. Why? Because excessive bureaucratic procedures are bad for time-to-market. If you want a software product delivered well before time and under budget, you should streamline any business processes that doesn't add value to the product. For example: when deciding a name for a product took more than two months, then something must've been very wrong.

I'm not against bureaucratic policies. It's a sign of maturity. But venture businesses are not made of maturity. If it's mature, then it's not a venture. Google is small, so there's no need for many layers of command. But when a company is as big as IBM, you'll expect more people taken into account when deciding something.

This is especially true in a software industry. Creativity (one of the component to differentiate products) doesn't come easily. Creativity can be encouraged from an environment, but cannot be produced. This is something I learned as an Industrial Engineer. Creating the environment is something not trivial. Excessive bureaucracy hinders creativity, because more and more people are required to decide over something.

Someone once said (can't remember who or where unfortunately), that success for a venture business has an inverse reslationship to the number of C*O it has. What it actually mean, is that the more people managing other people, the less it would able to produce quality products. The more people doing synergistic value addition at the same time, the better the product would be.

So, are we still managing others doing their own work or do we empower others doing everybody's work?

Share this post: | | | |
Filed under: ,
Available Now! Transfer any File with a Zune
10 July 07 08:30 PM | adrian | with no comments

Transferring any file using Zune wireless capability is not a new thing. It's been around for a few months. But the trick is, you'll need to sync together a set of images with the file you're transferring. From what I've heard, it's not even 100% working. Sometimes it works, sometimes it's just not.

I've came up with an idea of embedding the file you're transferring inside an image metadata, in this case EXIF. Looking around, I've found several pieces of code that when combined together would enable this JPEG-with-file-embedded-in-EXIF-metadata. Unfortunately, this works for a limited size file, namely around 64K.

I've then tried another, simpler workaround. This time, I've appended the file to a place after the original image. I've also embedded the file size into the EXIF metadata for decoding. The result, a HUGE image capable of carrying any file.

To date, I've successfully embedded and synced (although not yet transferred) an image file containing Virtual PC 2007 installer (size around 30M). Anyone with a Zune nearby can try my program and send me a feedback.

I've attached the program into this post (called zic.exe - short from Zune Image Container). A short manual follows:

  • This is a console application. For those who didn't know what a console application, it's like a lovely DOS app with text as the only interface. You don't get icons or menu bar.
  • To embed a file into an image, type the following in your command prompt (without the quotes): "zic encode original_image file_to_embed". original_image is the path (I recommend 8.3 file name) to a JPEG image as the container, file_to_embed is the path to any file you want to embed into the JPEG image. The result of this operation is a file named file_to_embed.jpg. So if you type "zic encode icon.jpg setup.exe" the result would be "setup.exe.jpg".
  • To retrieve an embedded file from a JPEG, you type the following: "zic decode embedded_image". embedded_image is the file from the above point. If you type "zic decode setup.exe.jpg" the result file would be "setup.exe" (back to the original).
  • I haven't added support for spaces and special characters in the filename(s), so I encourage you to use 8.3 format.

Now, on to v.next. I'm planning on creating a plugin for Zune Software, which you can drag and drop any file not recognized by Zune Software (say, .exe, .msi, .doc) and reroute it to the program that generates a .jpg image to sync.

P.S.: the original image is still viewable from the Zune. This creates a unique opportunity to embed the file's icon (just like in Windows Explorer) so that users can easily identify the file they're looking without reading the filename.

UPDATE 11/07/07: It seems I left some debugging code that breaks the whole app. Please redownload for the correct version.

Share this post: | | | |
iPhone vs. N95
07 July 07 10:10 AM | adrian | 4 comment(s)

If you've went to latest computer festivals and events, you'll see agressive marketing push from Apple about their new iPhone. The banners say "COMING SOON!", but the sales guys say "next year". Apple calls next year soon.

Anyway, apart from the huge hype Apple is creating about iPhone, I've came across an interesting comment on a blog post about unlocking the iPhone. The comment outlined the difference between Apple iPhone and Nokia N95. I'll put some interesting facts below:

  • iPhone doesn't have a sound recorder, video capture, wireless BT earpiece, and IR module.

But then again, I'll never buy any phone that is priced way above US$100. For me a phone is a phone (calls other), not some camera or edgy mini-computer.

Oh, and another interesting fact: currently you can unlock Apple iPhone on Windows machine using application built on top of .NET Framework 2.0. That's what I call interoperability!

Share this post: | | | |
Filed under:
Vista-based Team Goes to Korea
03 July 07 07:22 AM | adrian | with no comments

From the top 3 I've mentioned before, Aksara from ITB is finally crowned the winner of this year's Imagine Cup 2007 Software Design from Indonesia. The winner will go to Korea to compete with other winners from around the globe.

They build a Windows Vista-based application, utilizing some of the newest technologies fresh out of Microsoft Research,including Handwriting Recognition (convert handwritings to text), Speech Recognition (convert speech to text), Windos Presentation Foundation, and Multipoint (many mouse means many cursor, not just one). All of them are combined together creating a cool app that helps children read, write, and count (although only in English currently). This computer-based technology is even cheaper than any other solution because they require only single computer for the whole class. Each children would only need an additional mouse to operate the application.

But then, the application does require a polish here and there. It still has a very rudimentary look, although 100% functional. I hope one month extra time before going to the world finals is enough for them to improve their existing application.

Congratulation guys (and a girl), this is by far the most exciting Imagine Cup submission I've ever seen!

Share this post: | | | |
<blank> are Indonesia Imagine Cup 2007 Software Design Winner!
01 July 07 12:26 PM | adrian | with no comments

Who's that? Coming in an hour...

IC_3DLogo_07Korea

UPDATE: well, today's announcement are just the top three. They are: Aksara (ITB), Garuda (STT Telkom), and Musicaholics (ITB).

Aksara built a reading/writing software that utlizes Speech SDK, Multipoint SDK, and Handwriting Recognition SDK.

Garuda built a Windows Media Center-like app, but the media is books. They utilize WPF and compatible with all Media Center hardwares (means now you can use your plasma TV and remote control to read electronic books!)

Musicaholics built a music learning app that uses Windows Mobile device that analyzes sound patterns.

So the real event is tomorrow at Microsoft Indonesia office at 14:00, there the winner will be crowned and oficially go to Korea in August.

See you guys in Jakarta tomorrow.

Share this post: | | | |