Tuesday, 18 October 2011

Throw-catch programming

Sometimes people say it's not good to encode your programming logic in exception terms. I wonder why not. We should just love and embrace exceptions.

class CounterException : Exception
{
public readonly int Index;
public readonly int Max;
public CounterException(int index, int max)
{
this.Index = index;
this.Max = max;
}
public Exception Next
{
get
{
if (Index == Max)
{
return new FinishedCountingException(Max);
}
else
{
Console.WriteLine("Count = " + Index);
return new CounterException(Index + 1, Max);
}
}
}
}
class FinishedCountingException : Exception
{
public readonly int Bound;
public FinishedCountingException(int b)
{
Bound = b;
}
}
class Program
{
static void Main(string[] args)
{
Exception e = new CounterException(0, 10);
mytry:
try
{
throw e;
}
catch (CounterException ex)
{
e = ex.Next;
goto mytry;
}
catch (FinishedCountingException ex)
{
Console.WriteLine("Finished counting to " + ex.Bound);
}
Console.ReadKey();
}
}

Monday, 14 February 2011

How I would like the software to work.

As a developer and naturally a user of software, these are the primary general feature points I would like all the software in the world to have.

I realize these things I will ask for are definitely possible and practiced in various platforms with extensive number of technologies, but I want to be able to take them for granted for all the software out there. Whether they'll be implemented in lower level systems like operating systems, or will they just be some commitee standards, I don't care. Just like almost every interactive software nows what keyboard is, I want them to recognize these notions as well.

1. Generic interaction abstraction. With all these new mobile devices and different interaction methods, we need a way to make our applications work on all these. This is not only a cross-platform development tool like Java, or being able to run a piece of code on different hardware. But it's a way to smartly adapt these applications to those devices' interaction capabilities. Some devices have double touchscreen (see here), some devices have a dialer-keypad on them. Developers should make use of a framework with extensive dictionary of interaction technologies available, to make something roughly like this possible:
Step 1: This app is made with Java, so it'll work everywhere with Java runtime.
Step 2: This app preferably uses multi-touch interface with three input points.
Step 3: If the system doesn't have a multi-touch interface with three input points, the app can fallback to a traditional mouse-pointer interaction system, but then it'll put a few buttons on the corner of the screen to make up for the multi-touch capability.
Step 4: If the system doesn't have any pointer input available at all, the app supports all the features by using only arrow keys on the keyboard. Even if the user experience is marginally distressed, features are still available.
Step 5: The app ideally uses a 30-hz 16M-colour screen. But if the screen this system has is only a 0.5-hz e-ink screen, let the app know that so it can adapt the screen-layout in a way that will not require as many screen refreshes.
Step 6: The app ideally uses a 3D surround sound system for sound output. But if it's not available, stereo will do. Also, if a earphone is available, let the app know so it can make use of its auditory illusion tricks to fake 3D sound. If only mono sound is available, just don't run the app because it won't make any sense.

Yes, this should all be available within single development platform, preferably in a declarative way. Instead of porting everywhere, we can just define how our app translates to different devices' interaction ways and the platform (/middleware) will do the rest.

2. Application hibernation. As a user I should be able to hibernate a running service or GUI application with a single click, and it should be saved in a persistent memory like a harddisk. All the visual state and data, everything. Then I should be able to revive it back all with a single command, down to a half-way mouse click event that was about to happen. Again, this is surely possible via various technologies, but still we don't see any applications that can do this. Even firefox reloads every tab when you restart using the option "save tabs". It goes only half the way.

3. Dependency injection in a broader scale. How do we integrate our applications? We use configuration files, environment variables (the PATH god), registry entries. This is all practical but hassly and ridiculous at the end. I want something like unix terminals' nice "pipe" (|) feature or microsoft console's similar (>) sign. But not only for forwarding the standard input/output streams, for all the kinds of multi-part or sophisticated, synchronous or asynchronous inputs and outputs an application can process or present. Something between dependency injection frameworks, activex guids, mime type-related default applications, somewhere over there. Maybe something like this:
Rule 1: Dear firefox, please don't try to save my passwords on yourself, just interface with this awesome little app that can do it for you. Safari, please also do the same. (assuming that little app supports (let's say) IWebPasswordsStore.
Rule 2: Dear system, when that little app says it wants to write to persistent storage, it just wants to use my encrypted online virtual drive associated with my here-registered google [:)] account.
Rule 3: Dear system, give this powerpoint application a secondary monitor so it can present the slides on that monitor. But I don't really have a second monitor, I just want those slides to show up on my remote classrooms projector where I am connected with skype.

Am I just flying too high?

Wednesday, 22 September 2010

One to one meetings

This is a brilliant element for software team managers. While I was working for Realtime Worlds, we used to do these with my manager David Lofthouse. These meetings provide a lot of friendliness and comfort between the manager and managees.

Every week (or every other week) at the same time, 15 min-ish. Most of the time, there was not much to talk about, except the occasional "recently I have been having isolated tasks, I would like to work more together with people" and David would assign me tasks accordingly where possible. Read about 1:1 meetings from Michael Lopp:
http://www.randsinrepose.com/archives/2010/09/22/the_update_the_vent_and_the_disaster.html

Thursday, 9 September 2010

Snake game with Canvas

Just made a little snake game using sensational Canvas control intruduced with html5:

http://www.gorkempacaci.name.tr/snake-canvas/

* Thanks to Weeble and Ozgur Akgun for bug reports.

Wednesday, 16 June 2010

Phyton's range method in C# (or .net)

I don't frequently write phyton, nor am an expert on it. But I had a crush on Phyton's 'range' function and was looking for a subtitute on C#, especially after all these new functional programming elements.

Apparently, there was one identical implementation: Enumerable.Range! It's come with C# 3.0.

See: http://stackoverflow.com/questions/1271378/is-there-an-equivalent-of-pythons-range12-in-c

Saturday, 15 May 2010

Adobe vs Apple deal

Reading:
1. Steve Jobs' arguments about why they don't support Flash on iPhone and iPad: http://www.apple.com/hotnews/thoughts-on-flash/

2. Adobe's passive-agressive response: http://blogs.adobe.com/jnack/files/AdobeAppleAd.pdf

3. Adobe's CEO answering on the topic: http://blogs.wsj.com/digits/2010/04/29/live-blogging-the-journals-interview-with-adobe-ceo/tab/liveblog/


I agree with the CEO guy on that the technological issues are not enough of an issue to ban flash development for iPhone. As far as I know, iPhone doesn't support Java neither:

Jobs: "Java's not worth building in. Nobody uses Java anymore. It's this big heavyweight ball and chain." (source)

It doesn't take a Java fan to say it is very unfair to Java. Java's still serving us very well in many levels. (Altough Java programmers getting paid more IS a sign that it is dieing, Java is not only a programming language (*).)

Apple does have the tendancy to provoke a closed community with a sense of eliteness, and it has so far worked good for them. If they (and with 'they', I mean both customers and producers of iPad and iPhone) are fine with less applications then there is not much to say. Indeed, Jobs' manifest may be targeting only the Apple customers who demand Flash, telling them not having Flash is just another way to separate them from the crowd.

They must be making huge moneys from the app store, and freely available flash applications on the web would not help much. I wonder how many of those applications on the store would be obsolete if only iPhone supported flash?

I also am long disturbed with the Flash monopoly on rich internet applications and hoping to see what people will do with HTML5. But that's another topic.

--

Thinking Adobe had bought Macromedia only a few years ago, and Macromedia's Flash is now Adobe's most discussed product, It surely was a good buy.

Thursday, 18 June 2009

Banned Books Week

Did you even know there was a banned books week?

I think this is a brilliant idea.

It's the last week of every September.

For more info:
http://en.wikipedia.org/wiki/Banned_Books_Week

Friday, 12 June 2009

More on Oracle and MySql

Good point on that Oracle would improve MySQL towards Sql Server to steal its market share, rather than killing it. Altough I'm not sure implementing an oracle storage engine for the mysql front end would make technical sense.

http://andigutmans.blogspot.com/2009/05/mysql-can-be-great-for-oracle.html

Wednesday, 22 April 2009

latest news

'buys' operator being defined as: $;

sun $ mysql
oracle $ sun

at the moment, in a parallel universe:

apple $ oracle

bum! that specific universe collapses on itself.

but hey, we're safe.

Thursday, 9 April 2009

c# enum and IEquatable

Say you have a generic class like this:

class MyClass<T> where T : IEquatable<T> { }

and an enum:

enum MyEnum { MyOption1, MyOption2, MyOption3 }

would you be able to do this?

MyClass<MyEnum> MyMember;

Nope:

The type 'MyEnum' cannot be used as type parameter 'T' in the generic type or method 'MyClass<T>'. There is no boxing conversion from 'MyEnum' to 'System.IEquatable
What would you do?

Use EqualityComparer<T>.Default. By definition, behaviour is:

The Default property checks whether type T implements the System.IEquatable<T> generic interface and if so returns an EqualityComparer<T> that uses that implementation. Otherwise it returns an EqualityComparer<T> that uses the overrides of Object.Equals and Object.GetHashCode provided by T.

Nice.

Sunday, 29 March 2009

My "can't live without" firefox extensions

Tree Style Tab:
For tab-freaks like me, it doubles up the number of tabs you can concurrently manage. Shows your tabs on the left side of the browser as a tree (each new link having its referrer as parent). Especially if you have a wide screen monitor, you won't care the horizontal space you lose.
https://addons.mozilla.org/en-US/firefox/addon/5890

StumbleUpon:
At the beginning brings random web pages when you hit "Stumble!" button. As you go, you rate these pages with "I like" or "No more like this" buttons and it learns the pages you like. You can easily forward pages to friends with a single-line message.
https://addons.mozilla.org/en-US/firefox/addon/138

FlashBlock:
Blocks all the flash content in every page, unless you click on them. Extremely beneficial since flash content sucks up all the cpu you have.
https://addons.mozilla.org/en-US/firefox/addon/433

DownThemAll:
With a right-click, downloads every link on the page you're on, filtered by extension or a regex. It is also nice to download a single link, because it spawns multiple sockets (4 by default, I think) to download the file.
https://addons.mozilla.org/en-US/firefox/addon/201

From the times I was actively doing web development:
Web Developer:
Edits css in-place, browses/modifies HTML DOM, hides/shows images or their places, and a bunch of very nice features for a web developer.
https://addons.mozilla.org/en-US/firefox/addon/60

Saturday, 27 December 2008

How far the web has gone

Two signs of how far the web has gone. The second is pretty cool, though.

1. Google Native Client, runs native binary code inside the browser, deploying the necessary binaries just in time of browsing the page.
http://code.google.com/p/nativeclient/

2. VisualWebGUI, implements Windows.Forms in web context using AJAX, so after replacing System.Windows.Forms references to Gizmox.WebGUI.Forms and moving the source to a new project, your forms work on the web.
http://www.visualwebgui.com/Community/Resources/QuickStarts/tabid/365/articleType/ArticleView/articleId/392/How-to-Migrate-a-WinForms-application-to-the-Web-using-Visual-WebGui.aspx

Earlier than this, we were trying to run web applications on offline machines, mostly using installation packs containing middleware like apache/php/mysql. I guess the basic drive behind this was to make offline machines run the same application. They weren't rare at that moment, but now offline machines are barely considered as proper computers.

We're trying to run web applications locally, and local applications on the web. We're desperate.

Java was right to the spot, and 7 years before .net was there. I don't know, maybe it was too early for the concept, or Sun couldn't make a good job on keeping Java up to date. But I'm sad to see Java is dying. How do I know? Because Java programmers are paid well these days.

Thursday, 27 November 2008

What is scrum

A simple blog entry, just point at a video that explains 'what is scrum'.

Well, "it's a great method... to develop software..."

http://uk.youtube.com/watch?v=XYsFTGDSY9A

Credits to Kestutis from work.

Wednesday, 26 November 2008

Teach them assembly first!

Alice

I've come across a project, a software that aims to teach object oriented programming through 3D objects in a virtual world.

http://www.alice.org/../what_is_alice

For example, you drag a skater onto the snowy mountains, right click to her and invoke her methods like move, turn, roll or whatever. Then you go to the little code window, and drag her methods into a list to execute them in order. You have some containers like 'loop', 'if', or 'do together' for parallel execution. You drag and move methods around, move them inside containers and put together a program that controls the movement of the skater.

It brings no new teaching approach to programming model. It only removes the hassle of type-written languages and compiler-oriented problems. I wouldn't let any student to spend time on such a tool, but the ones in primary school. Programming world is big enough not to waste time on such toys; and teaching programming is not hard anyway, if you have people who really understands it and knows how to express the knowledge correctly.

Object Oriented Lobotomy

Another terrible failure is teaching an object oriented language like java or c# to a newbie for his first programming experience. Later in their careers, they'll eventually need to learn low-level stuff anyway, and they'll be scared to death. They can't live in that abstract world of managed runtimes forever. On the other hand, these languages are designed to be coded, reused and maintained easily, through the years of experience. They're not designed to be learned easily. Yes, there's a difference between "easy to code" and "easy to learn how to code".

First of all, it's harder to appreciate something, if you don't know the lack of it. The inventors of the assembly language were possibly bored enough of combining numeric instructions together, so they have used mnemonics to represent instructions. That's why we call the Assembly language a 'second generation language'. And in time, because writing assembly code is mostly dull work, and maybe because it's also hard to read and follow, they have decided to write a program which writes assembly through easier expressions, hence came the compilers and 'third generation languages'.

This is exactly why some fresh programmers hate writing getters/setters. They don't know how messy things can get if you don't do this. They don't know why it would take times and times longer to maintain a code that uses some variables which are accessed and manipulated by large numbers of lines.

Teach them assembly first!

Start simple, and teach them how to program assembly. They don't need to go in details. Indeed, basic concept of assembly programming is a lot simpler compared to higher level languages. Just a set of basic instructions will be enough to teach what it is like to program a computer to do what you want. MOV, ADD, INT, CMP, JNZ... None of them asks for more than one line of explanation. Registers are the only variables they have, and they'll naturally learn pointers which are considered as one of the hardest concepts to grasp for beginners.

As they write loops in assembly, the pattern will be obvious, and they'll appreciate why that 'for' statement has three sub statements as initialization, termination and incrementation. Then they'll know what is happening during the compilation of that for statement, and they're free to analyse the machine code.

When they're fluent with a procedural language like C, they'll again notice patterns and drawbacks of it. Some of them will appreciate object oriented, and some of them will develop their own solutions and stick to procedural model until they are pushed to switch to object oriented by a teacher in school or team leader at work.

Tuesday, 18 November 2008

Roasted broccoli


Roasted broccoli
Originally uploaded by Görkem PAÇACI
A new and absolutely delicious way to cook broccoli.

Roast it with some salt, pepper and olive oil. The only important thing is that they need to be completely dry. Roast them until they get brown spots on them.

Take them out, add some more olive oil, lemon juice and parmesan cheese. Stir well so the juice is all over them.

Do you hear them screaming?

Eat us! Eat us!

"Hunkar Begendi" for David


He said he would take "requests" for our occasional Wednesday night post-yoga din-dins. So here I go!

Hunkar Begendi is a very typical Turkish dish. It takes time to prepare, so when it's cooked it's almost a special occasion. (at least in my family where every women works)

The name means "The sultan loved it", by chicken translation. Indeed the name comes from "Begendi", which is a mixture of béchamel sauce and aubergine purée. (also served as a "Meze" along strong drinks)

SERVES 4 NON-DAMIAN PEOPLE.

The base

What:
- 4 aubergines
- 3 tbsp flour
- 4 tbsp butter (half a tablet, I guess)
- 2 glasses of milk
- 2 tsp salt

How:
- Roast the aubergines in the oven. You can wrap them with foil. Try not to pierce them, since we don't want to lose the juice. Don't cook very much so they are dry or burnt. And don't cook so little so they still have the sponge touch. They should be very soft and juicy. After cooked, peel the black skin off and smash the aubergines to have aubergine purée.
- In a pan, melt the butter and add the flour. Slowly pour the milk, and the salt after that. After the béchamel is ready, stir the purée in.

The meat sauté

What:
- 1 kg of lamb meat
- 4 garlic cloves, smashed
- 1 tbsp flour
- 1 tbsp tomato purée
- 5 tbsp olive oil
- salt and pepper (amount up to you)

How:
- Cook the meat in olive oil, in low heat
- Add the flour and keep stirring
- Add the smashed garlic cloves and tomato purée
- Add salt and pepper
- Keep stirring until garlic and tomato purée are cooked.

How to serve
First, put the aubergine base onto the plate, and add meat sauté in the middle. You can also serve with rice, but it's mostly eaten with normal-bread in Turkey. Ciabatta or 'cross-cut bread' from tesco will do.

For drink
"Ayran" will go perfect with it. It's basicly shaked yoghurt, cold water and salt. 1 unit yoghurt to 1 units water. Tesco's light yoghurt has the same sour flavour like the yoghurt in turkey.

Enjoy!

Sunday, 2 November 2008

Logitech V150

Cable length is too short. Today I've bought this mouse but the cable length is around 50/60cm. It's obviously not the appropriate mouse for a desktop. Now I'll need to buy a usb extension as well.

I'm writing this because I couldn't find the cable length of the mouse anywhere on internet, before opening the packaging.

Edit: I've bought this usb hub and it's very pleasing: http://www.amazon.co.uk/gp/product/B000VN3454/ref=olp_product_details?ie=UTF8&me=&seller=

Friday, 10 October 2008

back to dundee

Holiday version Izmir Q4 has ended. A family gathering tonight, and flight to istanbul in the morning.

if you worry if I was in that plane crashed:

at 10:30 from izmir to istanbul
at 15:25 from istanbul to paris
at 20:25 from paris to edinburgh

and hopefully train from inverkeithing to dundee.

sunday will be possibly spent in Selcuk&Gokcen's. and in monday I'll be at work. I did miss the work as well :)

Sunday, 5 October 2008

whoops! holiday is already out!

DSC_0113.NEF

Last week of my holiday, and there's still a lot to do!

This photo is from today's meeting of Flickr Izmir group. Lovely people, lovely day.