In toamna aceasta Microsoft va distribui 100.000 de exemplare din Academic Resource Kit (sau simplu ARK), un DVD continand o colectie de instrumente educationale gratis. Aceste instrumente sunt disponibile pentru descarcare gratis si pe site-ul Microsoft, dar astfel sunt disponibile si celor carora le este mai greu sa le obtina online. DVD-ul contine urmatoarele instrumente:

  • ASP.NET AJAX 1.0
  • Internet Explorer 7
  • IronPython
  • Microsoft .NET Framework 2.0 si 3.0
  • Microsoft XNA Game Studio Express 1.0 si Framework Redistributable 1.0
  • Shared Source Common Language Infrastructure 2.0
  • SQL Server 2005 (Compact Edition, Express Edition SP2 si Express Edition with Advanced Services SP2)
  • Virtual PC 2007
  • Virtual Server 2005 R2 Enterprise Edition
  • Visual Studio 2005 Express Editions si SP1
  • Windows PowerShell 1.0 pentru Windows Vista, XP SP2 si Server 2003

O parte importanta a continutul DVD-ului este rezervata resurselor precum materiale de studiu si de predare (sisteme de operare, sisteme embedded, securitate, business intelligence) ghiduri si exemple pentru C#, VB, C++, platforma .NET, Visual Studio si SQL Server. Mai precis aceste resurse includ:

  • aplicatii demo ASP.NET AJAX 1.0
  • module de training pentru Business Intelligence pe platforma Microsoft
  • aplicatii demo IronPython
  • traininguri securitate
  • aplicatii demo SQL Server 2005
  • Visual Studio 2005: 101 Samples, Code Snippets si Starter Kits
  • Windows Academic Program Curriculum Resource Kit
  • Windows PowerShell 1.0 Documentation pack
  • etc.

As mai nota de asemenea prezenta a trei interviuri (video) de cate o ora cu Anders Hejlsberg, Jim Gray si Mark Zbikowski.

Incepand cu 25 septembrie, 30.000 de exemplare ARK vor fi distribuite impreuna cu revista CHIP. Toate resursele sunt gratuite si pot fi copiate. Daca va inregistrati insa propria copie ARK originala puteti castiga un Xbox.

Mai multe despre toate acestea se pot afla la www.microsoft.ro/ark.

Hits for this post: 8007 .

There is a very interesing fiction story by Cory Doctorow published on radoronline.com called SCROOGLED. It’s about Google going evil and allowing the US Department of Homeland Security to use Google information for catching “bad guys”. A US version of “political police”, a 21st century version of Stasi and other oppressive security organizations. Or if you like, a just another version of Orwell’s Big Brother. But I would not be surprized to hear that in a couple of years the fictions will turn into reality. It worth reading!

PS: Big Brother is wathing you…

Hits for this post: 8921 .

Consider the following C++ code:

void foo(int a, int b, int c)
{
   std::cout << a << ' ' << b << ' ' << c << std::endl;
}   

int main(int argc, char* argv[])
{
   int value = 1;
   foo(value++, value++, value++);   

   return 0;
}

That looks pretty straight-forward: there is a function that takes three integer arguments and prints them to the console. In main, it is called by incrementing a variable three times. You would expect that the output was 1 2 3. But surprise: it is 3 2 1 in a debug build and 1 1 1 in a release build (Visual Studio 2005 and Visual Studio 2008). Why? Because it writes multiple times to the same memory location between two sequence points, which is undefined behavior (and I know somebody that always stresses that undefined behavior is spelled W-R-O-N-G).

A sequence point is a point in the execution of the program where all side effects from previous evaluation have been performed and no side effects from subsequent evaluation have been performed. Between two consecutive sequence points an object's value can be modified only once by an expression. The function call operator is such a sequence point, but the order of arguments evaluations is not specified (unlike Java or C# where is always performed from left to right). Thus, modifying a variable multiple times in calling a function introduces undefined behavior.

Using the /RTCu (Run-time error checks) compiler option in the debug build produces different machine code and order of evaluation.

At machine code level, the code for main in the debug build looks like this:

; 34   :    

	mov	DWORD PTR _value$[ebp], 1   

; 35   :    

	mov	eax, DWORD PTR _value$[ebp]
	mov	DWORD PTR tv65[ebp], eax
	mov	ecx, DWORD PTR _value$[ebp]
	add	ecx, 1   

	mov	DWORD PTR _value$[ebp], ecx
	mov	edx, DWORD PTR _value$[ebp]
	mov	DWORD PTR tv68[ebp], edx
	mov	eax, DWORD PTR _value$[ebp]
	add	eax, 1   

	mov	DWORD PTR _value$[ebp], eax
	mov	ecx, DWORD PTR _value$[ebp]
	mov	DWORD PTR tv71[ebp], ecx
	mov	edx, DWORD PTR _value$[ebp]
	add	edx, 1   

	mov	DWORD PTR _value$[ebp], edx
	mov	eax, DWORD PTR tv65[ebp]
	push	eax
	mov	ecx, DWORD PTR tv68[ebp]
	push	ecx
	mov	edx, DWORD PTR tv71[ebp]
	push	edx
	call	?foo@@YAXHHH@Z				; foo
	add	esp, 12					; 0000000cH

and in the release build (or without /RTCu):

; 34   :    

	mov	DWORD PTR _value$[ebp], 1   

; 35   :    

	mov	eax, DWORD PTR _value$[ebp]
	mov	DWORD PTR tv65[ebp], eax   

	mov	ecx, DWORD PTR _value$[ebp]
	mov	DWORD PTR tv68[ebp], ecx   

	mov	edx, DWORD PTR _value$[ebp]
	mov	DWORD PTR tv71[ebp], edx   

	mov	eax, DWORD PTR tv65[ebp]
	push	eax
	mov	ecx, DWORD PTR tv68[ebp]
	push	ecx
	mov	edx, DWORD PTR tv71[ebp]
	push	edx
	call	?foo@@YAXHHH@Z				; foo
	add	esp, 12					; 0000000cH   

	mov	eax, DWORD PTR _value$[ebp]
	add	eax, 1
	mov	DWORD PTR _value$[ebp], eax   

	mov	ecx, DWORD PTR _value$[ebp]
	add	ecx, 1
	mov	DWORD PTR _value$[ebp], ecx   

	mov	edx, DWORD PTR _value$[ebp]
	add	edx, 1
	mov	DWORD PTR _value$[ebp], edx

If you know a little bit assembly language you can see that in the first case value is incremented after each evaluation of foo's arguments, and in the second case that happens only after the call to foo. After the call, in both cases, value becomes 4.

To achieve the intended behavior you should write:

int main(int argc, char* argv[])
{
   int value = 1;
   foo(value, value+1, value+2);
   value += 3;

   return 0;
}

It should be quite obvious, that the same behavior is encountered if the call to foo was replaced with:

std::cout << value++ << ' ' << value++ << ' ' << value++ << std::endl;

For more information about sequence points I suggest reading:
http://en.wikipedia.org/wiki/Sequence_point
http://c-faq.com/expr/seqpoints.html
http://msdn2.microsoft.com/en-us/library/d45c7a5d(VS.80).aspx

Hits for this post: 8623 .

Virgil Griffith, a CalTech graduate student created a tool called wikiscanner that traces the IP addresses of those that edited wikipedia articles. The tool revealed that CIA modified entries about Iraq or Iran, FBI about the involvement of Iraq in the 9/11 attacks, Vatican removed a reference to a newspaper article about Sinn Fein leader Gerry Adams and modified several articles about Chatolic Saints. Companies and organizations, such as Amnesty International, Microsoft, Apple, Dell, Coca Cola, Wal-Mart removed criticism and sometimes added negative comments to their competitors wiki articles. Some of the most important changes were made by Diebold, the company that supplied the voting machines used in the 2000 elections in the US.

One that I found particulary funny came from Wal-Mart.
Original:
As of 2004, about 70% of the products sold in Wal-Mart stores have at least a component manufactured in [[China]].
Edited:
Eve today, though, Wal-Mart buys merchandise and services from more than 68,000 U.S suppliers and supports over 3.5 million supplier jobs in the United States.

And another one, again from Wal-Mart:
Original:
Wages at Wal-Mart are about 20% less than at other retail stores.
Edited:
The average wage at Wal-Mart is almost double the federal minimum wage (Wal-Mart).

This is from Boeing, on their C-17 Globemaster III (added to the article):
The C-17 is regarded by many people in the [[aviation]] industry as being the most advanced, capable, safest, and superior aircraft ever built in the history of [[aviation]]. The rugged design and unmatched performance and reliability has allowed the C-17 to become the most repected and beloved aircraft in the world.

You can read more about it here:
http://news.bbc.co.uk/1/hi/technology/6947532.stm
http://www.wired.com/politics/onlinerights/news/2007/08/wiki_tracker#
http://www.tudy.ro/2007/09/11/students-program-causes-wiki-scandal

Hits for this post: 7529 .

A WPF TabControl contains multiple items (TabItem), just like any tab control, and adding new tabs is quite easy. The following example shows a tab control with two tab items.

Empty tab with two items


    
		
			
			
		
	

However, when you try adding child controls to a TabItem you’ll notice that you can actually add one single child. The following XAML code yields an error.


    
	
		
			
			
		
		
	
   

error MC3089: The object ‘TabItem’ already has a child and cannot add ‘TextBox’. ‘TabItem’ can accept only one child. Line 9 Position 6.
The solution however is simple: use a grid or panel (Grid, UniformGrid, StackPanel or WrapPanel) to host multiple items. In the example bellow a Grid control was used to host the label and textbox.


    
	
		
			
				
				
			
		
		
	
   

The result can be seen in the following image:

Multiple items in a grid in a tab item

You can create all that from code. The equivalent in C# is the following:

public Window1()
{
        InitializeComponent();

        // create a new tab control
        TabControl tab = new TabControl();

        // create tab items and add them to the tab control
        TabItem item1 = new TabItem();
        item1.Header = "First";
        tab.Items.Add(item1);

        TabItem item2 = new TabItem();
        item2.Header = "Second";
        tab.Items.Add(item2);

        // create a new grid to host other controls
        Grid grid1 = new Grid();

        // create a label and add it to the grid childred
        Label label1 = new Label();
        label1.Margin = new Thickness(10, 10, 0, 0);
        label1.VerticalAlignment = VerticalAlignment.Top;
        label1.HorizontalAlignment = HorizontalAlignment.Left;
        label1.Width = 66;
        label1.Content = "Name";
        grid1.Children.Add(label1);

        // create a textbox and add it to the grid childred
        TextBox textBox1 = new TextBox();
        textBox1.Margin = new Thickness(80, 10, 10, 0);
        textBox1.VerticalAlignment = VerticalAlignment.Top;
        grid1.Children.Add(textBox1);

        // set the grid as the content of a tab item
        item1.Content = grid1;

        // add the tab control to the main grid of the window
        masterGrid.Children.Add(tab);
}

where masterGrid is the main grid in the window:

public partial class Window1 :
     System.Windows.Window, System.Windows.Markup.IComponentConnector {

     internal System.Windows.Controls.Grid masterGrid;



Hits for this post: 20445 .

Exactly two months ago Codexpert.ro was launched. Our intention (and when I say ‘our’ I mean me, Ovidiu Cucu and Dragos Cojocari) as founders of the site was to bring together the C++/VC++ programmers from Romania. Among others, the site offers articles on topics such as Windows Programming, Visual C++, MFC, C++, etc. We are encouraging all of you to publish articles on the site. And by publishing an article you can win a t-shirt with the codexpert.ro logo. Each month the author of the best article designated by the Codexpert team wins such a t-shirt. You can submit the articles (in Romanian) in HTML or MS Word format at articles at codexpert dot ro.

Hits for this post: 7344 .

The w3counter.com site published several statistics based on 33 milion unique visits to 5664 sites. The statistics refer to the operating system, web browser, country and screen resolution of the visitor. The king of kings of operating systems is Windows XP with 83,48%, followed by Windows 2000, Max OS X and Windows Vista. Linux and Windows 98 have both 1.34% percent. In terms of web broswers, the leader is IE 6 with 47.01%, followed IE7 with 19.19% and Firefox 2.0 with 17.51%.

You can see the whole charts here: http://www.w3counter.com/globalstats.php.

Hits for this post: 8212 .

Let me spoil it for you: it’s not an actually class designer, because it’s only one way. It should have been called Class Viewer, but probably it get’s more publicity if it’s called designer.

Let me explain how to us it. Of course, you need to have some source code for which you want to see the class diagrams. Just to exemplify, let’s consider the following code:

enum TriangleType {Isosceles, Rectangular, Obtuse, Echilateral};

struct Point
{
	int X;
	int Y; 

	Point(int x = 0, int y = 0): X(x), Y(y)
	{}
};

class Shape
{
public:
	virtual void Draw() = 0;
};

class Circle : public Shape
{
	int Radius;
	Point Center;
public:
	Circle(int radius, const Point& center):
	  Radius(radius), Center(center)
	  {}

	int get_radius() const {return Radius;}
	void set_radius(int radius) {Radius = radius;}

	Point get_center() const {return Center;}
	void set_center(const Point& center) {Center = center;}

	virtual void Draw()
	{
	}
};

class Triangle : public Shape
{
	TriangleType Type;
	Point Vertices[3];
public:
	Triangle(const Point& p1, const Point& p2, const Point& p3)
	{
		Vertices[0] = p1;
		Vertices[1] = p2;
		Vertices[2] = p3;
	}

	TriangleType get_type() const {return Type;}
};

To be able to view a diagram for the classes, structs, and other entities, you must add a Class Diagram file (has the extension .cd). You can either do that from the menu (Project > Add new Item), Solution Explorer or simply by pressing Ctrl + Shift + A. The new file will be opened and you’ll have to drag and drop items from the Class View or the Solution Explorer.

Class View in Visual Studio 2008

When you drop classes that are part of hierarchies the arrows indicating the relationships are automatically shown.

Example Class Diagram for C++ classes

If you double click on a member (function, field, etc.) you will be directed in the code where it is defined. If you right-click on a class, you’ll get a menu with commands, but, as I was saying earlier, there is no possibility to add new elements from the designer.

Context menu in class designer

Class details are shown in an additional pane, and of course, they are also read-only.

Class details for the components of the class diagram

You can also use the Class Designer toolbar for sorting elements, changing the layout or zooming.

I can only hope this is only a first step and that the next version of Visual Studio will feature a real designer for C++ too.

Hits for this post: 15916 .

Beyond Compare is an advanced file and folder comparison utility for Windows, extremly helpful for developers for visualizing changes in code. A good thing about it is it’s extensibility through plug-ins. Plug-ins are enabled only if you use a registered version of BC2. I decided to write such a plug-in myself for comparing the dependencies of two executables (whether EXE, DLL, SYS, OCX or anything else that is a PE, regardless the extension). The plug-in is free both for commercial and non-commercial usage. Installing only implies copying the plug-in file to the Beyond Compare folder.

Here are several screenshots:

You can read more about it here.

Hits for this post: 4033 .

Microsoft has released today Silverlight 1.0 for Windows and Mac, a cross paltform, cross browser plug-in for building richer web applications. You can read more about the features on Scott Guthrie’s blog or visiting the official page.

Due to a partnership, with Microsoft Novell will create a 100% compatible run-time for Linux, called Moonlight. It will run on all Linux distributions and support FireFox, Konqueror and Opera browsers.

And if you thought that’s all, Silverlight 1.1 is also comming. Uff, they can’t be stopped!

Hits for this post: 4841 .