Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

2007-09-17

For young programmers only...

My little sister has started to study C++ at University.

She is in her second year but in their tasks with big black letters is required to give human readable names to variables and to module code. It's strange... evidently, Pascal at the first year didn't school what is good and how to make job easy first of all to yourself.

I've installed Eclipse to my sister, told about Unit testing a little. It's convenient - to write 5 or 10 lines of code right away tests are running for the checking. It's almost REPL. Testing is a guarantee of not turning program text into one long main function. And if something wrong happens then a couple of key pressing brings you to the debugger to the required place with required data.
It seemed to me she liked it.


I liked to demonstrate the popularity of the approach and was surprised by a huge list of frameworks for tests creation.

As for purpose for student projects there is a tiny file QuickTest.h.

if one is to judge nothing except of three elementary macros QT_TEST(testName),QT_CHECK_EQUAL(value1, value2), and QT_RUN_TESTS is required

P.S The first students C++ sounds in haskell about as follows:

minUncommonWord :: String -> String -> String
minUncommonWord s1 s2 =
foldl1 (\a b -> if length a < length b then a else b)
[x | x <- words s1, x `notElem` words s2]

2006-07-25

MFC vs WinForms vs SWT

All that you need to know to embed an Office application into:

MFC
http://www.rsdn.ru/article/com/xoffice.xml and http://www.rsdn.ru/article/com/autoatl.xml
two articles in about 10-12 pages - beat in a drum to adjust a project


WinForms
http://blogs.gotdotnet.ru/personal/k_savelev/PermaLink.aspx?guid=6d39ad7d-d1ae-4daf-8ce2-9b881ca7091a
A heap of links, ready external component and therefore a little headache when installing application to client


SWT
http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/WordOLE.htm
a couple strings of code and everithing works from the box

2006-06-08

Setter returns this

I've spied in new Eclipse a new feature or even pattern of beautiful code.

Void is useless. When every expression has a value it's cool.

/**
* This class provides a convienient shorthand for creating and initializing
* GridData. This offers several benefits over creating GridData normal way:
* The same factory can be used many times to create several GridData instances
* The setters on GridDataFactory all return "this", allowing them to be chained
*/


For example:
// Example : Typical grid data for a wrapping label
// GridDataFactory version
GridDataFactory.fillDefaults()
.align(SWT.FILL, SWT.CENTER)
.hint(150, SWT.DEFAULT)
.grab(true, false)
.applyTo(wrappingLabel);

// Equivalent SWT version
GridData wrappingLabelData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
wrappingLabelData.minimumWidth = 1;
wrappingLabelData.widthHint = 150;
wrappingLabel.setLayoutData(wrappingLabelData);

2005-12-12

Eclipse: Testing the multi-thread code.

A short snippet:

public void setUp() throws Exception {
finished = false;
}

public void testSomething() throws Exception{
new Thread(){
try{
doSomethingLongAndLogIt();
} finally { finished = true; }
}.start();

while(!finished && !Display.getCurrent().readAndDispatch()){
display.sleep();
}
}


There, it seems to be the full Eclipse emulation. Now one can be sure that inside doSomethingLongAndLogIt() method all communications with UI are going within Display thread.

Can't do without 'while' because the workbench might be already closed before it comes to UI calls.