QBCon
 Development blogMinimize

What's the use of coding standards?

Fri, 12 Nov 2010 07:35:00 +0000

Although people think of programmers as nerds and geeks, they are actually a very varied group of people. In our own office you have mothers, geeks, jocks and even very arty people. Their programming styles vary just as much as their personalities and lifestyles. You get everything from the cowboy programmer that programs from the hip to the meticulous programmer who will write a comment for every line. This also leads to very different coding styles. Although it might not seem to be a problem initially, it can become a huge, time-consuming problem. For instance, when Mrs. Meticulous has to work with or on the cowboy’s code, the fact that he indented his code by only one space may make his code almost unreadable to her.

The compromise in the end is to have a coding standard: a set of rules that explains what the standard way of coding will be. It can specify everything from the amount of comments to where the period after a line of code must be placed. To say it is a compromise is accurate as no one person would be completely happy with all the rules as many of them might clash with their personal preference.

The advantages of a coding standard are obvious. The end result will be neat, uniform code that can easily and quickly be read by a programmer who is familiar with the standard. It will make it easier for new programmers to become acquainted with the code and for existing programmers to take over code that has been written by programmers that has left the company. Although a coding standard fixes a lot of problems, some caution has to be employed. Setting down the standard can be very time-consuming, as anyone who has sat through a two-hour meeting on where to put a “then” can attest. It might be valuable to get a neutral outsider to help negotiate the standard.

For more information please visit the QBCon home page.

GUI versus Character, the ultimate battle!

Wed, 20 Oct 2010 11:20:00 +0000

When thinking about the differences between a character system and a graphical user interface (GUI), a few things come to mind. The most prominent is the look and feel of the system. When working in a character environment all you need is your keyboard. It is a bit more rustic than GUI, but you can still design a great interface for your customer’s specific needs. Working with a keyboard takes some getting used to, but when you are familiar with all your keys and their functions you can run through a system like a hot knife through butter! The sacred art of double-clicking becomes a thing of the past. The programmer controls the flow of action, as the user can only leave a specific field by pressing enter or the tab key. When a user starts a function or action he must either finish that action or back out of it completely before choosing to do something else.

GUI, on the other hand, is a bit more refined and friendly to end-users because it’s a lot like the Windows operating system. GUI gives the programmer the ability to play around with the screen layout, sometimes to the point of frustration. Often, too much time and effort goes into the design of the screens and not enough into the logic behind it. The user controls the flow of action because he can skip over certain fields using the mouse. A user can change his mind while busy with an action and change a security option before finishing.

What character systems buttons lack in finesse, they make up for in transparency. There's no wondering what Appr. means ('approve' for those who don’t know). With GUI you can pick an icon, but what might look like ‘approve’ to the programmer might mean something else to the user. Always be sure to add your tooltip when designing buttons in GUI. Buttons often look like hieroglyphics to the user.

Virtual real estate is something that doesn't exist in a character system and probably never will. Limited space will always be a problem, so designing a system that is understandable is a priority. Real estate and virtual real estate is one of the great features in GUI. There are no limitations to the amount of buttons you can add to your toolbar or the number of tabs you can add to your program. If and when it does become a problem a bigger screen is an easy solution.

I always remember thinking when I was young that a GUI system is an upper-class software system that only the elite can use. Recently I’ve come to realize that both character and GUI offer the exact same functionality and ease of use. It all boils down to personal preference. I have come to appreciate the 3D frames and fancy buttons that come standard with a GUI system, but deep down I will always be a fan of character.

For more information please visit the QBCon website.

Written by Denielle Horn on behalf of QBCon.

Evolution of tools

Wed, 08 Sep 2010 11:53:00 +0000

Some purists may argue that man only really stepped up and made progress after the invention of electricity since most major inventions has been made in the last 100 years and no period in time has ever seen the progress made as in the last hundred years.

I, however, feel that man made his biggest evolutionary leap when he first realised that having a tool to help complete work is better than not having any tool at all, albeit the wheel, metal hammer or whatever implement of war you like (queue the overused 2001:a space odyssey reference where the ape realised the POWER of tools when he kills his fellow ape with the bone from an animal)

Apply that principal to development and the same rule applies. The better your tools, the more POWER you have.

In my team, the principal exists that a proper set of base line tools will not only help speed up development but will also help to decrease bugs and other well documented problems in the development life cycle. We have the motto that whenever a new development starts we carefully evaluate what tools we have available, what tools we can buy and ultimately what tools we need to develop ourselves to enable us to do the work smarter and faster.

One set of these tools are our code generators. Now there may be various products on the market that allow you to efficiently generate mass amounts of code, but they are expensive and often customization of specific needs take more time than what the actual benefit may be. So we develop our own. These Code generators then enable us to generate various pages (Data manipulation pages), Search pages, Code snippets and generic usage pages that not only boost development time, but also assist junior developers in understanding certain concepts. One of the major advantages of these generators are the fact that the code that is generated has already been tested, approved and cleaned up to the extent where limited bugs exist, and should a new bug be found, ALL the code can easily be regenerated with the fix and applied to existing code.

So whenever your next project starts or even in your current development / maintenance / QA cycle, keep your eyes open for opportunities to either buy or develop your own development tools.Although you may not see the benefits immediately, once the tools are refined and they start producing results the benefits will not only become clear but it will become an essential part of your development arsenal.

Not having the proper tools is like having a great car with a broken gearbox, you will always be stuck in first. So in the next project you do, PLAN properly around the proper tools and you will find yourself picking up speed in no time.


For more information visit the QBCon home page.

SketchFlow – Client Interaction Made Easy:

Wed, 08 Sep 2010 11:39:00 +0000

One of the most tedious steps when starting a new project is mapping workflow. It acts as the benchmark for the rest of your application, but the initial idea hardly ever sticks. Getting sidetracked during the design process is as certain as death and taxes. Trying to represent another's vision is a time-consuming process that often causes delays due to miscommunication. A client often won’t be interested in the flow of a program, but in how it looks or whether it will sell. Clients propose one thing and a developer will interpret it differently, purely because of different mindsets.

During design, we use fonts and colours that we are familiar with. When pitching the design, this is the first thing the client notices. It draws the client's attention away from the functionality of the application.

How do we avoid this problem until the basic functionality is complete? When I discovered SketchFlow, I felt like screaming, "Eureka!" This tool not only makes workflow mock-ups unfathomably easy, but it focuses on the simple things needed to help developers clarify the bigger goals.

This however, is not the only gun in SketchFlow’s arsenal. Clients can actually see the progress of a design and present feedback on it instantly. This feedback, in its purest form, is packaged and relayed to the designer with notes and ideas in place. It avoids confusion and speeds up the design process by focusing on core components. It gives clients the power they really want, namely being involved and in control.

Listing 1.1 shows screens as displayed in a ‘SketchFlow Map’ format. This gives a clear indication of which screens are connected. Developers might know a child window from a UserControl but to clients this might be a foreign concept. SketchFlow’s enables the designer to give different screens a Visual Tag. This makes it easier for the client to read what is being presented.






Listing 1.1.

Listing 1.2 shows the core of what the client sees. SketchFlow focuses on functionality of design, instead of image. Designs are based on a non-colour, non-font example. This helps the client to stay focused on what the program should do instead of what it looks like.


Listing 1.2.


Listing 1.3 displays SketchFlow as the client would see it. From here the client can view the map, navigate between screens individually, or follow the flow of the program as it would be in real-time. It’s published client side and makes the communication much easier. When something is unclear to the client, they can easily have a quick look instead of taking the long road through developers, designers etc.


Listing 1.3.


Listing 1.4 displays the proverbial honey of SketchFlow.






The client can draw and highlight areas on the screen and add text as notes. This gives maximum feedback and can visually present an idea, which is sometimes easier than verbalising it. It makes communication between designer and client much more reliable, which cuts out time delays on trying to decipher concepts.





Listing 1.4

SkethFlow holds many treasures for a designer. Clients are often blindsided by the end product, which takes focus off of what is important. We need to crawl before walking; SketchFlow aids in perfecting the core steps of applications before they can adopt their full potential.

ASMX or WCF? Choose your pizza

Thu, 02 Sep 2010 07:53:00 +0000

When you do a Google search on “ASMX vs. WCF” or similar you will find a lot of results. This is how I see it:

A man called Smith ordered a Regina pizza with broccoli from his local pizzeria. The man behind the counter was stunned. Why would anybody order this particular pizza? He asked the man if he would be interested in the new, awesome pizza, namely a Regina base with broccoli, pepperoni, bacon, avocado, steak, mushroom, three cheeses and pike.

The little scenario above is a mediocre comparison between ASMX* web services and the new WCF*. Although broccoli (ASMX) is still an excellent technology, there are better, newer pizzas out there (WCF).

I’ll admit it is easy to eat the broccoli pizza without making a mess. A description of what your service methods and classes will look like is stored in a WSDL*.Now, we simply decorate a method (inside a .asmx) with the [WebMethod] attribute and viola, any property with public accessors and modifiers we pass in or out, will be serialized into XML. Your method can now be called over HTTP and hosted on an IIS.

The snags with broccoli, uhm, let me think…to name a few:

  • ASMX doesn’t specify how to deliver over the transports and to use a specific type of security.
  • ASMX has a tight coupling with the HTTP runtime and is dependent on IIS to host it.
  • ASMX service is instantiated on a per-call basis
  • ASMX provides the way for interoperability but it does not provide or guarantee end-to-end security or reliable communication.

Now, let's discuss the pizza with all the new toppings. WCF irons out all of the concerns listed above and replaces all the following technologies: ASMX, MSMQ*, WSE*, COM+ and .Net Remoting.

You might have noticed that one of the toppings in my metaphor, pike, has no business being on my pizza. This represents the configuration that is keeping a lot of developers from implementing WCF. With WCF the configuration might be a bit “messy”, but the reward is an awesome, tasty pizza. From a developer's point of view the coding side stays the same, the bottom line being a method gets called with an “object” as parameter and an “object” is returned (To get the technical lingo out of the way…we call this a message).

We no longer decorate only the method, but an interface, meaning any class that implements the interface can be a service. We are no longer limited to hosting the service only on an IIS, but in Console Apps, Windows Forms, WPF, etc. A description of the Service is still stored in a WSDL (.Net 4 has support for WSDL 2.0)

WCF is the future of the .Net platform, thus it will be time wisely spent to familiarise, educate and become proficient in it.If you have been holding back I encourage you to forget about your trusty broccoli pizza and reap the benefits of a pizza with a lot of awesome toppings.


Definitions

  • ASMX: Active Server Method File
  • WCF: Widows Communication Foundation
  • WSDL: Web Service Description Language
  • MSMQ: Microsoft Message Queuing
  • WSE: Web Services Enhancements

For more information visit the QBCon home page.

How to choose: Web or Windows Application?

Tue, 31 Aug 2010 10:39:00 +0000

Choosing between writing a Web application and a Windows application is like choosing between Superman and Batman. The man of steel can fly, shoot lasers from his eyes and pack a mean punch, while the Dark Knight has cool gadgets, a Batmobile and is a billionaire with a secret lair.

At QBCon we work on Web and Windows applications. There are a lot of things to consider when deciding between Web and Windows. Let’s look at some of the pros and cons.

Web applications

Pros

  • No special configuration or changes are needed on the user’s computer.
  • The application and information is accessible to a wide audience all over the world.
  • Centralised data is secure and easy to backup.
  • Anyone with a browser can access it, regardless of their operating system.
  • Deployment and version management is easy, making the application immediately available to all users. There is no installation to contend with.
  • When the application is used for in-house Intranet systems, no Internet connectivity is needed. Users only need access to use a local network.
  • Documentation, like quotes or invoices, is readily available to clients.

Cons

  • Depends on the hosting server.
  • Web applications that rely on the Internet to transfer data rather than a computer's local hard drive may operate slower.
  • Security risk of running an application of the Internet is more significant than when running an application on a standalone desktop computer.

Windows Applications

Pros

  • Program can be used without Internet connectivity.
  • The program runs faster as it sits on the local computer.
  • Reduced security risks that might include hacking.
  • Users don't have to compete for resources on the servers.
  • Direct access to machine com objects.
  • Cheaper over time.

Cons

  • Deploying a .Net application might be tedious because the .Net Framework needs to be distributed and installed on all client computers.
  • Platform dependant.
  • Software can be pirated.
  • Less chance of finding restrictions that the clients’ computer may have imposed.

Due to the fact that there is no clear winner, I suggest taking the following into account when deciding.

  • Security
  • Server’s hardware and software
  • User’s machine hardware and software
  • Geography of users
  • Delivery and development times
  • Downtime and maintenance
  • Updates and patches
  • Cost of development and maintenance

If the client has a smaller budget and needs an in-house application, go for windows applications. In all other cases, I prefer Web applications. With Web applications, I don’t need to go the client for debugging and maintenance so often. If the Windows application is flexible enough to be developed as a Web application, why not do that?

Written by Rudolph de Kock on behalf of QBCon.

For more information see the QBCon home page.

"When the pupil is ready, the master will appear."

Fri, 27 Aug 2010 11:49:00 +0000

In The Mask of Zorro Diego de la Vega puts Alejandro Murrieta through his paces. At long last Alejandro Murrieta completes the parry flawlessly. Before he can enjoy his success Diego de la Vega says one word, “Again!”

Repetition, repetition and repetition! Getting something right for the first time usually means that I remembered the steps of the process for the first time. The process becomes ingrained by repetition. To repeat a process is to perfect the process.

In my attempts to becoming a developer, the first thing I did was read a book. Learn C# in 24 Hours seemed a good choice. I thought reading would help me to develop applications. Sadly it did not. 90% of what I read was lost on me. Only now do I understand what they were talking about. One of the roadblocks was that I knew how to create web pages but I did not know the technical jargon. Speaking of aggregates and arguments only made me feel like begging them to speak English.

Guidance for junior developers is invaluable. Being left to one’s own devices is like being a classroom without a teacher for a year. The chances of passing the exams at the end of the year are slim if a syllabus was not followed. After a year of pointlessly suffering through allocated work I went into the design aspect of applications solely because I was better at it than at development.

A few years along the line I was bored out of my mind. A chance came my way to get back on the development wagon. At first I was not very excited about the prospect of developing again (keeping in mind the torture of not getting it right the first time), but my fears soon abated. A new manager, better understanding of how to allocate work and a better judge of proficiency made my second venture into the developers’ domain a pleasant experience.

Keep it simple stupid! (KISS) The acronym was first coined by Kelly Johnson and is still relevant as ever. I started out with Manage and Add/Edit screens. These were the least complicated parts of most applications, yet they contained a little bit of everything. Controls, data sources, classes, methods and stored procedures, each of these were a bit more difficult than the previous one. The next step was to start writing my own stored procedures. It took approximately eight hours of development time per page. After a month or two, the time was reduced to approximately four hours – not exclusively due to commitment, but rather to working smarter and not harder.

As I became more confident, the work became more complicated. For every four modules a more difficult module was assigned. Want to learn SQL? Try writing reports. In six months' time I went from knowing how to select a list of items from a database table to writing complex and dynamic queries that even I'm surprised at.

The last part of the success secret was a ‘work buddy’ who was assigned to me. My work buddy helps out at the stages where my progress was brought to a grinding halt due to inexperience.

For more information visit the QBCon home page.

“Suddenly you’re like a pirate, you’re 65 years old and you’ve got an ear-ring....”

Thu, 08 Jul 2010 09:20:00 +0000

I just love this quote. It shows us our unchanging ways and how we stick to something for the sake of sticking to it and after careful consideration we might find that something that held true for years and which we either liked or came to depend on is no longer relevant.

This is maybe the biggest challenge I find as a leader, to continuously challenge the process and to refine it, redefine the reason and to improve on it.

In my team we continuously investigate all processes and try to either improve on them or at least see whether they still hold true or whether we are just doing them for some legacy reason. Processes are only relevant if they still hold true.

Here is an example of our revision when it comes to tracking development work and bugs.

“We need prisoners to interrogate, and that tends to work best when they're alive”

As with prisoners you also need to keep bugs in a location so that they don’t “escape” and cause mayhem. We I took over the department, bugs was handled in a spreadsheet that was mailed around and everyone could do one, add one and it was expected that every developer would test his own bugs / work and bugs was only reported and added to the sheet after the publish was made to the client. This means that most of the bugs were reported by the client. (Not so good)

I started looking at the process and it was very inefficient and costly. Sometimes the same bug would be fixed by two developers, communication on the process and progress was shoddy and we often had recurring issues.

The process was insufficient

The first step we took was to centralize the logging, progress tracking and assignment of bugs by creating a system we call “Devlog”. This meant that all bugs was hosted in a databases and that developers would only do the bugs that was assigned to them or in some cases where the developers were faster than I could allocate work they could claim bugs. This tool has now evolved to where it helps with overall planning and resource allocation.

This process seemed to work really well: in the beginning. Soon loop holes appeared and bugs would still be recognized too late or developers would not test their own work properly.

The process was better, but had loopholes

I soon realized, as a developer, I would test around the conditions that made the software work and users tested a completely different way. Since there was no way I could sufficiently do Hallway testing I decided to hire someone to do my QA (see our blog on QA). So my Quality assurance department was born. Rules were wrote up, reports styled and we would soon dedicate time for every developer to give their work QA for testing, and we would allocate time before any release for testing and bug fixing. This meant that most bugs were reported internally and the client would never see 90 % of the issues instead of reporting 90 % of the issues.

The process delivers results

Soon we had less bugs, better turnaround time, and due to the QA reports being official and used in every developer’s revue we had less bugs and software that was developed faster and better than ever before.

“The Code is more like guidelines, really”


Although this is a small part of our entire development process and even our current QA process, it is a critical one and we continuously look to giants like Microsoft, Apple and Google to see what they do differently and how we could take their processes and apply them to our business. Taking into consideration that we don’t have Google type budgets, man power or timelines there always seem to be some tweaking to a process to get it to work for us, but it does help us to see that one fact holds true. Even though a process might be sufficient today, it can always be optimized tomorrow.

Visit the QBCon website.

INTERNET EXPLORER 8: COMBINING CSS, TABLES AND DIVS TO SOLVE ALIGNMENT ISSUES

Thu, 08 Jul 2010 09:11:00 +0000

The main difference between IE7 and IE8 seems to be that the alignment is all messed up in IE8. Although the alignment issue isn't ideal, IE8 has improved support for various web standards, especially cascading style sheets. Cascading style sheets is separate content from presentation. This will be our starting point. For this solution to work it is necessary for the presentation to be defined in external style sheets.

Step 1: Referencing the external Style sheet

In Example 1 an external style sheet is referenced and inside the tags a

tag is specified with an id=”DIV_Body”.

Example 1:

Head1" runat="server">
title>XYZ
link href="StyleSheet/StyleSheet_Main.css" rel="stylesheet" type="text/css" />
/head>
body style="margin: 0 0 0 0; width: 98%; text-align:center">
div style="text-align: center" id="DIV_Body">
/div>
/body>
/html>

Step 2: The Style sheet layout

My alignment solution is based on the relationship of the #DIV_Body class and table element as seen in Example 2.

Example 2:

#DIV_Body {
text-align:left;
margin-left:auto;
margin-right:auto;
vertical-align:baseline;
position:inherit;
width:98%;
}
table {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
padding-left:0px;
margin-left:auto;
margin-right:auto;
}

Step 3: Let the magic begin!

Insert the following on every page in your website/-application :
.
The rest of the solution relies on the user using tables for layout purposes inside the
tag.
Workarounds Available
• Emulate IE7 by inserting the following in the section of your page :
OR
• Click on the Compatibility View button supplied

Conclusion

It seems everyone's moving from a table-based website structure to a div-based website structure. However it's still necessary for the developer to know when to use what. Because a website is not the same as a web application I am sticking to my table-based structure roots when it comes to the application part. It's much faster to draw up a table with six rows and ten columns than it will ever be with divs. I use div tags for the structure of web pages and tables for the structure of page content.

For Web Applications:

The most important part of the table element style is the margin-left:auto and margin-right:auto. If the values aren't set to auto the layout won't work. These attributes will allow for the calculation of the margins of the tables position in relation to the main div tag. There are workarounds (as specified above) for existing sites but those are only temporary fixes.

For Web Sites:

IE8 now supports the display:table property

Example 3:

This is an example of a page with three columns, a header and a footer using div tags for the layout instead of tables:

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
html >
head>
title>Title
meta content="text/html; charset=utf-8" http-equiv="content-type" />
link href="Stylesheet_Main.css" rel="stylesheet" type="text/css" />
/head>
body>
div id="header">Header

div id="main">
div id="col_left">Left column

div id="col_right">Right column

iv id="col_center">Content


div id="footer">Footer
/body>
/html>

#main{
width: 100%;
display: table;
}
#col_left {
width:20%;
display: table-cell;
}
#col_right{
width:20%;
display: table-cell;
}
# col_center {
display: table-cell;
}

Microsoft Visual Studio tips and tricks

Thu, 08 Jul 2010 09:06:00 +0000

Today I will discuss some Microsoft Visual Studio tips and tricks any web developer should be aware of. These tips and tricks will improve your productivity and ease your day-to-day development duties so that every developer can boost his output.

Keyboard shortcuts can save a lot of time. Microsoft Visual Studio ships with an arsenal of standard keyboard shortcuts for common tasks and allows for customisation (Tools > Options (Show All Settings) > Environment > Keyboard). As part of our in-house development and training programme, every developer is expected to know Visual Studio. Below is a list of useful standard keyboard shortcuts used in common day-to-day tasks:

1. F7: Toggle between code-behind and mark-up.
2. Shift + F7: Switch the designer between modes e.g. Source and Design Views.
3. Right Alt + Right Shift + Enter: Switch between full screen and normal mode.

This is particularly useful for code files, where every bit of display real estate is valuable.

4. Ctrl + K + D: Formats any code file's content with properly defined indentation for readability.

5. Debugging shortcuts: F5 > Run with Debugging, Ctrl + F5 > Run without Debugging, F10 > Step Over and F11 > Step Into.

6. Ctrl + M + L: Toggle code files between collapsed or expanded view.
7. Shift + Del: Delete the current line.
8. F12: Go To Definition of the current item.
9. Ctrl + K + C: Comment the current code block.
10. Ctrl + K + U: Uncomment the current code block.

Environment setup can hog a computer with unnecessary eye-candy robbing you of valuable development time. Here are a few tweaks to speed up Microsoft Visual Studio: (All these options are under Tools > Options (Show all settings))

1. Environment > AutoRecover: If you're in the habit of regularly saving your work and have a source control server, you can turn this option off and save precious hard drive access.

2. Environment > General: Adjust or turn off visual enhancements (VS2005: Animate Environment Tools and VS2010: Automatically adjust visual experience ... )
3. Environment > Startup > At startup > Show empty environment: Speeds up launch time and does not download content from the news channels.

3. Launch time: Right-click the Microsoft Visual Studio shortcut, click Properties > Shortcut and add -nosplash at the end of the Target. This will speed launch time even more.

4. Page file: Hard drive access has a significant impact on Microsoft Visual Studio. By default the page file is located on the system drive. To speed up the system, move the page file to another physical drive to take pressure off the system drive. Preferably the physical drive used for the page file should do only paging for maximum benefit.

5. ReadyBoost: If you are using Microsoft Windows Vista / 7, you could take advantage of the ReadyBoost feature. ReadyBoost keeps a shadow copy of the page file on a device with faster access time and burst read speed than a typical hard drive.

Normally, a flash drive would suffice this requirement and is a cost-effective means to speed up system performance without upgrading hardware.

There you go, a bunch of easy tips and tricks to make you more productive and maximize your development experience. Enjoy!

Using PageMethods in ASP.Net Ajax

Thu, 08 Jul 2010 08:56:00 +0000

In addition to allowing XML-HTTP requests to call conventional Web service methods, ASP.NET AJAX also supports a special type of Web method known as the page method. Page methods are Web service methods implemented in Web pages (*aspx). This means there is no need for a conventional ASMX (Web services) file. Page methods enable developers to trigger XML-HTTP type call-backs (in other words, there is no need for a PostBack to the server) without building dedicated Web services.

Page methods must be public static methods and must be decorated with the [WebMethod] or [ScriptMethod] attribute. Your page must be ajax enabled, meaning a ScriptManager must be present (Set the EnablePageMethods attribute to true)

[WebMethod]
public static string example(int var1, int var2)
{
return "This string was returned by the Page Method with values" + var1 + " and " + var2;
}

PageMethods can return any variable type and even objects as long as it is serializable.

The setup for using PageMethods is now complete. Let’s have a look at how to put it all together.
Using JavaScript, call the webmethod as defined in your aspx.cs file by making use of the PageMethod object.

function btnSomething_Click()
{

var var1 = 10;
var var2 = 20;
PageMethods.example(var1, var2,
function success(result, context, methodName)
{
window.alert(result + ‘ was returned by ‘ + methodName);
},
function failed (err, context, methodName)
{
window.alert(methodName + "\n" + err.get_message());
},
“this is a context variable” );

}



Successful execution resulted in the success javascript function being called. This method receives three parameters. Result contains the value returned by the PageMethod.

If the PageMethod could not be called, or something went wrong in returning a value back to the client the failed javascript method is called.

In the above example, both the successful () and failed () functions received a parameter called context. This is a optional parameter that can be supplied by the user in the original PageMethod call. The value of the user context variable will now contain the value “this is a context variable”. If nothing was passed to the page method, this value will be null. We use PageMethods religiously when the client expects increased performance and response times. Combined with a healthy understanding of HTML rendering and Stylesheets (see our blog on CSS) there is little a well-constructed Javascript function using Pagemethods cannot do.

And that is all that is to it. Easy!

Carel Steenkamp

To clone or not to clone

Thu, 08 Jul 2010 08:50:00 +0000

Have you ever needed to copy an object’s values to another object of the same type? If you have and have done this manually by copying each value separately this blog entry is for you. In this post I will guide you to make the object cloning process as easy as possible.

Let's say you have the following classes

public class Person
{
public Person()
{ }

private string _FirstName = "";
private string _LastName = "";
private Car _Car = new Car();

public string FirstName
{
get { return _FirstName; }
set { _FirstName = value; }
}

public string LastName
{
get { return _LastName; }
set { _LastName = value; }
}
public Car PersonCar
{
get{return _Car;}
set{_Car=value;}
}
}

public class Car
{
public Car()
{ }

private string _Make = "";

public string Make
{
get { return _Make; }
set { _Make = value;
}
}
I will now create two instances of this class. One where I create the Person object from scratch and another where I assign the new person to be the same as Person One.

Person personOne = new Person();
personOne.FirstName="Peter";
personOne.LastName = "Cane";

Person personTwo = new Person();
personTwo = personOne ;

If this code is executed, the values of the two person objects will be the same. But when you change the FirstName of person two, the the FirstName of person one will also change. When you use the equals (=) sign to assign an object to another object, you only copy the reference to the actual values. If you change any propery of any of the person object, the value will change for person one and person two. Thus a change made in one instance will also affect the other instance directly because they are the same instance with different names.

To copy the actual values of the object and create a new object, you need to implement the ICloneble interface. To implement this interface add the following to your class declaration.

class Program :ICloneable

When you implement this interface, the following method is added to your class. You need to implement the method so that is does the cloning for you.

public object Clone()
{
throw new Exception("The method or operation is not implemented.");
}

Types of cloning

There are two types of cloning. Shallow copy and a deep copy of the object. Shallow copy will clone the objects value types,but will only copy the references of any reference types in the object. For example, let’s say you clone the Person object created above using shallow copy. The person will be cloned, but the car object will not be cloned. In other words the new Person will still use the other guy’s car. To clone the object so that both have their own car, you have to use deep copy. A car will be cloned for the new guy as well.

• Shallow Copy : use the MemberwiseClone function. This will copy the value types, but only copy the references to the reference types

public object Clone()
{
this.MemberwiseClone();
}
• Deep Copy : To implement a deep copy, you will need to serialize the object and then deserialize the object as follows.

public object Clone()
{
MemoryStream mm = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(mm, this);
mm.Seek(0, SeekOrigin.Begin);
object o;
o = bf.Deserialize(mm);
return o;
}

In this instance I would say cloning is the optimum solution, as for cloning sheep….I don't agree.

Dewald Fortier.

QBCon training on the way up

Wed, 30 Jun 2010 12:07:00 +0000

Productive and effective developers are difficult to come by. As the market continuously demands better software developed in less time, it's important to train and keep developers sharp and up to date on current trends.

One of our main internal training resources and assessment methods is QBMoodle.
Moodle is an open source course management system (CMS), also known as a learning management system (LMS) or a virtual learning environment (VLE). It has become very common among educators around the world for creating online dynamic websites for students.

Moodle gives educators the best tools to manage and promote learning.
At QBCon we use Moodle to provide training in HTML, Silverlight and all new technologies. Although QBMoodle is still in diapers, this unique way of training has already started bearing fruits. The effects of the training are already reflecting in our products.

Combined with W3Schools, MSDN and other online resources, this training system is one of the most effective, low cost and user-friendly learning tools available. We can access most of our learning material and preparation on the web or eBooks, but the assessment is done on Moodle. We write a test on each subject using the material available on W3Schools. Each test has a time limit. Previous test scores are saved to monitor the student’s progress. The student has to score a mark of at least 70% within three tests to pass the current subject.

In future we aim to expand QBMoodle to cover all subjects for all levels of programmers, from novice to expert. As the QBCon saying goes: “There is no place for average”. Visit the QBCon website at http://www.qbcon.com

We’re all mad here

Tue, 30 Mar 2010 07:46:00 +0000

These words aren't only true for Alice in Wonderland. It seems there's an element of madness in every software development project.

Sales teams over-selling and underestimating development times, project managers getting lost in a project that's running behind schedule, developers complaining and clients expecting demos can make us team leaders feel like we're staring down the rabbit hole.

More often than not the difference between tumbling down to Wonderland or staying afloat comes down to one decision: Will we stop the mad tea party and plan properly, or will we be sucked into the frenzy and just start the project?

As someone who has made the mistake of simply starting a project, I will now dispense the best advice I have: DON’T.

As Alan Lakein so succinctly put it: “Failing to plan, is planning to fail”

Even when you have limited planning time in comparison to development and delivery time, you should still make the time to do planning. Even the most rudimentary notes are better than not having any at all.

Here are a few things I like to look at when my planning time is limited and I need maximum results.

  • What mistakes did we make in previous projects?
  • How did we fix this?
  • Are all the team members aware of how the problem was approached in the past?
  • What codes or modules can we salvage from previous projects?
  • Code reuse is not just some fancy tactic employed by overzealous programming teachers. It saves time (if code is modularized and planned properly)
  • Get a proper code generator
  • Do we have samples or best practices documents?
  • Very often, even junior developers can do certain tasks when examples are readily available. Even though Google is probably the best teacher in the world, it's impossible to find answers if you don't know what you're looking for.
  • Identify difficult coding or modules and pre-assign them to experienced developers
  • Very often just assigning the work to random developers saves time in creating the project plan, but wastes time during development.Be aware of upcoming difficult modules, interaction with other modules and the availability of strong developers.
  • KNOW YOUR DEVELOPERS
  • Knowing your developers will aid in assigning work. Do you need a developer that will generate brilliant code over a longer period or a developer that can complete the code within a time limit?
  • Force developers to keep to the specification
  • As developers we try to be brilliant (especially when trying to impress clients) at the expense of the deadline. If the client specified a Mini, don’t code a Porsche. Not only will it be more prone to bugs, but you will also have wasted time on extras. Chances are the nice-to-haves will come back with change requests that could take development over the allocated time. Stick to the basics, keep your deadline in mind and don't over-complicate.
  • Plan technically
  • If you don’t have any overall idea of what you want done on the system, stop. In my experience, if there aren't any technical guidelines, everyone will do as they please.
  • Planning helps with code maintenance and stability
  • Proper planning will enable a junior developer to maintain code that a senior developer developed. Senior developers are generally busy with new complex work. Without proper planning they are often required to maintain the code as well, leading to development bottlenecks.
  • Identify future problems before you get there.
  • If you have 10 days to code, take at least two to plan. Ensure what you want to do is what the writer of the specification intended. Changing your planning is easier than changing the code.
  • Make notes of decisions taken in meetings.
  • Very often a white board session is more than sufficient, as long as you take notes. Don't rely on your memory. It tends to fail.

These are just some of the basics that work for me when I need to achieve results within a limited time. Of course we would all prefer sufficient time to plan projects. However, considering all the variables, sometimes you just have to make things work by force of will.Proper planning will help you do so.

Remember, in this business the only constant is the one you code yourself.

Why QBCon Developers Use C-Sharp

Mon, 02 Nov 2009 11:32:00 +0000

Having been in the IT industry for several years, I’ve tried a good number of programming languages; from various assembler languages to 4GL (4th Generation Languages) and finally OOP (Object Orientated Programming) languages. Some languages are easy, others are just downright impossible to do.

For the last couple of years I did mostly maintenance work on a Classic ASP website written in VBScript (Visual Basic Script). Fun at first, but later-on I start running into problems. With the evolution of web systems and web applications, the classic ASP platform is seriously lacking in controls needed to awe the client.

Finally I had enough and decided to look at alternatives. For starters, I needed to move over to the .Net framework and opted to give C# a go. It’s an elegant, simple and object orientated language that allows you to build a breath of applications. Easy to find your way around, with lots of code samples available from online communities. It seems like everyone was using C#. I was able to write classes, implement design practices to ensure the classes were clean and reusable.


  
QBCon (Pty) Ltd. (2008/003367/07) - Phone: +27(0) 12 643 4400 Fax: +27(0) 12 643 4401 Physical: Tuinhof Building, Karree Wing, 3rd Floor, 265 West Avenue, Centurion, 0157 Postal: P.O. Box 7525, Centurion, 0046, South Africa