Fremus.co.za

Demistifying Life and Web Development

Archive for the 'Application Development' Category

Concept, CV Updater

One of the things that I see a lot on websites of other developers is a resume or CV section. It seems only logical that a developer would want to show off their pedigree, but I’m guessing a lot of developers would not mind some extra work (and extra cash). Creating a resume for your website is relatively straight forward, just create it! You just create some HTML page and add the information and its done, or is it? Well I found myself thinking in the shower (weird place to get an idea) and I thought that it would be really useful to write some code that made the maintenance of a resume or CV easy. Useful code does not have to be unnecessarily complex, because it achieves a certain function or purpose.

I consider maintaining my CV easy when I can edit the content of my CV and export the CV in as many formats possible. So basically I want my CV stored in one place where I can update it on a continuous basis, and when needed download it in Word, for instance. I’m sure that what I am doing has probably been done many times before, but I guess part of being a developer gives you the freedom to create your own solutions. And something I think developers should always do is use their own IP (intellectual property) to create solutions that they themselves use.

So for the CV solution I am thinking of using a very basic XML document with a very basic structure of sections and subsections. Think about it, a CV or resume is made up of sections and subsections. For instance I have a personal information section with subsections for my name, address, etc. Thus you can derive a quick schema:




  
    
      
    
  


Once the CV is in XML I can pretty much do with it what I want both in terms of modifying its content and exporting it. I actually started this idea by typing it out using Inkscape, simply because I dont have Word installed on my desktop machine, but also because it allows me to draw diagrams and go mad. I started off by defining some generic XML structure (without using XSD):



    
          
                CVSubsection Value
          
    

As you can see from the code that a CV could be made up of multiple sections and that each section could have multiple subsections. If you relate this structure to a more practical example:



    
          
                Fredrik
          
          
                Erasmus
          
    
    
           
                BSc Computer studies
           
    

It fits into the structure quite nicely. Each section will only have a single attribute called “name”, and each subsection will also only have a single attribute called “name”, but the subsection will have a node value, whereas the section name will not. The question begs though, what if you want to say where you got your qualification from? How would you structure that? Well you could add a custom attribute to the section called “institution”, which would change your xml:

    
           
                BSc Computer studies
           
    

The basic operations for the sections and subsections would mostly involve adding,editing and removing items. I think Linq to XML would perform this quite well.

  • Share/Bookmark
Tags: ,
posted by fr3dr1k in Application Development and have No Comments

Building a case for ORM

Okay, so I have been guilty in the past for not implementing any form of ORM (Object Relational Model) for some of the projects I have written. The main reason for this is/was that the projects I have worked on have never really used them. But the more I code the more I realise I sometimes find myself re-coding the same stuff. I mean my understanding of an ORM tool is that it creates a set or sets of classes that map to one or more databases. But why is this beneficial and why does this improve my life as a developer. I started out by reading this article on Wikipedia, which is not as detailed as I had hoped, but I guess its a starting point, because it lead me to this article. I also found this article and watched the video and from it got to understand that for the relational world to co-exist with the OO world several things need to be considered:

  • Inheritance: In the OO world a User object might serve as a base class for users of type teacher or student. How do you map this relationship in the relational database?
  • Granularity: This happens if the classes do not match up to the tables in the database. You might for example have a situation where a User is associated to a country. In your database you might represent this as two tables, but in your class you might represent the country as a property or field of the User class. So there exists a mismatch. How do you map this situation?
  • Identity and Equality: Lets say you query a database for a User with ID 100. The result you get back will always point to user with ID 100. If you look at it from an OO perspective, will a User with ID point to the same object, or multiple instances of it?
  • Association (directionality): In an OO model you associate classes with each other by placing references in each class of the other. In a relational model you create the associations by placing a foreign key in a table.
  • Type systems: The types in a database are quite different from those in an OO environment. For instance a VARCHAR with a size of 100 is not the same as a string, because a string is dependant on the amount of memory available.

I then read two StackOverflow topics, one here and one here. From what I could gather ORM’s are not great at performing bulk operations, but what they lack in that area they make up for in developer productivity.

I remember coming across an article that compared the performance between various ORM mappers on this website.

  • Share/Bookmark
Tags:
posted by fr3dr1k in Application Development and have No Comments

IMAP and Lumisoft Mimeparser

One of the requirements in a recent project was to give clients the ability to login to any email account from within our application. Email accounts generally use two RFC standards:

  • RFC 1730 – IMAP
  • RFC 1939 – POP

Its important to briefly understand the differences between the two. Think of IMAP (Internet Message Access Protocol) as a network folder where you have access to resources that do not physically reside on your local machine. IMAP never downloads any messages whereas POP (or post office protocol) on the other hand works by downloading email messages to the client’s machine.

Both protocols work with commands – you send commands and receive responses. I found this website useful for IMAP commands. You can check IMAP from a telnet console if you really want to.

With some basic knowledge of the two protocols and also knowing that GMail supports both, I started searching for some sample code. I found this library on CodeProject and found that the first library did not support SSL, which is a GMail requirement. I ended up on Codeplex and found that the library had been extended by someone else and that it included support for SSL. SSL stands for Secure Socket Layer and simply put means that the connection between the client and the server is secure. The solution on CodePlex comes with two C# projects, the library and a console application. The console application gives you a good place to practice and learn some IMAP commands. Once you get a basic understanding of these commands you can start writing web-based applications. Its important to understand that IMAP commands need to be given in a specific sequence. You first login, then you select a folder (INBOX) and then you can run FETCH commands to retrieve message data. Thats the easy part though, because once you get that data back you have to be able to parse the messages which requires a MIME (Multipurpose Internet Mail Extensions) parser. Introduce the Lumisoft Mime parser which parses almost everything.

  • Share/Bookmark
posted by fr3dr1k in Application Development,C# and have No Comments

Do you code through Google?

On my way to work this morning I thought about some code I used yesterday for object serialization and object deserialization, and I must admit that I got the code through a Google search, and that I did not really take much time to understand what the code is doing. So in a way, if asked to reproduce the code, I would not be able. I say in a way, because maybe I could reproduce it (but only if I understood it). Serializing objects means taking an instance of an object and transforming it into a format such as XML or JSON. Once the object has been serialized you can deserialize it again and have an instance of a class available. So in essence the XML representation is an object that has been instantiated. It seems I do understand the concept at least, but the implementation is a bit more tricky.

My point though is that some percentage of code that I use comes from code searched for on Google. Are we really developers then if we just regurgitate other people’s code? The other day I also used an IMAP class library to check an IMAP email account, specifically GMail. I just tweaked the code a bit here and there. The fact that I am just using the library does not mean that I understand where IMAP fits into the Internet Protocol Suite, because POP also forms a part of it, and items such as TCP/IP. It also doesn’t mean I understand that HTTP is a stateless protocol! Or maybe it does I’m not sure.

I often find myself going to MSDN and referencing some piece of code, because I do not know it. For instance I find myself checking out implementations for things like the StreamReader/Writer class or how to implement IEnumerable for a class. Do you ever find yourself doing this?

  • Share/Bookmark
Tags:
posted by fr3dr1k in Application Development,General and have No Comments

Thoughts on Application development

I recently started a new job, and in my current environment I have a C# developer, who comes from a Windows Forms Development background, an SQL Server 2000/2005 DBA, a VB.NET/AJAX/JavaScript developer and another VB.NET developer. There is another guy that does C# as well. I must honestly say that working with all of them has proven that every single developer has his/her preferred approach to development. For instance the SQL Server 2000/2005 DBA and the VB.NET/AJAX/JavaScript developer work closely together and they seem to build all their application logic into SQL Server. The stored procedures that they build handle the majority of the application logic. And there is nothing wrong with this approach, but in my mind Microsoft have gone to great lengths to make things like data structures readily available in C# and VB.NET. Why do I say that? Because I prefer doing my application logic in the C# application. Are there any real performance benefits?

  • Share/Bookmark
posted by fr3dr1k in Application Development,General and have No Comments

Creating a pivot like structure – without using any server controls!

Ok, so programming is a challenge as all programmers should know, and this is the caveat that programming gives you. On the one hand its difficult but on the other hand you get to try so many approaches to developing one particular aspect that it gives you the opportunity to learn a lot. So here is my scenario:

I have to create a pivot-like table without the use of server controls – everything has to happen in the code. In most of my work at the moment we do not use server controls – everything is purely AJAX and uses SOAP calls to web services to generate the user interface. So there is no cool way of tallying things up, you gotta do it yourself, the SOAP response has to display the data. So typically this solution has a first column on the left and a first row on the top that represents the ‘labels’, and between the two aggregate values are generated in the area between the label areas where they intersect. So any intersecting value between the two should give you a total made up from the two. The last column in the table contains a running total of each row and the last row keeps a running total as well.

From the description it is clear that you have several ‘fixed’ variables, or fixed areas:

  • The y-axis labels
  • The x-axis labels
  • The y-axis running total
  • The x-axis running total
  • The data area

The variables or objects defined above should be able to accept any data and display it accordingly. How do you approach it though? What approach do you follow to achieve the correct SOAP response message? C# 3.0 provides several technologies to do this:

  • Generics, lists, dictionaries
  • ADO.NET which provides you with data access
  • Share/Bookmark
Tags:
posted by fr3dr1k in Application Development,C#,General and have No Comments

What does code-reuse mean?

So what does code-reuse mean in terms of Object Oriented Programming? Well, it doesn’t refer to copying and pasting code from one application to another, but rather to the creation of components that can be re-used through class instantiation. In other words lets say you create some code that performs a specific task, and within another application the need exists to re-use that functionality, you would instantiate a class and invoke the functionality within the class that you want to re-use it. Make sense?

I have also pondered about namespaces, and my theory is that if you use namespaces wisely you only have to declare a namespace in one class and let other classes inherit from the class that uses that namespace. Thus lets say you connect to a SQL Server 2005 database, and you intend to use the System.Data.SqlClient namespace, you could use that namespace once in a class and let any other classes inherit from the class that contains the System.Data.SqlClient namespace. Thus you only use the namespace once. Thats my thinking anyway.

  • Share/Bookmark
posted by fr3dr1k in Application Development and have No Comments

Word 2007 Automation

So today I revised my strategy of using a COM component to automate Word 2007, simply because the component is not really intended to run in a web server environment, according to Microsoft. Even though my application worked beautifully with the COM component on my development machine it totally failed when I ran it in a production environment. The reason, according to Microsoft, is that Word works on a totally different permission level when compared to web applications that run on a web server, and I guess it kinda makes sense.

Whats the alternative you may ask? Microsoft Word 2007 Open XML.

More to follow.

  • Share/Bookmark
Tags: ,
posted by fr3dr1k in Application Development,C# and have No Comments

A week in review continued…

In my previous post I mentioned how my week went, kinda. I just want to elaborate a bit and share some other tidbits. So I started my new job, on the 5th of January. My career goal for 2009 is to become a great C# developer, not just for web, but for any platform. Programming for different platforms present different challenges, but the C# at the core remains pretty much the same, so its worthwhile becoming proficient at C#. During the week I was asked to code a C# application that auto-generated label creation with data. Initially I thought this task to be way beyond anything I could ever have done, simply because so much of my previous development effort was aimed at the web platform. So I started off with my trusty old friend Google and started reading some C# Word automation samples, and started out with this simple Microsoft Knowledge Base Article, and progressed to reading several articles on the Microsoft Word Object Model. I find that breaking a project down into smaller functional areas first, helps with making sure you understand how a specific piece of functionality works, from which you can build more complex functionality.

  • Share/Bookmark
posted by fr3dr1k in Application Development,C# and have No Comments

Let’s blog again for a change

Okay so today I did a few interesting things, the first of which was to setup Vista and XP on the same network, and I must be totally honest, its not as difficult or insane or bad as this one guy at a computer shop told me. The impression he gave me was that Vista and XP were like totally incompatible, and of course I found this to NOT be the case. I was able to share files, and do a few TS sessions. Not sure what the hidden dangers are here. I would love to have Windows Server 2008 actually, with IIS 7.

I also did some more VBA today. Now before you cringe there is one important thing that people need to realise in today’s situations and that is that solutions that work ultimately win over customers, whether you use VBA or C# to achieve it, it doesn’t matter really. I must say that I have to force myself not to type a semicolon after each line of VBA code. The VBA code I looked at again was creating PowerPoint presentations from Access. This is useful when you use a lot of presentations on a regular basis, and the information being used in them can be normalised, and made more reusable.

  • Share/Bookmark
posted by fr3dr1k in Application Development and have No Comments
Get Adobe Flash playerPlugin by wpburn.com wordpress themes