Learn HTML & CSS For Free

Check out the link below for a free beginners and advanced guide to learning HTML & CSS.

http://learn.shayhowe.com/html-css/

 

htmlcssforfree

Advertisements

Video Coding Walk-through at TheCodePlayer.com

Found a cool website that gives you video a walk-through of all kinds of CSS3, HTML5, amd Javascript widgets.  The videos show the code being written on the left side of the page and the changes happening on the right. You can also change the code yourself and see how that affects the scripts. I recommend, when you’re watching the videos, to turn the playback speed to 5x instead of the default 10x if you’re just getting started.

Currently there are about two dozen walkthroughs demonstrating things you can do with Javascript, CSS, and HTML5. Some popular examples include making a stopwatch with CSS3 (no images or Javascript), making an accordion-style slider in CSS3, and making a particle system in HTML5 canvas.

Check out the site if you want to see some neat scripts in action and maybe learn a new trick or two. TheCodePlayer is in alpha right now, so hopefully there will be many more videos in the future.

Awesome Web Design Inspiration Site – Pattern Tap

A great site for getting inspiration for a unique web design is PatternTap.com.  It’s basically a collection of images of web pages which are categorized by tags.  These tags can be used to help search by page type, color, or region.  There’s a collection of user generated tags which allow for even more ways to classify and search for ideas.

Here’s an excerpt from the about page which may help to explain what the site is.

The Secret Origins of Pattern Tap

A long time ago, in an Internet far, far away … or 2008, Matthew Smith saw that there wasn’t any place on the Web that inspired other designers to be better at their craft. Sure there were web galleries galore, but nothing that really highlighted the nitty-gritty of great design and interaction work. With that idea firmly planted into his brain, he set out to build a shining beacon on the Web for designers to find the inspiration and education they needed.

Four years later, Pattern Tap has more than 25,000 registered users from around the world and across the galaxy. Designs are posted not only from Earth but as far away as the Constellation of Centaurus. Just wait until you see what some of those four-armed Centaurians design … those interactions are pretty far out and in four-dimensions!

Fantastic Font Sites

If you’re a web designer or graphic designer or just someone who likes fonts, then check out these fantastic font sites.

Identifont

Great website that allows you to search for a font by appearance, name, picture, or designer.  You can even look for fonts with a similar appearance by providing a specific font.

Google Webfonts

You can search fonts by several different criteria and easily see a preview of fonts after changing characteristics like thickness, slant, and width.

WhatTheFont 

This site allows you to upload an image which will be compared to an online database.  If there’s not a match found, you can even submit it in a forum section where users can help identify your font.

Asynchronous Programming with Async and Await

Check out this article on MSDN for a new feature in VS 2012 which makes asynchronous programming easier.  Here’s a brief summary:

Summary

Visual Studio 2012 RC introduces an approach that relies on two keywords, the Async (Visual Basic) or async (C#) modifier and the Await (Visual Basic) or await (C#) operator. The async modifier indicates to the compiler that a method or lambda expression is asynchronous and that suspension points can be designated within it by using an await operator. Such a method is referred to as an async method.

Inside an async method, you apply an await operator to a particular task to suspend execution of the async method until the task is complete. In the meantime, control is returned to the caller of the async method while the task completes its work. The suspension is accomplished without actually exiting from the async method, and finally blocks don’t run.

The compiler does the difficult work that the developer used to do, including signing up continuations for the completion of the suspended method. As a result, asynchronous code is much easier to write, and your program retains a logical structure that is similar to synchronous code. In addition, routine processes that can be difficult in traditional asynchronous code, such as loops and exception handling, cease to be roadblocks to successful solutions. For more information about previous approaches to asynchrony in the .NET Framework, see TPL and Traditional .NET Asynchronous Programming.

The .NET 4.5 Framework contains many members that work with async and await. You can recognize these members by the “Async” suffix that’s attached to the member name and a return type of Task or Task<TResult>. For example, the System.IO.Stream class contains methods such as CopyToAsyncReadAsync, and WriteAsync alongside the synchronous methods CopyToRead, and Write.

Example

The following code example shows a method written twice. The first is a synchronous version and the second is an asynchronous version using the new keywords “async” and “await”.

// Synchronous version of a method that downloads the resource that a URL
// links to and returns its content.
private byte[] GetURLContents(string url)
{
    // The downloaded resource ends up in the variable named content.
    var content = new MemoryStream();

    // Initialize an HttpWebRequest for the current URL.
    var webReq = (HttpWebRequest)WebRequest.Create(url);

    // Send the request to the Internet resource and wait for
    // the response.
    using (var response = webReq.GetResponse())
    {
        // Get the data stream that is associated with the specified URL.
        using (Stream responseStream = response.GetResponseStream())
        {
            // Read the bytes in responseStream and copy them to content.
            responseStream.CopyTo(content);
        }
    }

    // Return the result as a byte array.
    return content.ToArray();
}

// Asynchronous version of the same method. The changed lines

are marked with **.

// **Change the method name and the return type. Add the async modifier.
private async Task<byte[]> GetURLContentsAsync(string url)
{
    // The downloaded resource ends up in the variable named content.
    var content = new MemoryStream();

    // Initialize an HttpWebRequest for the current URL.
    var webReq = (HttpWebRequest)WebRequest.Create(url);

    // **Call GetResponseAsync instead of GetResponse, and await the result.
    // GetResponseAsync returns a Task.
    using (WebResponse response = await webReq.GetResponseAsync())
    {
        // Get the data stream that is associated with the specified URL.
        using (Stream responseStream = response.GetResponseStream())
        {
            // ** Call CopyToAsync instead of CopyTo, and await the response.
            // CopyToAsync returns a Task, not a Task.
            await responseStream.CopyToAsync(content);
        }
    }
    // Return the result as a byte array.
    return content.ToArray();
}

Click here to view a video of another example.

Learning Through Reading Code

I’ve started reading a lot of code lately from all kinds of different sources.  It’s pretty easy to find new tricks and techniques when reading someone else’s code.  Open source projects and blogs are great places to find code to look over.  Microsoft even has  a site dedicated entirely to sample code.  I like these projects because they’re small and categorized so you can quickly filter to what you’re interested in.

There’s also a free app that you can download to easily browse through over 3500 projects.

How to Create a Hidden Property or Method That’s Still Public

Have you ever needed to hide a property or method on a class, but still needed to access it outside of the class?  Obviously declaring the property as “internal” will only allow the property to be accessible from within the same assembly, but what if you needed to access it outside of the assembly, but also didn’t want to make it public for others to see.  An example of this might be a business entity that you allow customers to retrieve and save data using a WCF service client.  The entity exposes properties that represent a business object that you persist to a database.  The entity is also used in other business processes which require information that you don’t want to expose as part of the entity.

The following method describes a technique to add a property or method to a class that isn’t directly accessible on the entity, but is available explicitly through an interface.

1. First let’s create an entity with a public property.

    public class MyEntity
    {
        /// <summary>
        /// My Public Property
        /// </summary>
        public string MyPublicProperty { get; set; }
    }

2.  Now, let’s create an interface with a property that we want to use on the entity.

public interface IMyHiddenPropertiesInterface
{
string MyInterfaceProperty { get; set; }
}

3.  Now, have the entity implement the interface, but explicitly implement the interface property. I’ve also overriden the “ToString” method so we can print out the property values later.

public class MyEntity : IMyHiddenPropertiesInterface
{
/// <summary>
/// My Public Property
/// </summary>
public string MyPublicProperty { get; set; }

/// <summary>
/// My Explicit Implementation of my interface property
/// </summary>
string IMyHiddenPropertiesInterface.MyInterfaceProperty { get; set; }

public override string ToString()
{
return MyPublicProperty + " " + ((IMyHiddenPropertiesInterface)this).MyInterfaceProperty;
}
}

4. Finally, here’s a console app that creates an entity and sets both of the properties.

class Program
{
static void Main(string[] args)
{
// Create a new entity and set the public property
MyEntity entity = new MyEntity() { MyPublicProperty = "Hello" };

// Set the hidden property
IMyHiddenPropertiesInterface entityInterface = (IMyHiddenPropertiesInterface)entity;
entityInterface.MyInterfaceProperty = "World!";

Console.WriteLine(entity.ToString());
Console.ReadLine();
}
}

Notice when you look at the meta data associated with entity that you don’t see the MyInterfaceProperty.  That’s because it’s only accessible through the interface.

Here’s what you see when you look at the interface data from intellisense.

MyInterfaceProperty is hidden when acting on the MyEntity variable, but it’s available explicitly through the interface.  This allows you to hide data on your entity that you don’t want customers to easily access and still make it publicly available outside of the assembly.  If your entity code is publicly available to your consumers and their code savy, then they can get to your property, but it’s not as easy as making it public.

Here’s the program output when executed:

Explicit interface implementation is ideal for classes that implement multiple interfaces with the same properties or method names, but since explicit implementation doesn’t make the properties available directly on the class, it’s also a tricky way of hiding something that you don’t want to make public.  Another option is to make your property internal and create a public utility class within the same assembly that can access the property.   This works just as well since it makes it much less obvious to consumers outside of your assembly that there’s hidden data on the entity.

Related Articles:

MSDN Explicit Interface Implementation