Developping for the translation industry RSS 2.0



 Friday, 29 February 2008

Originally taken from codesnipers.com

Programming is like sex because :

  • One mistake and you have to support it for the rest of your life. (Michael Sinz)
  • Once you get started, you'll only stop because you're exhausted.
  • It often takes another experienced person to really appreciate what you're doing.
  • Conversely, there's some odd people who pride themselves on their lack of experience.
  • You can do it for money or for fun.
  • If you spend more time doing it than watching TV, people think you're some kind of freak.
  • It's not really an appropriate topic for dinner conversation.
  • There's not enough taught about it in public school.
  • It doesn't make any sense at all if you try to explain it in strictly clinical terms.
  • Some people are just naturally good.
  • But some people will never realize how bad they are, and you're wasting your time trying to tell them.
  • There are a few weirdos with bizarre practices nobody really is
    comfortable with.
  • One little thing going wrong can ruin everything.
  • It's a great way to spend a lunch break.
  • Everyone acts like they're the first person to come up with a new technique.
  • Everyone who's done it pokes fun at those who haven't.
  • Beginners do a lot of clumsy fumbling about.
  • You'll miss it if it's been a while.
  • There's always someone willing to write about the only right way to do things.
  • It doesn't go so well when you're drunk, but you're more likely to do it.
  • Sometimes it's fun to use expensive toys.
  • Other people just get in the way.
Friday, 29 February 2008 16:51:24 (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Thursday, 07 February 2008

The company where I work is currently hiring.  We’re searching for two superstar C# developers for a Research and Development project.

So, if you live near Montreal (Canada) or wish to move here and want to contribute to a great team, send me your CV at stan@stanbiron.com and I’ll contact you individually for more details.

 

Thursday, 07 February 2008 09:23:01 (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Thursday, 20 December 2007

If you’re using SQL Server 2005, you probably have encountered this error at least once.  When people see this error, they may not know where to start searching.  This post is a recap of every possible cause to this problem (that I know of).

The error message you get is :

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connection. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

The possibles causes are:

Server accessibility and availability:

  • Depending on your connection type, make sure that TCP/IP or Named Pipes are enabled in the Surface Area Configuration tool.
  • Also make sure that TCP/IP or Named Pipes are enabled in the SQL Server Configuration Manager.
  • Make sure that you can ping the server from the client.
  • Make sure that your SQL Server is started (obvious but still needs to be on the list).

Connection String:

  • You should also double check your connection string to be sure that there is not a typo in the server name or instance name.
  • You also should try both Server\Instance and Server\\Instance in your connection string.  This is because some applications convert \\ to \. 
  • You may also try to add the SQL port to the connection string (ex: Data Source=mysqlserver\myinstance,1433).

If you are using SQL Server Express:

  • Check that SQL Server Browser is enabled and is started in the SQL Server Configuration Manager.  If it was disabled, also make sure that you set the Start Mode to “Automatic”.

If your SQL Server is behind a Firewall:

  • Check that there is an exception in your firewall configuration to let the traffic through port 1433 (for SQL Server) and 1434 (for an UDP packet sent to get information on the SQL Instance like the protocol, the TCP port to use, etc).

 If your SQL Instance is on a cluster:

  • UDP packets are dropped in some cases when dealing with an instance on a cluster.  This is a known issue and I don’t know if Microsoft will do something about it.  For more details and workarounds, you can go here, here or here.

if you’re trying to connect to your SQL Server with an ASP.NET application:

  • Make sure that the version of the .NET Framework loaded in IIS on the server for this specific Web Site is the right one (I experienced this error when I deployed an application built with the version 2.0 Framework on a web server with 1.1 loaded by default).
  • The process account of the ASP.NET application must have rights to connect to the SQL Server database.

This list may not be complete. So if you know another cause or element that needs to be checked for this particular scenario, drop me a line at stan@stanbiron.com and I’ll update this post.

Thursday, 20 December 2007 17:37:05 (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
SQL
 Wednesday, 19 December 2007

Jeff Atwood recently posted on the topic of sorting strings in a more natural order that the default string sorting gives us.  His main point is, when we’re dealing with numbers, a simple alphabetic sorting doesn’t cut it.

So. just for fun, here’s my little C# 2.0 Implementation of a more human-friendly sorter.

 

public class FriendlySorter<T> : IComparer<T>

{

    public int Compare(T x, T y)

    {

        if (x == null || y == null) return 0;

        if (x.ToString() == y.ToString()) return 0;

 

        string[] left = Regex.Split(x.ToString(), "([0-9]+)");

        string[] right = Regex.Split(y.ToString(), "([0-9]+)");

 

        int index = 0;

 

        while (true)

        {

            while (left[index] == right[index]) index++;

 

            if (left.Length == index && right.Length == index) return 0;

            if (left.Length <= index) return -1;

            if (right.Length <= index) return 1;

 

            try

            {

                return (int.Parse(left[index]) - int.Parse(right[index]));

            }

            catch

            {

                int CompareResult = String.Compare(left[index], right[index]);

                if (CompareResult != 0) return CompareResult;

            }

 

            index++;

        }

    }

}

 

The following code :

List<string> list = new List<string>();

 

list.Add("Track 1 : abc");

list.Add("Track 2 : abc");

list.Add("Track 10 : abc");

list.Add("Track 5 : abc");

list.Add("Track 11 : abc");

list.Add("Track 22 : abc");

list.Add("Track 9 : abc");

 

list.Sort(new FriendlySorter<string>());

 

Will produce the results :

Sshot-4

For small sets the performance is Ok.  But when dealing with a larger amount of data (1000+ items), the sorting performance drops a lot (I currently have 5 seconds to sort 1000 random elements).  I will probably try to enhance it in the future and update this post.

Happy holidays !

Tags:
Wednesday, 19 December 2007 18:42:12 (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
.NET | C# | Code Snippet
 Wednesday, 28 November 2007

Visual Studio 2008 is a great tool.  But there is one very annoying point. The bad news of the day is that, if you tried the pre-release version of Visual Studio 2008, there are a whooping 22 steps needed to un-install it.

Needless to say that it made me really cranky when I found about this.  I guess it's the price to pay when you are an early adopter..

Wednesday, 28 November 2007 11:20:34 (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Thursday, 22 November 2007

Some complex queries involving more than one layer of calculations cannot be easily done in SQL.  Let’s say you need to compute the average number of sales per customer.  Your first thoughts may be something in the lines of :


SELECT AVG(COUNT(SALE_ID)) FROM SALES GROUP BY CUSTOMER_ID

But when you try to execute this kind of query, you will get an error message looking like this :

Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

At this point, your instinct should tell you that the average of sales per customer should be something relatively easy to compute using SQL.  Some folks use temporary tables as a workaround to this limitation.  This solution is very bad for your query performance, especially when you have to deal with large databases.  The flow for such a task is :

1– Create a new temporary table to hold the computed values.

2– Insert the values in the new table.

3– Select the value you need from the temporary table.

4– Delete the temporary table.

The easier way that’s a lot faster both to write and to execute is to use derived tables.


SELECT AVG(number_of_sales) FROM (SELECT COUNT(SALE_ID) AS number_of_sales FROM SALES GROUP BY CUSTOMER_ID) dt_sales


The magic here lies in the FROM part.  The FROM keyword can use tables OR derived tables.  A derived table is simply created by writing the query and giving it an alias (in my examplen it is dt_sales).  Derived tables are created only in memory and thus are a lot faster than on-disk temporary tables.

Derived tables can be used exactly as regular database tables.  For example, you can make joins between them or between regular tables and derived tables.

Tags:
Thursday, 22 November 2007 13:13:09 (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
SQL
 Tuesday, 23 October 2007

There are so much “productivity hacks” out there.  The blog lifehacker is full of little productivity hacks to boost your effectiveness.  For developers we have more stuff to look at that every one else combined.  This is not an article about some yet-another-incredible-new-tool, because there will be a better one next week.  I’ll have plenty of time later to talk about my favorite tools that are great Time Savers. But IMHO, there is no tool yet that is as high a productivity booster as owning whole features in an application.

The current problem with any tool is that you can have a productivity increase of 1.5x – 2x.  Maybe you can make that number 3x - 4x if the tasks you have to accomplish are repetitive, you are a master of your particular tool and you take the time to enhance it, creating your own snippet or macros.  The thing about it is that, with most these kind of tools, you just become a faster typist.  Since the number of lines of code is a terrible productivity metric, we can assess that being a faster typist doesn’t necessary make you a more productive developer.

The real productivity gains lies elsewhere.  It has been given many names : Being “in the zone”, “in the moment”, “in trance”.  Everybody has experienced this state of mind where time seems to stop, you lose awareness of everything around you and you wake up, several hours later, having done a week’s worth of work.  This state of mind is one of the main points of the classic software project management book Peopleware.  Getting into that state of mind can take from 15 minutes up to a full hour or even more depending on the individuals and many others parameters (ambient noise, stress level).  And getting out of that state of mind is terribly easy. 

But what’s all this have to do with developers owning some features?  Simply that owning some code will make the “in-the-zone-boot-up-time” a lot shorter when working on that particular piece of software.  Basically, what’s happening when you are in the process of getting in the zone?  Your subconscious mind is loading (or, at least, tries to load) the entire problem space that you’re facing.  When there are unknown elements, as there are always in shared code situation, the problem space is filled with variables elements, making the process really harder than if you know everything about the problem.

When you own features, you have seen (and probably written) every single line of code and you know every bit of functionality, every hack that shouldn’t be there and every little design flaw.  So when you work on that feature, the feature problem space contain only known elements and is a lot easier to load in your subconscious mind.  Moreover, it helps a lot for debugging and refactoring situations to know the entire feature characteristics.  The developers that own their features will avoid a lot more pitfalls than those who share functionnalities, simply because they know the implications everywhere of the code they’re writing.

Owning features is not only beneficial on the developer’s performance side.  Developers in general are elitist people and they don’t like others developers messing with their code.  The fact that it is clearly stated that features X, Y and Z are properties of Joe Developer will surely make him not only happier on the job but he will be a lot more committed to those features than he could ever have been otherwise.

But that’s just me, what’s your opinion on this subject?

Tuesday, 23 October 2007 08:28:49 (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Monday, 22 October 2007

At the office, we use an Outlook addin (that I originally developed in Visual Studio 2002 targeting the 1.0 .NET Framework).  Finding that technology to be a little obsolete (all of our others internal applications are on the 2.0 Framework), we’ve decided to migrate it to 2.0 and add some news features while we’re at it.

The migration and installation went fine at first on my Vista development PC but I couldn’t get the addin to load on the users computers (that are on WinXP).  Every thing I tried, didn’t work and the addin couldn’t load at all.  What I ended up doing is a complete rebuild of the application using VSTO SE (Visual Studio Tools for Office Second Edition).  Since everything works well now, I’ll share with you every resource that I came across about creating an addin with VSTO.

1. Get the prerequisites:

In order to deploy a VSTO addin, you need the following prerequisites installed on every user’s computer:

 

2. Code the addin:

Pretty straightforward step, depending on your company’s requirements.  I’ll write another article about that part soon with some code examples.

 

3. Prepare for deployment:

In order to prepare for the deployment of your solution, you need to set the code access security policy for your assemblies.  To do so, you need to do the following tasks:

  • Get the “SetSecurity” project here and add it to your project.
  • Sign your assembly (or assemblies) in the Signing section of the project’s properties.  All you need to do is to check the Sign the assembly check box and create a new strong name file.  You need to make sure that every assembly that you deploy is signed (including the SetSecurity.dll assembly).

 Sshot-1

Sshot-02

 

  • Add the SetSecurity project output to your deployment project and add a custom action for Installation, Rollback and Uninstall.

Sshot-3

In the custom action data for the Install custom action, you need to enter the following data, replacing “OutlookAddin” with the name of your addin:

/assemblyName="OutlookAddin.dll" /targetDir="[TARGETDIR]\" /solutionCodeGroupName="MyCompany.OutlookAddin" /solutionCodeGroupDescription="Code group for OutlookAddin" /assemblyCodeGroupName="OutlookAddin" /assemblyCodeGroupDescription="Code group for OutlookAddin" /allUsers=[ALLUSERS]

For the Rollback and Uninstall, all you need to provide in the custom action data is:

/solutionCodeGroupName="MyCompany.OutlookAddin"

 

That’s a wrapper of about everything useful I found in my research.  I hope this helps you!  If there is something you think would be a good addition to this article, feel free to email me at: stan AT stanbiron DOT com.

Some more useful resources:

  • If you don’t have VSTO as part of your Visual Studio Installation, here is the link to download it separately.
  • If you code on a Vista PC and you use Visual Studio 2005 (with the Vista service pack), you won’t be able to debug into a VSTO addin for Office 2003.  Microsoft has issued an hotfix to resolve this problem.
  • If you can’t get the addin to work on the target computer, you can use this really great Outlook Addin Checker that looks for missing registry keys, prerequisites or Code Access Security policies.
  • There is a two-part article on MSDN for every step needed to deploy an VSTO addin or document customization: part 1 and part 2.  These article are somewhat long but every bit of information for the deployment part is there.  They also explain how to set custom deployment conditions to ensure that the prerequisites are installed.

 

Monday, 22 October 2007 16:14:29 (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General | Office Interop | Tools

Navigation
Advertisement
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2017
Stanislas Biron
Sign In
Statistics
Total Posts: 135
This Year: 0
This Month: 0
This Week: 0
Comments: 1
All Content © 2017, Stanislas Biron