I'm currently working as a network administrator in a small real estate agency. However during this financial crisis my agency encounters great difficulties and management need to cut salaries. There are also some positional movemevements between workspaces. During these movements I moved to the workplace of a receptionist. We have two workplaces for them but there is only one receptionist at a time. However she couldn't do all her work always alone so now I help out receptionist to do their because. That's not very hard for me, but is a great experience for me and help to the receptionist.
Sunday, April 19, 2009
Saturday, March 07, 2009
NonLatin symbols in MySQL
While developing my recent program in databases I found that my program on C# doesn't work correctly with onlatin chracters. It happend with recent version MySql.Data connector assembly from MySql. But there was no such problem when I've used old ByteFX.Data assembly. But old connector has some other error (at least when it works with server 5.2). After digesting a problem I found how to make my program work correctly with nonlatin characters. The solution is obvious: program must use a unicode, so here I'll show that to change in configurations of database and cliet software.
- Encoding of connection must be Unicode. For this in connection string add this parameter: CharSet=utf8;
- Encoding of database also must be Unicode. In my.cnf file following variables must be set to utf8: default-character-set and chracter-set-server
- However this helped me only on Linux machine, on Windows MySQL crashed after string with such prameters. So on Windows I found another possible solution: specify charset only for database: CREATE DATABASE dbName CHARACTER SET = utf8;. This solution is more flexible than previous because it affects only your database and not whole server.
Tuesday, December 30, 2008
Loading Satellite Assemblies From Custom Path
One thing that distracted me in default localization technologies in .NET was that culture-specific folders are placed on one level with executable file. So if binary files lie in the root of application folder, as a result en-US, ru-RU and other folders are mixed with something like Data, Resources and others. Not good layout of folders.
By default .NET searchs for dependendent assemblies in directory of executable file in and in GAC. But developer can specify additional directories in exe.config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="./Lib" />
</assemblyBinding>
</runtime>
</configuration>
There are some limitations: no absolute paths and no walking up the directory tree ( ..\Lib will not work). Recently I've tested this for satellite assemblies and I have found that frameowork searchs in provided directories for satellite assemblies. So I can make something like that:
Main.exe
Main.exe.config
I18N\en-US\Main.resources.dll
I18N\ru-RU\Main.resources.dll
However as I've mentioned if I move Main.exe to Bin directory this will not work correctly. I know 2 possible ways to override this:
- codeBase element in config file, but it requires absolute path
- Adding handler for ApplicationDomain.AssemblyResolve event which will return whatever you want.
Friday, December 26, 2008
WPF Application Doesn't Load Resources in IDE
While working with WPF application I've experienced a problem: library assembly requests resource from System.Windows.Application which is defined in executable assembly in XAML file and this resource isn't loaded while I work in IDE! If I debug application all works fine, but XAML designer doesn't load resource, library method fails and window isn't rendered in designer. Of course I still can work with pure XAML and mostly I do so, but I prefer to have an ability to quickly watch results of my work in designer. So to workaround this problem I changed failed method so he will return not fully correct value which will not depend on application resources.
Wednesday, December 24, 2008
Google Chrome Can Prevent JavaScript From Generating Dialogs
Google Chrome has a wonderful feature: if one element in web page call one JavaScript function multiple times from them second time Chrome adds a checkbox to stop future dialogs to appear.

This is a very handy feature because some pages may generate infinite number of dialogs and because it locks browser you couldn't close tab with it (at least in Firefox). The only way to deal with such a problem in FF is to close the whole application. And if it setted up to load pages from previous session on start you could have some problems! Of course there are still possible ways to prevent browser from loading this page again but it will require an extra effort.
Monday, August 25, 2008
Enum as a ComboBox.ItemSource in WPF
Currently I'm working on my first project with WPF and study it on a practice. In this short article I want to give example how in XAML make ComboBox list values (or names) of enum.
ItemsControl.ItemsSource uses IEnumerable as source of items to list in ItemsControl (which ComboBox is derived from). In C# you can do this very simply:
comboBox.ItemsSource = Enum.GetNames( typeof( Dock ) );
You can do the same using only XAML:
In this sample ObjectDataProvider is a wrapper for a method call and to assign this data provider to ItemsSource binding is used. As you can see XAML version of requires more lines of code. But it is usefull if development team strictly follows the rule that interface view must be defined in XAML without code on C#.
ItemsControl.ItemsSource uses IEnumerable as source of items to list in ItemsControl (which ComboBox is derived from). In C# you can do this very simply:
comboBox.ItemsSource = Enum.GetNames( typeof( Dock ) );
You can do the same using only XAML:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="ItemsSource test" Height="70" Width="150" WindowStyle="ToolWindow">
<Window.Resources>
<ObjectDataProvider x:Key="DockNames"
MethodName="GetNames" ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type Type="{x:Type Dock}" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</Window.Resources>
<Grid>
<ComboBox Margin="5" Width="120" Height="23" Name="comboBox"
HorizontalAlignment="Left" VerticalAlignment="Top"
ItemsSource="{Binding Source={StaticResource DockNames}}"
SelectedIndex="0">
</ComboBox>
</Grid>
</Window>
In this sample ObjectDataProvider is a wrapper for a method call and to assign this data provider to ItemsSource binding is used. As you can see XAML version of requires more lines of code. But it is usefull if development team strictly follows the rule that interface view must be defined in XAML without code on C#.
Wednesday, July 16, 2008
Setting Type of Paper in Docbook
Some months ago I was setting up Fop on my computer and found that Docbook XSL converts files from Docbook to Fop format with setting paper to USLetter while I need A4 paper. I didn't knew how to set type of paper for XSL, spent much time exploring Docbook XSL and as a result changed something in them and get paper format A4. I don't remember what I have done but it worked. However I needed to format disk of that computer so lost this settings.
After some digging I found that setting type of paper is very simple: to XSL transformator send parameter paper.type with value of you paper type. If you use Fop and runs it with docbook file and XSL transformation in commandline arguments specify: -param paper.type A4.
After some digging I found that setting type of paper is very simple: to XSL transformator send parameter paper.type with value of you paper type. If you use Fop and runs it with docbook file and XSL transformation in commandline arguments specify: -param paper.type A4.
Monday, July 14, 2008
Firefox 3 Instant Crashes
I use Mozilla Firefox as my browser. I started from version 2, when I migrated from Opera because it wasn't supported by some Google web applications. Version 2 frustrated me with periodical freezes - they lasted for about 30 seconds and then FF came back to live. Now I'm using FF 3. There was a lot of buzz about it. I found that it has some new valuable features that still keep me from downgrading to FF 2. But FF 3 on my computer crashes several time per day. At first it was happening at notebook with Vista. So I had some suggestions that this are the problems with OS. But I found that these crashes happen on desktop computer with XP. Moreover recently I reinstalled OS on notebook and firefox crashes on almost "clean" OS also.
I don't use any *not very popular* extensions. Even more - I disabled them all, but FF 3 continue to crash. May be I should disable some plugins? I don't know. And I didn't heard any significant buzz about "FF crashes on my PC every hour!" so I come to conclusion that these are problems with my environment (Russia, ISP, some software on PC, anything else). But Opera works finely. So I have three ways:
I don't use any *not very popular* extensions. Even more - I disabled them all, but FF 3 continue to crash. May be I should disable some plugins? I don't know. And I didn't heard any significant buzz about "FF crashes on my PC every hour!" so I come to conclusion that these are problems with my environment (Russia, ISP, some software on PC, anything else). But Opera works finely. So I have three ways:
- With great patience continue to use FF 3
- Downgrade to FF 2 (remember the buzz "downgrade to XP from Vista")
- Use another browser: Opera, Maxthon, IE, Safari.
But... I've been waiting for FF 3 and wanted to use it. And now I found it to be a big piece of crashes for me.
Simple (and funny in some way) recursy in C#
While recent work with reflections in .NET I found a funny way for recursion:
using System;Getter of property gets PropertyInfo of itself and calls GetValue method.
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
Program p = new Program();
Console.WriteLine(p.Property);
}
public String Property {
get {
Console.WriteLine("Getting property, counter {0}.", counter++);
return (String)this.GetType().
GetProperty("Property").GetValue(this, null);
}
}
int counter = 0;
}
}
Thursday, June 19, 2008
Firefox 3 — am I the only one who is disappointed?
Firefox 3 was released yesterday and there was a great buzz about it. Mozilla announced special "Download day". As I have read there was about 7.5 million downloads of FF yesterday. I've started using it from Beta 6. And I have to say that I couldn't share the joy about FF of others. No, I don't speak new features: they are good and I love new address bar which search not only through addresses but also through titles of pages. I'm speaking about FF bugs. FF crashes regularly on my computer. Most of problems occur on AJAX sites like GMail or Todoist after closing the tab with this site (though it doesn't crash always after closing this site). It seems that this is one error which causes crashes on my computer.
Another issue happened with bookmarks: at one day FF deleted all my bookmarks (I don't remember but may this already happened to me with FF 2). In itself this isn't a dramatic problem: FF creates daily backups of bookmarks and I also have done them in JSON format. But... FF refused to restore backup and said there is an error. Luckily final release of FF 3 was able to import my bookmarks :).
There are also some other issues with Internet (some pictures are not loaded from first few attempts and some pages also) but I'm not sure they are caused by FF because it seems other browsers also suffer from it.
But the bug with GMail really disturbs me. May be it is caused by any specific setting or software on my computer but I've made some new clean installs of FF and this didn't helped. And FF after crash doesn't say something meaningful about the reason of error: if it is caused by any plug-in or extension why not say this me so I'll disable it?
In coclusion I have to say that FF 2 had some really disturbing bug: sometimes it became frozen and doesn't respond to my actions but after about half a minute it came bake to normal work cycle. It seems in FF 3 this bug is fixed. But... it also seems that some new bugs came into it. So now I use Prism to work with GMail and Todoist. But Opera with it's new release 9.50 gets a new chance on my computer :)
Another issue happened with bookmarks: at one day FF deleted all my bookmarks (I don't remember but may this already happened to me with FF 2). In itself this isn't a dramatic problem: FF creates daily backups of bookmarks and I also have done them in JSON format. But... FF refused to restore backup and said there is an error. Luckily final release of FF 3 was able to import my bookmarks :).
There are also some other issues with Internet (some pictures are not loaded from first few attempts and some pages also) but I'm not sure they are caused by FF because it seems other browsers also suffer from it.
But the bug with GMail really disturbs me. May be it is caused by any specific setting or software on my computer but I've made some new clean installs of FF and this didn't helped. And FF after crash doesn't say something meaningful about the reason of error: if it is caused by any plug-in or extension why not say this me so I'll disable it?
In coclusion I have to say that FF 2 had some really disturbing bug: sometimes it became frozen and doesn't respond to my actions but after about half a minute it came bake to normal work cycle. It seems in FF 3 this bug is fixed. But... it also seems that some new bugs came into it. So now I use Prism to work with GMail and Todoist. But Opera with it's new release 9.50 gets a new chance on my computer :)
Monday, May 26, 2008
NAnt over MSBuild
While working on my C# projects I found it useful for me to start using a build tool. Visual Studio builds assembly files, but many other tasks such as generating documentation are not part of assembly build and can not be just added to "pre-build" and "post-build" actions. So I've decided to use NAnt.
After some working with NAnt I decided to try MSBuild. There were some reasons for that: MSBuild is a part of .NET Framework so there is no extra dependencies; moreover it provides a good integration with project files generated by VS. But after a day of converting my NAnt project to MSBuild I've decided to return back to NAnt. There a plenty of reasons for that, which I found during this day.
The most important (for me) is that almost all settings to MSBuild tasks are set through attributes. The question "What to use: attributes or elements?" is long living and still doesn't have a clear answer (e.g. see this and this articles), but I found it a little inconvenient to set up all parameters of task through attributes. I won't speak here about what as I think should be element or property, but properties with long length data doesn't look good (e.g. lists of files).
In NAnt I feel very comfortable with setting tasks up through elements and attributes and in most cases I think that type of XML node is chosen right for property. And what is more NAnt provides and ability to define in custom tasks to define what property should be: attribute or element, while MSBuild follows it's convention and all properties are set up through attributes. Quite inflexible, though it removes a headache of deciding of type of node.
Secondly writing long lists or properties is a little inconvenient in VS: I prefer to have lines of code not very long and I need to write attributes on several lines. And if I press Enter after a property on a new line VS doesn't suggest me a list of possible items. It is need to start typing on previous line and press Enter only after writing property in editor. Of course I can write all in one line and use Wrap lines ability of text editors, but I prefer not to do so.
All-in-all I've returned to NAnt as a build tool. Sometimes I write additional tasks for it (those that are not in NAnt.Contrib) which gives me an ability to use not only for application builds but for other purposes.
Links:
After some working with NAnt I decided to try MSBuild. There were some reasons for that: MSBuild is a part of .NET Framework so there is no extra dependencies; moreover it provides a good integration with project files generated by VS. But after a day of converting my NAnt project to MSBuild I've decided to return back to NAnt. There a plenty of reasons for that, which I found during this day.
The most important (for me) is that almost all settings to MSBuild tasks are set through attributes. The question "What to use: attributes or elements?" is long living and still doesn't have a clear answer (e.g. see this and this articles), but I found it a little inconvenient to set up all parameters of task through attributes. I won't speak here about what as I think should be element or property, but properties with long length data doesn't look good (e.g. lists of files).
In NAnt I feel very comfortable with setting tasks up through elements and attributes and in most cases I think that type of XML node is chosen right for property. And what is more NAnt provides and ability to define in custom tasks to define what property should be: attribute or element, while MSBuild follows it's convention and all properties are set up through attributes. Quite inflexible, though it removes a headache of deciding of type of node.
Secondly writing long lists or properties is a little inconvenient in VS: I prefer to have lines of code not very long and I need to write attributes on several lines. And if I press Enter after a property on a new line VS doesn't suggest me a list of possible items. It is need to start typing on previous line and press Enter only after writing property in editor. Of course I can write all in one line and use Wrap lines ability of text editors, but I prefer not to do so.
All-in-all I've returned to NAnt as a build tool. Sometimes I write additional tasks for it (those that are not in NAnt.Contrib) which gives me an ability to use not only for application builds but for other purposes.
Links:
- NAnt official site: http://nant.sourceforge.net/
- NAnt.Contrib (additional tasks): http://nantcontrib.sourceforge.net/
- MSBuild reference (as I found on practice links to MSDN often become broken after some time): http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx
- MSBuild community tasks (additional tasks not included in official release): http://msbuildtasks.tigris.org/
Labels:
automation,
build,
microsoft,
NAnt,
programming,
review,
visual studio,
workspace
Wednesday, April 23, 2008
RescueTime
For a month I'm using a web-based application RescueTime. It counts the usage of software and websites on computer so you can find which application you use the most. What is more RescueTime provides ability to assign tags to applications to group them, and to assign efficiency score to each tag. It draws some diagrams shiwing your efficienty so it's much easier to find out whether your are doing something useless to your or perform a productive tasks. And moreover in RescueTime you can create goals on using software, e.g. "Spend less than 1.5 hours per day on games." or whatever can be interpreted as "use something less/greater than..."
I think RescueTime is rather an interseting application that could help better manage time spent with computer.
I think RescueTime is rather an interseting application that could help better manage time spent with computer.
Saturday, March 29, 2008
MyMiniCity.com
On site www.myminicity.com everyone without registration can start its own minicity. Though there aren't many ways to control your city: the only thing you can do is to post links to the page with your city. Each visit of page increases population of city. As with city growth some new features appear: Industry, Transport network, etc. Each has its own link to invest in development of this city infrastructure. As a result city from small village can grow to the big megapolis.
That's my mini city: http://kaaglecity.myminicity.com/
That's my mini city: http://kaaglecity.myminicity.com/
Thursday, March 20, 2008
I'm in the Internet again!
Hurray! After moving to new flat I've finally connected to the Internet again. I have a lot of work now but hope soon I'll continue to write to my blog.
Monday, December 24, 2007
New experience in C#
During last week I was doing rather interesting work: programming on C# my own Windows control similar to TextBox class. I was programming a text editor and needed to make color syntax. But RichTextBox allows to change color and other properties only for selected text, that isn't good. So I've decided to try to make my own control to work with text. Now it is rather good and implements some common functions. The most important is that I've understand that this is *really* possible, not only on paper. And through developing this control I've experience many difficulties. So now I want to write something like "How to make TextEditorControl on C#". Of course not on a professional level but I think I need to write down all this experience, while it fresh in my mind. So in future it will be easier for me to implement similar things. Moreover while writing I will unconsciously analyze what I'm writing and may be will get better solutions or completely new ideas.
Furthermore I want to write similar article about making tool to explore .NET assemblies using reflections. I already have basic implementation of such a tool and it need more polishing.
Bye.
Furthermore I want to write similar article about making tool to explore .NET assemblies using reflections. I already have basic implementation of such a tool and it need more polishing.
Bye.
Sunday, December 09, 2007
Funny Bug in Visual Studio 2008 Beta
While uninstalling MS Visual Studio 2008 Beta 2 I found one funny bug.

Trivial message from uninstaller that indicates that one or more of the files or directories to remove are occupied. The only thing to do is too close this application and click Retry. If this doesn't help, well click Ignore and hope this will not have any negative effect. But... what the heck is application named 4812? Well, it's may be not a name but an ID of process so I open Task Manager and look up for a process with ID 4812. Here it is!

Oops. It is a setup application itself blocked something and couldn't delete it. I tried to click "Retry". And it was a successful attempt process of uninstaller continued.
I even could make a guess why this short story happened but had a good final. While checking files/directories to remove setup.exe locked them. According to my guess releasing of lock is placed in destructor. When message appeared object that locked files was "deleted" but garbage collector wasn't called until that moment so hadn't called destructor. While I was thinking about this problem and taking screenshots garbage collector was invoked and called destructor that released locks. Of course this guess can be true only if setup.exe is using garbage collector. Well, as Andrew Troelsen in his book about C# suggested it is better to manually call method Dispose and release all resources when they already could be released and don't leave this job to GC, which is unpredictable.
Of course my suggestion is only a suggestion, but I think it is rather useful to try to explain bugs in not your applications even if source code is inaccessible.

Trivial message from uninstaller that indicates that one or more of the files or directories to remove are occupied. The only thing to do is too close this application and click Retry. If this doesn't help, well click Ignore and hope this will not have any negative effect. But... what the heck is application named 4812? Well, it's may be not a name but an ID of process so I open Task Manager and look up for a process with ID 4812. Here it is!

Oops. It is a setup application itself blocked something and couldn't delete it. I tried to click "Retry". And it was a successful attempt process of uninstaller continued.
I even could make a guess why this short story happened but had a good final. While checking files/directories to remove setup.exe locked them. According to my guess releasing of lock is placed in destructor. When message appeared object that locked files was "deleted" but garbage collector wasn't called until that moment so hadn't called destructor. While I was thinking about this problem and taking screenshots garbage collector was invoked and called destructor that released locks. Of course this guess can be true only if setup.exe is using garbage collector. Well, as Andrew Troelsen in his book about C# suggested it is better to manually call method Dispose and release all resources when they already could be released and don't leave this job to GC, which is unpredictable.
Of course my suggestion is only a suggestion, but I think it is rather useful to try to explain bugs in not your applications even if source code is inaccessible.
Wednesday, December 05, 2007
The Dialog with Myself
I've already written that what I want to change in myself. Surely it's not easily to change myself (at least for me). And I think that to put off bad habit may I need to have split personality in some way. And one of that personalities must say "That is bad, don't do it" when it is needed. May be this should be something like fight between good and evil, though I'm not sured that someone in me is really good or evil. May be both of them should help each other. There must be a dialog inside of person, dialog with himself. But how to speak with myself? The most obvious way for is to have to "Me's". May be this a psycho disease? But to learn on fault your need to have someone who will point on them, and nobody as you can now what you do and why you do.
Visual Studio 2008
In the end of November MS released the new version of its IDE Visual Studio 2008. I've used Beta version already. It that post I've written that first impression was that is is very buggy, and later practice showed that there are some mistakes. I usually had some problems with Intellisense and IDE crashed. I have to note that I used Professional Edition.
Now I'm using Express Edition. I'm not so rich to buy IDE now, so use free edition. Of course it's not so functional as Pro version and for each language (C#, C++, VB.NET, Web development) there is it's own IDE. However I'm currently programming only on C# so this is not a big problem for me. Visual Studio is rather comfortable IDE (especially comparing to Turbo C we have in unversity :(. The problem is that it can't be used for editing all types of files I need with syntax coloring. So for editing files such as Nullsoft installation scripts, Python files and others I use PSPad. But for C# Visual Studio is much more preferable because autocompletion, Intellisense and many other small but very useful features.
One interesting note about Visual Studio: with IDE many other components are installed (SQL Server Compact, etc.). But uninstalling them is a manual operation. Not rather comfortable.
I have to say that Visual Studio is one of my favorite MS products and I haven't a lot of complains about it.
Now I'm using Express Edition. I'm not so rich to buy IDE now, so use free edition. Of course it's not so functional as Pro version and for each language (C#, C++, VB.NET, Web development) there is it's own IDE. However I'm currently programming only on C# so this is not a big problem for me. Visual Studio is rather comfortable IDE (especially comparing to Turbo C we have in unversity :(. The problem is that it can't be used for editing all types of files I need with syntax coloring. So for editing files such as Nullsoft installation scripts, Python files and others I use PSPad. But for C# Visual Studio is much more preferable because autocompletion, Intellisense and many other small but very useful features.
One interesting note about Visual Studio: with IDE many other components are installed (SQL Server Compact, etc.). But uninstalling them is a manual operation. Not rather comfortable.
I have to say that Visual Studio is one of my favorite MS products and I haven't a lot of complains about it.
Labels:
C#,
C++,
microsoft,
programming,
pspad,
review,
visual studio,
workspace
Saturday, November 24, 2007
What I Don't Like in Myself
There are some thing that I do not like in myself. Often I'm not tolerant to others in relations with other people. I sometimes behave too angry towards people around me. And moreover I'm took weak physically, especially in strength of arms.
What do I do to surpass these problems of my nature? Firstly, to become stronger I try to do everyday exercise with weights. And I think that gave me some positive result in strength of arms. However I have some problems with strength of will in aspect of physical exercises : in fact I don't do them everyday but usually one time in two or three days. That's not good. And I still continue to make them regularly everyday. Now that's not a problem of physical strength but of strength of will above laziness.
Furthermore how do I improve my tolerance to others? That's far more difficult question than just physical strength. I think the reason for angriness toward others is in some way linked to my warlike character and to that I think there are some traits in people which couldn't be tolerated. About this I'll try to write in future. And now I have to say, that I try, really try to tolerate other people while they act in way I do not like. Sometimes I say them, that I don't like what they do, and wait whether my word will have any effect. And I keep waiting for good changes. But sometimes... behavior of one goes beyond borders which as I think are acceptable.
Or I'm just tired of them and can't keep dam of my patience. So then comes something that is like affect: I'm very-very-very angry and behave in a way I don't like after that.
So what to do? I think, just try to understand others imperfection, accept them as they are (but may be not accept their bad traits?). It is better to have a war with own bad traits than with others', it is easier to make better yourself, than the others, but others sometimes need help to become better.
What do I do to surpass these problems of my nature? Firstly, to become stronger I try to do everyday exercise with weights. And I think that gave me some positive result in strength of arms. However I have some problems with strength of will in aspect of physical exercises : in fact I don't do them everyday but usually one time in two or three days. That's not good. And I still continue to make them regularly everyday. Now that's not a problem of physical strength but of strength of will above laziness.
Furthermore how do I improve my tolerance to others? That's far more difficult question than just physical strength. I think the reason for angriness toward others is in some way linked to my warlike character and to that I think there are some traits in people which couldn't be tolerated. About this I'll try to write in future. And now I have to say, that I try, really try to tolerate other people while they act in way I do not like. Sometimes I say them, that I don't like what they do, and wait whether my word will have any effect. And I keep waiting for good changes. But sometimes... behavior of one goes beyond borders which as I think are acceptable.
Or I'm just tired of them and can't keep dam of my patience. So then comes something that is like affect: I'm very-very-very angry and behave in a way I don't like after that.
So what to do? I think, just try to understand others imperfection, accept them as they are (but may be not accept their bad traits?). It is better to have a war with own bad traits than with others', it is easier to make better yourself, than the others, but others sometimes need help to become better.
Labels:
problems solving,
self discipline,
society,
thoughts
Sunday, November 18, 2007
Relaxation day
Sometimes there are days when I don't do almost anything. I just read something for fun, play games. I want to do something but in fact can't make me to do anything. I think that's are relaxation days. One such day was today.
Sunday, November 11, 2007
This week
Previous holidays was rather productive: I've made a lot of thing especially in programming and in study. That was a three good days. After that I've got not very good working week: I've studied a lot, made homework but that took a lot of time, I was tired and bored toward evening. As a result I haven't done much progress in my tasks.
So now are another holidays. This day wasn't rather productive, though I've made more than on workdays. And moreover my favorite football team FC Zenit became a champion of Russian Premier League!!! :)
Hope, next days (I haven't got study hours on Monday) will be more productive.
So now are another holidays. This day wasn't rather productive, though I've made more than on workdays. And moreover my favorite football team FC Zenit became a champion of Russian Premier League!!! :)
Hope, next days (I haven't got study hours on Monday) will be more productive.
Pragmatic Programmer
Pragmatic Programmer is a classic book for many programmers. It has valuable advices and techniques, which aren't linked to any language or environment, they are applicable to programming as it is, without any additional conditions.
I've read it in September and was highly delighted with it. I think there are two main things I've got from that reading: serious attention to automation and taking responsibility about your decision and having proud of your work.
I've read about automation before PP in "Code Complete" and understood it advantages, but didn't use it actively. Though in PP I haven't read anything new about it I've understood it better and decided to use it more.
Moreover authors of PP actively convince programmers to proud of their work, not think "it is the best program in the world!" but always left your sign on it, never lie that "it's not mine!", taking responsibility about its errors. It is applicable not only to programmers, but also other people who's work is about crafting something new.
I highly recommend PP to all programmers, who haven't read it already and for those who already has a copy of it to read it again, I'm sure you still can get something new from it. :)
I've read it in September and was highly delighted with it. I think there are two main things I've got from that reading: serious attention to automation and taking responsibility about your decision and having proud of your work.
I've read about automation before PP in "Code Complete" and understood it advantages, but didn't use it actively. Though in PP I haven't read anything new about it I've understood it better and decided to use it more.
Moreover authors of PP actively convince programmers to proud of their work, not think "it is the best program in the world!" but always left your sign on it, never lie that "it's not mine!", taking responsibility about its errors. It is applicable not only to programmers, but also other people who's work is about crafting something new.
I highly recommend PP to all programmers, who haven't read it already and for those who already has a copy of it to read it again, I'm sure you still can get something new from it. :)
Thursday, November 01, 2007
My Own Scripting Language for .NET Framework
I've wrote about dynamic languages and that they are good at combining already written components into full application. As I'm programming at C# now which isn't very laconic and simple language I have an idea of scripting language for .NET Framework. There are a lot of languages ported on it, among them: Python, Ruby, etc. But I still has an idea of implementing my own interpreter. It will be very useful in implementation of DSLs for my own applications. At least if I wouldn't be .NET programmer I'll get a lot of experience in developing interpreters. It's not a simple task but very interesting and useful.
Currently I'm working on library of common classes for .NET. I wasn't pleased with standard implementation because I didn't find a way for customization, e.g. changing path of saving configuration file.
Also there is a LogFile class, which implements DebugListener abstract class. I attach it to Debug to write down messages about errors.
P.S. I've passed all laboratory works in programming and think now I'll have more time for non-study programming.
Currently I'm working on library of common classes for .NET. I wasn't pleased with standard implementation because I didn't find a way for customization, e.g. changing path of saving configuration file.
Also there is a LogFile class, which implements DebugListener abstract class. I attach it to Debug to write down messages about errors.
P.S. I've passed all laboratory works in programming and think now I'll have more time for non-study programming.
Monday, October 29, 2007
My reason for blogging
Why I blog? There are some reasons, but they are connected with each over:
- Develop my skills in English language — many people think I'm rather good in English, but I think there is enough space for me to develop in this direction. May be my friend think that I'm good at English but this comes mush more from that they know it worse than me, not from that I'm good.
- Develop my speech writing capabilities. This is close to previous but it isn't connected to particular language. This is ability to shape idea into clear explanation. And the language is a tool to express it to others.
- Develop my mind. When I write about something I think about it. And what is more I watch this from different angles and have different points of view on it. As a result my brain works and moreover I could make my opinion about something having different points of view as a base. Overall blogging trains my brain so it will give ideas. And this links to previous reason: these ideas needs to be shaped into explanation.
- Specially for programming blog: by blogging I share my knowledge (if anybody is interested in it), that will help myself not to forget results of my programming experiments and of course as in previous reason while wring post I analyze topic and shape my opinion and develop me programming mind.
[Update] Well, as you see sharing knowledge isn't my goal. But I think that is a very good use of blogs. So in future I think I'll add this to my reasons. Probably after I'll train myself in English :-)
Winter session exams: Programming is already passed
It's not a secret that I love programming :). And I'm rather good at it. So I've decided not to wait end of semester to pass all laboratory works on programming and passed last this Saturday! 9 works in 8 weeks — good result I think. And I won't need to pass exam on it. Now I only need to make a documentation to my coursework. So now I'll have more free time. :)
Dynamic and static languages
As I've mentioned I'm reading a "Design Patterns" by Erich Gamma. Yesterday I've finished reading about structural patterns. I have to say that this book contributed a lot to my understanding of object-oriented programming, not only in a way of giving information about patterns, but also about whole programming. While reading I've often found examples of difference between dynamic programming languages and static ones.
In most cases dynamic languages looked better that static. Some methods hard to implement in static languages are easy to implement or built in dynamic languages: creating prototypes, changing behavior of object on-the-fly, programming by interface not implementation. It's not a secret dynamic languages such as Perl, Python, Ruby, etc. usually require less amount of code lines than static like C++. This mainly provided by different approaches to code handling: static languages are usually compiled, while dynamic are interpreted.
Dynamic nature of languages like Python provide rather wide abilities to work with classes and objects but in most cases programmers doesn't need available but rather low-level features (does we need very often put definition of function in if-statement?). And the cost is slow execution speed. Moreover if there is an error in program developer will know about it only when interpreter will reach this piece of code, while some of such errors could be caught during compilation.
As I think, is that in most cases interpreted languages are enough good for very big range of application what is proved by current trends in programming. But compiling languages still are rather popular. They are much better in implementing complex algorithms which uses a lot of resources. I agree with J. Ousterhout in article "Scripting", that static languages are useful for complex data structures from basic data types, which are often accompanied by low-level difficult to understand algorithms; and with dynamic (scripting) languages we can combine this elements to systems. Present dynamic languages (at least as I know Python and Ruby) provide an ability to plug into program modules written on C/C++. Thomas and Hunt in "Pragmatic Programmer" wrote a lot about DSL (Domain-Specific Languages). They can be thought as scripting languages with very tight integration into application. I think in future we can expect not only the expansion of using of dynamic languages but also developing of more tight integration between them and static languages.
In most cases dynamic languages looked better that static. Some methods hard to implement in static languages are easy to implement or built in dynamic languages: creating prototypes, changing behavior of object on-the-fly, programming by interface not implementation. It's not a secret dynamic languages such as Perl, Python, Ruby, etc. usually require less amount of code lines than static like C++. This mainly provided by different approaches to code handling: static languages are usually compiled, while dynamic are interpreted.
Dynamic nature of languages like Python provide rather wide abilities to work with classes and objects but in most cases programmers doesn't need available but rather low-level features (does we need very often put definition of function in if-statement?). And the cost is slow execution speed. Moreover if there is an error in program developer will know about it only when interpreter will reach this piece of code, while some of such errors could be caught during compilation.
As I think, is that in most cases interpreted languages are enough good for very big range of application what is proved by current trends in programming. But compiling languages still are rather popular. They are much better in implementing complex algorithms which uses a lot of resources. I agree with J. Ousterhout in article "Scripting", that static languages are useful for complex data structures from basic data types, which are often accompanied by low-level difficult to understand algorithms; and with dynamic (scripting) languages we can combine this elements to systems. Present dynamic languages (at least as I know Python and Ruby) provide an ability to plug into program modules written on C/C++. Thomas and Hunt in "Pragmatic Programmer" wrote a lot about DSL (Domain-Specific Languages). They can be thought as scripting languages with very tight integration into application. I think in future we can expect not only the expansion of using of dynamic languages but also developing of more tight integration between them and static languages.
Wednesday, October 24, 2007
My Example of Factory Method Pattern
I found rather useful reading a "Design Patterns" and found some examples of those patterns in programs I've written or read. And some days ago I've used one of the patterns - Factory Method.
What was the case? I've wrote two types of collections for C#: Vector (casual array) and LList (Linked List). They have the same interface ISequence and sane base abstract class SequenceBase which implements most of operations leaving virtual only basic operations, such as Insert, Remove, etc. And I wanted to have tests for all methods for both implementations. I'm using NUnit, and I didn't wanted to have two test classes with identical content, in except of operation new. So what I've made:
Whats is good, as I think, is that such an approach could be used to test all implementations of each interface. Write tests for interface in abstract class, write tool to search implementations and generate required test classes and you can be sure that this interface work well in all cases, or in other case you get a pointer(s) to error(s).
I think I'll try to use this approach in my practice and write such a tool to make concrete classes for tests of interface implementations.
Off-topic: While writing this post I again faced the question: why implement array and linked list with same interface? The difference in the way they work make some operations unsuitable for one type while be good for other, so why include these operation in common interface? I think it's the question worth its own article, so I'll explore this question in future.
What was the case? I've wrote two types of collections for C#: Vector (casual array) and LList (Linked List). They have the same interface ISequence and sane base abstract class SequenceBase which implements most of operations leaving virtual only basic operations, such as Insert, Remove, etc. And I wanted to have tests for all methods for both implementations. I'm using NUnit, and I didn't wanted to have two test classes with identical content, in except of operation new. So what I've made:
- Wrote an abstract class with all test cases (e.g. SequenceTester). All test methods have their Test tag.
- Class defines an abstract method Instance, which returns an object of tested interface, ISequence in my case.
- In all test methods I use Instance instead of operation new.
- For each tested class I define a test class derived from SequenceTester. In have to implement only Instance method that returns an instance of tested class and tests for an implementation of interface is ready!
Whats is good, as I think, is that such an approach could be used to test all implementations of each interface. Write tests for interface in abstract class, write tool to search implementations and generate required test classes and you can be sure that this interface work well in all cases, or in other case you get a pointer(s) to error(s).
I think I'll try to use this approach in my practice and write such a tool to make concrete classes for tests of interface implementations.
Off-topic: While writing this post I again faced the question: why implement array and linked list with same interface? The difference in the way they work make some operations unsuitable for one type while be good for other, so why include these operation in common interface? I think it's the question worth its own article, so I'll explore this question in future.
Monday, October 15, 2007
What I've done and haven't done
Firstly, I had written this post to my software blog, but then I've decided that it isn't software-specific and should be posted here. However I'm too lazy to revise it and remove "programmisms" from beginning part.
It is useful sometimes to take a pause and look at what you wanted to make some time ago, what you have done, what you are doing, what's the progress on it and what you want to do.
What I've wanted and what's the result?
It is useful sometimes to take a pause and look at what you wanted to make some time ago, what you have done, what you are doing, what's the progress on it and what you want to do.
What I've wanted and what's the result?
- I've wanted to pass all these labs in different subjects. Success.
- Successfully finish study at courses of databases. Success.
- Daily read news from internet. Successful in whole, thought I've sacrificed some news-feeds because it is too hard to read 'em all. Success (may be not full, not sure)
- Regularly write to my blog (now I have two blogs). Not very good results: I don't write much to them. Thought I haven't dropped and forgotten them, so Partial Success.
- I've wanted to read a lot of books. From those in list I've read only "Code Complete". But I've read two another books: about C# and "Pragmatic programmer" (Aahh, I haven't written about that! Need to fix that in near future!). And now I'm reading "Design Patterns". And I really want to read any book about UML. Result: All in all I think that's a success, however not following first plan.
- Write some software to practice. During summer I worked on Egnoly text editor. And now I continue to work with .NET Framework, have some projects in mind and write some code for libraries on C#. Success, not 100% but about 90%... :) Or I'm not objective and too love myself??? May be...
- I still haven't got a girlfriend. It isn't programming of course but has an effect on mind and mental condition.
- I still have got chaos on shelves I don't use regularly. Terrible, but there is a relative order on my desk :)
- I haven't made my programming language. May be I'm too young for that. But this idea still in my head and don't want to go away, instead it becomes stronger and stronger after reading Pragmatic Programmer.
- I wanted to use Test-Driven Development, nut still don't use it actively. However I regularly try to write tests for my applications. And they give the result! So I think that's a matter of time. May be I'll not become a TDD programmer, but the one who actively and properly uses tests. Result: 40% of Success.
- I've taught myself to actively use scheduling. Now I use not a calendar but a Todoist and I often don't follow it but I've already have a place where my wishes and plans on this day are written.
- Something more that a achieved and haven't achieved. Couldn't remember all of them.
What I'm doing by now?
- Studying
- Writing some soft on C#, not very useful, but some practice
- Also reading Design Patterns: useful book, sure I'll write review about it!
- Participating in open source project Battle for Wesnoth as a translator.
What I want?
- Make such list and judgement of results rather regular.
- Follow schedule that I'm making for myself. And make this schedule more wisely and realistic!
- Develop my relations with human beings :). I don't want to communicate only with computers.
- Still want to make scripting programming language.
- Write software on C#: develop Egnoly, common stuff for .NET, and something new, i.e. tool to synchronise my desktop PC and laptop.
- Study well in university.
- Continue and develop my participation in OSS projects. May soon I'll be able to contribute to Wesnoth as a programmer? Or contribute to another project either as a programmer or translator.
- Start project with my fellows. There is no concrete plans on it, now it's a long-distance target.
[Update] Add target to communicate more with people. Just forgot about it :(.
Labels:
books,
planning,
programming,
self discipline,
study,
thoughts
Thursday, October 11, 2007
Some major tasks for close period finished
During last week I've spent much time visiting hospital and passing some physical examinations. It took rather a lot of time especially because of long distance between my home and hospital.
During last weekend I've made a lot of study work and for now has lesser major tasks to do. I've done functionality of my coursework on programming and now need to make program look good and make report for it.
Coursework is one of big projects that lasts more than a few days. What other big projects do I have? At first it is reading books. Now I'm reading "Design Patterns" about programming. My programming projects got some attention on last week but on this week they have lacked it. Hope I'll correct this in next days.
Eh... No any ideas more for now, I'm going to sleep... I've slept rather a small time during last days.
During last weekend I've made a lot of study work and for now has lesser major tasks to do. I've done functionality of my coursework on programming and now need to make program look good and make report for it.
Coursework is one of big projects that lasts more than a few days. What other big projects do I have? At first it is reading books. Now I'm reading "Design Patterns" about programming. My programming projects got some attention on last week but on this week they have lacked it. Hope I'll correct this in next days.
Eh... No any ideas more for now, I'm going to sleep... I've slept rather a small time during last days.
Sunday, October 07, 2007
Implementing custom tool in Visual Studio 2008
I've recently wrote about making tool to generate C# code. We may say that are macros for C# (it fact it is only one defined macro — for fields and properties).
And how to implement this tool? There can be two ways: write tool on scripting language that generates C# code file and is called before compilation. Another way is to use ability of Visual Studio to switch user custom tool for generating files. Firstly I've implemented tool by first way on Python and now I want to make a custom tool for Visual Studio written on C#. But how to plug custom tools in Visual Studio? Now I've got an answer, though I've spent much time to understand this.
Firstly, to develop plug-ins for Visual Studio it is needed to download Visual Studio SDK (for appropriate version of Visual Studio). I have to say that after installing it my Visual Studio 2008 Beta 2 became very unstable: IntelliSense regularly produces errors which crashes the whole Visual Studio.
After that Visual Studio will add templates of its addins. That's a base for future project (although may be addin can be created without all that stuff that is in template).
To make custom tool for generation of files the one must implement IVsSingleFileGenerator interface. I've spent a lot of time trying to make this and fails mainly because if this problem: in some places of documentation it is said that function generate gets a parameter of type out IntPtr[], in some it is said that it is out IntPtr and in fact interface has just IntPtr[]. Not any out! So how should I return value of pointer? Ok, I'm not a great specialist in .NET and arrays a sent be reference. Even if this is not a problem why there is an array not one pointer? Another outgoing parameter of function on exit must contain an amount of bytes in that array but how this will help if I'll allocate a different amount of bytes in different pointers in array. However I don't see a use for an array and just tried to allocate it and use only index 0. But this doesn't helped me and I failed in implementing that interface. May be that a bug in SDK and interface must have out IntPtr[]? Don't know I'm not a guru in Visual Studio.
I've failed to get a proper answer from MSDN documentation and my attempts so I've googled this problem.I've found some solutions but the most notable part is that in Visual Studio 2003 there was an abstract class which covered that horrible interface under much more comfortable interface. However "evil" Microsoft removed that class from version 2005. But good guys placed dll with it in Internet, i.e. here. So It's needed to implement function GetCode from that class and tool is ready to use!
However it is still needed to plug it in Visual Studio. First step is to register it as a package. This can be done by tool regpkg. It is placed in <%MVS SDK Dir%>\Tools\Bin\ directory. Just run it with a path to our compiled tool as a argument. This step can also be done manually,
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\<%MVSVersion%>\CLSID\{<%guid%>}]
@=<%Tool name%>
"InprocServer32"="C:\\WINDOWS\\system32\\mscoree.dll"
"ThreadingModel"="Both" "Class"=<%class name of tool%>
"Assembly"="<%asm name%>, Version=<%asm version%>, Culture=<%culture%>, PublicKeyToken=<%public key%>"
As you may noticed custom tool must be in GAC. May be there is a way to keep it somewhere else but I don't know.
What is next? Registered custom tool need to be registered as a generator. In registry dir of Visual Studio there is a directory Generators. There is some dirs in it: FA... is a C#, 16... is a VB.NET. It is needed to register tool for each language separately. In directory of proper language add directory with name of your tool, i.e. for my tool called CSGen:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Generators\{fae04ec1-301f-11d3-bf4b-00c04f79efbc}\CSGen] @="CSGen tool to generate code on C#"
"CLSID"="{<%clsid registed in \CLSID\%>}"
"GeneratesDesignTimeSource"=dword:00000001
After that start Visual Studio choose file in project and in properties type name of custom tool. After each save file will be regenerated. It is also can be forced manually: right-click on file in Solution Explorer and "Run custom tool".
These articles with examples could be helpful (I'm not a good explainer, just learning):
And how to implement this tool? There can be two ways: write tool on scripting language that generates C# code file and is called before compilation. Another way is to use ability of Visual Studio to switch user custom tool for generating files. Firstly I've implemented tool by first way on Python and now I want to make a custom tool for Visual Studio written on C#. But how to plug custom tools in Visual Studio? Now I've got an answer, though I've spent much time to understand this.
Firstly, to develop plug-ins for Visual Studio it is needed to download Visual Studio SDK (for appropriate version of Visual Studio). I have to say that after installing it my Visual Studio 2008 Beta 2 became very unstable: IntelliSense regularly produces errors which crashes the whole Visual Studio.
After that Visual Studio will add templates of its addins. That's a base for future project (although may be addin can be created without all that stuff that is in template).
To make custom tool for generation of files the one must implement IVsSingleFileGenerator interface. I've spent a lot of time trying to make this and fails mainly because if this problem: in some places of documentation it is said that function generate gets a parameter of type out IntPtr[], in some it is said that it is out IntPtr and in fact interface has just IntPtr[]. Not any out! So how should I return value of pointer? Ok, I'm not a great specialist in .NET and arrays a sent be reference. Even if this is not a problem why there is an array not one pointer? Another outgoing parameter of function on exit must contain an amount of bytes in that array but how this will help if I'll allocate a different amount of bytes in different pointers in array. However I don't see a use for an array and just tried to allocate it and use only index 0. But this doesn't helped me and I failed in implementing that interface. May be that a bug in SDK and interface must have out IntPtr[]? Don't know I'm not a guru in Visual Studio.
I've failed to get a proper answer from MSDN documentation and my attempts so I've googled this problem.I've found some solutions but the most notable part is that in Visual Studio 2003 there was an abstract class which covered that horrible interface under much more comfortable interface. However "evil" Microsoft removed that class from version 2005. But good guys placed dll with it in Internet, i.e. here. So It's needed to implement function GetCode from that class and tool is ready to use!
However it is still needed to plug it in Visual Studio. First step is to register it as a package. This can be done by tool regpkg. It is placed in <%MVS SDK Dir%>\Tools\Bin\ directory. Just run it with a path to our compiled tool as a argument. This step can also be done manually,
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\<%MVSVersion%>\CLSID\{<%guid%>}]
@=<%Tool name%>
"InprocServer32"="C:\\WINDOWS\\system32\\mscoree.dll"
"ThreadingModel"="Both" "Class"=<%class name of tool%>
"Assembly"="<%asm name%>, Version=<%asm version%>, Culture=<%culture%>, PublicKeyToken=<%public key%>"
As you may noticed custom tool must be in GAC. May be there is a way to keep it somewhere else but I don't know.
What is next? Registered custom tool need to be registered as a generator. In registry dir of Visual Studio there is a directory Generators. There is some dirs in it: FA... is a C#, 16... is a VB.NET. It is needed to register tool for each language separately. In directory of proper language add directory with name of your tool, i.e. for my tool called CSGen:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Generators\{fae04ec1-301f-11d3-bf4b-00c04f79efbc}\CSGen] @="CSGen tool to generate code on C#"
"CLSID"="{<%clsid registed in \CLSID\%>}"
"GeneratesDesignTimeSource"=dword:00000001
After that start Visual Studio choose file in project and in properties type name of custom tool. After each save file will be regenerated. It is also can be forced manually: right-click on file in Solution Explorer and "Run custom tool".
These articles with examples could be helpful (I'm not a good explainer, just learning):
Labels:
automation,
C#,
microsoft,
programming,
source code,
visual studio,
workspace
Subscribe to:
Posts (Atom)