Category: Software development

Software development in general

Greg Young webcast

Greg Young made his first summer webcast live from PCMS Conseil office in Montreal today. I work at PCMS so I had the chance to listen to it live.

The presentation was about how the DDD Ubiquitous Language is actually not that ubiquitus. In rΓ©sumΓ©, Ubiquitus Language can only be ubiquitus if you place it in a bounded context. If you have Eric Evans blue blook read the chapter 14. If you don’t have it, get it. Or go to DDD-Step-by-Step, it’s a great start.

He also explained why separating your bounded context from the start is important. Since you won’t be using DDD in all of them, you need to abstract them and focus on the core of your business. It’s alot like the AGILE priorisation technique, you split your context, then focus on the core business of your client, the one where your client need an advantage. This way you can see an ROI of using DDD, because the technique is more expensive than other simpler approach.

It was a nice presentation, minor some technical problems (wich I didn’t have, since I was on site). The presentation was recorded, I’ll post a link to the video here once Greg put it online.

building v8 using mingw on windows

By default v8 only builds on MSVC for Windows. It also supports building with mingw, but it is not documented anywhere and I’ve lost some time finding how. So here it is, easy steps for whoever needs it.

Prerequisites

1. v8 source code (of course), in my case I used trunk.

svn checkout http://v8.googlecode.com/svn/trunk/ v8

2. scons (building tool used by v8)

http://prdownloads.sourceforge.net/scons/scons-1.3.0.win32.exe

3. mingw32 (gcc 4.x.x is required to build v8)


binutils-2.20.1-2-mingw32-bin.tar.gz
gcc-full-4.4.0-mingw32-bin-2.tar.lzma
make-3.81-20090914-mingw32-bin.tar.gz
mingwrt-3.15.2-mingw32-dev.tar.gz
mingwrt-3.15.2-mingw32-dll.tar.gz
w32api-3.13-mingw32-dev.tar.gz

You can get those from http://sourceforge.net/projects/mingw/files/.

Building v8 with mingw

1. Using the “toolchain=gcc” command line paremeter doesn’t work, so you need to modify Scons.

a) Open file C:\Python26\Lib\site-packages\scons-1.3.0\SCons\Tool\__init__.py
b) Find the line “if str(platform) == ‘win32’:”
c) Modify the tools lists to use mingw tools instead of msvc tools by default.

Should look something like this once done:

linkers = ['gnulink', 'mslink', 'ilink', 'linkloc', 'ilink32' ]
c_compilers = ['mingw', 'msvc', 'gcc', 'intelc', 'icl', 'icc', 'cc', 'bcc32' ]
cxx_compilers = ['g++', 'msvc', 'intelc', 'icc', 'c++', 'bcc32' ]
assemblers = ['nasm', 'masm', 'gas', '386asm' ]
fortran_compilers = ['g77', 'gfortran', 'ifl', 'cvf', 'f95', 'f90', 'fortran']
ars = ['ar', 'mslib', 'tlib']
other_plat_tools=['msvs','midl']

2. Open a command line (cmd.exe)

3. Set you environment path (if required)


set path=c:\python26;c:\python26\scripts;c:\mingw\bin;%PATH%

4. Build v8


scons mode=debug visibility=default

note: the visibility=default parameter is required otherwise gcc generate a warning (as an error) and the build doesn’t work.

note: currently (revision 4432) only static debug mode works with mingw building, debug=release produce errors (warning as error) and so does library=shared (building dll). Will try to fix this in a next post.

Have fun with v8 πŸ˜‰

Exporting html to excel 2003 and 2007 using utf-8

Using html in Excel is very usefull, because it allows to do easy reporting with nice features like colors, tabular formatting, etc.

First we need to output some headers so the browser will open the ouput with Excel. This works in both 2003 and 2007 :

(pseudo-code)
headers.Add(“Content-Type”, “application/vnd.excel”)
headers.Add(“Content-Disposition”, “attachment;filename=something.xls”)

The tricky thing was the output encoding. In utf-8, it worked in 2007, but not in 2003. In utf-7 it worked in 2003, but not in 2007. In unicode, it did not work at all.

After alot of tries, I finally discovered, that the output must be in utf-8, but we need to output the UTF-8 BOM wich identify the utf-8 byte order. Then it worked perfectly. You need to output this at the beginning of your data :

(pseudo-code)
OutputStream.WriteByte(0xEF);
OutputStream.WriteByte(0xBB);
OutputStream.WriteByte(0xBF);

exceptions and threads with mingw

If you’re having trouble using exceptions and threads with MingW, here is the solution:

1. Add these compiler options:
-mthreads (enable exception support in threads)
-fexceptions (enable exception handling)

2. Get the latest version of gcc (I have the 4.4.0, see the g++ -v ouput below)

It is very important that you check your gcc version and configuration (-v), because the last version I had 3.4.0 did not work even with the -mthreads.


Using built-in specs.
Target: mingw32
Configured with: ../gcc-4.4.0/configure --enable-languages=c,ada,c++,fortran,jav
a,objc,obj-c++ --disable-sjlj-exceptions --enable-shared --enable-libgcj --enable-libgomp --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --prefix=/mingw --with-gmp=/mingw/src/gmp/root --with-mpfr=/mingw/src/mpfr/root --build=mingw32
Thread model: win32
gcc version 4.4.0 (GCC)

I lost a lot of time trying to debug/fix this, so I hope this helps.

Using dynamic canvas creation with google excanvas using IE

When you are using IE and ExplorerCanvas, dynamically created canvas with document.createElement are not working. They’re are not extending the ExplorerCanvas functionnality by default.

Include this script after excanvas.js in your html header to extend the created element at creation:

if ( /MSIE/.test(navigator.userAgent) )
{
document._createElement = document.createElement;
document.createElement = function( tag )
{
var element = document._createElement( tag );
if ( tag == “canvas” )
{
//width and height are required for initElement
element.width = 1;
element.height = 1;
G_vmlCanvasManager.initElement(element);
}

return element;
}
}

Now you’re dynamically created canvas will actually work. This is surelly not the best way to do it, because of performance overhead, but at least it works. Plus, you rarely use tons of canvas in the same document.

if ( /MSIE/.test(navigator.userAgent) )
{
document._createElement = document.createElement;
document.createElement = function( tag )
{
var element = document._createElement( tag );
if ( tag == “canvas” )
{
//width and height are required for initElement
element.width = 1;
element.height = 1;
G_vmlCanvasManager.initElement(element);
}

return element;
}
}