saush

What am I?

Posted in general by sausheong on May 25, 2006

I’ve been this industry for 11 years now, 13 if you count those years I’ve freelanced as a system administrator during my university days. Which industry? High tech? Some include biotech in this so it’s too wide — nah. Infocomm? That’s what Singapore likes to call us though technically it also includes those people in the telco industry, and I don’t know why besides that the Infocomm Authority of Singapore (IDA) is a merger of the old NCB (National Computer Board) and TAS (Telecommunications Authority of Singapore). Software? Well, software developers like it or not can’t run away from the hardware, and where does that lead the system administrators and network engineers? Computer? Ditto — where does that lead the network guys? ICT? That’s information and communications technology, sounds like infocomm except more pretentious. Yucks. Information technology? That’s what I usually call it actually though it still doesn’t feel exactly right. I dunno.

So it’s IT? I’ve been doing IT for 11 years? I’m an IT professional, I just do IT?

What do you call it then?

So what does ‘IT’ cover? Software? Hardware? Firmware/embedded? Systems? PCs? MIS/EUC (for those uninitiated that’s Management Information System/End User Computing)? Internet? Network? Multimedia?

Which side are you on? Software vendor? Hardware vendor? System integrator? User advocate? System administration? Project management? User support? Research? Education? Consulting? Or none of the above?

Who do you work for? Multi-national? Small local company? Large local company? Start-up? Internet company? Government-related? Civil/public service? Military?

Which niche market(s) do you serve? Oh this is a tricky one. It could be multiple products to multiple markets (think IBM) or it could be specific product to specific market (think Corillian, who sells only Internet banking software to banks). Or it could sell a specific product to multiple markets (think Documentum, selling a document management software) or multiple products to a specific market (I tire of giving examples, you try).

How about your pecking order in the company? Do you do? Manage? Lead? (what’s the difference?) Strategize? Sell? Support?

I suppose a taxanomy is in order here. A large map showing the various spaces available in this ‘IT’ industry, something what these research companies like Gartner or Forrester often come up with. It would be a huge map though. Just say software and it’s a nightmare to classify already.

Ok, ok, so what am I? I manage a software development group in a multi-national, mid-sized payment software vendor company delivering a niche software product to bank for use in their card payment business. Phew! A mouthful. Software – check. Software vendor – check. Mid-sized multi-national company – check. Specific product to specific market – check. Manage – check.

What’s this blog entry about? Nothing — just a reality check on myself, and what the heck am I doing in an arbitration course with my final exams in the next two days! Argh! And it’s way past midnight and I have another exam tomorrow! Double argh! Go to sleep!

Hope I pass.

JSS Commands

Posted in java by sausheong on May 21, 2006

JSS files are BeanShell scripts and normal Beanshell commands apply. In addition, there are a number of JSS-specific commands that can be used for your convenience.
redirect_to(String action)
Redirects the browser to the given action, for the same controller. Use this to redirect after a committing a transaction.

redirect_to(String controller, String action)
Redirects the browser to another controller and action. Use this to redirect after a committing a transaction.

render_view(String layout, String view, Object data)
Forward the request to the view, given the layout and the data. Use this if you still want the request to be used by the receiving view.

render_view(String view, Object data)
Forward the request to the view, with the given data. Use this if you still want the request to be used by the receiving view.

render_view(String view)
Forward the request to the view. Use this if you still want the request to be used by the receiving view.

get_parameter(String parameter)
Get the parameter of the given name from the request object

delete(Object object)
Remove the persistence of this object from the database

update(Object object)
Update the persistence of the object

update(Object object, Map params)
Populate the object with the given parameter map and update the persistence in the database. If the object doesn’t exist, create it

find(Class clazz, Serializable id)
Finds and returns a single object of Class clazz given the id

query(String query)
Creates and returns a Hibernate Query object

sql(String sql)
Creates and returns a Hibernate SQLQuery object

sql(String sql, Class clazz)
Executes the SQL query provided for the provided class, and returns a list of objects

id()
Retrieves the id from the request parameters

With these changes in the JSS commands, a simple controller file (from the tutorial) becomes something like this:

import com.saush.jss.model.Recipe;

layout = “main”;

index() {
redirect_to(“list”);
}

list() {
query(“from Recipe”).list();
}

edit() {
layout = null;
find(Recipe.class, id());
}

update() {
Recipe recipe = jss.find(Recipe.class, id());
update(recipe, params);
redirect_to(“list”);
}

add() {
return new Recipe();
}

create() {
update(new Recipe(), params);
redirect_to(“list”);
}

delete() {
Recipe recipe = jss.find(Recipe.class, id());
delete(recipe);
redirect_to(“list”);
}

Notice that this file has become much simpler than before. Noticeably, I dropped the usage of the ‘jss’ default object, as well as created a command id() that extracts the id from the request parameters automatically. This controller is much more readable than the previous one. One comment I had from someone is that such code becomes ‘un-Java like’ and it becomes another chore to understand another programming language, which is counter to JSS’s simplicity principle. Not really. The code is still Java, and if you choose to do so, you can still program the whole thing in 100% Java — but you have ‘helper’ commands that simplify the command tasks and makes the code much more readable and maintenable.

Note that JSS’s simplicity principle is largely meant for the maintenance of the software, and not for building it. Anyone can write complex code. The rationale for writing simple code is not to build faster applications — piling enough competent  programmers in a project can usually do the job (to a certain extent). However complex code is hugely difficult to maintain and that is usually the trick in large-scale software development. It’s not in the building but in the maintaining. There’s a saying in Chinese — ‘Building an empire is easy but maintaining it is difficult.’ Heed the saying.

Space Invaders

Posted in general by sausheong on May 21, 2006

I remember when I was around 10 years (in the early 80′s) old my family started to go to Genting Highlands for vacation during the Chinese New Year holidays, almost every year. As our parents and my uncles and aunts went to the casino to try their New Year fortunes, my brother and other older cousins head towards the arcade games room with me tagging along. That was when I first saw them.

It was Space Invaders first, then Pac-Man and Galaxian. We were totally hooked. 20 sen coins went fast and furiously into those machines, until our cash reserves were exhausted. Life was never quite the same after that. It wasn’t as if I was really that good either — I never went past the first few levels anyway. I suppose I never really had enough coins to play for too long but those times at the arcade games changed me in different ways. I realised that machines can be intelligent and interactive, and fun.

I suppose after so many years this has never left me — I’m still trying to ‘play’ with every single machine I see, every time I buy a new piece of hardware, the first thing that comes to my mind is — ‘how do I program it?’ Well, I bought a Gameboy for my son a few months back, and an NDS Lite for myself last month. The question of programming both of them naturally came to my mind especially when the NDS has mouth-watering wifi capabilities, two screens, with one of the being a touch screen and amazing graphics and sound system.

Of course I’m no game programmer — have been doing only enterprise applications for most of my working career (11 years and counting) but it’s something that really caught my imagination. I started thinking back to my days at the arcade with the Space Invaders. Well, yes, it’s the first arcade game and it’s really primitive but it’s fun as well. So that’s what I wanted to do — a Space Invaders clone on the Gameboy. There’s one already in the market but this one will be all mine.

I promised myself to do it after my GCIA exams, and here I am about to embark on it. I spent a couple of hours fiddling around it and I got a sprite bouncing back and forth the screen. Nothing spectacular but it’s a start. At the end of it I’ll write a short tutorial on how it could be done. Wish me luck!

Layouts and AJAX support for JSS

Posted in java by sausheong on May 18, 2006

I added in layout support, as well as some fundamental AJAX support for JSS. I’ll put in a tutorial later to show exactly how it’s done, but for now a quick description of how to do layouts in JSS:

Layout support

There is a layouts directory under the views directory which contains a list of all your layouts. For example, let’s say you have a layout file called main.jsp. Your layout file might look something like this, though you can do whatever you like with it:

<%@ taglib prefix=”jss” tagdir=”/WEB-INF/tags”%>
<html>
<head><title>JSS Recipe Demo</title>
<style>
table {
border: 1px solid black;
}
body {
font-family: verdana;
}
</style></head>
<body>
<jss:content_for_layout/>
</body>
</html>
table {
border: 1px solid black;
}
body {
font-family: verdana;
}
br /> body {
font-family: verdana;
}<br

Where you want the content to be placed (i.e. your content) put in the tag <jss:content_for_layout/>. At the top of your controller file (e.g. recipe_controller.jss), after the import statement, put in the layout declaration:

layout = “main”;

where main is the name of your layout file.

That’s all! All your views under this controller will be using this layout. If there are any views you don’t want to have a layout, just put anywhere in your view method:

layout = null;

If you want to use another layout just for that view, you can also set the layout to something else e.g.

layout = “report_layout”;

So what does it do? Using a layout for a controller allows you to enforce the same look and feel or have shared data for all the views under the same controller. This extends to the rest of your web application. I’ll talk a bit more about the AJAX support in another post.

Arsenal lost

Posted in general by sausheong on May 18, 2006

Don’t want to talk about it … depressing. Woke up 2am in the morning to watch an exhilirating but ultimately disappointing match. Arsenal fought admirably though and Ronaldhino was quite pathetic most of the game. Hope he improves in time for the World Cup in Germany … I’m supporting Brazil as usual :)

Follow

Get every new post delivered to your Inbox.