Monthly Archives: July 2012

Windows 8 Metro style application – Where’s my Back button?

images

Windows 8 Metro style applications offer a new world when it comes to navigation. After all, Metro style apps hinge on the functionality of touch, meaning that applications running in this environment are intended to be used and navigated via touch.

While it is true that users can still operate a mouse, a keyboard and/or a pen to direct their travel across your app’s pages, it is good to keep in mind that touch is where you should initially focus on your app’s navigation features.

So what do you do when a crucial part of the navigable features doesn’t seem to work? Many developers have run into problems finding a visible and functional Back button when working within a Metro style app basic page template. You don’t have to have much experience with any mobile device or Internet browser to know the Back button is crucial. But not to panic, there is a way to address this issue.

Your Back button may not be visible due to improper use of the Frame Buffer. Windows 8 determines whether your Metro style application will have a Back button by checking to see if there are any pages loaded in your StackPanel.

StackPanels provide the developer the ability to stack the elements of your app in an assigned direction. In Windows 8, content flows vertically by default, but can also flow horizontally.

However, if there is nothing in your StackPanel, then your Back button has nothing to go back to, and therefore it won’t display. To rectify this problem you must create a roadmap for your Metro style app to follow using your StackPanel. Once you’ve mastered roadmaps, you’ll be on your way to creating better Metro style applications.

Want to learn more? Take an online training course!

While it isn’t necessarily user-friendly to have to build in a function in order to create a Back button feature, it can be done. Doing so will make your Metro style app run much more smoothly.

Developers – Do you learn by doing?

web-based-learning-bed

As mentioned in my last blog, there are four learning styles that we cover in our online courses. These styles were identified as:

  • Visual
  • Aural
  • Read/Write
  • Kinesthetic

Today, I’d like to take a deep dive into Kinesthetic learning, which as identified in studies is used – to some degree – by the largest share of learners.

If your dominant style of learning is kinesthetic, what impact does this have on you?

As a kinesthetic learner, you learn by doing…you’re a physical learner, a tactile learner or a “hands on” learner.

What type of education works best for you, Classroom or Online?

Kinesthetic learners often struggle within the traditional classroom. When confined to a desk and expected to learn visually or by listening to instruction, kinesthetic learners are deprived of the direct physical involvement needed to support their learning. As a result, many kinesthetic learners will struggle to concentrate. They will be easily distracted and will look for reasons to leave their seats.

Fortunately, an online learning environment is much more accommodating to the kinesthetic learner. Online training courses allow the learner to click the mouse and move things around. Hands on labs also work well for kinesthetic learners – it’s how the physical translates to the online. It helps some learners to write things down as part of the kinesthetic and visual aspects.

In our courses, a learner uses many senses. They can:

  • Watch our video demonstrations
  • Follow the expert trainer using sample code
  • Actually build the code by utilizing the hands on labs

In the following video, you can see many aspects of kinesthetic learning! This snippet is part of our course on “iPhone/iPad Development using Objective–C“.

To strengthen the kinesthetic learning experience, a learner should use sample code to follow along with the author. The learner should also use the hands on labs.

Food for thought:

  • Are you a kinesthetic learner?
  • Do you use tools to help you learn efficiently and effectively?

Property Access Expressions in JavaScript

Thumbnail for 684

Expressions are the building blocks of JavaScript code, the mechanism you can use to manipulate data and change the state of an application. They are snippets of code that the JavaScript interpreter can evaluate to produce a value, and can be as simple as a literal value or as complex as a complicated arithmetic process that combines multiple values using a variety of operators to perform various operations on the data.

JavaScript provides a rich set of expressions that you can use to build an application with, and a robust set of operators you can use in many kinds of expressions. In this article we’ll take a look at Property Access Expressions.

Property Access Expressions

A property access expression provides access to the value of an object property or the value of an array element. JavaScript has two syntaxes for these expressions, as shown in the following code. You can use either syntax to access the value of an object property and just the second, using square brackets, to access an element of an array.

Using either type of access expression, JavaScript follows a general process for evaluating the overall property access expression. Keep in mind that an object in JavaScript is essentially a collection of name/value pairs.

  1. It first evaluates the expression before the . or [. If the value is null or undefined, it throws a type error because those values don’t have properties.
  2. If the value is not an object or array, JavaScript converts the value.
  3. If the expression uses the . notation with an identifier, JavaScript retrieves the value of that property from the object, which becomes the value of the overall expression. If the property doesn’t exist, the value is undefined.
  4. If the expression uses the [] notation, JavaScript evaluates the expression within the brackets and converts the value to a string, then reads that property from the object or element from the array. It again returns undefined if the property or array doesn’t exist.

The following code demonstrates a few variations of these property access expressions. It starts by defining an object with top, left, bottom, and right properties, then an array with numeric elements and the obj object. The first two console.log statements access the left property of the object using both types of access expression syntaxes. The third line emphasizes that what is contained between the square brackets is an expression, so JavaScript has to evaluate the expression and concatenate the letters of “left” before it can access the property. The next line accesses array element 2 (the third element in the zero-based array index) of the array. The final statement makes JavaScript evaluate the expression in the square brackets to determine which array element to access, which is the obj object, then accesses its left property. This last statement shows that you can mix the two syntaxes in a single expression. Figure 15 shows the results.

Figure 15. The results of property access expressions.

Get more JavaScript training Today!


Understanding Windows Azure Cloud Data Storage Solutions

Thumbnail for 686

Among the Windows Azure/Cloud Storage Solutions are block blobs, tables, and SQL—eachencryption-capable and each with utility features important to the enterprise and purpose.

Storage Solution: Block Blobs

Features: high availability; easy data unit manipulation

Block blobs store masses of unstructured data units (or entities of units) within one blob. So, for example, if the data is songs, images, clips, etc., these can be stored and still easily available to customers; and blocks within the blob can still be moved, ordered, reordered, inserted, reinserted, or deleted with ease.

Storage Solution: Tables

Features: high availability to all OS’s and all languages; unlimited capacity

Runs inside Windows Azure, table can store large data units such as customer authentication information, order information/order history, game points of registered customers, etc., which is stored in a sortable, filterable mode. Capable of any storage amount, the table holds data that is available to all operating systems in all languages as data of pay-for-consumption use or as fee-based, ongoing use.

Storage Solution: SQL

Features: high availability; high security; low maintenance; high scalability

An SQL (Structured Query Language) storage solution is used for a library of text articles, encyclopedia entries, archived news reports, social gaming data, etc., for tens of thousands of units/users. SQLs have high availability/accessibility, but require minimal code changing and are server-side computation capable as well as co-server compatible.

Another valued feature of the SQL option is high scalability—because this multitenant database can/does move databases from machines that are heavily accessed to other machines with less action or from, say, machines incurring disaster to other machines out of the danger zone.

More information for on-premise, Windows Azure center-housed, or other cloud service-hosted data storage solutions can be found at Windows Azure Cloud Storage or Storing Data in Azure.

Learn more about Windows Azure!

Variable Cautions and Gotchas in JavaScript

Thumbnail for 688

When it comes to JavaScript, there are a few variable cautions and gotchas to be aware of.

Keep in mind that although the value stored in a JavaScript variable is strongly typed—a string, number, Boolean, or object—the variable can hold any type during program execution. There is no type defined as part of the declaration. So the following code, although convoluted and probably confusing to maintain, is perfectly legitimate. Don’t do this! Use each variable for a single purpose to make your code clearer and give it a name related to that purpose. In general, you should use each variable for a single type, even though JavaScript doesn’t enforce this.

Be careful when splitting a var statement across multiple lines! If you accidentally omit any commas, all of the subsequent variables will be declared as global variables, which pollutes the global namespace and causes hard to find bugs. So, for example, if you omitted the comma after the count variable is declared and initialized, as in the following code, JavaScript injects a semicolon at the end of the first line and the minMsgID and lastName variables will be global variables. (The indenting makes no difference to JavaScript.) This problem is avoided if you have the entire var statement on a single line in the code file or declare each variable in its own statement with the var keyword.

TIP: In ECMAScript 5/Strict mode, it is an error to assign a value to an undeclared variable. But in older versions of the standard, and in ECMAScript 5/Default mode, the variable is declared as a property of the global object as described above.

It is legal and generally harmless to declare a variable more than once with the var statement, although it takes extra typing and clutters up your code. If a later, redundant var statement also initializes the variable, it acts as a simple assignment statement. No matter how many times you declare a variable within its scope, you’ll have only a single instance of the variable.

Get more JavaScript training Today!

Object Comparisons in JavaScript

figure-21-comparing-objects

In our last article, we discussed Escape Sequences in String Literals and their use in JavaScript. In this article, we’ll take a deeper dive into JavaScript and look at the use of object comparisons.

Object Comparisons

Unlike primitive values, JavaScript compares objects by reference. This means that two object variables are equal only if the two variables hold a reference to the same object in memory. If the two variables hold a reference to two different objects in memory, even if the objects are the exact same—have the same properties, in the same order, all with the same values—the object variables are not the same.

Some code will show how this works. It starts by creating two objects in memory, obj1 and obj2, each with an identical set of properties each set to the same value. The first comparison checks to see if these objects are equal, which they are not. Then the code creates another object variable, obj3, and sets it to reference obj1. This time, because obj1 and obj3 both hold a reference to the same object in memory, the comparison is true. You can see these results in Figure 21.

Figure 21. Comparing Objects.

Next the code changes a value in obj1, setting its t property to 10. The code then displays the value of t for each of the three object variables and once again tests to see if obj1 is equal to obj3. You can see the results in Figure 22, which shows that t in obj1 and obj3 are still equal, but obj2 is unchanged because it is an entirely different object.

figure 22 changing value of an object with two references
Figure 22. Changing the value of an object with two references.

If you want to make a copy of an object in memory, rather than having two variables that reference the same object in memory, you have to write the code to do it. The following code shows two ways to copy an object. The first is a brute force way to do it, creating an empty object that will be the copy, and writing code to copy the value of each property from obj1 to obj4. The second way uses some nice features of JavaScript objects to loop through the objects’ property collection and the [] notation to reference object properties instead of the dot (.) notation.

WARNING! This is not robust code for copying objects in memory. It copies only one level of properties—you can have object properties in addition to primitive values—and will copy a base object’s properties as well, if any. There are ways to robustly copy objects in JavaScript, but that will have to wait until you learn more about JavaScript objects. Figure 23 shows the results displayed in the Console panel.

figure 23 results of creating two new duplicate objects in memory
Figure 23. The results of creating two new duplicate objects in memory.

If you want to inspect either obj4 or obj5, you can switch to the Scripts panel and put a breakpoint on the last line of code, the final console.log statement, and refresh the page. Then hover the mouse over either obj4 or obj5 to see its properties and values, as shown in Figure 24. As you can see, the properties of obj5 are identical to those in obj1 (remember that the code earlier changed it to 10).

figure 24 inspecting properties of an object in scripts panel
Figure 24. Inspecting the properties of an object in the Scripts panel.

TIP: When you first go to the Scripts panel, it may not have the JavaScript code
from the page loaded. Just refresh the page, and the panel should display the
code.

Get more JavaScript training Today!

Escape Sequences in String Literals Using JavaScript

Thumbnail for 692

One of the fundamental tasks handled by programming languages is to temporarily store and manipulate bits of data in memory, mostly strings and numbers, but often also dates and other special data types, called values. One of the defining characteristics of a programming language is the data types it supports and the features it has for working with those types. A language’s types define the kinds of values you can represent and work with. When you need to save a value for later use in the program, you can define a variable and store the value in it. A variable is a symbolic name for the value that you store in memory, and lets you refer to the value by name and, over the course of program execution, assign different values to the same variable.

Following is an explanation of Escape Sequences in String Literals and their use in JavaScript.

Escape Sequences in String Literals

When you need to include any of a number of characters that have special meaning within a string literal, you can create an escape sequence using a backslash to identify the special character. For example, if you absolutely must include the type of quote used as a string delimiter within the string, you can create an escape sequence as in the following string literal. By making it an escape sequence, the single quote will appear within the string, even though that is also the string delimiter.

The reason why this is called an escape sequence is that the backslash causes an escape from the usual interpretation of the single quote character in the previous example. Table 2 lists the available JavaScript escape sequences.

If you include the backslash in front of any other character than those shown in Table 2, JavaScript will ignore the backslash, such as if you include * in a string literal. This is risky however, because future versions of JavaScript could define new escape sequences that would give meaning to the sequence in your code. As unlikely as that may seem, it’s best to avoid the possibility of broken code in the future.

The following code demonstrates some of these escape sequences. Some lines are broken in random places to fit on the page, but each console.log statement should appear on a single line in a code file. Figure 3 shows the results in the Console panel.

Ch02_blog

Figure 3. The results in the Console panel of running sample escape sequence code.


Get more JavaScript training Today!

Xamarin Releases MonoTouch 5.2

Thumbnail for 694

 

If you’re not using MonoTouch 5.2, the latest version of the company’s cross-platform software for building new tablet and phone applications, here’s what you’re missing. The new version promises faster performance, a greater ease of use and over 300 new enhancements.

Many of the new features focus upon memory use and management. The first notable feature is the new MonoTouch memory profiler. The new memory profiler tracks the usage, growth and referencing of managed objects. SGen, the generational garbage collector, is the new memory management system. SGen identifies free, reachable objects and eliminates those objects not needed to support program usage. The generational garbage collector will improve performance and may reduce memory use. The newest version also includes improved memory diagnostics.

Many of the new features grant greater control to developers. The new API MonoTouch.Dialog helps developers to create new dialog boxes and screens. This API also displays data within easy to use cell tables. MonoTouch 5.2 will now automatically stop and start applications when other programs are running, such as debuggers, without requiring user involvement or confirmation. The new System.Numerics library contains complex numeric data types. These include integers and complex numbers. The new library also supports Memory Mapped IO.

Perhaps the most impressive new feature is the device testing framework. If you create an app and want to make sure that it works prior to release, you can test the app through MonoTouch’s new simulator on your device. The tests can be performed manually or automated, according to your preferences.

Many of the new features are supported by tutorials to help developers in their early use. The full list of new features, additions and enhancements can be found by visiting the documentation section of Xamarin’s website.

What’s next for Xamarin? Apple is busy putting the finishing touches on iOS 6 that was announced at Apple’s WWDC 2012 back in June and is scheduled to be released some time in the fall. Xamarin is already working on the next release of MonoTouch to include support of these new features.

Learn to develop applications for the most popular mobile platforms!– iPhone/iPad Advanced Development Using MonoTouch 5.2

Developers, What Style of Learner are You?

Thumbnail for 696

To succeed as a developer you must know and understand what your result should be, plan your direction on how to get there and use the right process with the right technical ability to build your application. Success comes from knowing how to write effective and efficient applications, which requires you use the right training / reference material to get up to speed in the technology you are using. Will “just any” training material work? My opinion is that you will only succeed if you use training material that best fits your learning style and covers all learning styles.

Learning Styles
According to Neil Fleming, designer of VARK (A guide to learning styles), there may actually be 18+ dimensions of learning, including temperature, light, food intake, biorhythms etc. Trying to work with 18 dimensions of learning styles and making practical sense from the information would be impossible in my opinion. Fleming identified four learning styles in his research:

  • Visual
  • Aural
  • Read/Write
  • Kinesthetic

Studies at www.vark-learn.comcategorized respondents to questionnaires by learning style. The studies identified that most people use multiple learning styles with Kinesthetic being used – to some degree – by the largest share of learners.

  • 61.6% prefer more than one learning style
  • 34.1% use all four learning styles

As the above shows there is not a dominant learning style (most are multi-modal) so in order to create a learning tool that is effective, my opinion is that you must cover all modalities and not just one or two.

At LearnNowOnline we believe that no matter how you develop applications – whether it’s using Visual Studio, SharePoint, SQL Server or Java – you must have a working knowledge of the technology. And when it comes to learning your technology of choice, you’ll learn best by using a method consistent with your preferred learning style.

Below I have described the VARK learning styles in practical terms and how they relate to LearnNowOnline training and reference materials. Types of materials available include video, sample code, comprehensive courseware and hands-on labs.

  • Kinesthetic = watching video demonstrations, working with hands on labs, following the expert with sample code.
  • Read/Write = reading comprehensive courseware, taking notes
  • Aural = listening to the expert during the video including lecture on topics and code demonstrations
  • Visual = viewing the sample code, charts, diagrams and slides

To best accommodate different types of learners, we feel very strongly that training and reference material should address all four modalities of learning, which is why our training incorporates video and audio with add-ons for sample code, courseware and hands-on labs.
Some Food For Thought:

  • What type of a learner are you?
  • Are you an efficient and effective developer?
  • Do you use reference and training material that fits your style?
  • Does your training material cover all the learning modalities?