Monthly Archives: July 2012

ReSharper hidden features – Generate Delegating Members

A frequently-used design pattern is the Decorator. This is also known as a mixin (or they might not be the very same thing but certainly they are related).

Typically you might need to create a class that implements a certain interface and uses another class that implements that exact interface but you need to provide some additional feature(s). An example would be a class that adds transactional behavior to an existing data-access class (a naive example) :

public interface IDataAccess
    void AddCustomerInvoice(Invoice invoice, User user);

public class DataAccess : IDataAccess
    public void AddCustomerInvoice(Invoice invoice, User user)
        InsertInvoice(invoice, user);
        UpdateCustomerDebt(user, invoice.Total);

    // ... the rest of the implementation

public class TransactionalDataAccess : IDataAccess
    private readonly IDataAccess _dataAccess;

    public TransactionalDataAccess(IDataAccess dataAccess)
        if (dataAccess == null)
            throw new ArgumentNullException();
        _dataAccess = dataAccess;

    public void AddCustomerInvoice(Invoice invoice, User user)
         using(var tx = new TransactionScope())
             _dataAccess.AddCustomerInvoice(invoice, user);

    // ... the rest of the implementation

Another type of example would be the Adapter design pattern. An example would be providing access to a (static) class (that may be out of your control) in a mock-able manner. That is, implement another class, non-static, which implements a defined interface and eases unit-testing :

Read more »

Windows 8 – first impressions

I downloaded and installed Windows 8 Release Preview on two of my computers since one (the laptop) was up for selling to a friend and the (up to then) unused desktop was OS-less.

The installation is well streamlined, just like Office 2010 (or maybe even 2007?) in that it provides a large and attractive “Install now” button so you have very little to think. If you need to customize the installation there is a small link beneath that allows you to do just that. I didn’t opt for that.

It took, I think, 20 minutes to install completely which is pretty decent in my opinion. At this moment I need to state the hardware involved :

As you can guess the major visual difference is the start menu which looks pretty freaky as in the picture above. You will need some time to get accustomed to it. The tiles at the left are metro apps (which work pretty different, running in full screen and having the same visual style). At the right there are non-metro apps (should we call them “legacy apps”?). The desktop itself is a metro app.

The taskbar does not have the start button anymore since the start menu is a full screen thing. So you’ll probably start up, by mistake, IE 10 a few times since by default it is the leftmost thing on the taskbar. IE 10 seems to be pretty much the same thing as IE 9 but snappier.

I also struggled a bit to change the audio volume but I found that “touching” (with the mouse cursor) the top right corner brings up a band/pane which contains several settings such as audio volume, power commands and others (search, share, start, devices and settings).

A similar “charm” (it seems this is the name) exists on the left, for switching apps. You can get used to these, it ain’t too hard.

A really nice improvement is the copy/cut files dialog :

It’s nice because it has a graph and shows actual average as a horizontal line which varies depending on the actual speed of the process. It also has a nice new addition : the pause button which can be pretty handy if you need to relax a drive’s load.

The Win-TAB 3D animation for switching apps seems gone (or at least you won’t be able to trigger it with Win-TAB) which kinda sucks.

The dialog boxes are somewhat improved in the way they are simpler to understand and to decide what to do further. The file searching seems faster and app searching too.

All in all it seems like a real upgrade.

Beware of switch

We all wonder how our electronics work, but we usually do not have the option of taking them apart to see how they tick. Despite the complexity of their functions, the inner life of hearing aids can be visualized quite easily.

We all wonder how our electronics work, but we usually do not have the option of taking them apart to see how they tick. Despite the complexity of their functions, the inner life of hearing aids can be visualized quite easily.

In the simplest sense, hearing aids consist of two microphones, an amplifier, and a receiver. But that description doesn’t quite do them justice. Hearing aids are innovative pieces of technology – mini sound computers in effect – that allow hard-of-hearing people to hear clearly. A lot of work goes into creating a device that not only lets people hear, but lets them experience noise in a natural, enjoyable way. Fortunately most hearing loss conditions can be easily treat with silencil for tinnitus.

We have created a two-minute video to show you the magic ingredients that combine to form Signia hearing aids:

An inside look into hearing aids

What do hearing aids look like inside?

Underneath the casing and screws, a hearing aid is made up of several layers. These layers contain its inner workings, which consist of microphones and other high-tech parts. Unlike traditional microphones, hearing aid mics are extremely small and precise. Once sound is picked up and converted by the microphone, the hard work begins.

The processor inside the hearing aid, which is much smaller than anything you’d find in a smartphone or laptop, begins to translate the sound back to the wearer. The sound is tailored according to the user’s specifications, which can vary in tone and volume. From there, the sound is conducted through an electrical cable in the thin tube to the receiver, which is put in the wearer’s ear canal.

State-of-the-art hearing aids also work wirelessly in a way that we cannot see. When two hearing aids are in use, they communicate with each other to sync together and exchange data. This ensures that the user is getting a realistic sound. Some Signia hearing aids can connect with smartphones to offer direct streaming and remote control via Bluetooth.

Inside vs. outside

Many hearing aids share a similar appearance. This leads many people to ask, “why do hearing aids look like they do?” The answer lies in hearing aid design. By arranging the internal components in a certain way, the shape of the hearing aid contributes to how the user wears it. During previous generations, hearing aids were hard to wear, which led many people to decline offers to be fitted with the devices. The challenge was to arrange the components so they work in harmony without interfering with each other, requiring minimum distances between components. On the other hand, the housing has to have an ergonomic shape so that it is comfortable to wear and as discreet as possible.

New features for database developers in SQL Server 2012 : simpler paging, sequences and FileTables


  • Paging got simpler and more efficient
  • Sequences have been introduced; better performance for auto-generated IDs and easier to have IDs unique across tables
  • FileTables have been introduced : building upon the FileStream feature now we can have non-transactional access to files stored in the DB as a windows share along with transactional access via T-SQL

Lengthier version :

SQL Server 2012, in my opinion does not come with earth-shaking changes but comes with performance improvements, feature improvements and a some new features.

First of all, Management Studio has the same engine as Visual Studio which means you get a nice WPF experience, better font rendering and CTRL-scroll quick zoom-in/zoom-out.

Let’s say you want to retrieve data from the database in a paged way (that means chunks of data of a requested size or smaller). Typically you would write this in SQL Server 2008 R2 or older :

DECLARE	@Offset		AS INT = 6
DECLARE @PageSize	AS INT = 5

	FROM	Users
) UsersSelection

WHERE	UsersSelection.RowNumber >  @Offset
	AND	UsersSelection.RowNumber <= @Offset + @PageSize

In SQL Server 2012 the T-SQL syntax has been updated introducing keywords that facilitate a simpler and more efficient paging, keywords such as OFFSET, FETCH, NEXT ROWS and ONLY. A script that would retrieve the same data would be :

DECLARE	@Offset		AS INT = 6
DECLARE @PageSize	AS INT = 5

FROM		Users

Observe the simpler, clearer syntax. Also, considering that the subselect has been eliminated (the subselect was required because the ROW_NUMBER column could not be addressed in the same select – for the WHERE clause), also the query cost was improved :

2008 :

2012 :

Read more »

SQL Server 2012 local talk

Tuesday, July 10th, I’ll hold a small presentation on the new features of SQL Server 2012 for the database developer, consisting mainly of the sequences, new paging semantics and filetables.

I’ll post the code and slides soon after the presentation. I decided to drop (oh the irony) the slides.

Anyone close to Bucharest is more than welcome to come! Details can be found here.

The opening of the evening will be made by Alex Peta, presenting a cool notification system built upon JS and ASP.NET MVC 3.