All the fuss about FizzBuzz

July 31, 2007 on 11:23 pm | In Uncategorized | No Comments

Recently I’ve read once again about the FizzBuzz. For those not familiar with this term: Fizzbuzz is a taks that could by used while interviewing a software developer for a job. It’s is essentially a trivial task of listing all the numbers from 1 to 100 but replacing multiples of 3 with Fizz, multiples of 5 with Buzz and multiples of both with FizzBuzz. A task that an intelligent person, with some background in software development, suppose to crack in 5 (10 tops) minutes. But of course there are good solution and better solutions. I’m thinking about the solutions provided after Jeff Attwod post on his blog. People are so eager to post a solution without thinking about the problem through. They are forgetting to print the number that does not match FizzBuzz pattern. Or a white board problem: you use > instead of < in a for loop. Is it bad? Actually I think it’s not. The great idea with giving such a task, while interviewing is not to get a perfect solution. It is to see how the interviewing person thinks, how doe’s she get through analyze and “implementation”. You should seek for a perfect solution, but you have to praise the better ones. And plase! PLEASE! Give the “software developer to by” a task involving software development while interviewing. Because if you will not, you could get someone without a value. Really I’ve seen enough large mouths that could lie their way all up to the skies, but were miserable software developers.

Originally published at Sunday, May 13, 2007

My personal bookshelf revealed, part I

July 31, 2007 on 11:20 pm | In Books | 1 Comment

Silence on the wireIs it possible to by a good software developer and not to read books? Probably, but I think only if you are true genius! Otherwise you are lost in modern tech world if you are not keeping track. Sure you can read blogs, but nothing is better than good technical book from time to time. I love to read good books. Earlier I was a true bookworm. Now I have less and less time, but I still like to take I while to lay back and read. Interestingly enough more and more of my bookshelf is taken by technical books.

I’ll tray to review from time to time an interesting tech book for you. I would like to begin with a book that is especially close to my heard. I don’t know weather it is because the author is Polish or because I found inside the best description of how to get from transistor to a logical gate ever written! The book is called Silence on the Wire: A Field Guide to Passive Reconnaissance and Indirect Attacks and the author is Michal (or better Michał) Zalewski. The book was originally written in English but I’ve seen some translations too (Polish and German). It is not a book strictly aimed on software developer, but it is surreally one that every software developer that works with Internet (so every software developers ;) should read. It is more a set of essays reaching from the lowest level like generating random numbers through TCP stack to web client identification. In no means is the book a dray academical paper! It is build on authors experiments on a living system. That makes this book special. It dims the minor drawbacks like “uncohesivnes” in book structure (it is more a set of lose papers than a solid book that you have to read from cover to cover). Have a nice reading!

Oracle Hierarchical Queries

July 31, 2007 on 11:14 pm | In Oracle | 1 Comment

It is rather common developer task to draw a hierarchical data on the screen. You have tons of controls that draw a tree like structures. But did you know that when you are using Oracle you are able to select hierarchical data direct from database? How?

It is rather simple. As an example we will draw a tree of an organization structure. Lets create a simple table with employees:

CREATE TABLE EMP
(
ID NUMBER(2,0) NOT NULL,
REFID NUMBER(2,0) NULL,
NAME VARCHAR2(40 BYTE) NULL
)

Its time to fill the table with data:


INSERT INTO EMP(ID, REFID, NAME)
VALUES(1, 1, 'John');
INSERT INTO EMP(ID, REFID, NAME)
VALUES(2, 1, 'Mary');
INSERT INTO EMP(ID, REFID, NAME)
VALUES(3, 1, 'Tom');
INSERT INTO EMP(ID, REFID, NAME)
VALUES(4, 2, 'Michael');
INSERT INTO EMP(ID, REFID, NAME)
VALUES(5, 5, 'Richard');
INSERT INTO EMP(ID, REFID, NAME)
VALUES(6, 6, 'Andy');
INSERT INTO EMP(ID, REFID, NAME)
VALUES(7, 6, 'Helen');

Guess what? That’s almost done! We have to write only one select statement to get the hierarchical data:

SELECT id, refid, name, LEVEL, SYS_CONNECT_BY_PATH(name,'/') path
FROM emp start WITH id = refid
connect BY nocycle prior id = refid

Voila! You should get something like that:

Peace of cake! Right?

Originally published at Sunday, February 25, 2007

Waiting for Clarion.NET…

July 31, 2007 on 11:12 pm | In Clarion | No Comments

… and learning Clarion 6. It’s quite interesting to switch from “normal” programming to RAD programming. Learning Clarion teaches you new meaning of the words Rapid Application Development.
Few times I heard this term in while speaking about VS. I think that it is a over interpretation. I’ll make a competition with you. We will write a database driven application simultaneously. You will do it in .NET and I will do it in Clarion (after 3 days of learning ;) . Few tables in connection to one another, few browse, few forms. I’m pretty suer that I’ll beat you.

Sure Clarion is no comparison to VS in terms of developer comfort, flexibility, debugging, team work, and so on, and on, and on. But VS is no Comparison to Clarion in terms of Database driven application writing. Trust me.

PS. I’m writing tutorials about that what I’m learning. Here you have on of then. It shows how to style a single cell (or column) in clarion list box (browse) according to some condition.

Originally published at Saturday, December 16, 2006

Clarion date and time in .NET

July 31, 2007 on 11:10 pm | In Clarion | No Comments

In Clarion date is defined as follows:

number of days that have elapsed since December 28, 1800

Why? I think that’s when Seoftvelsocity CTO’s grandgrandma reached Florida but they say its because this date was inherited from Btrieve Record Manager. Well. Cool, but in .NET DateTime looks different. How to get a Clarion Date for a given .NET date?

public static int GetOLDate(DateTime dotNetDate)
{
CultureInfo ci = new CultureInfo("de-DE");
DateTime baseDate = DateTime.Parse("01.01.1801", ci);
System.TimeSpan ts = dotNetDate - baseDate;
int l = ts.Days + 4;
return l;
}

How does Clarion defines time?

Number of hundredths of a second that have elapsed since midnight, plus one.

How to manage this in .NET?

public static int GetOLTime(DateTime now)
{
int l = now.Hour * 360000;
l += now.Minute * 6000;
l += now.Second * 100;
l += now.Millisecond / 10;
return l + 1;
}

And another way around?

public static DateTime GetTime(int clarionTime, DateTime baseDate)
{
int lHours = Convert.ToInt32(clarionTime / 360000);
int lMinutes = Convert.ToInt32((clarionTime - (lHours * 360000)) / 6000);
int lSeconds = Convert.ToInt32((clarionTime - (lHours * 360000) - (lMinutes * 6000)) / 100);
int lMiliseconds = (clarionTime - (lHours * 360000) - (lMinutes * 6000) - (lSeconds * 100)) * 10;
DateTime then = new DateTime(baseDate.Year, baseDate.Month, baseDate.Day, lHours, lMinutes, lSeconds);
return then;
}

Hope it will help!

Originally published at Sunday, November 26, 2006

Redirecting standard input

July 31, 2007 on 11:06 pm | In Uncategorized | No Comments

Lets say you have to start a program with a parameters from a file. With a command line you will write simply something like that:

program.exe < ParamFile.txt

Using System.Diagnostics.Process you cannot redirect a content of a file to an external application like that. You have to redirect standard input to you process. You can do it like this:

StreamWriter paramFileStreamWriter = someProcess.StandardInput;
string[] paramData = File.ReadAllLines(paramFile);
for (int i = 0; i < procedData.Length; i++)
{
paramFileStreamWriter.WriteLine(paramData[i]);
}
paramFileStreamWriter.Close();

Some more information is to by found on MSDN.

Originally published at Saturday, November 11, 2006

Forms Authentication and ASP.NET Development Server

July 30, 2007 on 8:10 pm | In Uncategorized | No Comments

If you are using forms authentication while developing with ASP.NET Development Server and you have some static elements to show on the login form (I’m sure you have) you will have a problem with standard configuration. Before the user is authenticated by ASP.NET, he will not see the images and the css will not by loaded. Well its not a big deal because the same website deployed on the IIS will behaves correctly. But if you are perfectionist like me it will by annoying to see something like this:

It’s way better to see something like this:
Form before

Here’s the reason why this happens. By default passes IIS all the static data (images, style sheets, java script files, and so on) directly to the client. This elements never reach the ASP.NET only the files with extension aspx, ascx, and so on are interpreted by ASP.NET framework. Only this elements are secured with .NET security systems. You can off course change it by redirecting a given file extension to a given ISAPI extension, but that’s not the point. The ASP.NET Development Server passes always all the elements through ASP.NET and its security systems. So if you are using forms authentication and you are not eat authenticated you wan’t by able to see the static content. There is a workaround. you have to temporarily grant all access in you web.config to your css and gfx directory like this:

<system.web>
<authorization>
<allow users=”*”/>
</authorization>
</system.web>

Voila! Now your login site looks normal while developed. What a relief!

Form after

Clarion.NET close encounters

July 30, 2007 on 8:04 pm | In Clarion | 1 Comment

I’ve seen Clarion.NET in action. Well actually it was something that WILL by a Clarion.NET. But from the beginning…

Clarion Developers Meeting CollageThere was a Clarion Developers Meeting in Cambridge last week. I was there at 27th and 28th of July 2006. I’ll skip the Clarion “Core” part, because its irrelevant for us (.NET developers). I’ll say only one thing, I thought it’s a common knowledge that when you are making a presentation, you are not supposed to read all that you have on your PowerPoint slides – the attendees are getting the whole ppts, they surely can reed ;)

I was waiting anxious for Clarion.NET presentation. I’m tired of shuffling the data in .NET manually (writing a code to manage the database connectivity, care about the relations to object mapping, and so on). I don’t see the point for developer to worry about database while writing business code (to some degree of course). In my imagination I saw a big future for a tandem: Visual Studio 2005 + Clarion.NET. You make all the boring data centric work in Clarion.NET and when you have something sophisticated to do (e.g. Web Service) you grab VS. What I saw was rather disappointing: actually all there is to Clarion.NET right now is ABC (Clarion intern language) language “compileable” to IL. Sure that’s not trivial to write new .NET language buts not that what’s make a RAD RAD. There was no presentation of application generation and data dictionary – because they are no ready yet. So Clarion.NET right now is noting more than new language for .NET Framework. I can think of a better name right now, it will by ABC.NET. Good news: the whole Clarion.NET with templates and data dictionary should by available this year – so Softvelocity CEO Robert Zaunere. Another good news: according to my CEO they are never showing their products before they are fast ready to ship. I surely hope so!

clarion.jpgLittle technical info about Clarion.NET. The IDE is taken completely from SharpDevelop. The “visual” part of SharpDevelop has not changed a lot. Actually when you create new document in Clarion.NET you get the default SharpDevelop class template. I hope that Clarion.NET will keep the extensible architecture of SharpDevelop and developers will by able to write their plug-ins. The Data Dictionary Designer wont by written in managed code and will by based on ADO.NET (no out of the box support for other O/R mapping). I haven’t seen anything about templates.

So yet a little disappointed, I’m waiting still anxious for Clarion.NET. I hope only that I won’t reach the average age of a “normal” Clarion developer (which is something about 104 years old ;) before I’ll see the Clarion.NET in action!

Originally published at Thursday, August 03, 2006

MVP Website with .NET Remoting

July 29, 2007 on 9:10 pm | In Clarion | No Comments

I’ve written a short article about extending the MVP (Model View Presenter) with .NET Remoting. “MVP in ASP.NET with .NET Remoting” is available on CodeProject. This article is a extension of great text “Model View Presenter with ASP.NET” by Billy McCafferty. You are welcome to read and flame!

Originally published at Friday, August 11, 2006.

Welcome to IProgrammable.com

July 26, 2007 on 11:03 pm | In Uncategorized | No Comments

Welcome to my blog. Few years ago when the big blog balloon blow up I surely wasn’t expecting me to blog. But the times are changing. Everybody has a blog so I’ll have mine too ;)

I wont write here about my cat or daughter (have neither). I’ll write about what I do. I’m software developer. I write mostly in .NET (C#) but I have background in Java (J2EE) and PHP. My main point of interest is web development.

So think about that. The new ASP.NET web project in version 2.0 is not compiled to one assembly. You have a bunch of small assemblies (when you publish without the possibility to update the precompiled site). Let’s say you need a version number for your project (a set of Web Services). How can you do that? Create AssemblyInfo.cs class like that:

public class AssemblyInfo
{
public static string GetVersion()
{
Assembly a = Assembly.GetExecutingAssembly();
return a.GetName().Version.ToString();
}
}

Simple, isn’t it? Welcome to my .NET blog!

Originaly published at Monday, July 31, 2006.

PS. This post was originally created at July, 31th 2006. I’ve decided to move back to my old hosting and to change the blogging engine to WordPress and now I’ll by recreating some of my old posts. Enjoy!

After I decided to move back to my old hosting I’ll recreate some of my old posts. This is the first one.

Powered by WordPress with Pool theme design by Borja Fernandez.
Text © Marcin Kawalerowicz. Hosting CODEFUSION.