Programming « Datadial Blog
0208 6000 500

On the subject of Programming

Alex

July 20th, 2008.

Design Patterns

Design Patterns are an essential tool for any object orientated programmer who wants to take his/her skills to the next level. Understanding the specifics of Design Pattern practices and methodologies will help developers uncover reoccurring patterns in software development and give them the tools to apply the correct solution.

For every difficulty encontered during application development, chances are this problem was encountered before (and solved). Design Patterns represent key programming practices that have been proven to get the job done in the most efficient, reusability and extensibility. This greatly increases efficiency of code and helps to break an application down into loosely compelled manageable chucks.

As a .Net developer you may have used some of these patterns without even knowing. A design patterns name captures the basic concepts that govern its use and a common practice is to include the pattern name in the name of the object that implements it.

You may have come across the following names while working with the .Net framework:

  • Proxy
  • Adapter
  • Command
  • Factory

The deeper your understanding of Design Patterns the more you’ll be to understand the .Net framework and how it can leverage you applications.

Main Design Patterns Concepts

  • Use interface inheritance over concrete base class inheritance
  • Create loosely coupled objects to promote code reuse by keeping object small and specialised
  • Defer / Delegate responsibility to specialised objects using composition

Choosing the correct pattern
The best way to decide which pattern is fit for the jobs it to break down your development specification into each requirement. If these requirement exhibit certain characteristics that relate to a design pattern then apply it. E.g. If you application is responsible for monitoring a file system and reporting changes back to a number of objects you are most-likely to implement the Observer pattern.

Summary
Once you have gained an understanding of object orientated concepts you should be ready to tackle Design Patterns. You will be surprised how many patterns that are already familiar to you and how much the put things into perspective. You’ll also find that the more you learn, the more you’ll see application development from a different perspective (almost like seeing the Matrix!!). To truly understand the benefits of Design Patterns you have to apply them to your application development. This will improve your object reuse and make future program changes less painful!

List of Design Patterns LINK:

  • Adapter Pattern
  • Command Pattern
  • Composite Pattern
  • Decorator Pattern
  • Factory Pattern
  • Flyweight Pattern
  • Intepreter
  • Model-View-Controller
  • Null Pattern
  • Observer-Observable
  • Singleton
  • State Pattern
  • Strategy Pattern
  • Template Pattern
  • Union Pattern
  • Visitor Pattern

Alex

July 20th, 2008.

Introduction to Developing .Net Mobile Applications

There are many tools on the market for creating application for mobile phones and portable devices. This blog post investigates the technologies necessary for creating Microsoft related ASP.Net mobile applications.

Window Mobile (OS)
Window mobile is a compact operating system for mobile devices. These devices include Pocket PCs, Smartphones, Portable Media Centres and on-board computers for cars. Windows Mobile has been designed to be similar aesthetic to Vista and is currently at version 6.1 with a new release scheduled for 2010.

.Net Compact Framework
The .Net compact framework is a scaled sown version of the .Net Framework and uses some of the same class libraries with a few additional libraries designed specifically for mobile devices. This can be integrated with Visuals Studio 2003, 2005 and 2008 to develop impressive mobile windows form based and web based applications.

ASP.Net Mobile Controls and the Microsoft Internet Toolkit
Developing applications for mobile devices can be a challenging as there are certain limitations, which include:

  • Different mark-up languages for PDAs, Cell phones or Japanese phones.
  • Devices have a varying number or display lines, horizontal/vertical orientation and screen colours.
  • Different network connectivity
  • Capabilities, display resolution and ability to make phone calls.

All these factors must be taken into consideration when developing applications for mobile devices.

This is where the Microsoft Internet toolkit comes in, as it addresses these issues so that developers can build one mobile web application that delivers the appropriate mark-up for a wide range of mobile devices.

The mobile toolkit contains:

  • Mobile web form controls which are similar to ASP.Net controls as the generate mark-up code
  • Mobile Internet Designer which integrates with Visual Studio .Net IDE to provide a web application design environment
  • Browser Capabilities which makes it possible to run ASP.Net functionality on mobile devices
  • Quick Start Tutorial with sample code
  • Developer Documentation
  • Device adapter code samples

Using a combination of the Windows Mobile operating system, .Net Compact Framework, and the Microsoft Internet Toolkit applications can be written to run on a wide range of mobile devices in a similar manor to that of regular browser base applications.

Summary
These are the three basic tools that are necessary to start building applications that target mobile devices.
Mobile devices are becoming increasingly popular as people continually want to stay connected when they are away from their desk. Microsoft has developed a cohesive little package of products that integrate well together and provide an infrastructure similar to their full blown application development environment. This will hopefully encourage developers to venture into the world of mobile application development.

Alex

July 19th, 2008.

Microsoft .Net Framework 3.5

The .Net framework 3.5 (released November 19th 2007) is the latest framework to be released by Microsoft. It has a host of new features and will be shipped as standard with the latest version of Visual Studio .Net 2008 IDE.

.Net framework 3.5 is an incremental build which means that instead of creating a completely new framework Microsoft has instead added new assemblies and fixed known bugs. This decision helped make the transition between .Net framework 2.0 and 3.0 as painless as possible. In essence .Net framework 3.5 contains the 3.0 framework which contains the 2.0 framework.

New assemblies include:

  • System.Data.Linq.dll – The implementation for LINQ to SQL.
  • System.Xml.Linq.dll – The implementation for LINQ to XML.
  • System.AddIn.dll, System.AddIn.Contract.dll – New AddIn (plug-in) model.
  • System.Net.dll – Peer to Peer APIs.
  • System.DirectoryServices.AccountManagement.dll – Wrapper for Active Directory APIs.
  • System.Management.Instrumentation.dll – WMI 2.0 managed provider (combined with
  • System.Management namespace in System.Core.dll).
  • System.WorkflowServices.dll and System.ServiceModel.Web.dll – WF and WCF enhancements (for more on WF + WCF in v3.5 follow links from here).
  • System.Web.Extensions.dll – The implementation for ASP.NET AJAX
  • System.Core.dll – In addition to the LINQ to Objects implementation, this assembly includes the following: HashSet, TimeZoneInfo, Pipes, ReaderWriteLockSlim, System.Security.,
  • System.Diagnostics.Eventing. and System.Diagnostics.PerformanceData.
  • System.Data.DataSetExtensions.dll – The implementation of LINQ to Dataset.
  • System.Windows.Presentation.dll –WPF support for the System.AddIn.
  • System.VisualC.STLCLR.dll – STL development in the managed world.

 

AJAX support has been added to .Net 3.5 as standard so that server and client-centric AJAX functionality can be added to existing and future web applications.

Some additional data-controls have also been added, in the shape of ‘ListView’ control for displaying data and the ‘LinqDataSource’ data control that exposes LINQ data to web applications. The ListView control is highly customisable (using templates and styles) and supports edit, update and delete operations as well as paging and sorting functionality.

Support from Vista styled Windows application has been added, which will even allow developers to update the appearance of old applications written using previous frameworks. Common file dialog boxes will be automatically updated to the Vista version. (See. http://support.microsoft.com/kb/926167)

Some of the biggest language orientated changes to.Net 3.5 are the inclusion of XAML, C# 3.0 and LINQ. Link and XAML are covered within my Silverlight and Visual Studio.Net posts.

Summary
One of the most important things to realise is that current web and windows application can be easily upgraded to .Net 3.5 as it is essentially built on the back of the previous two frameworks. Developers can make the switch safe in the knowledge that it won’t break their existing applications (unless their application exploited a bug, in which case it will!).
These types of upgrades are extremely welcome as it lessen the learning curve and give .Net developers more faith in Microsoft frameworks core infrastructure.

Alex

July 19th, 2008.

ASP.Net Vs PHP

Firstly let me start by saying that I do not claim to be an expert in either PHP or ASP.Net. Although I use ASP.Net daily, I am fairly new to it. I have decided to do little investigation to the age old debate about the difference between PHP and ASP.Net. This is only a short post, but hopefully it will give readers a better understanding of how the two technologies differ. Hopefully this will be as un-bias as possible.

The reason I have chosen to investigate the difference between the two is that non-programmer constantly ask the questions: “What’s the difference between PHP and ASP.Net”, “Why can’t PHP applications talk to ASP.Net applications?” or “That could have been done in PHP so much quicker, for free”. There are so many deciding factors when choosing a web application framework. I will attempt to outline the differences using a For and Against bullet point format for both.

For PHP

  • Free
  • Open source
  • Easier to learn due to its basic scripting language structure and build in functionality
  • PHP5 now offers many object orientated development concepts
  • Has many free IDEs available that are very impressive and well supported (e.g. Eclipse)
  • Runs on Apache server which is open source
  • Run on IIS 6.0 and IIS 7.0 due to Microsoft’s implementation of FastCGI open standard
  • Has multiple platform support
  • Marginally faster due to the overheads imposed by .Net’s Common Language Runtime, which is responsible for intermediate compilation of .Net’s many languages
  • Has a huge support base as it is open source

 

Against PHP

  • Although it claims to be free, when using free 3rd party add-ons developers often run into issues when developing commercially available applications (i.e. ownership of code / intellectual rights)
  • Most PHP IDEs require lots of add-ons in-order to add similar functions to Visual Studio
  • No built in support for AJAX. Requires add-ons.

 

For ASP.Net

  • Can be developed using the stunning Visual Studio.Net IDE that offers vast array of features, that make coding much easier and development more productive
  • Developers can download a free scaled down version of Visual Studio that offers an impressive array of features. This is aimed at students and hobbyists
  • Runs on IIS (Internet Information Services)
  • Applications can be written using many programming languages (e.g VB.Net, C#, J#, C++ COBAL)
  • The .Net framework (the engine that ASP.Net is runs on) has more sophisticated error handling capabilities than PHP
  • Allows better separation of design and application logic using of code-behind pages and user-controls
  • Has built support for AJAX as of .Net Framework 3.5

 

Against ASP.Net

  • Requires a Microsoft licenses
  • Requires a basic knowledge of object orientated concepts which can sometimes deter newbie developers
  • Single platform and will only run on Microsoft web servers

These bullet points emphasise some of the main differences, advantages and disadvantages of the two languages.

Quotes from other developers for ASP.Net and PHP

For ASP.Net
ASP.Net is Strongly Typed, Object Oriented, Sandboxed, Multi-Syntax, Component Centric, Event Driven, forms oriented, pre-compiled experience.

PHP is a loosely typed, objects optional, fixed syntax, component-less, runtime interpreted, structured programming model.

Joe Stragner

For PHP
In the end, PHP is less expensive, faster, more secure, and able to be deployed from a Linux server that is also less expensive, faster, and more secure than their Windows based counterparts.

Anon

Conclusion
There are many factors that may sway you decision about which web application framework to choose. This decision should be based on the factors above, the kind of career path you want to choose and detailed research. In reality though the decision is usually down to which framework you are exposed to first as many develops get comfortable with on languages syntax and features.

My advice would be to use both; if you can, as each one has its own merits and has earned its place in today’s web application development industry.

Alex

July 1st, 2008.

Layering IFrames using positioning and z-index

I was recently given a task by a client that required me to layer multiple IFrames on top of each other in order to facilitate the display of 3 separate content blocks (share price feeds) so that the content of two of them was only partially shown.

Each frame was a simple, relatively small area of text that displayed the current share price for a listed fund:

There were to be 3 frames in total.  Each frame was to display a different price, in the bottom 2 frames, only the share price was to be displayed and not any of the other content.

Using standard CSS positioning techniques I was able to position the 3 frames so that the 3 share prices were aligned correctly:

(Note the CSS code here is inline for simplicity)

<div style="display:block;position:absolute;top:0px;">
|||||<iframe src="http://www.myurl.com/iframe1" frameborder="0" allowtransparency="yes" scrolling="no" style="width:200px; height:90px; position:relative; left:-20px;top:30px;margin:0;padding:0;" />
</div>
<div style="display:block;position:absolute;top:30px;">
|||||<iframe src="http://www.myurl.com/iframe2" frameborder="0" allowtransparency="yes" scrolling="no" style="width:200px; height:90px; position:relative; left:-20px;top:30px;margin:0;padding:0;" />
</div>
<div style="display:block;position:absolute;top:60px;">
|||||<iframe src="
http://www.myurl.com/iframe3" frameborder="0" allowtransparency="yes" scrolling="no" style="width:200px; height:90px; position:relative; left:-20px;top:30px;margin:0;padding:0;" />
</div>

The major problem here is the overlapping of IFrames, while the positioning is correct, the 3rd IFrame overlaps the 1st and 2nd IFrames, and the 2nd IFrame overlaps the 1st IFrame.

To get around this we use the z-index property of CSS.  This property only works on elements that have been positioned, as we have done with each IFrame, in that it has been placed within an absolutely positioned HTML div element.  Z-index facilitates the display order (or ‘stack’ order) of elements on a page.

Hence we get the following by setting the z-index of each div to 999, 998 and 997 respectively.

<div style="display:block;position:absolute;top:0px;z-index:999;">
|||||<iframe src="http://www.myurl.com/iframe1" frameborder="0" allowtransparency="yes" scrolling="no" style="width:200px; height:90px; position:relative; left:-20px;top:30px;margin:0;padding:0;" ></iframe>
</div>
<div style="display:block;position:absolute;top:30px;z-index:998;">
|||||<iframe src="http://www.myurl.com/iframe2" frameborder="0" allowtransparency="yes" scrolling="no" style="width:200px; height:90px; position:relative; left:-20px;top:30px;margin:0;padding:0;" ></iframe>
</div>
<div style="display:block;position:absolute;top:60px;z-index:997;">
|||||<iframe src="http://www.myurl.com/iframe3" frameborder="0" allowtransparency="yes" scrolling="no" style="width:200px; height:90px; position:relative; left:-20px;top:30px;margin:0;padding:0;" ></iframe>
</div>

Note the lower the number the z-index, the lower the priority it has in the stack.  Z-indexes can also be negative.

The solution was effective enough for the client to be implemented on their site and saves the space that would otherwise be needed on the web page if there were 3 IFrames positioned separately from each other.

Recent Posts »

Our work »

What we do »

Who we work with »

Got Questions? Lets Talk »