Tuesday, October 28, 2008

Offer Accepted

Finally got an offer from that company I mentioned before - the one that everyone knows about. And accepted, too. Looking forward to it. The company is huge, though it is not a software development or a consulting company. The development team is about 30 people and only develops software for company's internal needs. I start in 4 weeks.

Oh well, enough about it for now I guess.

by . Also posted on my website

Thursday, October 23, 2008

A Quick One Before I Forget

Cause it's Friday.

I came across a very good list of tips and tricks that every developer who uses Visual Studio 2008 should know:

Essential Visual Studio Tips & Tricks that Every Developer Should Know.

Ones I did not know are: 1, 4, 7, 10.

by . Also posted on my website

Small Thing Learned Today

I needed to hide some of the rows of a databound DataGridView at runtime. However, when I added a piece of code to do that,

foreach (DataGridViewRow row in myDataGridView.Rows)
{
if (someCondition)
{
row.Visible = false;
}
}

I was getting an exception sometimes:

'Row associated with the currency manager's position cannot be made invisible.'

I found out that the exception was happening when the row I was trying to set invisible was selected. The solution to this little problem is to change the code the following way:

CurrencyManager currencyManager1 = (CurrencyManager)
BindingContext[myDataGridView.DataSource];
currencyManager1.SuspendBinding();
foreach (DataGridViewRow row in myDataGridView.Rows)
{
if (someCondition)
{
row.Visible = false;
}
}
myBindingSource.ResumeBinding(); // this is myDataGridView's binding source
by . Also posted on my website

Monday, October 20, 2008

Small Thing Learned Today

So I needed to show a type name in the textbox today. Like 'DateTime', or 'Integer' etc. I decided to create a binding source and bind to System.Type.Name like this:

this.propertyTypeBindingSource.DataSource = typeof(System.Type);
/* snip */
this.nameTextBox.DataBindings.Add(new System.Windows.Forms.Binding
("Text", this.propertyTypeBindingSource, "Name", true));
/* snip */
Type PropertyType = typeof(DateTime);
this.propertyTypeBindingSource.DataSource = PropertyType;

However, when I try to run the application, I get an exception

"Cannot bind to the property or column Name on the DataSource. Parameter name: dataMember"

So, looks like I'm not allowed to bind directly to System.Type. Maybe I have to do some simple trick ... I create a class

public class StubPropertyType
{
public StubPropertyType(Type type)
{
this.StubPropertyTypeName = type.Name;
}
private string _stubPropertyTypeName = string.Empty;
public string StubPropertyTypeName
{
get { return _stubPropertyTypeName; }
set { _stubPropertyTypeName = value; }
}
}

and my binding now looks along these lines:

this.propertyStubBindingSource.DataSource = typeof(StubPropertyType);
/* snip */
this.nameTextBox.DataBindings.Add(new System.Windows.Forms.Binding
("Text", this.propertyStubBindingSource, "StubPropertyTypeName", true));
/* snip */
Type PropertyType = typeof(DateTime);
StubPropertyType stub = new StubPropertyType(PropertyType);
this.propertyStubBindingSource.DataSource = stub;

And it works like a charm!

by . Also posted on my website

Wednesday, October 15, 2008

Small Thing Learned Today

In SQL Server 2005, if I need to know what are the columns and data types of the certain table, I can run a simple query to know it:

select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='MyTable'

What's especially good for me is that it not only works with tables, but with views too. My current task is to create an interface for users which would allow them to generate custom reports through a set of views. They need to be able to apply criteria to the reports so that if the column's data type is datetime, they can use 'Is Before' or 'Is After', but on integer columns they can use 'Larger Than' etc.

by . Also posted on my website

Tuesday, October 14, 2008

Very Busy This Week

On Friday I will have to go for an 'online test'. That's it, no more details. I've been for a 'first round' interview, and after about a week or so I got a call and was invited to this testing. I have no idea what the testing will be about, but I studied everything relevant on Tech Interviews and even registered with Brainbench cause they have a free C# test there. It's a bit hard to prepare when you don't know what you're preparing for. Well it's a C# development position, so this gives me sort of an idea.

by . Also posted on my website

Thursday, October 9, 2008

Stack Overflow!

This site

seems to be very useful for those seeking answers for their computer-related questions. I fould a link to it here.

This is how it works:


Every question in Stack Overflow is like the Wikipedia article for some extremely narrow, specific programming question. How do I enlarge a fizzbar without overwriting the user’s snibbit? This question should only appear once in the site. Duplicates should be cleaned up quickly and redirected to the original question.

Some people propose answers. Others vote on those answers. If you see the right answer, vote it up. If an answer is obviously wrong (or inferior in some way), you vote it down. Very quickly, the best answers bubble to the top. The person who asked the question in the first place also has the ability to designate one answer as the “accepted” answer, but this isn’t required. The accepted answer floats above all the other answers.

Read more.

by . Also posted on my website

Tuesday, October 7, 2008

Browsing The Job Listings

Is there even such thing as a 'Junior Project Manager'? The title caught my eye as I never seen anything like this before. And the salary on offer is even significantly less than I have as a developer at the moment ...

by . Also posted on my website

Monday, October 6, 2008

Snippets

You know how in Visual Studio you can type 'mbox', press Tab twice and Visual Studio will convert it into

MessageBox.Show("Test");

Or, you can type 'ctor', press Tab twice and the constructor for the class will be generated?

This can be customised. Have a look at the following file:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>props</Title>
<Shortcut>props</Shortcut>
<Description>Code snippet that checks for a null property</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>field</ID>
<ToolTip>backing store</ToolTip>
<Default>mProp</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Property type</ToolTip>
<Default>int</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Property name</ToolTip>
<Default>MyProperty</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[private $type$ $field$;
public $type$ $property$
{
get
{
if (this.$field$ == null)
{
this.$field$ = new $type$();
}
return this.$field$;
}
set {this.$field$ = value;}
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

You can now save it with any name you like, and then press Ctrl-K, B (or choose Tools -> Code snippets manager), press 'Import', navigate to this file and select it.

Now, if you type 'props' and press Tab twice, the system will convert it into the following little pattern for getting a private member through a property, with checking if it is null:

private int mProp;
public int MyProperty
{
get
{
if (this.mProp == null)
{
this.mProp = new int();
}
return this.mProp;
}
set {this.mProp = value;}
}

From here it's easy to understand how to make 'snippets' that do anything you want.

by . Also posted on my website

Sunday, October 5, 2008

Interview Question Of The Day

The easiest of those I did not answer today was 'What is the difference between a class and a struct?'.

Yes, everyone should know it. For explanation why I did not, refer to the title of this blog. Later I found quite a detailed answer here:

Difference between class and struct in C#

I knew some of these, but did not realize there are that many. Some can be combined though, for example "When you instantiate a class, it will be allocated on the heap.When you instantiate a struct, it gets created on the stack" is obvious if you already know that "Classes are reference types and structs are value types".

by . Also posted on my website

A Well-known Interview Tip

Everyone knows this one. You should research the company you're going to for an interview - what it does, what are their goals, who their main competitors are etc.

Sometimes, however, you have a luxury of skipping this step. If a company is so huge or well-known that literally EVERYONE knows it, I think it's pretty safe to skip it.

I was at such company last week, maybe for the first time in my life. No, they didn't ask me 'so, what do you know about us?' :)

by . Also posted on my website

Thursday, October 2, 2008

Exciting Day At Work

Implementing permissions in the application.The database structure is there. There is "Permissions" table, there is "Roles" table, there is "RolesPermissions" table. There is an interface that allows to create additional roles and add different permissions to them. So, what is the exciting thing that's not yet implemented?

I have to go through the code and insert pieces of code that actually check user's permissions and look like this:

if (CurrentUser.IsAllowed(Permissions.MyPermissionToSeeSomeHighlySensitiveData))
{
//existing code remains here
}
else
{
MessageBox("GoAway", "You have no permission to do that");
}

There are about 130 separate permissions and about 190 places in the application where permissions are checked ... what an exciting way to spend Friday.

by Evgeny

Now Reading

"Peopleware: Productive Projects and Teams (Second Edition)"

Great book. I won't try writing a review since there's plenty of them on the Internet. It's probably the most interesting book on managing software projects since

"The Mythical Man-Month: Essays on Software Engineering"

(I don't read much on the subject anyway, so I could have missed a few dozens of good books).

Well after doing some reading, I learned a couple of things: my workspace is designed in the most counter-productive way possible and the project I am currently working on has all chances of joining those 25% of software products that are never actually used.

Mood: insanely optimistic.

by . Also posted on my website