Thursday, 25 September 2008

ENUM in C

I never know ENUM in C can be used in this way.

enum
{
CT3ID = 0,
CT3_HD,
CT3_IM,
CT3_MACHINE,
CT3FORM_ID,
CT3FORM_OUTPUT,
CT3FORM_RETURN,
CT3_REGION,
CT3_POLAR,
CT3_INAIR,
CT3_OUTLINE,
CT3_OPTIMISE,
CT3_COMP,
};

int main(){
printf("%d\n",CT3_IM);
return 0;
}

Friday, 5 September 2008

Document with Doxygen

This is a quite cool tool for your documentation.

It generates the documents based on the structure of the software and the comments in the codes. Of course there are some specific ways to comment in the codes which makes the generated codes more beautiful but it still works with the normal comments in the codes.

You can download it from its official website, Doxygen, or install it from Synaptic Package Manager if you are using Ubuntu. You may also like to install Graphviz to let Doxygen to generate more advanced graphs.

It is also easy to use Doxygen. Before it generates the documentation, it asks for a configuration file, which also can be generated automatically.

Use command
doxygen -g

It generates a template. And then you need to edit this file for your own purpose.

Set your project name first:
PROJECT_NAME = "myproject"

Set following to YES:
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES


If you like treeview, switch it on by setting:
GENERATE_TREEVIEW = YES

If you like the graphs, set:
HAVE_DOT = YES
CALL_GRAPH = YES

By default, it generates html and latex, but you also can generate other formats and the options are in the template file.

You can change the switches as you like, and it will show you the different features. Once you finish all settings, let Doxygen do the rest.
doxygen

It generates the documents you want!

JUnit testing in netbeans

Netbeans has JUnit test, which allows you to create your own test packages.

"Tools -> Create JUnit Tests" will generate a few Java tests in "Test packages". You either can use automatically generated tests to test your classes or write more test classes for your own tests.

Here is a very good example.

Tuesday, 2 September 2008

classes in C#

Class is used in C# as well as C++.

In the book,'Beginning Visual C== 2005', it is not very well described. I get lost in chapter 8 and chapter 9.

You might have to do some web search to understand what is described in this book.

Like C++, C# also has the abstract class by adding a keyword 'abstract' in front of the class name. Sealed class is new in C#, which is not inheritable. Sealed can avoid being override.

Interface is allowed in C#, which won't allow access modifiers like public, private, protected etc. There is no code body in interface and no field member as well.