Friday, September 4, 2009

A Second attempt at blogging

Unfortunately, I have not been able to meet my objectives around documenting all my findings for my final year project. Working and studying does take a lot of time and effort and at some point documenting was the least of my considerations.

However, I succeeded in completing my final year project. My timetabling systems rocked and generated timetables through a batch process and displayed them on a real calendar.

During my presentation, it was more than apparent that my lecturers liked it a lot ;). I finally came out with a Distinction, something I never thought would happen given the amount of time I spent at work instead of lectures.

I have been promoted as Technical Architect now at TNT and got the opportunity to work on an Architectural Spike aimed at identify new web UI standards for our organization. Since our projects are kicking off now, I think it is time that we finalize these standards and as such my research at home will aim at identifying and structuring these UI standards through this blog. Eventually, I will document these in a more formal manner.

Tuesday, January 27, 2009

Spring – Bring it On !

So here I am after … 2 weeks at TNT Express ICS. I must say, it has not been hard to adapt. With the help of each and everyone and especially Javed, I have been able to make a place for myself. Work now begins with a first small component development relevant to implementation of security. The exciting thing  is that this component is going to be Spring based. And as per TNT’s technical objectives, all future services are going to foster Spring framework instead of EJB. I always wanted to innovate whatever be my place of work and hopefully while learning and implementing Spring in my new venture, I will do just about that. As from now on, this blog would also serve as a repository for my spring research and findings.

Saturday, January 17, 2009

SSADM WorkBench

While doing my final year project for my undergraduate course, I had loads of trouble finding a good tool that will help me to generate nice professional DFDs. There are huge amounts of such tools out there but none could really suit my needs. After loads of digging, I finally came across SELECT SSADM WorkBench (Version 4.1). This one might be the old looking (windows 3.1) type of software but gosh, it really produces nice stuff.

This year on, while doing the same sort of work for my postgraduate course, I happened to forget the name of this tool. Digging around through my old hard drive for around two weeks now finally brought its results. Thats when I said, i need to put it on my blog so that I don’t forget it. After all, this is what I’m gonna use it for :P

Monday, January 12, 2009

A New Start

Today, I joined TNT ICS Express as Senior Analyst Programmer. This is for me a major step forward as I always wanted to work for a big corporate organization where standards are already set and you can focus on leveraging your skills by implementing technology at the very high level.

I have a full week of training which has been scheduled but from the two induction sessions we had today, I am already eager to get my hands on a TNT project in order to grasp the business perspectives of the company. Have to be a bit patient, though. In the meantime, hopefully, I can focus on my final year project at home and quench my thirst for coding with my University Timetabling and Scheduling application :P

Friday, January 9, 2009

Creating a VMWARE Image with VMWARE Player

I remember someone saying that it was not possible to create a vmware image from scratch with vmware player itself. This tool was supposed to be used only to run vmware images. While i thought that this was a bit weird at that time, today i found out that he was not totally wrong. However, i still got to create a vmware by using a workaround solution which consists of:

(1) Creating an empty hard disk image

(2) Using a vmware configuration file template and customising it to my needs.

While these might take a bit of time, I found out that the following site (http://www.easyvmx.com/new-easyvmx.shtml) allowed users to do just the above through a nifty web interface.

After creating and downloading an empty vmware with my desired configuration from the above web site, I started it with vmware player. However, in order to install my operating system, I had to change the CD ROM boot sequence in BIOS as I wanted my ISO file to be loaded at boot time.

The following article (http://blogbuildingu.com/articles/using-vmware-player-to-create-images-for-new-virtual-machines) has been helpful in understanding this workaround though some of the configuration steps which were independent from the easyvmx website did not work for me. It might be worth a look though.

Friday, January 2, 2009

Log4Net with ASP.NET Application

I implemented log4net before but as usual, I could not remember all the steps to do it again in my UTS web application !! I also remember one of my team members (the same who deleted oracle directory under linux :P ) who had difficulties implementing for some weird reason which even i could not figure out. So, here i go documenting the simplest implementation of log4net in an ASP.NET Web application.

(1) First of all Download log4net extension

(2) Create a seperate log4net.config file and place all your configurations. Mine are as follows:

<?xml version="1.0" encoding="utf-8" ?>
<log4net>
  <root>
    <level value="DEBUG" />
    <appender-ref ref="RollingLogFileAppender"/>
  </root>
  <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
    <file value="../logs/utslog.log" />
    <appendToFile value="true" />
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="100KB" />
    <staticLogFileName value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%d [%t]%-5p %c [%x] - %m%n" />
    </layout>
  </appender>
  <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
    <file value="../logs/utslog.log" />
    <appendToFile value="false" />
    <datePattern value="-dddd" />
    <rollingStyle value="Date" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%d [%t]%-5p %c [%x] - %m%n" />
    </layout>
  </appender>
</log4net>

(3) In your Global.asx, add the following method that will instantiate log4net configuration for your web app. Make a call to this method in Application_Start

protected void ConfigureLogging()
{
    string logFile = HttpContext.Current.Request.PhysicalApplicationPath + "log4net.config";
    if (System.IO.File.Exists(logFile))
    {
        log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(logFile));
    }
}

(4) To use log4Net in your code behind simply initialize an instance of log4net

#region Logger Setup
    protected static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion

 

(5) To eventually use logging in your code behind

protected void Page_Load(object sender, EventArgs e)
{

      log.Debug("In Page Load Function"); 

}

 

Saturday, November 29, 2008

Generic DAO with LINQ to SQL

One of the first thing I try to implement when learning a new programming language is a Generic Data Access Layer. I hate to write repetitive code and always try to find ways of working around this. I managed to implement this in Java and PHP and had no doubt that .NET will allow me to do so. After a good bunch of reading on the net and playing around with the tutorials for a while now, I managed to implement Generic DAL by using LINQ to SQL.  Here is what I did:

[ Step 1 ]:

I created a seperate Class Library to Generate all my Business Objects and handle all my Data Access Objects (DAO). In this Class Library I created a a LINQ to SQL Data Context and named it UTSDataContext.

[ Step 2 ]:

I then created a Generic class which had two Parameterized Type variables one being the class representing a Business Object and the other being the Primary Key type.

public class GenericDAO<E, K> where E : class

[ Step 3 ]:

I then added all methods that will carry out CRUD tasks. The code for the Generic DAO is as follows:

public class GenericDAO<E, K> where E : class
    {
        private UTSDataContext context = new UTSDataContext();

        public UTSDataContext Context
        {
            get { return context; }
            set { context = value; }
        }

        public virtual void save(E instance)
        {

            this.save();
        }

        public virtual void save()
        {
            context.SubmitChanges();
        }

        public virtual List<E> selectAll()
        {
            return context.GetTable<E>().ToList();
        }

        public virtual void insert(E instance)
        {

            context.GetTable<E>().InsertOnSubmit(instance);
            context.SubmitChanges();
        }

        public virtual void remove(E instance)
        {
            context.GetTable<E>().DeleteOnSubmit(instance);
            context.SubmitChanges();
        }

        public String getKeyProperty()
        {
            String primaryKeyFieldName = typeof(E).Name + "Id";
            return primaryKeyFieldName;
        }

        public Expression<Func<E, bool>> getLambaKey(K id)
        {

            var parameter = Expression.Parameter(typeof(E), "e");
            var propId = Expression.Property(parameter, typeof(E).GetProperty(getKeyProperty()));

            return Expression.Lambda<Func<E, bool>>(Expression.Equal(propId, Expression.Constant(id)), parameter);
        }

        public E findById(K id)
        {
            return context.GetTable<E>().Single(getLambaKey(id));
        }
    }
}

Limitations

(1) I am not in REFLECTIONS yet in order to identify primary key property field through annotations. As such, all my primary key fields are named as follows:

Exact Table Name +"Id"

For Example, the table Department will have DepartmentId as primary key Field.

 

(2) There are some reasons why an Object will no longer reside in LINQ Context and as such not be monitored for Changes. The most frequent one being Deserialisation. For example, if you stored an Object in session and retrieved it later on, you will have to fetch the object again from database (by using its Primary Key Identifier perhaps) and then write the changes to it.