Wednesday, 30 July 2008

The Apex community (or standing naked in the window)

A few years ago I was assigned to a project in London and, as a result, found that my working day was bookended by one-hour train journeys to and from work. (It was an ... interesting project which involved designing a database in conjunction with a team of "flat-earther" web developers who didn't believe that relational databases were important and in whose world E F Codd was probably strangled at birth.) As the train neared London it snaked past a residential area. One day I looked up from the novel I was reading and caught a brief look of a woman standing in an upstairs window - completely naked.

The internet is something like that. The promise of anonymity that it affords us often brings out the weirdest facets of our personalities; the same facelessness that emboldened that nameless woman often makes people go on messageboards and act like fools.

However, fortunately, I have found that the Apex community - and it is a community - is completely different. Every day I am discovering new blogs that outline in painstaking detail solutions to problems I didn't even know I had yet. (I spent this morning writing code to log users out of my app if they've been inactive for half an hour: I found everything I need to achieve this here. I also adapted code I found here to write myself form that'll enable me quickly enter help text for the items in my app.) It's also quite nice that not long after I posted an entry questioning Oracle's commitment to Apex I got a response from David Peake, the product manager for Apex in Oracle reassuring me. Just in case you've had questions of your own on the same subject here's part of what he had to say:

Oracle has shown its commitment to Application Express by making it part of the seed installation of Oracle Database 11g. Therefore, whenever you install Oracle Database 11g it automatically installs Application Express. Such decisions are not made lightly and not made for tools with limited life expectancy.

Internally Oracle Application Express has also become a critical development tool. Every Oracle Employee utilizes our ARIA People Search application (also downloadable from our Packaged Applications on OTN) built with APEX. There are countless internal applications hosted on our internal site with the majority of development teams using APEX applications in varying degrees.
I'll be emailing his response to the bosses and developers at work. It might be the final reassurance they need to confidently make business and career decisions.

Anyway, that was all I really wanted to say; I just wanted to note on record how helpful the Apex community is. My next post will probably be about this report builder that I want to write with Apex. I'll write that tomorrow - if I'm not too busy taking long train journeys and looking out of the window!

Monday, 28 July 2008

What does the future hold for Apex?

Last year was the worst year of my working life. Okay, maybe that's putting it a little too strongly - it's not as if I ended up sleeping in cornershop doorways being pissed on by drunks, fighting over half-eaten sandwiches with rats while supporting my crack cocaine habit by selling my body. But sometimes things seemed that bad: I spent, you see, last year working with Oracle ADF. (Arrgh, even after this much time the very name floods my mouth with bile.)

I'm willing to give ADF the benefit of the doubt and say that maybe (just maybe) it's actually a ... passable product, but it's definitely NOT the right product for an Oracle Forms developer to graduate to. The learning curve is far too steep and the technology is still far too tetchy.

Oracle Application Express is altogether a different story. I returned from a rather elementary 5 day course at Oracle and immediately felt ready to dive in head first. Yes, I'm still discovering new facets of the product even now, but at no point has this mountain felt unclimbable.

The one question I do have is one that no one outside Oracle would really be able to answer, and one which no one inside Oracle would necessarily answer truthfully: what does the future hold for Apex?

Just last week my boss at work informed us that the majority of our new development would now be written in Apex (which is great for me since I'm currently the only Apex 'expert' that we have). But at that meeting everyone turned to me and asked what my feelings about the future of Apex are - would Oracle give it the investment it will need to become an industry-leading development tool or will they abandon it one year down the line and move on to the next hyped thing? Does Apex even possess the oomph to power large-scale applications? Will we regret hitching our future to this bandwagon?

My answer was this: I don't know. However I'll be very interested in hearing what everyone else thinks.

Thursday, 24 July 2008

Ajax and Improved help text (or the wasted life of Mungo Park)

Studying history in a Nigerian school was, sometimes, like having a conversation with a schizophrenic. They teach you African history from the European perspective - and then they teach you, well, the truth. I remember our teacher (hello, Mr Dumatonu) teaching us how Mungo Park discovered the river Niger in the 18th Century; and then I remember him returning to class the next day to tell us how, in truth, the Africans had discovered it millennia before that.

Sometimes studying Apex I feel a little like old Mungo Park discovering paths that many have walked down as if they're new. (It's kinda like Neil Armstrong landing on the moon and discovering a KFC.) Yesterday, for instance, a colleague commented that the popup windows that, er, pop up when you click on an Optional Label with Help link are terribly ugly. He was right, and so I spent today investigating ways to rewrite it. (I've been messing with about with my templates a lot of recent; perhaps I'd be better off making a copy of the whole theme so I don't do any irreparable damage?)

I've had to travel down many strange paths and some that are only half-familiar: the first thing I did was create a CSS div class which I put in an After Header region on my Page Zero. Whilst there I created an HTML region, inside which I created a div and applied the class I'd just created. My plan was to hide my div and use it to display help text when needed.

Next I wrote an application process which would take an item_id and return the appropriate HELP_TEXT from APEX_APPLICATION_PAGE_ITEMS (by the way, does anyone know if item_ids are unique or do I have to qualify my query by app_id and page_id too?).

And finally (and this is the bit I really enjoyed) I wrote some javascript (which I fired from the anchor tag of my label template) which contained some Ajax that executed my application process (to get my help-text). Next it was a simple task to place that text inside my div, position it on my page and set it to visible. (I created a timer to keep it visible for 5 seconds, which should be long enough for the slowest of readers.)

The Ajax I had to learn today. To call an application process is really easy. You create a new htmldb_get object (var lookAtMeMum = new htmlb_get(null,&APP_ID.,'APPLICATION_PROCESS=myApplicationProcess',0);). You can pass values into your application process - in my case I wanted to pass in the item_id: (lookAtMeMum.add('F_ITEM_ID',itemValue);). And finally, you get the value returned from your application process (you'll need to add a htp.prn(returnValue); in your process to send a value back).

Easy-peasy. When you know how. (It took me all of today to figure it out.)

Oh, one difference between Mungo Park and I. He died on the river Niger. I intend to die on the breast of a beautiful, leggy blonde.

Just watch.

Tuesday, 22 July 2008

htp and htf (or seeking a sprig of parsley)

I'm still wrestling in my mind, seeking out ways to deliver more than the bare bones of the functional spec that has been handed to me. My philosophy as a software developer is this: give the client what they have asked for - but make sure you also give it a little flourish, like the sprig of parsley that completes that Michellin-starred meal.

That sprig of parsley isn't going to be one big thing - I have neither the inspiration nor, at the moment, the expertise in Apex to do that - but hopefully I'll think up loads of little things that'll make my application a pleasure to use - or at least not a pain.

Today I decided to give my users the ability to bookmark pages in the app an add shortcuts to them on the homepage. (Yes, I know browsers natively possess the ability to bookmark pages: don't be a smartarse!) To implement this functionality I'd have to wander down paths I'd avoided till now: regions based on dynamic PL/SQL, the htp package and the htf package (which, I've got to admit, I'd never even heard of until today).

Basically, what I'm gonna have to do is write some javaScript to grab the contents of the address bar, write a package to parse it (in order to find if any parameters have been passed to the page), and save this info to a database table.

I'll then build a region containing PL/SQL to create a list (hello htp.listitem and htf.anchor - it's nice making your acquaintance) based on the contents of my table.

Easy-peasy when you know how.

Obviously at the start of the day I didn't have a clue how to do any of this, or even know if it was possible. Yes, I know I could have hit the forums and copied someone else's work, but I wanted to figure it out for myself. That's the only way I'm going to learn the intricasies of the Apex thing.

Monday, 21 July 2008

To upgrade or not to upgrade? (Or the evolution of the slug, baby!)

Here's what happened with the slug:

Many millennia ago all the users had a meeting to discuss adoption of some new functionality that God was introducing to his hardware. There was Legs 1.3 and Brains 1.0 and Eyes 0.1. All the other users decided to adopt one module or another, or at least put them through some measure of suitability testing for a 30 day trial period.

But the Slug said, "Nah baby, I don't think I'll be adopting any of these new modules, baby." (If slugs could talk they'd say baby a lot: don't argue with me about this.) "I'm happy with the functionality I've got now, baby, and I'm not sure this new functionality will even work. This legs module sounds a bit like a gimmick. So no, I'll not be upgrading. Baby."

Upgrade after upgrade came and each time the slug, afraid of change and the work it entails, refused to upgrade - until other users had upgraded to a level where they could go down to the beach on a summer day in a teensy-weensy bikini and the slug was still stuck on Version 1.0, hiding in the undergrowth and scared of salt.

There's a point to this story (there isn't always a point to my stories); I'm wondering if I should upgrade my Apex to version 3.1. And, I've got to admit this, I'm rather hesitant. Oracle and I have had a long and tumultuous marriage, and upgrades haven't always gone well in our history. I even got very peed off when I was installing Apex. I accept that half the time the fault lies completely with me (I do not read instructions), but that doesn't change the facts: upgrades don't always go well.

So what I have to do now is weigh the pluses against the cons. On the one hand there's all the cool new stuff that comes with version 3.1 like interactive reports (actually is there anything new in 3.1 other than interactive reports? That's all everyone seems to talk about), and on the other hand there's the potential complete destruction of my database, the loss of my job, the breakdown of my relationship, penury, destitution, leprosy and a lonely death in the poorhouse.

I must upgrade immediately!

I've had a look at interactive reports and I think they're brilliant, taking power over the data out of the hands of the developer and giving it back to the owner of that data. But - and I'm not joking here - how much of that power does the user really want? My application is aimed at simple, basic computer users and I'm worried that the flexibility (and accompanying complexity) of interactive reports will scare them more than it would excite them. Too many times we software developers assume that the things that excite us will automatically excite our users - and we end up writing software for ourselves rather than them.

And so, for the time being, I think I'll be a slug (baby) and not upgrade to 3.1, even though polls seem to show that other developers love it. I'll come late to the party and make a dramatic entrance. Hopefully.

Sunday, 20 July 2008

Throw some D's

Ask anyone who works with Oracle Application Express and they'll probably tell you that the most difficult/unreliable/uncontrollable/unruly ghetto in its whole universe is the tabular form. In truth, I don't really have enough experience to agree with them with any certainty, but hey, if that's what the experts say then who am I to disagree?

This past week I've had to create a few data entry tables (based on an irregularly-structured database table [someone else's fault - of course]) and I found that the regular wizard-driven tabular forms just couldn't cut it. And so I packed my rucksack and headed down the road signposted APEX_ITEM.

Actually I'm exaggerating when I say "signposted", cos like everything else in the Oracledom, the whole thing is very poorly documented, and I only stumbled across it by chance. But now that I'm here I'm having a really great time. It's so easy to use - all you do is write your SQL statement, throw in APEX_ITEM.TEXT(indexNo, defaultValue) (where indexNo is a number counting up from 1) , stick it in an SQL Report and - voila! It's brilliant.

And for data manipulation all you have to do is create a PL/SQL process that'll loop through the rows (you'll need APEX_APPLICATION.G_FindexNo(rowNumber) to read the values) and do what you want with them. To quote someone I like and respect a great deal (me, me!): it's brilliant! It's way better - if a little more fiddly - than the wizard-driven tabular forms.

There's only one little thing that I need to figure out how to do now. I'd love to be able to include some javaScript (did I tell you how much I'm enjoying the javaScript book I bought? There's this other non-tech book that I'm reading - and enjoying - at the moment, but often I find myself choosing the javascript one over it) to validate each text item as it is entered. You can't do that with wizard-driven tabular forms (I think), but I reckon it should be possible with these manual tables. It's Sunday today, I'll look into it tomorrow: can't wait.

In other news today: my laptop is old and crappy - the wifi has gone deaf and the keyboard is arthritic. The ctrl is missing and, today, the D key has stiffened. So if you find any words in today's entry that aren't in the lexicon just do like the rap song says and Throw some D's on it.

Monday, 14 July 2008

Oracle Forms: Alfa Romeo

Everyone goes on about how much better than Oracle Forms this Oracle Apex thing is - and they're right; I hate going back to bug-fix my old Forms apps (not that I have much choice; the application that makes my employers most of their money is written in Forms). But one thing people don't mention is how developing in Apex makes you feel.

I was watching Top Gear the other day and the presenters were practically having a communal orgasm as they discussed Alfa Romeos: they agreed that they were terribly unreliable cars that were likely to spend as much time with your mechanic as with you, but they said that even that was more than made up for by the way Alfa Romeos made you feel when you got behind their wheel.

So what does developing in Apex feel like compared to developing in Forms? Well, let me persist with the car analogy: developing in Apex is like driving a Ferrari - it's fast and smooth and enjoyable - for the first 100 miles. After that you begin to wish the seats were a little more comfortable and you begin to miss those little 'useless' extras that you took for granted in your old family sedan.

Okay, enough with the car analogies. Truth is the only thing I've driven in the past 10 years was a Segway, and if I went anywhere near a Ferrari I'd probably get arrested. The point I'm trying to make is that somehow I've found that developing in Forms was more fun; Apex is great but I don't know that I'll ever learn to love it the way I loved Forms. Yes, it's easy to build applications and create pages and graffiti them with pie charts and scattergrams - but have they made it too easy?

My application is now a 65-page sprawl that keeps spreading like eczema and I'm reasonably proud of it, but the truth is that these days I have the most fun when I'm writing database packages, procedures and functions, and not when I'm building (yet another) Apex page. It was never this way back in my Forms days.

Sunday, 13 July 2008

Javascript and Jean Grae

This weekend I'm mostly studying Javascript (and listening to Jean Grae's new album, Jeanius - but that's none of your business). It hasn't taken me long to realise that I won't survive long in the world of Oracle Apex (or any web technology) without it.

Coming from an Oracle Forms background it's a miracle I even know what javascript is - it's a bloody miracle that I even know what HLTM is (that was a joke, by the way - laugh with me, not at me)!

Fortunately for me I've got HeadFirst's excellent book to help me along. It makes studying a breeze, and with every chapter I see loads of ways I can - to use marketing wank speech - bring my app to life with what I'm learning. I almost can't wait to get back to the office.

Having said all that it's not that my app is completely bereft of JavaScript. One of the first things I did was install Patrick Wolf's Apexlib Framework, which is kinda excellent. No, not kinda excellent - just plain excellent. Only problem with it (apart from the fact that, if I remember correctly, it was a bit of a bitch to install) is that it works so effortlessly that I don't remember what is ApexLib and what is just simple, native functionality. So maybe I'm giving it too much - or too little - credit.

It's blokes like this Patrick Wolf and many, many other experts (I've got a bookmark list as long as your ... well, as long as you claim your ... is) that make working with Apex a joy. Whenever I encounter a problem - and that's not happening as frequently as it used to - there's always a blog somewhere on the webbienet with the answer. Sometimes it makes me forget that 8 months after I ordered the one official Oracle Apex book it still hasn't arrived. I recently got another email from Amazon saying its release has been pushed back - again!

Anyway, back to Javascript. And Jean Grae.

Great work, Batman

My project manager has been standing over me a lot these past few days, casually eyeing my monitor. Yes, he's my friend and he comes over to talk football (he's a Man U fan - but since when have you expected good sense from a project manager), but why do I get the feeling that he's surreptitiously keeping an eye on my progress?

It probably doesn't help that the application I'm writing is being shared by two different projects and so I have project managers fighting over my time like drunk guys fighting over a girl in a pub (you can tell I live in the rough part of town, can't you?).

My latest challenge (hey, get the image of the slutty chick in the pub out of your mind and keep up, willya?!) is writing in functionality to produce mail merge letters from the app. Sounds easy, doesn't it? You'd have thought that every one would want that, that all I'd have to do would be to hit the forums and copy someone else's work, right? Wrong. Well, kinda wrong. Scott Spendolini has written a utility that does mail merges that works excellently - until you try to merge a document that's larger than 32k in size! Great, what is this - mail merges for bloody elves?

So I've had to spend days amending the code to get it work with larger documents (the problem was that SUBSTR and REPLACE and htp.p work with VARCHAR2s and so can't go beyond 32767 characters). And so I've been fiddling with CLOBs and DBMS_LOB, breaking my documents down into bitesize chunks. And I've always bloody hated CLOBs so the last thing I want is a bloody Man U fan standing over me as I work! Grrr!

Anyways, I finally got it working (see how I take all the credit, instead of admitting that it was really Mr Spendolini that did most of the work?) and so now my users will be able to merge mail to their little hearts desires. Great work, Batman!

Saturday, 12 July 2008

No dumb blonde

So my direct boss is having a go at me again about the way my application looks. It's not that the app is all skew-whiff and ramshackle, with text items all over the place like alphabet magnets on a fridge door, but I admit that it won't be winning any beauty pageants any time soon. (I'm using the Light Blue theme, which I think is the coolest of the themes that come packaged with Apex 3.)

The problem is that I'm working to such a tight deadline and I've got miles of specs left unploughed. I haven't got the time to put make-up on the application. That'll have to wait till later.

The thing that makes my boss such a good boss is the same thing that makes him a rubbish boss at times: he loves tech. As long as it's new and shiny and being written about in tech magazines he loves it. And since he's too busy to try stuff out himself he's always on at me to try them. And ever since he stumbled across Ext JS (which is this really cool javascript library) he's been badgering me to use it to pretty up my app.

"When a client looks at an application for the first time," he said to me, "70% of his first impression comes from the look of it, only 30% of it is based on functionality. So make it prettier!"

The thing that sucks about this whole thing is that I agree with him. And the reason I agree with him is that I made up that bloody fact. Back in the days when we used to develop butt-ugly apps in Oracle Forms I used to have a go at him all the time that we needed to make our products prettier, and to convince him I made up this beauty-versus-functionality percentage thing. And now he's using it on me!

So, if anyone out there has some suggestions on how I can make an Apex app pretty, in ways that go beyond simply applying a pre-packaged theme but won't take too much time - and don't require much more than the basic skills of an Oracle Forms developer - then I'md love to hear them.

Oh, and on a total tangent: are all women crazy or is it just the ones I go out with? Or perhaps there's something about going out with me that drives them to craziness.