Monday 21 December 2009

WCF, Remoting and Sockets

Don't fear transport protocol plumbing. Use sockets.

Thursday 3 December 2009

Word (Reviewing Toolbar)

Can choose "Final", "Final Showing Markup" from combo box. Then can "Accept change" or "Accept all Changes".

Unlearning Excel

Among the newfound-fangledness that begets the so-called modern new Excel, for which user-friendliness it would appear was not so high on the design agenda, is the difficulty of tracing precedents.

Tracing Precedents

Formulas tab - trace precedents, trace dependents.

Tuesday 24 November 2009

REMOVE Bayesian Computing from MS OFFICE

TO MS OFFICE: If I want a macro I'll write it myself thank you very much. STOP WASTING MY TIME trying to second-guess my actions. A word processor should be a DETERMINISTIC SYSTEM.

An Answer is Useless if No-one Understands It

Many papers are written in long-winded academic style. The style of writing is what makes the paper inaccessible, not the content. Reasoning is often not clearly explained.

Sunday 22 November 2009

The Law of Windows: Baker & McKenzie LLP

Law firm Baker & McKenzie, whose London office is based in New Bridge Street (near Blackfriars Bridge)and is a specialist on IP law, reflects on the "Laws of Windows", or more rightly licensing of Microsoft's Open Office XML formats. Baker's NY office is in Avenue of the Americas (the home of the New York Hilton), also known as Sixth Avenue, whose Northern end is Central Park South (59th Street), traffic moves in a Northerly direction towards Central Park.

Excel Hell FAQ

Excel Hell, How do I split a window in Excel? It used to be so easy!

Excel Hell: In the olden days you used to do Window->Split. Now you click View and then the small "Split" button in the toolbar (you may need to expand your Excel horizontally to see this).

How do I turn off those annoying "loss of fidelity" messages when saving workbooks?

Excel Hell: Click on the big Windows button. Prepare->Run Compatibility Checker and turn off "Check Compatibility".

The Business Model of Making Simple Things Complex

Complicating simplicity is a business in the software industry and a sad trend to which there is currently no counter (think "complexity-defense" lawsuits from customers). Many "Rainbow Warriors" and "Princess Mononokes" have come forward through the history of the world to attack complexity and should be commemorated in the annals of software history. Amongst the warfarers is Alan Cooper Esquire, the power-programmer behind "Visual Basic 1.0" which debuted in March, 1991 as Microsoft's first visual development tool. VB came out of Tripod which Microsoft bought in 1988.

Good Software

Good software is so wonderful precisely because it is so rare. The power to create personalized software is so wonderful because software today is so bad. Software used verily is an extension of the human consciousness and an ode to human ingenuity, used incompetently it is an ode to human stupidity.

Saturday 21 November 2009

InvalidOperationException: Cross-thread Operation Not Valid

DO NOT mess with Windows Forms Controls (even just READING a text field is BAD NEWS) from a a thread other than the GUI thread (unless a) you use Invoke, b) don't know anything about Windows programming. The following "wisdom-sommaire" from MSDN summarises aforesaid most appositely:

"If you use multithreading to improve the performance of your Windows Forms applications, you must make sure that you make calls to your controls in a thread-safe way. Access to Windows Forms controls is not inherently thread safe. If you have two or more threads manipulating the state of a control, it is possible to force the control into an inconsistent state. Other thread-related bugs are possible, such as race conditions and deadlocks. It is important to make sure that access to your controls is performed in a thread-safe way. It is unsafe to call a control from a thread other than the one that created the control without using the Invoke method."

As aforesaid, even reading a text box is bad news, amigos. I can't say this enough times:

Access to Windows Forms controls is not inherently thread safe.
Access to Windows Forms controls is not inherently thread safe.
Access to Windows Forms controls is not inherently thread safe.

Failure to comply WILL result in IOE. But what about WPF?

Activist Programmers

The notion of activist hedge funds is to effect change in companies. Activist programmers can do the same. If they do not like the direction a company is taking in terms of computer software, they should rebel. Such action will lead to the company producing stronger products and ultimately to be in a stronger competitive position.

The Art of the Multiline Label

To create multiline labels in dot net, set AutoSize=False, and Dock=Fill.

Excel Macros in Excel 2007: Selection.Unmerge

Excel 2007 help menu system is a gimmick. In fact, the whole of Excel 2007 is a graphical gimmick. Previous versions were imperfect yet better-designed. But here our priority is to discuss macro action in Excel. Wherefore art thou macros? Click on: View->Macros->Record Macro. Once recorded, you can do View->Macros->View Macros.

One useful and simple macro is Selection.Unmerge. Reason for this is when you need to highlight columns and can't do so - primarily because of MERGED CELLS. Probably those cells got merged as a result of cut-and-paste operation gone wrong.

Friday 20 November 2009

Gulf of Execution

This is the gap between the user's perceived actions to perform a task and the required actions. To learn more, read Donald Norman, the "dean" of usability and cognitive psychology. Some companies seem to thrive by increasing the gulf of execution in their products (sigh).

Thursday 19 November 2009

Excel Memory Madness

The memory madness that is new Excel can lead to situations where new worksheets are impossible create due to memory constraints. This usually happens when you already have a worksheet open that you opened from an email (this takes more memory). Solution is to save the file locally, close Excel and reopen.

Wednesday 18 November 2009

Apply Multiple Slide Masters to PowerPoint

All pressies contain at least one SLIDE MASTER - idea is to make universal style changes that apply to every slide.

View -> Master -> Slide Master (ALT-VM)

Right click the slide master you want to copy. Copy and PASTE.

Now you have copied and pasted all the SLIDE MASTERs, the next phase is to copy slides across and associate those slides with slide masters.

Now for the TRICKY PART.....

Right click on a slide and select Slide Design. Right Click on a prototype slide in the Slide Design window and click "Apply to Selected Slide". Boombah!

Saturday 17 October 2009

Programming Puzzles Ahoy!

Never mind Logic Problems, solve these engaging Prolog puzzles right now!

Wednesday 7 October 2009

Analysis ToolPak and Solver in Excel 2007

Analysis ToolPak

First things first, let MOB == "Microsoft Office Button" which is the big round button at the top left of the window.

To load Analysis ToolPak in Excel 2007:

1. Click MOB. Hit "i" to enter "Excel Options". (Alternatively: Alt-F-i will get you there).

2. Click add-ins. Add the AnalysisTP and TP-VBA add-ins.

Once Analysis ToolPak (ATP) is loaded it appears as "Data Analysis" icon in Data menu.

Solver

Step 1: Make sure this add-in is installed.

How does Solver work?

Specify: Set target cell [cell which contains formula], By Changing Cells [cells containing inputs], Subject to constraints e.g. $B$5$ <= 5.

Tuesday 6 October 2009

Excel 2007 is Weird (Part II)

Excel 2007 dispenses with the classic paradigm of menus and accelerator keys. It uses a new "results-oriented user interface" (ROUI). What would happen I wonder if MSVC were to switch to a ROUI, would productivity be significantly enhanced? Also, Excel now supports up to 16 million colors. Why do I need that in a spreadsheet?

Quoting MS: "Commands and features that were often buried in complex menus and toolbars are now easier to find on task-oriented tabs that contain logical groups of commands and features. Many dialog boxes are replaced with drop-down galleries that display the available options, and descriptive tooltips or sample previews are provided to help you choose the right option."

Hang on...complex menus? That's why we have menu accelerator keys....what's going on here?

From Charles Ellis: "On the product team, we differentiate between accelerators, which are keyboard ways to access the Ribbon, menus and toolbars, and shortcuts which are essentially everything else. This list isn't meant to include accelerators, not because they aren't a big part of what keyboard users use (ALT+E+S+V+Enter and ALT+E+A+A come immediately to mind), but rather because shortcuts, unlike accelerators, are much more difficult to discover; the UI only lists a handful of them and good and reasonably complete documentation is often difficult to find."

Difficult to find? Microsoft used acclerators since 1991, at least. Accelerators work. Ribbon? No thanks.

Sunday 4 October 2009

Adding Controls to Excel Spreadsheets (Forms Toolbox) and other Tricks

Forms Toolbar

First ensure the "Forms Toolbox" is visible (View->Toolbars->Forms). Then add a button to the worksheet (Click on the button icon and then "draw" the button in the sheet). It will prompt you for a macro name. Think of one and click ok. You can then record a macro.

How to Undo an "Undo"

Undoing an "Undo" is the same as doing a "Redo". This can be down via the Redo button (part of the Standard toolbar in Excel).

Tuesday 29 September 2009

Excel Formatting Demystified

To display negative numbers in brackets
Set custom format to: #,##0;(#,##0);0

Monday 3 August 2009

Bad Employees Demoralize Good Employees - Spolsky

The Guerrilla Guide to Interviewing by Joel Spolsky stresses the need to hire programmers who are A) smart, and B) get things done. Joel de-emphasises the value of brainteaser questions, explaining if you have heard the answer before you are at a massive advantage - true!

Some thougths from Joel:

"When interviewing experienced candidates, you can talk about their most recent assignment from their previous job"

Here's another really interesting observation from Joel:

"Often CS majors will just assume that everyone knows what Bates Theorem is or what O(log n) means. If they start doing this, stop them for a minute and say, “could you do me a favor, just for the sake of the exercise, could you please explain this in terms my grandmother could understand.” At this point many people will still continue to use jargon and will completely fail to make themselves understood. Gong! You don’t want to hire them, basically, because they are not smart enough to comprehend what it takes to make other people understand their ideas."

Monday 27 July 2009

TCP for Windows Hackers (And a bit of TCP History)

A TCP connection is half-open when the station at one end of the connection has crashed or otherwise removed the socket without informing the other end.
An embryonic connection is a TCP connection which is in the process of being established.

In UDP you can just start sending packets, whereas in TCP, you need to establish a connection before you send packets. Establishing a connection in TCP is done via a three-way handshake: client sends SYN, server sends SYN-ACK, then client sends ACK back to the server. At this point, client and server both have an acknowledgement of the connection.

Another difference between TCP and UDP is retransmission of lost packets.

The big names in packet network protocols are "Father of the Internet" Vint Cerf and Bob Kahn (PhD Princeton). In 1974 they published an IEEE paper: "A Protocol for Packet Network Interconnection". A central part of this protocol was the Transmission Control Program, later to evoive into TCP.

Need to understand TCP connections well to understand DOS and DDOS attacks.

Tuesday 21 July 2009

Evidence-Based Scheduling

New Joel Spolsky article. Includes tips on budgeting for interruptions and status meetings.

Thursday 9 July 2009

Building Windows DLLs

Check out creating a DLL, MSDN Guide to DLLs (lo-bandwidth)

To build a DLL in MSVC Express, create a Win32 app, then reload the project as follows: File->New->Project from Existing Code. Eventually you will reach an option that lets you change the project type to DLL.

Wednesday 8 July 2009

Dot Net Posters

Christmas has come early for C# programmers with the Visual C# 2008 Keybinding reference poster. Truly awesome shortcuts, such as Shift-F12 to "Find all references", and Cntrl-ML (to "expand/collapse all") will save you hundreds of thousands of mouse-clicks in the long-run.

When you open the pdf in Adobe Reader (mine is Version 8.0), hit Control-L1 to display the poster Actual Size and in full-screen mode.

There is a really AWESOME, voice-synthesis feature in Adobe Reader (click View->Read this Page Only).

Tuesday 7 July 2009

NTVDM has encountered an illegal instruction

This comes up when you do something weird in a DOS window, and appears in a plain messagebox with title "16 bit MS-DOS Subsytem". Perhaps you are running a command that requires bash to be initialised? VDMs are run as applications rather than server processes. Subsystems are server processes, like Windows environment subsystem (csrss.exe -> Client/Server Runtime Subsystem).

ColumnChoosers and Such-Like

A C# dgv column chooser? is that too much to ask?

Infragistics have a solution, that works as follows:

(basically you need to set the RowSelectorHeaderStyle property on the DisplayLayout property of the grid.)

using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
this.ultraGrid1.DisplayLayout.Override.RowSelectorHeaderStyle =
RowSelectorHeaderStyle.ColumnChooserButton;


Telerik also have a solution via their winforms gridview:

http://www.telerik.com/help/winforms/telerik.wincontrols.gridview-telerik.wincontrols.ui.radgridview-columnchooser.html

Sunday 5 July 2009

Legacy C#

System.Winforms (.NET 1.0) is now System.Windows.Forms. WinForms is key to knowing C#. C# 2.0 and beyond is a different beast to C# 1.0,1.1 so quite a leap is needed in terms of learning/adjusting to the new object model.

DataGrid --> DataGridView (DG -> DGV)

DGV has a new way of doing TableStyles. In the old datagrid, to hide a column we could just access the column width hierarchically, via the TableStyles and ColumnStyles properties e.g. grid.TableStyles[0].GridColumnStyles["myfield"].Width = 0 however the DGV has no concept of TableStyles. Features are directly exposed on the DGV control, the relevant one here being HeaderDefaultCellStyle. Read more on "styling a DGV" here. DGV is easier in a way, we can just to dgv.Columns[ColName].Visible=false.

ContextMenu --> ContextMenuStrip (CM->CMS)

CMS is typically displayed when user right-clicks a control. Many visible controls have a Control.ContextMenuStrip property. CMS can be shared between multiple controls. The principle is the same for CM as for CMS.

Wednesday 1 July 2009

Dotfuscation

Aristo's Dilemma

"How does one obfuscate one's Dot net code?" asked the aristocratic programmer. "Why is such obfucation useful, even, dare one say it, necessaire?"

"Dude, Obfuscation, or should I say, Dotfuscation, is about scrambling radical code, data and symbols to thwart the reverse engineering of one's awesome Dot Net code," replied Bill, of Excellent Adventure fame.

"Oui, oui, but how does one achieve such, as you say it, Dotfuscation, or to paraphrase, obtain obfuscated statoos in one's programmatory creationarios?" insisted Monsignor Aristo. "I am most concernatoried with respect to tools like that dastardly Reflector being used to read my most excellent codified verbiage".

"Dude, if your verbiage is, like, on the server, then it's not an issue, man!!" ranted Bill, and Ted echoed. "Yeah, dude. For web scenarios, it's like, no problem".

Aristo was not satisfied. "This is a most pertinent issue for ISVs selling client applications containing 'les secretes' of trade".

"Ok, then!" said Bill. "Try Dotfuscator Community Edition, man". Said Ted, "Yeah, dude. Protect your dot net apps, dude".

"Dotfuscator? As in Dotfuscation?" inquired Aristo. "What other options do I have? Can one utilise open source libros well to achieve same end-goal? If answer is nein, can one develop one's own obfuscation software? What techniques can one use to achieve same end-goal?"

Dotfuscation Techniques

Tuesday 30 June 2009

The Art of Wsdl

Generating Stubs from windowskarate.wsdl

wsdl.exe http://../wsdl/windowskarate.wsdl /nologo

If this results in:

Error: Destination location 'x' could not be opened for write operation - Access to the path is denied.

You need to re-open the MSVC command prompt as Administrator.

There is no short-cut to success in "The Art of Wsdl".

An important class for SOAP clients

SoapHttpClientProtocol (SHCP) class lives in System.Web.Services.Protocols namespace, from System.Web.Services DLL. It is the class proxies derive from when using SOAP. Other SOAP-related classes in this namespace include SoapHeader and SoapMessage.

Thursday 25 June 2009

STL Map: Foundation Skills

MSVC has very good STL support.

Consequently, one owes it to owns good self to know the STL well in order to harness it to maximum power in MSVC-exploiting programmaction. One knows STL well if one knows all the data structures, methods and time complexities of using the various STL methods.

The first super-basic thing we will cover is iterators on a map.

map::lower_bound - returns an iterator pointing to first element in a container whose key is not < (but possibly equal to) x, where x is the argument to lower_bound. So map::lower_bound returns an iterator the the lowest value in the map. The elements of a map are ordered by the key. Complexity is logarithmic in size.

map::upper_bound(x) though returns an iterator to the key whose value is STRICTLY greater than x. then doing map.erase(result-of-lbound, result-of-ubound), will delete all elements with keys in the range [lbound,ubound).

STL multimap ("multi-key map") also has similar iterator functions. In fact, definition of lower_bound and upper_bound is same for map and multimap.

For completeness, we describe the equal_range(x) function. This returns a pair of iterators demarcating the start and end of a range for elements equal to x in the map.

Sunday 24 May 2009

Race Condition in netio.sys on Vista (and allusion to BIOS shadowing)

This results in BSOD on multiprocessor system. Solution is to download the MS hotfix (they will send you a password protected zip file to install the hotfix from).More details here.
When your PC crashes you may also see a message to disable ROM caching or shadowing. ROM is much slower to access than RAM (120ns compared with 50ns, say), so a performance "trick" is to shadow the ROM in the RAM (i.e. mirror the code). There is usually a separate parameter to control the shadowing of the system BIOS, video BIOS and adapter ROM areas.

Saturday 23 May 2009

Performance Considerations for using .NET framework

Very good article here.
Also details some of the optimisations on the path from MSIL to native, such as:

  • Constant folding - if x=5+7 at compile-time, x=12 at runtime
  • Loop unrolling
  • Code hoisitng - read the article to find out what this is!

Friday 22 May 2009

Why Windows Networking ipv6 Rocks

To be a Windows configuration and networking uber-master, you must be fully familiar with the the command-line tools like ipconfig, route.exe and netsh. You must also aware and ready for the oncoming onslaught of IPv6, know why it is needed and also be reasonably au fait with the new IPv6 header format (similarities and differences with IPv4). You need to know what SSIDs are (easy, they are Service set ids used to identify 802.11 wireless networks).
Even then, you will only be skimming the surface of knowledge possessed by true Windows networking gymnasts.

The key beauty of v6 IP, is its incredibly ingenious and generous 128 bit source and destination IP addresses (FOUR TIMES THE SIZE OF IPv4), which can express over 10^38 possible combinations - amazing! Ubiquitous, interplanetary computing here we come!

IPv6 will form the basis of the IP-routing infrastructure of the 21st Centuramos. This is a certainty.

Here's ANOTHER super-cool fact about IPv6, it has standards-based security built in in the form of IPSec - ENCRYPTION SERVICES for IP NETWORK TRAFFIC. I know what you are thinking? How do I QUICKLY apply IPSec technology to secure traffic between client and server? There is some terminology to get familiar with before you start reading up on IPSec meaningfully. The first is L2TP (Layer Two Tunnelling Protocol).

IPv6 configuration is complicated by different types of addresses (G-L-S), for varying levels of GLOBALNESS and LOCALNESS. We have Global addresses (globally reachable on IPv6 portion of the Internet; these addresses typically begin with "2" or "3"), Link-local, used on a specific link (always begin with fe80), site-local, used within an organization's intranet, can be reused for different sites of an organization.

Praciticalites - To get help on ipconfig, open a command window and type ipconfig /?.

Now you can type:

ipconfig .. or...
ipconfig /all

You'll probably see rows like:
Wireless LAN adapter
Ethernet adapter Local Area Connection 2:
Ethernet adapter Local Area Connection 3:
Tunnel adapter Local Area Connection* 6:
Tunnel adapter Local Area Connection* 7:

You'll see IPv6 addresses are given before IPv4 addresses.

What is a tunnel adapter I hear you holler? some IPv6 transition technology, methinks...prepare to see a lot of these "transition technologies" going forward!

Sunday 10 May 2009

Programming Quotes

Monte Carlo sampling is no way to understand code.
Gordon McMillan (comp.lang.python)

You think you know when you can learn, are more sure when you can write, even more when you can teach, but certain when you can program.
Alan Perlis

Just getting something to work usually means writing reams of code fast, like a Stephen King novel, but making it maintainable and high-quality code that really expresses the ideas well, is like writing poetry. Art is taking away.
Erik Naggum (comp.lang.lisp)

Friday 8 May 2009

PowerPoint Science

PowerPoint puts presentation-making powers into the hands of ordinary Windows Joes. Here are some top tips:

Q: How do I view lots of slides on 1 page?
A: File -> Print Preview, Select: Print What [ Handout (6 slides per page) ]

Q: How do I view two slides at the same time?
A: Window -> New Window. Window -> Arrange All.

Wednesday 6 May 2009

Windows Numbers

3389 - the default port to listen for RDP connection requests on a Windows machine

127.0.0.1 - standard IP address used for a loopback network connection

Monday 4 May 2009

Windows Processes

Some Windows processes not adequately explained by Task manager:

* igfxsvrc.exe: process associated with Intel Common User Interface, installed with graphics card drivers with Intel chipsets.
* igfxext.exe: related

If lots of instances occur, it could be malware.

* monitor.exe: Windows process, relating to monitoring hardware components for performance bottlenecks

Saturday 2 May 2009

Virtualization on Windows - And Why you Need it Now

VMware Player allows you to run virtual machines on Windows (or Linux)...but on this blog we are only interested in Windows! The current version is 2.5. It's used to operate VMs created by VMware Workstation, VMware Fusion, VMware Server or VMware ESX and Microsoft Virtual Server and Microsoft Virtual PC virtual machines. Woo hoo! If you want to run Sage (open source math application) on Windows YOU NEED VMWARE PLAYER!!!

A lot of investment is going on in hypervisor technology.

Hypervisors may include software or hardware used to create virtual machines. They are also known as VMMs or virtual machine monitors, and are referred to as hosts, with the VMs they create being known as guests. The term hypervisor is actually quite old in computer terms, it dates from 1974 in an article by Gerald Popek (PhD mathematician from Harvard, later to taken on various CTO roles) and Robert Goldberg. They came up with the hypervisor classification of Type 1 (bare metal, or the "old IBM way") and Type 2 ("software way") which is adopted by many companies such as VMWare. A Type 2 hypervisor is also known as a "hosted hypervisor".

A lot of dynamics around the industry are changing in the area of virtualization.

Wednesday 8 April 2009

What is a Domain Controller in Windows?

What is a Domain Controller in Windows? This question is motivated by the error message: "Configuration information could not be read from the domain controller". The domain controller is a Windows server that responds to security authentication requests (logging in, permission checks) within the Windows server domain. Elements of a DC would include an LDAP database and KDC (Key Distribution Center).

Saturday 4 April 2009

24 Channels of Audio, QuickTime 7.6

What is new in Quicktime?
7.6? Remember the Rhyme.
24 Channels of Audio, "Surround Sound" we exhort!
Inter-frame Prediction, H.264 Support!

Saturday 28 March 2009

A Poem on Metaprograms

Compiler, Compiler, Burning Bright,
In the template struct of night.
What immortal metaprogram,
Can frame thy fearful factorial.
In what template struct enum,
Inductive definition looms.
From the general to the specific,
The blessed base case blooms.

Example

The classic example of TML is the factorial function, i.e. fact(n)= if n is zero ret 1 else return n* factorial(n-1).

template <int N>
struct Factorial { enum { value = N * Factorial<N - 1>::value }; };

template <>
struct Factorial<0> { enum { value = 1 }; };

To print factorial values, do something like the following: int x = Factorial<4>::value; // == 24.

There are TWO parts to Template Metaprogramming, template definition and template instantiation.

Analysis

Compile-time versus execution-time tradeoff: longer to compiler, faster to execute!

Libraries

Boost MPL can be used in MSVC. Here's a tutorial.

TML is generally Turing-complete, any computation expressible by a computer program can be expressed by a template metaprogram.

Thursday 26 March 2009

ACE libraries

The ACE libraries (ADAPTIVE communication environment) comprise an OO framework that implements a bunch of concurrent design patterns. Read this article on wrapper facades. They are used in ACE.

Should you wish to use POSIX threads in Windows you can. The pthreads-win32 project DLL does just that.

Monday 23 March 2009

deque better than vector?

MSVC is more STL-friendly now. It can help us resolve questions like, is deque better than vector?

C++ strongman Herb Sutter helps us find the answer.

Ever wonder how associative containers like maps are implemented? The standard implementation is to use a self-balancing binary search tree, such as Sedgewick's red-black trees. Red-black trees are trees where each node is either red or black and the root node is black (in most definitions). The tree has the property of being "roughly balanced" - formerly defined this says that

longest path(RL) <= 2*shortest_path(RL)

(<= reads "less than or equal to" or "cannot exceed", RL == root_to_leaf). in that tree.

Tree traversals are important in computer science (preorder, inorder, postorder). These should be known forwards, backwards and back-to-front.

Saturday 21 March 2009

Swedish Financial Supervisory Authority grants banking license to Online Game

grant_banking_license( swedishSupervisoryAuthority, entropiaUniverse ).
developer( entropiaUniverse, mindark ).
currency( entropiaUniverse, projectEntropiaDollars ).

Virtual banks need to be regulated in case they become a vehicle for money laundering. Some countries (e.g. China) are also looking at virtual worlds as a potential source of tax revenues.

The Virtual Worlds conference (now Engage! Expo) is a forum for discussing innovations in virtual worlds, such as entropia universe.

Customization in Vista

Hmm. ..customizing Vista requires rewiring your brain if you have been used to WinXP for a while.

If you want to change the desktop background you need to:

Click Start, click on control panel (on the transparent section RHS) then find Personalization. Here you can change: Desktop Background, Screen Saver, Theme. Is it possible to take customization one step further and create a new Windows theme? A commercial product called Vista Style Builder has been written by Andreas Verhoeven, a programmer in Rotterdam. Andreas has done good work cracking the internal format of .msstyles files. Various styles can be found at skinbase.org.

Thursday 19 March 2009

Monday 9 March 2009

Business of Software 2009

Joel Spolsky: "The business people have no hope of learning the technology, it's just too much. The hill is too steep to climb that hill. But that means for a software company to succeed the people at the top, I believe, have to be software people, they really have to be the technologists, but they also have to have business skills, so they're just going to have to learn them". More here.

Sunday 22 February 2009

Becoming A Windows Boxing Champion

A famous boxer once said: "Champions aren't made in gyms. Champions are made from something they have deep inside them - a desire, a dream, a vision. They have to have the skill and the will. But the will must be stronger than the skill". Put up your hands, Windows Joe is in the house.

Monday 16 February 2009

Threading Basics in Dot Net

In C#, before you use threads, consider whether you can do the same thing just using events or delegates (i.e. built-in, implicit threading).

If you want to create threads explicitly, you can use System.Threading namespace. Useful stuff in this namespace include the ThreadPool class, and the Timer class, which will execute callbacks on thread pool threads.

The Thread class is a sealed class i.e. cannot be subclassed (structs, can be used for lighweight objects e.g. Point, Color, can are implicitly sealed. You cannot subclass a struct).

Thread th = new Thread( new ThreadStart(display) ); // display is a method
th.IsBackground = true;
th.Start();


An interesting article on deadlock in C# is here.

Sunday 15 February 2009

The Asynchronous Art of the Dot Net Delegate (BeginInvoke, EndInvoke etc)

Custom Event Handling Techniques Using Delegates (together with event keyword)

Suppose you have a combo box that, on changing state, wishes to send an event to other windows (a kind of internal messaging, if you will). You can define an event handler as a delegate, which takes 2 variables (an object representing the sender, and a custom "event args" object, which encapsulates the state of the event).

Then can explicitly declare the event using the delegate: "public event ClickMeDelegate clickChange" and a method to "fire" the event. All "listeners" register on this event by adding and instantiating new event handler objects.

Declaring, Instantiating and Invoking a Delegate

Note that I DON't say C# delegate, as multicast delegates are found across the .Net framework - e.g. they are also found in Visual Basic .NET and Visual J#. However we will use C# as the lingua franca in which to present delegates.

A delegate in C# is an objectified function pointer. They are .NETiquitous in two ways:

1. EVENT HANDLING
2. ASYNCHRONOUS EXECUTION

To declare a delegate use the following syntax:

public delegate void MyDelegate(string message);

Now MyDelegate becomes a reference type which can encapsulate a named or anonymous method. Now we can define a method "MyDelegateImpl" which matches the signature.

MyDelegate m1 = MyDelegateImpl; // instantiate delegate with NAMED method
MyDelegate m2 = delegate( string msg ) { do s/t; }; // ANONYMOUS method

// invoke
m1("ya"); m2("hoo");

Difference with Multicast Delegates

Maintains an invocation list (implemented as a linked list) of methods it is bound to. The method Combine adds a method to the invocation list and Remove removes it. Combine is used for creating event handlers, that call multiple methods when an event occurs. The binary operators +, - can be used as stand-in for Combine and Remove as this example shows.

It should be strongly emphasised that +,- do not change existing delegates but rather return a delegate representing the result.

Key classes are System.Delegate and System.MulticastDelegate, both part of mscorlib.dll. Multicast delegates can be used to implement the Observer design pattern.

What declaring a multicast delegate entails

When you declare an MCD the CLR creates a class that extends System.MCD, and adds the methods: Invoke, BeginInvoke and EndInvoke. Invoke is what the CLR calls during synchronous execution. To execute asynchronously, use BeginInvoke which is non-blocking and returns an IASyncResult reference. When you call EndInvoke to get the result (this is a blocking call) you need to pass in the reference.

Tuesday 3 February 2009

The History and the Future - Acrimonious Hacking on Windows

"Acrimonious hacking" involves hacking with acronyms. Certain programming experts assert that the best hackers think in acronymns. Take Simonyi's Hungarian notation for example. Even in verbose codebases, the best hackers mentally abbreviate objects and varnames into condensed versions they can manipulate quickly in their brain and perform rapid mental refactorings. Victory be to the acrimonious hackers!

"Acrimonious hacking" is an attempt to stem the complexity of imperative programming.

A "higher level" attempt to manage imperative-prog complexities is "intentional programming".

The creed is to separate the problem from the program, and to use generative techniques to create the program on the computer. A whole website on code generation, the "code generation network" describes projects in .Net, Java and MDA. MDA is a set of OMG standards and a special report is here.

Saturday 31 January 2009

A Great Editor for Windows Batch Files

Check out http://www.scintilla.org/. The best editor to edit Windows batch files.

Wednesday 28 January 2009

C# 4.0 Unveiled at PDC 2008

Topics that were covered included dynamic typing, optional and named parameters, improved COM interoperability, and covariance (overriding return types) and contravariance support. Eric White has a write-up here. The dynamic allows you to define a dynamic type, where member resolution is deferred till runtime. This allows for interoperability like languages like Python.

Anders Hejlsberg introduces the history of C#, from c# design group started in dec98 to build a new language for mged code. c# 2.0 - new features that didn't have time cos had to ship, c# 3.0 - first oppo to think of new things to do in langgeLINQ, functional progr features.

New features focus on more declarative styles of prog, dynamic prog lang resurgence, concurrent -> multi-core inflection pt. uber-trend -> classical taxonomies of prog lang are starting to break down. increasingly seeing langs borrow from each other. c# multi-paradigm prog lang, oop and all cornerstones of functional needs. imperative - hard to see forest from the trees - specify in excurciating detail.

Saturday 17 January 2009

Enjoying Tcl on Windows with ActiveTcl

ActiveTcl (21 MB download). Here's a short tutorial. Tcl is a compact, string-oriented language, easily integrated into special hardware. Tk is a platform independent GUI toolkit. Both were invented by John Ousterhout. Tcl is nice as it allows you to make short and unwordy programs. Java is verbose. Python is verbose. Tcl is just right. The set and puts commands are just a joy to use. Tk makes writing GUI code actually bearable and the brevity of its syntax precludes the need for IntelliSense.