03 May 2012 @ 11:56 AM 

As mobility has exploded onto the list of of top IT priorities over the past few years, many IT shops are realizing that one of the first steps in creating mobile apps that make use of data is figuring out how to properly expose that data via web services. Beyond the standard technical recommendations – there are some common architectural design principles to be aware of when designing and building services – whether they’re internal, enterprise services or public-facing mobile web services.

These principles are well documented throughout the internet, but I found it difficult to find a simple, concise, easily digestible format that wasn’t quickly treading into pie-in-the-sky architecture speak. Careful consideration should be given to these principles early in the design process in order to mitigate the downstream impact of poor architectural decisions. Most of these principles are also beneficial to other areas of object-oriented software development (i.e. loose coupling) – however, the below principles will become readily apparent and relevant when building services.

The six principles are:

  • Loose coupling
  • Autonomy
  • Statelessness
  • Explicit contracts
  • Composability
  • Discoverability

Loose Coupling

Several (autonomy, statelessness) of the six principles also assist in the creation of loosely coupled services. A loosely coupled service requires limited knowledge of the definition or inner workings of other components relied upon by the service. The benefit of loose coupling is the flexibility and agility gained by being able to change the inner workings of a service as needed, without having to make related changes to clients or other components relying upon the service. There are a variety of ways in which services can be tightly coupled – for example: contracts, security, technology, and statefulness.

Coupling via the service contract can occur when the contracts are built against existing logic from back-end systems (i.e. using ORM-generated classes that contain every single database field), which can hinder the evolution of a contract as it has not been designed independently of the underlying logic. Coupling via security or technology can occur when a service is based upon security or communication protocols that limit the adoption of the service – for example, a service built upon an outdated technology (i.e. CORBA or .NET Remoting), or a rarely-used security protocol which may not work across all devices. Coupling via state can occur when service operations must be called in a specific order, coupling the service with the order of operations and session state that must be maintained on the server. Coupling against state can also have a negative impact – for example, a step cannot be added into the middle of a process without updating all service clients.

Autonomy

Service autonomy is a design principle that allows for services to operate more reliably by having maximum control over their execution environment and relying as little as possible on the availability of external resources for which they have no control. Autonomy can be increased by running services on dedicated hardware (reducing dependence on other systems running on the same hardware) or by storing cached copies of data, thus reducing dependence on external databases. Not always possible in every scenario, but good to keep in mind.

Statelessness

Requiring that service operations be called in a specific order increases coupling via an implicit contract – meaning that the order in which the operations should be called is not known and documented by the service itself, but rather must be documented via outside knowledge. Reducing state within services allows for services to be more scalable, as the amount of resources consumed by the service to manage and track state information does not increase with the number of consumers. The most common way to reduce service state is to manage all state at the consumption level – forcing the client to keep track of its own state.

Explicit Contracts

Service consumers should rely only upon a service’s contract to invoke and interact with a service and those interactions should be based solely on the service’s explicit contracts, those which are defined by the service itself, e.g. via a WSDL document – rather than any implicit contracts, for example – external documentation.

Several best practices regarding contracts include:

  • Ensure that the contract definitions remain relatively stable over time to prevent downstream impacts on the service consumers.
  • If the service contracts must be changed, use versioning if possible so that existing consumers are not broken.
  • Avoid exposing private, internal data to consumers – remember the object-oriented design principle of encapsulation. Private implementation details (e.g. primary keys, internal flags, etc.) need not be exposed.
  • Contracts should be designed to be explicit as possible to prevent errors in interpretation.

Composability

Service composability is a design principle which encourages services to be designed in a way that they can be consumed by multiple external systems. This promotes the reusability and agility within a service-oriented environment, as it allows new systems to be built by re-using existing services. Composability is further enabled by several of the other design principles including Autonomy (increases reliability of the service such that it can be used in other systems) and Statelessness (allows the services to be used in conjunction with other services without regard for state).

Discoverability

Discoverability is a design principle that encourages services to be discovered more easily by adding metadata about how the service should be invoked and interacted with, and storing that metadata in a central repository if possible. By making the services more easily discoverable and cataloging the related information, the services are inherently more interoperable and can be re-used more easily. The core consideration for this principle is that the information catalogued for the services needs to be both consistent and meaningful. The information recorded about the services should be accessible by both technical and non-technical users, allowing anyone to evaluate the capabilities of the service and whether or not it should be used.

Service Design Recommendations

While not all of the services design principles can be followed to the letter in every real-world services implementation, the guidelines can generally be applied regardless of the scenario. The following recommendations should be observed in regards to building well-designed services.

  • Limit coupling where possible by limiting the amount of knowledge of inner workings required to consume a service. This allows for more flexibility in consumer systems and the ability to change services more easily.
  • Use common, well-supported message formats such as SOAP/XML or REST/JSON and well-supported security paradigms (i.e. token based authentication) to limit coupling via technology.
  • Use caching where possible within the services layer to speed data retrieval and response times, and to increase service autonomy.
  • Define explicit service and data contracts where possible, and avoid exposing private implementation details – sending only the data necessary to complete a unit of work.
  • When making breaking changes to contracts, consider including a version number in the HTTP headers or with the initial login web service call – if the service client or mobile app is out of date, the user can be alerted and directed to the app store for an app update.
  • Make services stateless whenever possible to reduce coupling, and if not possible – ensure that state is stored external to the service, e.g. in the session store or cache of your web framework.
  • Build systems by re-using existing services when possible to promote service composability and to avoid creating multiple versions of a service method that perform the same business function.
Posted By: admin
Last Edit: 03 May 2012 @ 11:58 AM

EmailPermalinkComments (2)
Tags
 06 Jan 2011 @ 11:06 AM 

Best Practices for Mobile Application Design and Development

When developing mobile applications, there are a number of key challenges where architecture and design are fundamentally different from that of a typical enterprise application. Careful consideration should be given to these mobile architecture issues early in the development process in order to mitigate the downstream impact of poor architectural decisions.

Click here to read the rest of this article on the WMP Blog.

Posted By: admin
Last Edit: 21 Oct 2013 @ 02:04 PM

EmailPermalinkComments (9)
Tags
 10 Feb 2010 @ 8:44 PM 

One thing that any web developer worth their salt should know is the basics of search engine optimization (SEO).  Much of SEO comes down to basic code-level best practices, and it isn’t terribly difficult to simply bake SEO into your development process when working on public facing web applications.  However, keep in mind that SEO will always be an evolving, fuzzy science, changing on the whim of the indexing strategies of major search engines.  Immediate results are rare, and a long term process should be in place to truly understand the benefit (or detriment) incurred.

I break the concept of SEO down into a few categories that I’ll explain further below…

  1. Content SEO (internal factors)
  2. Strategic SEO (external factors)
  3. Insight and Tracking

Content / Internal SEO

These ‘Content / Internal’ best practices are things that a developer or content creator can bake in during the site development process.  Only a few of these items will make a difference on their own, but as a whole can make an enormous impact.  These basic factors should lay the foundation for any SEO strategy. However, these internal factors absolutely cannot be the only part of your SEO strategy.  Here are a few of the most important ones…

  • Page Titles.  Arguably one of the most important content level factor, this is one of the few that can make an enormous difference on their own.  Your page titles (what goes in the HTML <title> tag) should be relevant to what is on the page whereas I often come across page titles that only contain the name of the site.  Instead, you should have the ‘title’ of the page prefixed or appended to the name of your site.  Some believe that appending the name of your site to the page title is better than prefixing.
  • Page URLs.  This goes hand in hand with your Page Titles, as page URLs carry almost equal important.  The URLs of your pages should mirror closely the titles of your pages, but don’t need to be exact.  Popular opinion is that the closer keywords in your URL are to the end of your domain name, the better.  Search engines have a very ‘human’ behavior in this case… tell me, which URL is more descriptive about this post? – “http://jsprunger.com/search-engine-optimization-101/” or “http://jsprunger.com/?p=88″.  Search engines think the same way.
  • Freshly updated and unique content.  The more your web site content is updated, the more often it will be indexed by search engines.  Sites with freshly updated content seem to get a bonus from most search engines.  Bloggers in particular should ensure that their sites are configured to ‘ping’ a service like Ping-o-Matic whenever you create a new post, this will immediately notify Google and many other services of your new content.  Having unique content is perhaps one of the most important factors, simply rehashing or copying content will get you absolutely nothing from most major search engines – in fact, duplicate content can seriously hurt your rankings.
  • Keyword usage in your content.  Also a highly important factor, whatever keywords that you want to rank for – make sure you’re using them in your content.  Think about what your customers or clients going to search for.  A few guidelines for keyword usage…
    • Don’t overuse your keywords, don’t be spammy.  Find the right balance between keyword usage and having readable, engaging content.
    • Make sure you have your keywords in your page title and URLs.
    • Use keywords within the first 100 words of the page or within HTML headers.
    • Get your keywords used in external links to your site.  More on this later…
  • Image alt tags.  This is a pretty minor SEO factor, but very important if you have any interest in getting results from services like Google Image Search.  The productivity from image search results is usually pretty low for most businesses, but every little bit can help sometimes.  Some web sites (i.e. e-commerce, product catalogs) can benefit from image search much more than others.  Make sure you have descriptive ‘alt’ attributes on your <img> tags – this is a best practice for usability and accessibility in general though.
  • Meta keywords and descriptions.  Long gone are the days of meta tags being useful for SEO.  However, the meta description tag can still play a huge role in your pages getting click-through from the search results. Google will use the meta description of your page as the ‘teaser’ for the search result, but if you’re missing this tag you’ll often just see garbage or irrelevant content for the teaser.  Users are much more likely to click through to your content in search results if the result description is accurate and compelling.
  • Updated Sitemap and sitemap.xml file.  Keeping an up to date listing all of the content on your site in a sitemap will greatly enhance the ability of search engines to properly index 100% of the content on your web site.  You can use a tool like the Google Sitemap Generator to keep a continually updated sitemap file.
  • Avoid so-called ‘black hat’ or any sort of sneaky SEO techniques.  These strategies usually revolve around hiding or cloaking text on your pages in an attempt to fool search engines.   It isn’t worth it – leading search engines can easily detect and adapt to these techniques, resulting in your search rankings taking a dive or even a complete blacklisting of your site.

Strategic / External SEO

Strategic SEO includes all of the factors external to your website that can affect your search engine rankings.  The number one external factor is getting ‘backlinks’ to your content, this is what made Google so ridiculously powerful and accurate – and their rankings are still very much based on the number, diversity, and quality of links to to your site.

Backlinking can be explained with this anecdote: Several years ago you could search for ‘Miserable Failure’ on Google and the number one result was the White House biography page for George Bush.  This was due to a simple viral campaign to get people to put links on their websites, comments, blog posts, etc. linking to the biography page with the anchor text ‘Miserable Failure’.  That’s how backlinks work.  The more external, inbound links to your site, the more ‘authoritative’ your site appears to be in the eyes of major search engines.

But how can you get these backlinks? A few examples…

  • Mainstream media and press releases.  Old fashioned, but if this is relevant to your industry, press releases for important announcements make their way around the internet very quickly.  This obviously works best if the press releases link back to your web site.
  • Getting linked and promoted in blog posts.  Do your friends, colleagues, or business partners have blogs or websites? Ask or barter with them to promote your content, requesting specific keywords be used in links to your web site.  This is a two way street – the more you’re willing to promote content from other sites, the more they’ll be willing to promote you back.  However, popular opinion is that one-way links are deemed to be of higher quality in the eyes of major search engines.
  • Twitter (annoying or ridiculous as many believe it to be) can be a great way to spread the word about your content.  Maybe you’ll get lucky and someone with 30,000 followers will retweet your link if you’ve included the proper hashtags.  After this happens, you’ll start to see your links pop up all over the internet.
  • Social Bookmarking.  Submitting your content to social bookmarking sites like Del.icio.us, Reddit, and Digg or more niche-specific sites can be a great way to spread the word about your content.  These services will also often directly link to your content with the exact text that you’ve specified – bonus!  Don’t be a spammer though, if you have high quality, unique content that people actually want to see – submit it.  If not, don’t bother.
  • Make it easy for your readers to submit your content to social bookmarking sites, for example – drop an AddThis button on your website like the one at the top of this post.  This allows your users to easily link and promote your content if they find it valuable.
  • Targeted submissions.  Do you have niche content? Find targeted venues for submitting your content and articles. For example, you’ve written an article relevant to the Healthcare industry. Track down some Healthcare industry groups on LinkedIn and submit your article to the news sections. Contact industry publications, they’re often happy to include high-quality articles.
  • Alliances and partnerships.  Work with your business partners and allies to cross promote each other where applicable.  For example, you’re a partner for a specific vendor. If you work closely with that vendor, they’re often more than happy to promote their most capable partners by linking them on pages within their own websites.

Insight and Tracking

As mentioned previously, part of SEO includes a process testing out your SEO changes and tracking their effectiveness over time.  A variety of free and paid tools are available to assist you in analyzing your search rankings, search terms, and keyword effectiveness.  Below I’ve listed a few tools that can help.

  • Google Analytics – by far the best free website traffic tracking software that I’ve ever used.  Formerly known as Urchin, Google Analytics allows you to slice, dice, drill down, and report into your tracking data any way you like.  Even better, Google Analytics allows you to configure “goals” for your web site which are basically actionable things that users of your site can perform that are of value to you, the business owner.  For example, submitting a contact form, downloading a white paper, completing a transaction, etc.  Dollar amounts, if applicable, can be tied to goals, allowing you to determine the exact revenue per visitor.  This effectively allows you to determine the most valuable incoming keywords and most effective traffic sources for your web site.  Beyond visitor value, Google Analytics can help you determine many more important statistics.  For example…
    • Most popular content on your website
    • Browser capabilities of your visitors
    • Location and language preferences of your visitors
    • Most popular search terms used to find your web site
    • Tracking of your CPC ad campaigns
    • Tracking visitor loyalty
    • Tracking the top exit pages for your web site (pages where visitors leave)
  • Keyword ranking monitoring and reporting.  There are a variety of free and paid tools that will allow you to continually monitor and report on current and historical keyword rankings for your own website, as well as the keyword rankings for your competitor’s websites.  These tools will allow you to see if you’re making progress on increasing your search rankings.
  • SEO analysis tools such as the Microsoft SEO Toolkit allow you to analyze the your website to check for content level flaws such as broken links and duplicate content that can affect your search engine rankings.  The Microsoft SEO Toolkit allows you to view detailed information about SEO problems on your website using built-in reports and dashboards – an extremely useful tool to use when analyzing the state of SEO on an existing web site.

There is much more to search engine optimization than can be written up in a single blog post (see also: thousands of blogs dedicated purely to the subject).  However, I hope this quick guide to the basics will give you the tools necessary to implement numerous high impact SEO quick wins for a client or personal web site. For web developers, the factors listed above should be kept in mind whenever developing customer-facing websites that could benefit from enhanced search results and search rankings.  Most of the ‘content / internal’ best practices can be easily baked into the development process of almost any e-commerce or content management system implementation project.

Posted By: admin
Last Edit: 10 Feb 2010 @ 08:44 PM

EmailPermalinkComments (15)
Tags
 01 Feb 2010 @ 8:30 AM 

The impact of performance is much more readily apparent in .NET Compact Framework applications.  The mobile devices commonly have a CPU that is 10 times slower than your desktop CPU, and possibly up to 100 times less RAM than a desktop or server.  In Agile or XP development, the mantra is often to ignore performance considerations until necessary – I don’t think you can apply that to .NET CF development or it will really bite you in the end.  You don’t have to go nuts and optimize everything up front, but there are some very important things to keep in mind when developing a Windows Mobile application…

Standard .NET Framework Performance Considerations

Many of the standard .NET Framework performance best practices can become apparent very quickly including…

  • Object Boxing and Unboxing.  Use generics wherever possible and avoid ArrayLists and type conversions.
  • String and StringBuilder.  Need to perform lots of string concatenations? Use a StringBuilder instead of the ‘+’ operator.  When you use the ‘+’ operator, a new string object is created each time you concatenate, increasing memory usage.  The ‘+’ operator is much slower if you’re concatenating a large number of strings.
  • Memory leaks.
    • When doing .NET CF development, if an object implements the Dispose() method – call it when you are finished with the object.
    • One of the most common causes of memory leaks is unhandling events when they’re no longer needed.  If you manually hook up an event with the ‘+=’ operator, ensure you’re unhandling it when finished with the ‘-=’ operator.
    • Pre-allocate collections if possible.  Standard .NET behavior is to automatically double the size of a collection when the upper limit is reached while adding items.  If you know the number of elements that are are going to be in a collection, pre-allocate the size of the collection when instantiating it.
  • Don’t use Exceptions for flow control in an application.  Exceptions are an expensive operation, performance wise.  I’m not saying don’t use exceptions, but don’t use them in areas where you can perform simple checks to prevent them from being thrown.  For example, if you might divide by zero – perform a simple check before the operation occurs rather than handling a DivideByZeroException.  The check is much less expensive than the exception.

.NET Compact Framework-Specific Performance Considerations

However, the .NET Compact Framework is different than the full framework in many ways, leading to a slew of .NET CF specific performance considerations…

  • Avoid making virtual function calls.  They are up to 40% slower than instance and static function calls.  I don’t completely understand the reason for this, but you can read more about it here if you’re interested.
  • There are a few things in .NET CF that are slow because of virtual calls and object boxing/unboxing.  These include:
    • Reflection.  Very slow in .NET CF.
    • XML Deserialization and DataSets.  Extremely slow  because reflection is slow.
  • Avoid creating many copies of Form objects.  Creating a Form is an expensive operation, and unused Form objects are a common cause of memory leak issues. You may want to create your Forms once and cache them in the background for reuse.
  • You can increase the speed of binding data to controls by using the BeginUpdate and EndUpdate methods on a control before and after your data binding occurs.  This will cause the control to not repaint until the binding is finished.
  • Cache expensive resources.  For example, don’t create many different copies of a web service client.  Create a single, cached instance of it that can be used throughout your application.
  • Always test your application on a wide range of physical devices.  If the target device is known, at least test on that device.  Some things seem to perform much betterwhen running on the emulator or when executing unit tests on your desktop environment.
  • This is a more general performance testing best practice, but always test with real data and real quantities of data. This can really bite you on deployment of your application.  I know this from experience – a great example is that deserializing a few hundred objects is MUCH much faster than deserializing 10,000 objects.  In my experience, deserializing 7,000 very simple DTO objects from an ASMX web service was taking up to 20 minutes in some cases.  To alleviate the issue, we ended up switching to a JSON web service, which was much faster to deserialize.
Posted By: admin
Last Edit: 08 Feb 2010 @ 09:34 PM

EmailPermalinkComments (5)
Tags
 30 Jan 2010 @ 1:36 PM 

I’m starting up a short Windows Mobile project again, so I thought it would be a good time to collect some of my best practices for .NET Compact Framework development and post them.  I’m going to break them down into two sections -  usability, and performance best practices (in another post).

Windows Mobile Usability Best Practices

Microsoft has put together a very specific set of guidelines for Windows Mobile usability – the point of this is to get a consistent set of look and feel and application experiences on their platform.  Apple has the same sort of guidelines for iPhone development and it really pays off – most applications have the same consistent look and feel and excellent usability.  Of course, many of these usability guidelines are relevant across many development platforms, but there are some special considerations for mobile development.

Usability is a challenge in mobile development.  Some of the main concerns include…

  • Limited screen real estate.  In Windows Mobile, the most common size is around 480 x 640 pixels.
  • Limited input options.  Touch screen.  Potentially no hardware keyboard.  No mouse, and no scroll wheel.
  • Lighting – Indoor / Outdoor usage.
  • Gloves (i.e. warehouse users)
  • Finger vs. Stylus

Here are some of the most important usability guidelines that Microsoft has set forth…

  • Only display the most relevant information and options on the screen, i.e. don’t clutter up the screen with 100 different rarely used options.  If a feature is rarely used, place it in a menu or submenu.  If a feature or action is used very often, think about assigning it to one of the standard left or right soft keys.
  • Use high contrast, sufficiently bright colors.   Lighting conditions are an important factor in mobile development.  For example, think about if your application could be used in low light or outdoor sunlight conditions.
  • Avoid very small font sizes.  The screen on a mobile device is very small as-is, and actions on a mobile device are often performed at arms length away from the user (in a warehouse, for example).  If a user has to interrupt their workflow to bring the device in front of their face to read the text, then your font is too small.
  • Make the user interface predictable and consistent in your application, keep ‘OK’ and ‘Cancel’ actions in the same location throughout your interface.  The same buttons should perform the same actions throughout your application.  To stay consistent with other Windows Mobile interfaces, one recommendation is to always assign the left soft key to ‘Back’ or ‘Cancel’ actions, and to assign the right soft key to ‘Next’ or ‘OK’ actions.  Another Microsoft recommendation is to avoid overriding the hardware buttons (i.e. the Home button).
  • Ensure your UI elements are appropriately sized.  Buttons sized for a stylus should be at least 21 pixels squared, buttons sized for fingerse should be at least 38 pixels squared.
  • Keep screen rotation in mind – developing to account for rotation is a pain, but very important for consumer applications.  Your options though are limited to either dynamically resizing the content, or to just design for a square screen.
  • Scrolling is discouraged in Windows Mobile applications, because it is kind of a pain for the end user.  Try to keep your content on one screen length/width if possible.
  • If your target devices may feature a keyboard, assign common actions to key shortcuts.  This can greatly increase efficiency for power users.
  • For displaying information, make use of Summary, Detail, and Edit views.  A ‘Summary’ view displays only the most necessary and relevant information about an item.  To access less commonly used information about an item, the user can drill down to a more complete ‘Detail’ view.  If a user needs to edit the information, they can access an ‘Edit’ view.
  • Ensure you’re setting focus on the appropriate text entry fields in bar code scanning scenarios, etc.  If a user is wearing gloves and has to take them off to set focus on a field before they scan a pallet, they’re going to hate your application.
Posted By: admin
Last Edit: 31 Jan 2010 @ 03:49 PM

EmailPermalinkComments (1)
Tags
Change Theme...
  • Users » 3
  • Posts/Pages » 16
  • Comments » 104
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About



    No Child Pages.