Freitag, 2. Dezember 2016

Why The Hate Against Useful UI Semantics?

Okay, this will be a rant. You have been warned.

You know, it used to be that lists were called tables, and tables had the following elements and semantics:

  • There were headers for each row with the name of the field in them.
  • You clicked on the header to activate/switch the sort to this field.
  • If the table was editable, you could tab through the fields.
  • If you left the row, you'd jump to the first field in the next row.
  • If the table had row insertion, there was an additional, empty row below the last row.
  • You added a new row just by editing this last, new row, which was marked by a little star.
  • The default sorting order was from top to bottom.
  • The scrollbar made it easy to navigate to the end of the list.
Of course, this was much too primitive. And complex. And unseemly. These days, things are way simpler and more user friendly, because the science of UX design has experienced massive improvements over the last two decades. /s

We have a hard time doing real scrolling on the web, so we reverse the sort order and perform weird "infinite scrolling" tricks so we still get some half-assed usefulness. Or we paginate the whole thing, and the user has to navigate by pushing some double-arrows. Argh.

For example, let's consider the "board" interface in pinterest:
  • Each board has a name.
  • In the "select board" popup, boards are in a vertical list, sorted by name ascending. There is no way to change that.
  • If you have more than x boards, there will be exactly three most-used boards on the top of the list.
  • There is no way to change that.
  • If you want another sort order, the only option is to somehow hack it into the name (by prefixing it with "00100" or some similarly stupid nonsense).
  • The "edit boards" interface, on the other hand, is not sorted by name, but (I guess) by creation time or id. So your whole clever hack is competely useless there. If you reorder the boards by changing their names, you get no visual feedback at all.
  • Neither is the "edit boards" interface a simple list. It's organized in tiles covering the whole screen width. You cannot change that either. I guess that one button would have cost too much screen real estate.
 Also, and I cannot stress this enough, 3D elements are evil. Because, you know, they feel like something you know from the real world, and we do not want people to have an intuitive handle on our precious UI. Duh.

Freitag, 11. Dezember 2015

Note to self:: Don't use SimpleXmlElement if you have to change the XML's contents.

In PHP, if you really HAVE to do php - never ever EVER succumb to temptation and use a SimpleXMLElement for CHANGING the XML.

It seems to have methods for doing so, but believe me, they just don't work.

You'll end up doing crazy stuff like this:

         $xml2 = self::sortArticlesByFileNames($xml);
         $xml = simplexml_load_string($xml2->asXML());

And then, of course, you have to return $xml, so if you are already returning something else, you'll end up with

        list($xml, $whatever) = doStuff($xml);

for every single function that will change the xml.

Blargh.

In fact, probably, it's better to simply refuse to use SimpleXmlElement at all. It stinks.

Just. Don't. Do it.

You have been warned.

Mittwoch, 30. September 2015

PHP and SFTP issues

We implemented an SFTP module for some website in PHP.

It was decided to use the php ssh2_* functions (PECL ssh2).

This worked as expected on the dev machines. It also worked from the staging machine towards my private external host.

The one thing that didn't work was connecting to the customer's host. Or, rather, it seemed to connect, but no file was ever uploaded. This made us all a tad sad, and me as the coder-in-charge slightly panicky.

We then proceded to install Net::SFTP (http://sourceforge.net/projects/phpseclib/). This worked like a charm.

I haven't found anything related to this issue on the whole wide internets.

What gives?

Sonntag, 12. April 2015

My vim/gvim setup for a node.js project

In my .vimrc, there is a function ProjectLoad() which will look for and read a session file in the current working dir, and then look for/source a  local .vimrc.

In the .vimrc for my current node.js project, there is a function NodeTest() which will run my project's test suite and paste the results into a new buffer.

Here are the relevant function definitions:

~/.vimrc:

function! ProjectLoad()
    if filereadable(".vimsession")
        so .vimsession
    endif
    if filereadable(".vimrc")
        so .vimrc
    endif
endfunction
function! ProjectSave()
    mks! .vimsession
endfunction

command! ProjectLoad call ProjectLoad()
command! ProjectSave call ProjectSave()

/path/to/project/.vimrc:

function! NodeIntoFile()
    redir! > out.log
    set nomore
    !node js/test/runTests.js 2>&1
    redir END
endfunction

function! NodeIntoBuffer()
    new
    r !node js/test/runTests.js
endfunction 
command! NodeTest call NodeIntoBuffer()


I wrote NodeIntoFile() while I was trying to auto-run the tests upon :w (i.e., FileWritePost), but that doesn't work out on Windows because it will always pop up a cmd window which stinks. If you know a way around that, please let me know!

Otherwise, maybe you can use those functions in your own setup.

Mittwoch, 25. März 2015

Do Your Weekend Projects!

There is a joke among me and my friends that every programmer should try their skill with the following at least once in their life:


  • a parser / parser-generator / programming language
  • an MVC framework
  • a text editor and/or a word processor
  • a raytracer
  • and just because it's a fetish of mine: a genetic algorithm
Last weekend, I was meddling around with Node.js, just to explore new territories, and I inadvertently treaded on the territory of MVC. And suddenly, a truism hit home that I had read a few times before but never quite grokked before:

You do not do a weekend project in order to get anything done.

An MVC, just as all the other examples above, has been done a trillion times, and most probably there are already thousands of excellent frameworks out there. I couldn't create something that's actually better than that. So why bother?


You do a weekend project because you will learn something, and because it's fun.

(If you're a professional coder, I sincerely hope that those two areas overlap for you. Otherwise you might consider switching jobs.)


I guess I had always had productivity and success somewhere in the back of my mind. "It isn't good if it doesn't sell", or at the very least if it doesn't solve some real-world problem.

Not true. I have fond memories of the time when programming was fundamentally fun and games and geek pride galore. Time to let go a little of the professional cynicism acquired in years of professional coding. Sure, at the job you have to, well, get the job done, and that's your top priority. But in your spare time, a little idealism can help you improve as a coder. I understand MVC better now, I have a little more insight into the nature of dynamically typed languages and DSLs, and I can happily put Node.js into my CV. What's not to love?

So, folks, have your weekend projects, hack away with pride, and DFTA!

Mittwoch, 28. Januar 2015

Using VIM as a Frontend for MySQL

Being deeply dissatisfied with MySQL Workbench, which tends to go nonresponsive on me at least once per day, I started looking around for other solutions. Since I'm a VIM aficionado, this occurred to me as one of the places to look. Of course, I got lucky.

Here's the solution (It's a slightly modified version of the code found here: http://superuser.com/questions/266934/how-to-pass-vim-buffer-contents-through-shell-command-and-capture-the-output-to):

function! FilterToNewWindow(script)
    let TempFile = tempname()
    let SaveModified = &modified
    exe 'w ' . TempFile
    let &modified = SaveModified
    exe 'split ' . TempFile
    exe '.! ' . a:script
    exe 'setlocal buftype=nofile'
    exe 'setlocal bufhidden=hide'
    exe 'setlocal noswapfile'
    exe 'setlocal noet'
    exe 'setlocal ts=25'
    exe 'setlocal number'
endfunction
command! MF call FilterToNewWindow('mysql --defaults-file=/etc/mysql/debian.cnf -t <DATABASENAME>')

Paste the above code into your .vimrc, open a new vim, and...:

  • Enter a SQL command into current buffer
  • Do :MF at the line you wish to use in mysql
  • A new buffer will open up with the results of your query. (Actually, of course, it's the other way around, but who cares...)
  • This buffer will be a scratch buffer, so you don't get an ugly error message when doing :q
You should use the mysql defaults file, otherwise your mysql credentials will end up in (I guess) your bash history. The -t argument will make mysql export its results in the nice table format used in the mysql command line client. setlocal number, noet and ts (tabsize) are not necessary, but I want them in my scratch buffer anyway.

Of course, you can use FilterToNewWindow() with all kinds of external programs. I'm sure I will put it to good use in the future.





Donnerstag, 12. Juni 2014

Tears in the Rain

<?php
class X {
    public function foo() {
        echo "foo";
    }
}
function foo() {
    echo "global foo";
}
X:foo();

This will happily print "global foo" on your screen. No complaints by the parser (nor by NetBeans or PHPStorm...)

In case you're wondering why this is strange, take a look at the T_ACHAT_NEKUDA between X and foo().

Yay.

Mittwoch, 19. März 2014

Performance Penalties In JavaScript: Recursion vs. Iteration / Native DOM Objects vs. jQuery

In one of my own private projects (codename "Tag Bonsai"), a little chrome extension for working with tags, I ran into some performance issues. I figured this was down to recursive creation of DOM tags, so I ran a little test. (Find the full code at the bottom of this posting!)

The results were astounding.

They were not astounding, though, regarding their general direction. Of course iteration is faster than recursion, and of course native JS objects are faster than their jQuery sires.

What was astounding was the sheer factor of performance penalties involved. On my puter, those are the results when creating 10000 spans:

recursive on jq objects: 11567.999999999302
recursive on js objects: 348.99999998742715
recursive on acc'ed html: 82.00000002398156
iterative on jq objects (without penalty): 10442.000000010012
iterative on js objects (without penalty)201.9999999902211
iterative on acc'ed html (without penalty): 41.99999998672865
iterative on jq objects (with penalty): 9248.00000002142
iterative on js objects (with penalty): 425.99999997764826
iterative on acc'ed html (with penalty): 61.000000016065314
 That's a factor of ~ 190 when writing html manually in an iterative loop, compared to recursively creating jQery objects, even if I penalize the iterative by doing a push and pull each time (because under production circumstances, I'd have to manage a stack of objects by hand).

Here are the results again, ordered by time:
iterative on acc'ed html (without penalty): 41.99999998672865
iterative on acc'ed html (with penalty): 61.000000016065314
recursive on acc'ed html: 82.00000002398156
iterative on js objects (without penalty): 201.9999999902211
recursive on js objects: 348.99999998742715
iterative on js objects (with penalty): 425.99999997764826
iterative on jq objects (with penalty): 9248.00000002142
iterative on jq objects (without penalty): 10442.000000010012
recursive on jq objects: 11567.999999999302

Okay, JS objects are obviously a bit slower than pure html text (by a factor of 3 or so), and recursion drops the speed by another 3rd or so; but jQuery is an awful lot slower than that!

According to this simple test, jQuery objects involve a forbidding impact on performance, especially when combined with recursion. (It's interesting that iteration w/ jQuery and recursion w/ JS objects are relatively close together.) So if you have to create lots of DOM objects, and if you know which browser you use, definitely use the native JavaScript methods!

(I'm not quite sure why some penalized versions seem to be faster than their non-penalized counterparts - there might be some bug in my code, or it's just some random imponderability in my machine; but I think the general direction is still correct and as revealing as a skimpy white dress under heavy rain. It's just staggering.)



Here's the code (The StopWatch class is taken from this Stackoverflow posting.):

            var limit = 10000;
         
            function createSpanRecJqObj(i, el) {              
                var div = $('<span>' + i + '</span>').appendTo(el);
                if (i < limit) {
                    createSpanRecJqObj(++i, div);
                }              
            }
            function createSpanRecHtml(i) {              
                var html = '<span>' + i + '</span>';
                if (i < limit) {
                    html += createSpanRecHtml(++i);
                }
                return html;
            }
            function createSpanRecJsObj(i, el) {
                var span = document.createElement('span');
                span.appendChild(document.createTextNode(i));
                el.appendChild(span);
                if (i < limit) {
                    createSpanRecJsObj(++i, span);
                }
            }
         
         
         
            function createSpanIterJqObj(i, el, penalty) {
                var stack = [];
                if (arguments.length === 2) penalty = false;
                var i;
                for (i = 0; i < limit; ++i) {
                    if (penalty) stack.push(i);
                    el = $('<span>' + i + '</span>').appendTo(el);
                    if (penalty) stack.pop();
                }              
            }          
            function createSpanIterHtml(i, penalty) {              
                if (arguments.length === 1) penalty = false;
                var html = '';
                var stack = [];
                for (var i = 0; i < limit; ++i) {
                    if (penalty) stack.push(i);
                    html += '<span>' + i;
                }
                for (var i = 0; i < limit; ++i) {
                    if (penalty) stack.pop();
                    html += '</span>';
                }
                return html;
            }
            function createSpanIterJsObj(i, el, penalty) {
                var stack = [];
                if (arguments.length === 2) penalty = false;
                console.log('penalty', penalty);
                var i;
                for (i = 0; i < limit; ++i) {
                    if (penalty) stack.push(i);
                    var span = document.createElement('span');
                    span.appendChild(document.createTextNode(i));
                    el.appendChild(span);
                    el = span;
                    if (penalty) stack.pop();
                }
            }
         
         
            $(document).ready(function(){
                var sw = new StopWatch();
                sw.start();
                createSpanRecJqObj(0, $('body'));
                var timeRecJqObj = sw.stop();
                $('#time').append('recursive on jq objects: ' + timeRecJqObj + '<br/>');
             
                sw.start();
                createSpanRecJsObj(0, document.getElementsByTagName('body')[0]);
                var timeRecJsObj = sw.stop();
                $('#time').append('recursive on js objects: ' + timeRecJsObj + '<br/>');
             
                sw.start();
                $('body').append($(createSpanRecHtml(0)));
                var timeRecHtml = sw.stop();
                $('#time').append('recursive on acc\'ed html: ' + timeRecHtml + '<br/>');
             
                sw.start();
                createSpanIterJqObj(0, $('body'));
                timeIterJqObj = sw.stop();
                $('#time').append('iterative on jq objects (without penalty): ' + timeIterJqObj + '<br/>');
             
                sw.start();
                createSpanIterJsObj(0, document.getElementsByTagName('body')[0]);
                timeIterJsObj = sw.stop();
                $('#time').append('iterative on js objects (without penalty)' + timeIterJsObj + '<br/>');
             
                sw.start();
                $('body').append($(createSpanIterHtml(0)));
                timeIterHtml = sw.stop();
                $('#time').append('iterative on acc\'ed html (without penalty): ' + timeIterHtml + '<br/>');
             
                sw.start();
                createSpanIterJqObj(0, $('body'), true);
                timeIterJqObj = sw.stop();
                $('#time').append('iterative on jq objects (with penalty): ' + timeIterJqObj + '<br/>');
             
                sw.start();
                createSpanIterJsObj(0, document.getElementsByTagName('body')[0], true);
                timeIterJsObj = sw.stop();
                $('#time').append('iterative on js objects (with penalty)' + timeIterJsObj + '<br/>');
             
                sw.start();
                $('body').append($(createSpanIterHtml(0, true)));
                timeIterHtml = sw.stop();
                $('#time').append('iterative on acc\'ed html (with penalty): ' + timeIterHtml + '<br/>');
             
            });

Mittwoch, 19. Februar 2014

Optional Parameters in Javascript

Want a nice laugh? Here it comes.

For years, I've been hacking in JavaScript, as it were, "on the side". Just as a necessary, sometimes fun, often loathesome part of the webproject experience.

When doing optional parameters, I always did this:

function foo(a) {
    if (arguments.length === 2)
        b = arguments[1];
    else
        b = 'bar';
}

The problem with this is so obvious I won't even spell it out.

Here's the puncher.

What I somehow managed to miss until today, is that you can also do this:

function foo(a, b) {
    if (typeof(b) === 'undefined')
        b = 'bar';
}

Shorter, sweeter, more obvious. If I'd just known this a bit earlier.

HAML, HTML, Ruby, and Marketing

I just took a look at HAML, having been linked there from Mark Hansen's blog posting @ http://www.markhansen.co.nz/autocompiling-haml/.

After about 2 minutes, I had two questions on my mind:

1.
Why, oh why, do ruby projects tend towards this massive, obtrusive self-marketing? "templating haiku", "Simplify. Enjoy. Laugh. 20 minutes later, you will never go back." To me, this just seems silly. Most of your users are technically-minded coders who will evaluate your project based on exactly one question: Will it make their lives easier?

When I look at, for example, www.vim.org, www.php.net, or, heck, even www.microsoft.com, I don't see that. Ain't nobody as can claim those are unpopular, failed sidenotes of IT history.

2.
Which leads me to my second question: In what way exactly is HAML more beautiful, elegant, or expressive than HTML? I mean, yeah, it has nifty "=" and "%" signs all over the place, and it doesn't duplicate code in closing tags, so that's an advantage I guess. On all the other hands, it seems to use semantic whitespace, which I loathe. I want my code surrondedwith fancy "{"s! I get to decide how to indent, and what, and why!!!!!111one!!

Maybe it integrates nicely into ruby/rails. I wouldn't know, I'm just a lowly PHP hacker. (It feeds me and my cats, so don't ask.) Maybe it's just a matter of taste. Maybe I'm gettin' too old for this sh*t. Or I'm not good enough.

Seriously, I just don't know.

Samstag, 5. Oktober 2013

Optional Parameters in PHP, and NULL

Consider the following PHP5 code:

<?php
class A{
      function foo() {}
}
function f(A $a = NULL) { var_dump($a); }
function g(A $a) { var_dump($a); }
f(new A());
f(NULL);
g(new A());
g(NULL);


Now, consider its output:

class A#1 (0) {
}
NULL
class A#1 (0) {
}

Catchable fatal error: Argument 1 passed to g() must be an instance of A, null given, called in a.php on line 13 and defined in a.php on line 8

Okay. So, a parameter, with or without a type hint, whether required or optional, receives an A if given an A. No surprise there.

An optional, type-hinted parameter, when given a NULL, results in a NULL. I guess that's fine, too.

However, a required parameter can not ever be set to NULL.

You're right: Setting something to NULL in the parameter list means something totally different than setting something to NULL anywhere else in your code.

I guess what they were trying to do was force the = NULL, passing NULL "idiom" to represent the fact that the parameter is optional, and is not set. I guess the reason is that you can not default a type-hinted parameter to anything besides NULL. The function body can not distinguish between a NULL stemming from the default in the parameter list, and an actual NULL, and NULL is the only indication that the optional parameter was left out, so passing a NULL is disallowed in the case of a required parameter.

Or something like that. (If you omit the type hint, passing the NULL works perfectly fine, by the way, thus making it even more confusing...)

Regardless of how long, or how hard I think about it, it keeps making no sense at all. It is neither consistent, nor is it useful. It is, at best, an attempt of the language to be clever - an attempt, I should say, that went terribly terribly wrong. At worst, it is a result of some obscurity in the parser that nobody ever really thought through.

In any case, it makes me even more sad to be forced every working day to work with tools as broken as that.

Dienstag, 24. September 2013

Magento and Getters

From the Magento core code (in class Magento_Core_Model_App):

    /**
     * Retrieve request object
     *
     * @return Mage_Core_Controller_Request_Http
     */
    public function getRequest()
    {
        if (empty($this->_request)) {
            $this->_request = new Mage_Core_Controller_Request_Http();
        }
        return $this->_request;
    }


Folks... puleaze!!!?

I just wasted about an hour on finding out where $this->_request was initialized. I debugged over $this->getRequest() about a gazillion times. This is just not the way to write code, for crying out loud! The phpdoc block actually states this, right up there: Retrieve request object. Retrieve!!!!!!!!1112. It doesn't say anything about initializing it.

I mean, yeah, by now I should probably be able to anticipate stuff like that, seeing as some of the magento standard models' load() methods have an optional parameter $create that defaults to... you guessed it! True!!

Some. Not all. That would be too consistent (even if it's decidedly wrong).

Duh.

Dienstag, 10. September 2013

realX

I know that this is not a very unique idea, but it's such a common mistake one cannot be reminded of it often enough.

Only recently, I stumbled upon a code fragment that performed something akin to sudo on a webshop. It took a customer_id from the request, checked the logged-in customer's permissions, and then it went about and set a

realCustomer

to the customer from the session... or it set the customer from the request to the realCustomer, while the session customer remained untouched.... or...

See what I'm aiming at?

If you're ever tempted to use something like "real" to distinguish between two objects, please take the time and think about what that object actually represents. The adminCustomer, maybe, the loggedInCustomer, or the effectiveCustomer. But never the realCustomer.

thesaurus.com is a valuable, and deeply underappreciated, resource for coders.

Mittwoch, 5. Juni 2013

Fields a table should always have

These are fields I think should be available in (almost) every database table, everywhere:


  • id
    • A unique identifier. There might be a few exceptions, but almost every time I designed a table without a primary key, I came to regret it afterwards.
  • created_by
    • Almost always, you want to be able to find out who did what, when, where.
  • created_at
    • Almost always, you want to be able to find out who did what, when, where.
  • updated_at
    • Almost always, you want to be able to find out who did what, when, where. Obviously you don't need this field on insert-only tables.
  • is_active
    • Most of the time, you do not actually want to delete data. You want to deativate it, mark it deleted. On rare, VERY rare occasions, it makes sense to move it to another table or database. But that's really the exception. By default, just mark it as unactive or deleted or whatever. Quite often, you might want a status instead of a flag. (But only VERY rarely, methinks, do you want both. It's a smell to have a lot of flags, and it's another smell to have a status field plus flags.)
  • source
    • AT LEAST on tables that you (might at some point) import from another database, you want to mark the source. I can't count the times I've had to create enormous code monsters just to heuristically find out what data came from the last import, just to then delete it and re-start the process. DELETE FROM funny_table WHERE source='my_funny_import' would have made my life so much easier! (There, I said it: Delete. Yep, that's definitely one exception where it actually makes sense.)

Samstag, 6. April 2013

iTunes

Folks... hello??? What the heck is wrong with you guys?

Controls that don't provide visual feedback on activation; a "new" watermark that never seems to vanish; when you're in the midst of the download and then have to switch off the 'puter, after switching it on again, the download doesn't restart. You have to find the mechanism to restart it inside of some obscure non-standard menu. And when you download 2 or more things, you don't get any information about that.

And here I was, thinking that apple was overpriced and arrogant, but at least they knew how to hire usability experts for my money.

Have you eaten fruit that didn't smell good, or something?

Dienstag, 2. April 2013

A Change Of Style

It used to be that I insisted on my conditionals alwaysinghave the positive part in the front, like so:

if (isOkToDoStuff)
    doStuff();
else
    throw new Exception('unable to do stuff');

My logic was that the use of !s should be minimized, that the positive part naturally should come first, and that you should have the actual code for your function on top.

However, in recent times, I find myself liking another idiom better: handling exceptional and error cases first, and then doing what the function is supposed to do, like this:

if (!isOkToDoStuff)
    throw new Exception('unable to do stuff');
if (!otherPrerequisiteINeed)
    throw new Exception('unable to do stuff');

doStuff();


The advantage being no (ugly!) indentations or (unreadable!) &&-ed expressions for additional error conditions. Which will always creep up after the first deployment, or at least after the initial coding session. 

Plus, no occasion to forget adding curly braces to the if clause. ;-)

The other, more important advantage, is that the idiom doesn't change over time. You always have the error conditions first, the code to ultimately run at the end, and the actual code is not buried under 16-indentation-weights forged out of nested ifs.

Somehow, it isn't as elegant. But more practical. Which, mostly, is to be preferred, whether we like it or not.

Freitag, 29. März 2013

My Big Fat Christkindle Wishlist

Dear Christkindle,


this is a - probably growing - list of rules, principles and just... nice features that I would rather much like our beloved industry to implement/adhere to:
  • Webshops and web20 frameworks
    • I want ONE way to search, and one customary location for the search field (upper right corner, or upper left, or upper middle... just... ONE location)
    • In general, I want more customs for webpage design, so it gets easier for users to find their way around.
    • Keyboard shortcuts across different websites and web20 frameworks should adhere to a few agreed-upon standards (can you confirm a popup with Enter? Ctrl+Enter? Does Shift-Enter add a linefeed in a textarea?, etc.). In an ideal world, those standards should always reflect the way the user's OS does it, because that's probably the way she wants it.
    • There needs to be some framework that deploys field and form validations to the server and the client from the same source. It is unacceptable that we mess around in PHP on the one end, and then do the same thing (or, rather, hopefully something akin to the same thing) in JavaScript on the other end.
  • Other web stuff
    • There are thousands of sites that fall into a large category of content: For example, there are thousands of blogs out there, mostly consisting of large chunks of texts (aka articles). I want them presented the way I find most readable - in a large, readable font, with columns that contain about 5-6 words per line, and with good contrast (roughly the way the Readability Redux plugin for Chrome does it). The same goes for other kinds of data. 
    • At the very least, the interface should be consistent across ONE site - most sites don't even manage to adhere to that basic idea.
    • Whenever you can design something as asynchronous, you should. I don't understand why I have to wait for the whole form to reload just to realize that I forgot to fill out a field, and when I enter my zip code, I want the damn thing to fill in my city as soon as possible.
  • IDEs
    • Keyboard shortcuts in IDEs should be standardized (especially the debuggers... they're such a pain in the glute, because they use similar-but-slightly-different keys.)
  • Coding Patterns
    • SQL
      • A primary key is an arbitrary value that has no meaning beyond uniquely identifying a tuple. Never give in to the temptation of using user-provided, editable values (such as email addresses) as primary keys. It'll come around and bite you in the abdomen big time! (There is an argument to be made for meaningful keys, as long as they don't change, or change only once every few years - such as a country code. I'm quite undecided in that case, frankly. Overnormalization vs chaos.)
    • Naming conventions
      • I won't make the mistake of starting holy wars here, though I think it might be time to start thinking about some general rules that everyone knows as a matter of honor - as things currently are, I'd be happy if they even existed on a per-team basis, at least. Working with external libraries that have different conventions is a pain in the sphincter, and having underscore_fields in sql, then camelCaseFields in php, but underscore_fields again in your html forms is, at the very least, very ugly - but for the time being, I don't see that changing, so I'm going for second best.
      • At the very, very least, if the database field name is is_locked, then the name in the code should not be isOpen, hasALock, or numOfChimneysInTheFactory. Yes I've seen (and, possibly, even produced) code at a similar level of insanity, sadly.
  • General stuff
    • If an object could be represented as a file, (such as an email or a bookmark, or an actual file in a filesystem) then it should be stored in a hierarchical system of tags, much the way gmail does it.
As you can see, my general principles here are the following three:

  1. The user should not be afraid of the designer, but rather, the designer should respect the user.
  2. Whatever we manage to standardize, is one issue we don't have to think about anymore.
  3. I forgot what the third one was.

Projects I Would Love To Get Done

This is a list of projects that keep floating in and out of my head, with precious little chance of ever getting done properly. But I still love fantasizing about them, and they inspire me to learn stuff, so they are actually rather useful still.

* An ERP
* A declarative data evaluation framework
* An ORM
* An in-browser scrum board
* A game based on evolutionary algorithms
* A browser plugin to normalize pages to the user's preferred view, based on evolutionary algorithms
* That android application my father would like to have
* A working DocBook editor

If you are so kind as to respond, please don't tell me that most or all of those already exist / are way too much work for one guy / are useless / make no sense, etc. I know all that. This is not about usefulness in the technical sense.

Instead, maybe you would like to share a few of your beloved dream projects that will probably never see the light of the screen.


 This is about having fun, for the very special value of fun that geeks like me subscribe to.

Mittwoch, 6. März 2013

Where is the gorram list of E_STRICT conditions...?

I've spent something like 20 minutes now, googling and perusing php.net, in search of a comprehensive list of the conditions under which PHP 5 will issue an E_STRICT warning.

I haven't found one yet.

So.... does anybody out there have a link for me? Pretty please...?

Dienstag, 5. März 2013

I Call Poe On That One (und zwar auf Deutsch, meine Lieben!)

Unter dem Titel "Aufmarsch der Hyperkorrekten" hat sich ein gewisser, sonst unauffälliger Alexander Kisser die Seele aus dem Leib geschrieben. Das ist zunächst einmal einfach einer, der uns auch schon über "Religionsfeindlichkeit, die neue Trendsportart" und ähnliche abendländische Untergänge ausgesprochen amüsant zu unterhalten verstanden hat.

Meine Mutmaßung: Es muss sich hier um einen Poe handeln. Wie anders ist zu erklären, dass er ausgerechnet die alten, doch deshalb noch lange nicht zusammengewachsenen Themen Vegetarismus und Homosexualität wieder in die ihnen ausschließlich von unseren lieben Fundis verordnete Zwangsehe presst? Gewiss verlässt er sich auf unseren Feinsinn, unser Ironiegespür, wenn er - ausgerechnet in einem öffentlichen Artikel im Internet - den Verlust seiner Meinungsfreiheit beklagt. Dass es sich bei seiner um eine Meinung handelt, die dank ihrer jahrtausendelangen politischen Umsetzung mit allen Mitteln von politischer Macht und frommer Rücksichtslosigkeit Millionen von Menschen in ihrer Freiheit massiv beschnitten hat und auch heute noch beschneidet, gibt dem ganzen erst den gehörigen Pfeffer. Es hat schon ein gerüttelt Maß an Metahumoristik, wenn so einer so etwas abseimt.

Ich vermute aber, er möchte uns nur auf künstlerisch subversive Weise darauf hinweisen, dass einige wenige unter unseren lieben christlichen MitbürgerInnen das Konzept der Meinungsfreiheit noch nicht vollständig zerebral resorbiert haben dürften. Sie laborieren scheinbar unter dem Wahn, dass es sich dabei um die Freiheit handelt, unter allen Umständen alles und jedes hervorzuwürgen, ohne dass ihnen widersprochen wird. Zur Sicherheit sei es noch einmal erwähnt, wenn es denn auch das hunderttausendste Mal ist: es geht ausschließlich darum, dass der Staat, und nur der Staat, die Absonderung auch absonderlicher Meinungen nicht zu verhindern hat, sofern sie nicht gegen höheres Rechtsgut verstößt.

Interessant ist natürlich immer auch die Frage, worin eigentlich die beklagte Unterdrückung besteht - um echte fundamentalistische DenkerInnen noch besser imitieren zu können, hat der Autor jede Andeutung dazu gekonnt vermieden. Ich vermute, er meint damit, dass ihm die letzten beiden Male, als er seine leise Furcht vor den privaten sexuellen Präferenzen wildfremder Leute offen zur Sprache brachte, jemand mit ein paar handfesten Argumenten lautstark klargemacht hat, warum er falsch gewickelt ist. Wenn du Schwachsinn reden darfst, darf ich auch entsprechend darauf antworten. So ist es nun einmal. Aber eine solche parodistisch überhöhte Wehleidigkeit kennen wir ja von vielem, was im Fundianerlager die Veräppelung tanzt, um dessen tolldreiste Dummheit der verdienten Lächerlichkeit preiszugeben.

Um beim Thema der gekonnten Parodie zu bleiben: Ganz besonders schmunzeln musste ich beim Satz "Wer es aber wagt, leise Zweifel anzumelden, zum Beispiel, ob vielleicht Homosexuelle doch nicht die besseren Eltern sind, der wird in Bann und Acht gesteckt, vergleichbar dem mittelalterlichen Spießrutenlauf." Auch bei langen, tiefen und tiefsinnigen Meditationen will sich meinem Gedächtnis keine Szene erschließen, in der jemand behauptet hätte, Homosexuelle seien bessere Eltern. Schon gar nicht kann ich mich an Szenen erinnern, in denen irgendjemand wegen seiner Angst vor dem bösen Schwulen zu einer tödlichen militärischen Strafe verurteilt wurde. (Nachlesen hilft durchaus, bevor man sich in unpassende Metaphern versteigt.) Soweit ich mich erinnere, war es am Stammtisch noch vor so ein, zwei Jahren durchaus normal, dass gegen Schwule gehetzt wurde, meist nach der höchst versöhnlichen Einleitung "Ich hab ja nix gegen Schwule... ABER...". Eine dem entsprechende Hetze gegen Heten meine ich hingegen kein einziges Mal gehört zu haben.

Man hätte halt gern mal ein paar handfeste, methodisch saubere Studien, die belegen, dass Homosexuelle schlechtere Eltern sind. (Schlechter inwiefern übrigens, gemessen woran? Wie geht man daran, das zu messen? Und wenn ja, wie groß ist überhaupt die Standardabweichung der Elternqualität? Stellen sich manche in ihrer skurrilen Weltsicht tatsächlich vor, dass zwei hasserfüllte, dafür aber heterosexuelle Eltern, die ihre Kinder schlagen und vergewaltigen, für diese Kinder besser sind als zwei liebende Männer oder .... oh Schreck... gar Frauen, weil letztere nicht dem Natur-, Schöpfer- und Volkswillen entsprechen, erstere aber schon?)

Ja, ich würde so etwas unter Umständen sogar lesen. Und dann die Metastudie dazu. Ich lasse mich jederzeit davon überzeugen, dass Schwulenehe bzw. Adoption durch Homosexuelle eine schlechte Idee ist - nur bräuchte es dazu halt Argumente und Evidenz statt Essentialismus und Intuition. Ich gebe nicht vor, zu wissen, welche Kombination von Eltern ideal ist - ich vermute eher, dass es niemand weiß. Und die, die behaupten, es doch zu wissen, kommen mir allgemein etwas um Argumente verlegen vor. Ganz davon abgesehen, dass das Leben nun einmal im Großen und Ganzen zumeist nicht sonderlich ideal verläuft.

In der Gesamtwertung war der Artikel eine parodistische Glanzleistung, die ich sehr gerne gelesen habe.

An einer Stelle hat mir der Artikel allerdings doch nicht so sehr gefallen. Da hat er seine ironische Absicht ein wenig zu deutlich verraten. Wenn er gegen Unisex-Toiletten anschreibt, weiß auch noch der letzte internetzkulturell herausgeforderte Mensch: Jetzt will er uns verarschen.