Input to be abstracted…

Work on Okteta continued a little. Yesterday I added a Find toolet, by doing also massive hacking in the program framework – not. All code that had to be done there was:

#include [kbytearraysearchtoolet.h]
Toolets.append( new KByteArraySearchToolet(this) );

Clean code, isn’ it?
And here the obligatory proof (as in fake^Wscreenshot) that it works:

Where is that byte string?

At the moment toolets are hardcoded, as seen above. Later they should be loadable as plugins, on demand and/or profile. I also had a look at the frameworks of Kate, KDevelop, KOffice/Flake and Ligature. Oh, don’t they all do the same with regard to managed model/view based programs, at least a little? I have the idea there is a way to merge all their frameworks into the one Okteta is based on. And I will try to come up with something of that kind, yeah 😛 It seems to be just a question of doing enough abstraction. And time.

Abstraction seems to be a key. When reading about parsing and operational semantics of languages it finally struck me: What else is the series of inputs by mouse/keyboard? It also is just a language of a certain grammar, and the input event handler just does the tokenizing/parsing/attributing and translates it into control commands like place cursor, select, drag etc. Now, this point of view gives me a new approach how to design the controller/toolets. And I think a promising one, once more. Did I already tell I like to design?

It’s “onBar” or “foo”, not “slotFoo”.

What would you think if you find somebody naming a function “publicDoSomething”? Or “voidDoSomething”? Or even “protectedVoidDoSomethingConst”?

It may be well what I think if these days I see somebody naming a function “slotDoSomething”. Although when I started with Qt programming you could see me giving similar names here and there. But this was just because I was following the great principle of Doing New Things By Example ™. And obviously some people had started before to apply some kind of partitial verbose hungarian notation to method names. And a funny thing about pattern based learning systems, like I and surely others are/were, is that they take correlating variations as hints to rules. And start to overdo: We see some methods that are slots being prefixed with “slot”, well, so we prefix them all. No idea, who started when and why, but now it’s there.

And I consider it to make the resulting code dirty. Being a slot is just a property of a method. Like “const”, the visibility, the return type or the types and number of parameters. All the latter properties is not referred to in the naming of the method, at least in the code I know. So why the being-a-slot property? I see no advantages, only disadvantages.

Methods that are given the property “slot” can be divided into two groups:

  • methods with a semantic to others
  • methods with a semantic to only the object itself

The first ones are functions which have a defined operational semantic, reflected in the method name, like “doFoo”. So other objects can call this method to achieve something. They are also set as slots because the operations done by the method make sense to be synchronized to certain events, by signals. Still the name is only based on the operational semantic. These functions are to be called by others (if only subclasses), so they are visible public or protected, e.g.:

class FooBar {
public Q_SLOTS:
void doFoo();
protected Q_SLOTS:
void doMoreFoo() const;

If one wants to synchronize an operation of the object to an event of another object, it writes:
connect( anotherObject, SIGNAL(bar()), object, SLOT(doFoo()) );

The latter ones differ in that they are methods whose only purpose is to catch dedicated signals. Signals with a given semantic. As reflected in the signal name, like “Done”. No other object will ever call these method, perhaps even not the object itself. It is only connected to the signal and called on it’s emission. So the semantic of the method is react-on-signal-x. In other languages like Javascript or Delphi those methods have a naming pattern: “onSomething” for the signal “something”. Makes much sense to me. Why should Qt programming be done differently?
Because these method can be only sensefully used by the class itself they are visible private, e.g.:

class FooBar {
private Q_SLOTS:
void onBar() const;

So connecting is done within the object by:

connect( anotherObject, SIGNAL(bar()), SLOT(onBar()) );
How beautiful is this code?

Think about it. A slot is just a property. Name your functions after the semantic, if is available to others, or the signal. Omit the property.
Well, or just disagree 😛

Hm, not yet convinced? Than take your final push:
“on” is two letters less to type. And two characters less to compare on function lookup, so results in faster linking. A little, at least. 😉 And without “slot” it is even four letters less.

Now you are convinced, right? Then go and improve your KDE code. Now! 🙂

From your comments I guess I was not too clear, hope the added text now helps to understand better what I mean. Some things should simply get some more days to be written, sigh.

Exclusive first picture of Okteta!

Those who looked into kdeutils/khexedit the last two years might have wondered:
Why does it include a byte editor library, but does not use it for the program KHexEdit itself? Read for an answer.

I spend some hours again with Okteta. And got it into a state where I can show at least pictures to the world. Well, looks similar to the old program KHexEdit. But the picture does not show what is interesting:
The core of the program does not have a clue about byte editor and byte array model. It just deals with document, views and so-called toolets. Toolets are the central part of this project. They operate on certain interfaces and plug their actions and monitor/control views into the window framework. E.g. a zoom toolet would automatically support all views with the zoom interface. But more on this at another time.

Prealpha run of Okteta

SUSE, oh SUSE, what shall I do?

Novell (HQ) throws themselves into Microsoft’s arms, marries into the business of logic patents. That sucks so much. As a member of the FLOSS community I feel betrayed.

I came into the world of FLOSS with a SuSE 5.3 (or so). Since then (by accident in the beginning) I never tried another distro, was always pleased with the SUSEs (after some minor tweaking now and then), spend even some money on some boxes, was amazed how smooth the updates usually went, promoted the use of it. And learned to use and like Yast 😉

Now this. I still am not sure I understood the published contract correctly, but I feel very bad about it. It smells. Very badly. I don’t care if Novell make a contract with Microsoft. But I do care that this contract is supportive of the principle of patents on logic/software. And even more proposes Microsoft to go after non-Novell FLOSS providers on this. Novell HQ, you did not get it. Patents on logic are dumb and a smack into the face of every software engineer/mathematician. And a smack into every company concentrating to deliver well supported, high quality software system to their customers, instead of cleaning and destroying the market by state-supported solution space mining. They are turning four-year contract managers and jurists into highwaymen and parasites of the brave working men and women. Novell HQ, go and help the US patent system to get rid of logic and primitive patents instead of complying to this evil. You now only suck. Big times. Betraying your fellow players by becoming a renegade and switching to the foul playing team. It can only be hoped Novell soon changes it mind/heads again and returns to saneness (well, when was Novell last sane? 😦 ).

By having been a verbose user of the SUSE distri to my neighbourhood I feel now a need to switch to something else. Very fast. Should I? I guess. What to? Fedora? Debian? KUbuntu? Kanotix? Mandriva? Any suggestions? What can live up to SUSE or is better?

Another, lesser smartness of yesterday which at least could give me a little ironic smile at:
At Spiegel online (big german news site) an article described the reaction to the movie “Borat” by some students from Kazakhstan, who are everything but pleased that people are making fun out of talking nasty bullshit about the country. And express their sorry that real facts about the world’s 9th largest country are so unknown. What was to be proved: The editors of the article had to correct themself on the name of the current capital of Kazakhstan after publishing.

I like human beings. They are so… funny. Haha.