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; }
Thu, 08 Jul 2010 09:06:00 +0000Today 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! Thu, 08 Jul 2010 08:56:00 +0000In 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 Thu, 08 Jul 2010 08:50:00 +0000Have 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. Wed, 30 Jun 2010 12:07:00 +0000Productive 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 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?
- 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.
- 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.
- 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. Mon, 02 Nov 2009 11:32:00 +0000Having 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. |