Search blog.co.uk

Thief of time

by cc0028 @ 2006-02-08 - 20:54:34

No. Not procrastination. Me. I stole a couple of hours off my employer today to write a bit more of my application. Don't tell, will you.

I've mentioned before how this project is building an application that has layers: the presentation layer, the business logic layer and the data layer. The interesting bit, from a programming point of view is in getting the bits to talk to each other; in particular in getting the presentation layer to talk to the business logic layer.

In the old days of plain vanilla C programming, developers would have to set up a connection between the remote objects using something like the Berkley sockets library. Not only that; they would also have to create a protocol of some sort to enable the objects at either end of the communication to talk to each other. This may sound quite easy, but in fact it's very hard.

Computer programs these days don't just deal with simple scalar types like integer numbers or ASCII characters. Because every computer program is a model of the real world, in some sense, programs have to create and manipulate complex software artefacts that contain internal data (state) and behaviours (methods). Passing objects of these types over a serial cable between distant computers involves a process called, not surprisingly, serialisation - or, as the Americans will have it, serialization.

Manually creating your own protocol for serialisation, which is sometimes also called marshalling, is not a thing to be done lightly; so programming systems have developed ways of doing all this in the background so that the developer doesn't have to worry about it. This is something that, in my opinion, .NET is particularly good at.

But it's very detailed and exacting work. Over time, I've developed a way of working that helps me through the complexity. First I create the object that is going to be called remotely. In .NET this means creating an object that inherits from a class called MarshalByRefObject. I give this object all the state and methods (data and behaviour) that my model - the UML, remember - called for. I then build another object, called a local client, that will call the remote object locally for testing purposes. When I'm sure that this works as it should, I create what is known as a proxy object. This is what will be called on the remote client side. It interacts with the remoting infrastructure provided by the .NET Framework to provide marshalling and unmarshalling facilities that allow you to pass complex structures over the wire. Think of it like encryption and decryption, if you like.

When I have all that ready, I build a server that will listen on a port on the server for requests from the proxy. When it gets a request, it passes it on to the remote object, and the remote object carries out the requested task and returns whatever kind of object the client expects.

Then a remote client has to be built. It would be possible to use the client-side code in the application's presentation layer for this, but it's easier to build a little Windows Forms program (a GUI, if you like) that calls the remote object remotely and tests all its functions. Actually, it calls the proxy: but it thinks it's calling the remote object although it's the remoting infrastructure that does that in reality.

This is where I got to today. The journey was not without difficulties, but I can now call my remote object remotely and get back the answers I expect - data from the remote database, in this case. There's still quite a lot to do, though. The next step is to replace the console-based server I wrote today with a proper service that will run in the background even when no-one is logged on to the computer. Most people who have only dealt with personal computers find this a bit hard to understand, but there's not a lot to it, really. You just have to understand that it isn't necessary for anyone to log in to the machine for it to be fully functional. It just isn't accepting instructions from a human being - or at least not one who is logged in locally.

The final step will be to hook up the presentation logic in the code-behind pages of my ASP.NET application to the remote object, in response to the appropriate events. For example, the drop-down list box for countries needs to be populated with a list of countries from the database in response to the page load event of the demographic details page.

Hopefully I'll complete these steps on Saturday; unless I can steal some more time, of course.


 
 

Trackback address for this post:

authimage

Comments, Trackbacks: Hide subcomments

menhirmenhir [Member]
10/02/06 @ 22:27

Hello,

I started to read you post knowing that I would have to dash out so I thought I would memorise an answer to write when I returned. Now if I had the system you are developing, I could have populated that with various styles of response and I would not have had to worry that I might forget what I was going to write, which in fact is what I have done.

Honestly, Peredur, I do think that when you have undoubtedly, successfully, completed your MSc, you should be able to offer some brain implants/programmes for people like me that suffer from the type 'senior moments' described above. ;)

menhirmenhir [Member]
10/02/06 @ 22:30

PS. You have one lucky employer to have people around with skills like yours and the increasing expertise that you will be offering. I little 'borrowed' time is a really good investment.

Fifth word in, first para. should read 'your' and not 'you'. I couldn't edit the reply, once posted.

cc0028cc0028 [Member]
http://www.peredur.uklinux.net
11/02/06 @ 10:19

I'll give you my boss's address. You can mail him and tell him.

:)

menhirmenhir [Member]
11/02/06 @ 10:46

Is is that tight!

Lord save us from myopic employers...

cc0028cc0028 [Member]
http://www.peredur.uklinux.net
11/02/06 @ 17:51

In fairness, I have to say that I think there's just a clash of cultures between my boss and me. He wants things done quickly and I want them done right.

menhirmenhir [Member]
11/02/06 @ 18:57

That means he wants both - not always viable and maybe it is saying more about a particular personality at any given time. That's a pressure you don't need.

I remember well in my early days of MSc just what pressure I was placed under to work normally, travel hundreds of miles to Uni, do assignments and like most of my fellow students reduce on the agreed study days. It's an endemic situation in most personal development circumstances and really makes the whole process a more exhausting one. There has to be great tenacity. I do think that there is, underlying all of the behavioural games and large measure of jealousy which translates in to the obstacles we learners have to overcome. I reckon we deserve real 19ct or 22ct gold medals as well as our degrees!! :)

Leave a comment :

Your email address will not be displayed on this site.
Your URL will be displayed.
Allowed XHTML tags: <!, p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, a, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small, img>
URLs, email, AIM and ICQs will be converted automatically.
Options:
 
(Line breaks become <br />)
(Set cookies for name, email & url)
Validation code:
Please enter the above code here:
For protection from spambots (case-sensitive).

Recent Posts

  1. A matter of style
    by cc0028 on 2008-09-11
  2. The late Helen Mary Bradley
    by cc0028 on 2008-08-10
  3. Install issues - harder than you think
    by cc0028 on 2008-08-10
  4. At your service
    by cc0028 on 2008-07-16
  5. The standard way of working
    by cc0028 on 2008-06-27
  6. Beyond lies the Web
    by cc0028 on 2008-06-25
  7. EPP
    by cc0028 on 2008-06-24
  8. Who dares, wins
    by cc0028 on 2008-01-28
  9. Streaming video in Linux
    by cc0028 on 2008-01-05
  10. A cat's tale
    by cc0028 on 2007-12-17

Footer

The content of this website belongs to a private person, blog.co.uk is not responsible for the content of this website.