Technology Ninja. Loving Father.

Home

Microsoft adds Mobile-first, Cloud-first development to Visual Studio 2013

Microsoft announced today at Tech-Ed North America that it will be adding first level support for Hybrid Mobile Application development via Apache Cordova/Phonegap to Visual Studio.

Here are some notes from the release announcement:  Article Source

Visual Studio 2013 Update 2

The final release of Visual Studio 2013 Update 2 is now available.  Update 2 brings dozens of significant new features to Visual Studio developers, including tools for Windows Phone 8.1 and universal Windows apps.   With over 5 million downloads of Visual Studio 2013 since RTM last fall, it’s been great.

Cross Platform Mobile Development with Visual Studio

With bring-your-own-device trends in the enterprise, and heterogeneity in the consumer mobile device market, developers are increasingly focused on building apps that can target a variety of devices.  We are committed to enabling developers to build apps for this heterogeneous, mobile-first world with Visual Studio for the technology of your choice – whether .NET, C++ or JavaScript.

Xamarin and Visual Studio

Last November, we announced a partnership with Xamarin to enable C# and Visual Studio developers to target additional mobile devices including iOS and Android.  Developers using Xamarin and Visual Studio can create native apps taking advantage of the underlying device, with the great productivity of C#, and sharing code and libraries between their iOS, Android and Windows applications.

Apache Cordova and Visual Studio

Today, we released a preview of Visual Studio tooling support for Apache CordovaApache Cordova is a popular open source platform for building multi-device hybrid mobile applications using HTML, CSS and JavaScript, targeting a broad range of mobile devices.  This includes support for iOS and Android, as well as support for Windows Store and Windows Phone thanks to Microsoft Open Technologies contributions to the project.

With the Cordova tools in Visual Studio, web developers can use their existing skills in HTML and JavaScript to create hybrid packaged apps for multiple devices while taking advantage of each device’s capabilities.

These tools support end-to-end development of cross-platform mobile applications targeting Android, iOS, Windows and Windows Phone using Visual Studio.

Project templates are available for both JavaScript and TypeScript, and provide a standard blank Cordova starter project.  Developers can pick their HTML/JavaScript framework of choice, whether Backbone and jQuery UI, or Angular.js and Bootstrap, or WinJS.

Projects can be built, deployed, and debugged against a variety of devices, device emulators and web-based mobile simulators.  By default, you can use the Apache Ripple simulator to test your application in the browser before deploying to a device.  This preview release also supports attaching the Visual Studio debugger to Ripple or a local emulator or a device.  You can stay in Visual Studio while debugging your JavaScript and DOM layout running on an Android 4.4 device

By installing and configuring the vs-mda-remote npm package on a Mac, you can even build for iOS, deploy to a device via iTunes, or start your app in the iOS Simulator on a Mac right from Visual Studio.

Apache Cordova is a popular choice today for applications that share a large amount of code across a wide variety of devices.  Combining Apache Cordova with Visual Studio provides a great end-to-end development experience for mobile-first development.  It’s great to be partnering with the Apache Cordova project on delivering these experiences.

“It is very exciting not only to welcome Visual Studio developers, but also to welcome first class tools to Apache Cordova. This development is a great validation of the hard work of the MS Open Tech team and Apache Cordova contributors. We look forward to continuing this cool work with Microsoft’s developers.”

    – Jesse MacFadyen, Adobe, Core Apache contributor @purplecabbage

Today’s preview release is an exciting first step to make Visual Studio the best tool for creating multi-device apps across iOS, Android and Windows. Whether you want the flexibility of native apps powered by .NET and Xamarin, or the standards-based development provided by the Apache Cordova platform, Visual Studio will support your choice with an amazing development experience.

Office 365 APIs for Multi-Device Mobile

With the Office 365 APIs preview release earlier this year, a rich set of REST APIs were exposed from the platform providing access to Mail, Calendar, Contacts, and Files in Office 365.  These services can be integrated into any application to connect to the high value enterprise data that is available in Office 365.

Today, we have made available custom client libraries for developing against these Office APIs from your multi-device mobile applications – both for C# and Xamarin, and for JavaScript and Cordova.

   // Get My O365 Calendar Events
   var exchange = new Exchange.Client(
       ‘https://outlook.office365.com/ews/data’,
       authToken);
   exchange.Me.Calendar.fetch()
       .then(calendar => calendar.Events.getEvents())
       .then(events => events.currentPage.forEach(addToView));

.NET Futures

Last month we shared updates on a variety of new investments in .NET primarily around the core of .NET and device development for Windows.  This included universal Windows apps, the .NET Native ahead-of-time compiler, the .NET Compiler Platform ("Roslyn") including new C# and VB compilers and a preview of new language features being considered for C# 6.

On top of these releases, we also announced the formation of the .NET Foundation, an independent organization created to foster open development and collaboration around the growing collection of open source technologies for .NET.  Throughout the last month, we’ve seen tremendous excitement around the .NET Foundation, with over 25 projects submitting proposals to move into the Foundation.

Today, we have added to these announcements some additional details about .NET on the server.  On the cloud and on servers, the future of .NET is about the modern web.  Our goal is for the next version of .NET to be the first and only framework designed for the cloud, helping you to create on-premises applications and move them to the cloud with no changes and at the same time leveraging all the power of the cloud.

Streamlining .NET for cloud and server workloads

A cloud-optimized .NET dramatically reduces the footprint of the framework by removing libraries that you won’t use in server applications such as Windows Forms and WPF, and only including the capabilities you are using in that particular application.  This cloud optimized mode allows the whole framework to be deployed with the application, which means you can upgrade on an app by app basis and you can run different versions side-by-side.  We’re also developing this with cross-platform in mind, and working with the Mono team to get it working on Mono.

ASP.NET vNext

ASP.NET vNext is an evolution of ASP.NET. Everything you know today about ASP.NET will apply to ASP.NET vNext. You can use the existing libraries or the new versions for those libraries in .NET vNext and get immediate benefits.

Web development in the cloud demands a simple, lean development experience built on top of a composable framework.  The next version of ASP.NET will be composed from a collection of packages, with each application describing its dependencies.

{
  "dependencies": {
    "Microsoft.AspNet.Abstractions": "0.1-alpha-*",
    "Microsoft.AspNet.Hosting": "0.1-alpha-*",
    "Microsoft.AspNet.Server.WebListener": "0.1-alpha-*"
  },
  "commands": {
    "web": "Microsoft.AspNet.Hosting server.name=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001"
  }
}

Developers will also be able to make changes to their web applications and see the results on a browser refresh, with no compilation needed.  This significant developer productivity enhancement is based on improvements to load times in the underlying CLR, as well as use of the new .NET Compiler Platform ("Roslyn").

On top of these foundations, Visual Studio will continue to provide the rich IDE experience for ASP.NET vNext that has made ASP.NET with Visual Studio a great environment for developing compelling web sites, apps and services.

Windows 7 and Windows 8.1 in the Azure VM Gallery for MSDN Subscribers

MSDN subscribers now have access to virtual machine images for Windows 8.1 and Windows 7 in the Azure VM gallery.  These images make it even easier for MSDN users to do development and test in the cloud on Azure using their existing benefits.  These images build on top of the Visual Studio 2013 images already in the gallery, and the Azure credits benefitthat all MSDN subscribers have access to.

AngularJS 2.0 looks impressive

Here is a snapshot of the new changes/features.  The Angular team does not have a timeframe for their releases but there are a lot of things in this roadmap that look delicious.

Designed for the future

We’re designing AngularJS 2 for the way the world will look when we believe folks will use it.  In particular, this means targeting modern browsers and using ECMAScript 6.

Modern Browsers

Modern browsers means the set of browsers known as ‘evergreen’ or always automatically updated to the latest version.  Building for these browsers let us drop many hacks and workarounds that make AngularJS harder to use and develop on than it needs to be.
The set currently includes Chrome, FireFox, Opera, Safari, and IE10/11.  On mobile, we’ll support something close to the list of Chrome on Android, iOS 6+, Windows Phone 8+ and Firefox mobile.  We’re looking into supporting older versions of Android, but the jury is still out.

 

Yes, there are still older browsers in use, but we’re targeting these newer models as they will be the primary ones in use by the time AngularJS 2 is ready and you good developers have had time to build apps on it.

ECMAScript 6+ (design)

All code in AngularJS 2 is already being written in ES6.  As ES6 doesn’t run in browsers today, we’re using the Traceur compiler to generate the nice ES5 that runs everywhere.  We’re working with the Traceur team to build support for a few extensions like annotations and assertions.
Don’t worry.  Though AngularJS will be in ES6, you can still write in ES5 if you don’t want to upgrade.  The compiler generates readable JS and there are human-sensible analogs for the extensions.  See the design doc for more info.

Faster

Faster change detection (design)

AngularJS apps are built around data-binding between DOM and JS objects.  The speed of AngularJS apps is driven largely by the underlying change detection mechanism we use.  We’ve talked at length on how we hoped to make this faster by using Object.observe() when it becomes available in Chrome M35.  And we will!
After some hard analysis (detailed in the doc), however, we’ve also found that we can make this much faster and more memory efficient even before this native change detection hits browsers.  Buttery-smooth app buttery-butterness is around the corner.

Instrumented (design)

The other half of the performance equation is the code that you write.  For this, we’ll provide high resolution timing details of where time gets spent in your application.  You can see in that this is a goal in the Change Detection design, but we’ll directly support this through a new Angular-wide logging service called diary.js.

Modular

When we released AngularJS 1.0, the features were in a take-it-or-leave-it single package.  You incur the download price for every piece whether you use it or not.  Though the whole of AngularJS is very small by desktop app standards, this can make a big difference on mobile devices.
One interesting thing we noticed was that when we split out the $route into a separate library, several innovative replacements popped up.
For performance and to enable innovation, our goal is that almost every piece of AngularJS should be optional, replaceable, and even used in other non-AngularJS frameworks.  You’ll be able to pick and choose the parts you like and write or select others that you like better.

Other Performance topics

Though there are no designs yet, there are many other areas of performance optimization we’ll include in AngularJS.  From increasing first-load time with pre-parsed templates to ensuring silky smooth 60 frames per second animations, we’ll invest heavily on a fully optimized user experience.  Please help us by highlighting areas where we should focus and techniques you can contribute to the shipping solution.

Simpler

Dependency Injection (design)

Dependency Injection is still a key differentiator between AngularJS and other client side frameworks in eliminating much of your application’s wiring code and making testability-by-default a reality.  Though we’ve enjoyed these benefits in building our applications, we’re dissatisfied with the current implementation.  We can make it less complex and more capable at the same time.
We’ll see a less complex DI by eliminating the config phase, simplifying the syntax by using declarative-style ES6+ annotations instead of imperative.  We’ll enjoy greater capabilities by integrating DI with module loading through ES6 Modules.  We’ll also see the ability to lazily-load parts of our JS through child injectors.
The doc linked above has our initial thoughts, but this is one part of AngularJS 2 that you can try today.  See the repo for current details on the implementation.

Templating and Directives (design)

The ability to specify templates directly in HTML and extend its syntax are the bread and butter of AngularJS.  We have some lofty goals for AngularJS’s template compiler in 2.  Namely:
  • Simplify the directive API
  • Integrate with other component frameworks using web standards
  • Improve performance
  • Allow tools like IDEs to analyze and validate templates
We’re so excited about these new bits that we can hardly wait to show them off.  There’s too much good stuff to extract into a summary, so please just go straight to the design doc to find out more.

More capable

Touch animations (design)

Users are accustomed to certain touch aware usage patterns. E.g. scroll through a list using their finger, circle through pictures in a carousel, remove list entries by swiping them away. However:
  • Current implementations of carousel, infinite scrolling, … don’t share a common core and by this have a lot of redundancy and different approaches.
  • Current implementations mostly don’t provide an option to use native scroll events, as older browsers and also some current browsers don’t support them well. However, by this they prevent the optimal performance on new devices.
We want to give these scenarios first-class support for the best user experiences possible in your applications.

Router (design)

The initial AngularJS router was designed to handle just a few simple cases. As AngularJS grew, we’ve slowly added more features. However, the underlying design is ill-suited to be extended much further.
We’re taking a careful look at known use cases and other router implementations across many application frameworks so we can deliver a simple yet extensible router that should fit the widest set of applications.
A few cases that we’re particularly keen on supporting include:
  • State-based routing
  • Integration with authentication and authorization
  • Optionally preserving state of some views.  Particularly needed for mobile!

Persistence (design)

Beyond AngularJS’s humble $http, many developers have desired a higher level abstraction for working with data from servers and local persistent data in the browser.
Mobile apps need to work in an “always offline” mode with syn to the server.  RESTful services need more than we’ve provided in $resource.  Some data can be updated in batches while some needs a continuous streaming model.
In this new persistence layer, we’ll provide clean structure for these cases and take much more out of the boilerplate currently necessary.

Q&A

When will it be done?

If you’ve been with us through the 1.2 announcement, you know that we don’t know. :)  Though we’re just posting the design docs now, we’re already prototyping many of the modules.  Dependency Injection and Zone.js appear to be usable.  All the work will be done on GitHub and we’ll continue to capture weekly meeting notes so you can follow along.

What will it be like to port an AngularJS 1.x application to AngularJS 2?

As AngularJS 2 is still in development, we honestly don’t know.  In our imagination, porting will be fairly straightforward but not free.  Taking advantage of ES6 will likely be the largest part of the job.   Templates will be largely the same with some mostly-mechanical find and replace exercises.  Your controllers contain your business logic and not much if any AngularJS API today.  Those should port easily.  The parts that will require the most thinking will be your use of Modules and Directives.

Is AngularJS 2 a replacement for mobile tech like PhoneGap or Ionic Framework?

No, AngularJS is still just the core framework.  You might still want libraries like Ionic for mobile-optimized CSS/JS components and tools like PhoneGap for app packaging and native API access.

How does AngularJS 2 relate to AngularDart?

When porting AngularJS to the Dart language, we build a new version of Angular using all the learnings we’d acquired to date.  Many of the improvements discussed in this document like improved Directive concepts and syntax and class/annotation-based DI are already present there.
While the implementation isn’t what we’ll arrive at for 2, it’s a great preview of what’s to come.

 

We’ll be upgrading AngularDart as we build AngularJS 2 so folks who prefer the Dart language can enjoy the same benefits as folks on JS.  Our goal is that there will be a single framework with your choice of language.

And this is why I hate politics..such a dirty game

Mark Dayton and Minnesota Lawmakers playing games

Minnesota residents hit another roadblock in getting the Minnesota Vikings a new stadium on Friday

“Gov. Mark Dayton’s veto of a high-priority GOP tax bill Friday drew an angry response from legislative leaders and concerns that the ill will could persist through Monday’s climactic vote on a Vikings stadium.”

“He vetoed our highest priority,” said Ortman said, who also is deputy majority leader. “I think there will be consequences. I think that he has lost the trust of many of my colleagues in the Legislature.”

So basically because one party didn’t get their way..everyone is going to pay for it and this stadium deal is at risk. Our forefathers are rolling over in their graves right now.

Javascript style guides

one of my favorite developers Addy Osmani has published a blog article on Javascript Style guides.

I don’t have a specific guide that I follow but I do have mental guidelines.

Here are 6 style guides to reference:

  1. Idiomatic.js. This is not only highly recommended and very comprehensive, but is also the style guide we’ve adopted for several of the projects I’m involved in. It includes contributions by jQuery core contributor Rick Waldron, jsPerf contributor Mathias Bynens and many other experienced JS devs in the community. Not all developers agree 100% with the practices it advocates, but that’s the great thing about a forkable style guide – it’s easy to adapt to your own needs.

  2. jQuery Core Style Guide. Perhaps the most popular style guide modern JS developers are aware of, it is used by the jQuery core team, jQuery UI, QUnit and many other projects. Rick Waldron once again had a hand in this as have Adam Sontag and John Resig, also of jQuery fame.

  3. Google JavaScript Style Guide. Written by former Google JavaScript developers such as Robby Walker (Closure Linter), this contains several readability best practices that those from a particularly traditional software engineering background will appreciate. Further comments on it can be found here.

  4. Dojo Style Guide Another very comprehensive alternative by the people that brought us the excellent dojo toolkit. Interestingly this guide is based on the structure of the Java programming conventions guide. If you like what you see, you might also appreciate dojo’s inline documentation sguide, which remains my favorite style of inline commenting in JS.

  5. Aloha Editor JavaScript Style Guide This guide comes from the authors of the relatively non-trivial contentEditable-based Aloha Editor. Whilst it recommends the jQuery style guide, it has some useful (minor) additions such as how they suggest styling AMD modules.

  6. Crock’s Code Conventions For JavaScript Another good guide, although perhaps not as detailed example-wise as others. I feel this has been superseded by Idiomatic.js, but if you strongly disagree with it or the jQuery core style guide, this is a much recommended fallback.

Automatically send behavior-based campaigns with Performable

No matter how much pleasure you get from putting together a solid, subscriber-focused email marketing campaign (hah!), there’s probably a point where you go, “By golly, I wish I could automate parts of this process.” Okay, so email campaigns are never going to write themselves, but when it comes to lining up emails to send at the most effective time, then both our app and our friends at Performable Analytics are here to help with triggered campaigns.

Last year, we released autoresponders to allow you to send campaigns when an event occurred within your subscriber list. Some of these campaigns were things like follow-up emails immediately after someone joined to your list, or an email offer automatically sent a week before a subscriber’s birthday. Now, Performable have taken this one massive step further with Engage, a service which extends the autoresponders in your Campaign Monitor account to schedule campaigns based on events occurring on your site. For most of us, it’s called “Wow, I just got a reminder email after abandoning my online shopping cart!” For the propeller-heads, it’s called behavioral marketing.

Starting condition in Performable Engage

This might all seem pretty fiddly, however the folks at Performable have smoothed out the process of connecting sites to their marketing analytics service, then in turn, connecting Engage to your Campaign Monitor account. For example, lets go back to the earlier shopping cart scenario. Lets say you’ve got Performable Engage rolling and a basic, ‘New subscriber signs up’ autoresponder (or two) in your account. You then want to send an email to folks who have signed up as customers, added an item to their online cart, but never completed their purchase. You also want to delay the email being sent by a couple of days and heck, send a follow-up email if additional criteria is met. Here’s what this workflow would look like in Performable Engage (click to enlarge):

Flow featuring multiple emails

Wow, that’s some pretty clever email marketing right there. Now, imagine extending this to folks who have signed up to receive your cracking latest album of ambient chiptunes, but haven’t gone on to download it. Or with Performable’s Zendesk integration, being able to contact people who have lodged a ticket with you, but haven’t logged back into their account for your web app. How crazy automated is that?

Engage stats

Performable Engage is also backed up by solid reports, both from within Performable and your Campaign Monitor account. Engage will tell you how many emails have sent and are scheduled to go (alongside Performable’s regular lifecycle marketing metrics) and we’ll keep tabs on opens, clicks and more via your autoresponder reports.

Based on this model, you may be well keen to check out our monthly pricing – with unlimited autoresponders and campaigns bundled into most plans, it’s simply less stress.

Of course, in the words of Master Splinter, with great power comes great responsibility. Just as most folk were sensible enough to not go mad with plain ol’ autoresponders, this kind of triggered campaign should be used with a bit of humanity. In short, to gently encourage subscribers to come visit you again, over being, well, annoying.

Finally, the folks at Performable have extended readers like you a 50% discount on their small business plans. To see if its suite of marketing analytics and email automation tools are suitable for your site, trial Performable for free and start scheduling ‘em emails.

Convention Based Localization With ASP.NET MVC – Davy Brion’s Blog

A feature of ASP.NET MVC that i really like is that when you use the LabelFor extension method in a strongly-typed view, the LabelFor implementation will try to retrieve and use metadata for the property you're creating a label for. For instance:
@Html.LabelFor(m => m.SomeProperty)

This will generate an HTML label for the SomeProperty property of your model. If you need localized views, you can annotate the property in your model like this:
[Display(ResourceType = typeof(Resources), Name = "Res…

Projection Screen Basics

Like Andrew, I also would like to have a projection setup someday. There’s simply no replacement for the sheer envelopment that a projector can bring with a 100″+ screen. Unfortunately, my current abode isn’t ideal, but I plan to set up a dedicated screening room in my next residence so I like to stay informed on the technology. Following on their HD projector overview, HD Guru goes over the various projection screens available (and yes, you do need a screen and not just some painted wall).

A few days ago I wrote an article espousing the virtues of front projection. I am an unabashed fan and hopelessly biased towards PJs. But to get the best performance out of a projector, you’re going to need a screen.

And this is the point where I lose the audience.

Still with me? Screens may seem boring, and there’s a lot to learn, but if you’re spending any amount of money on a projector you owe it to yourself to get a screen that lets you get the most from your new purchase.

HD Guru

Hover on “Everything But”

Adding a hover state to an element is durn easy. Let’s use an opacity change as an example:

div {
   opacity: 1.0;
}
div:hover {
   opacity: 0.5;
}

But what if we want to have that hover state apply to everything but the element actually being hovered over? (e.g. other adjacent sibling divs)

Let’s assume this basic HTML:

<section class="parent">
  <div></div>
  <div></div>
  <div></div>
</section>

We’ll apply the current CSS properties to all the children of the parent when the parent is in the hover state.

.parent:hover > div {
  opacity: 0.5;
}

Then when the parent is hovered and the individual div is hovered, we bump the opacity back up, giving the final effect we are looking for.

.parent:hover > div:hover {
  opacity: 1.0;
}

Real World?

A similar kind of thing is in the Twitter for Mac app on individual tweets:

Demo

This idea can be extended into multiple levels of depth. Here is an example of three “lists.” All list items have full opacity in their regular state, but as you roll over the lists, the currently hovered list is slightly more opaque than then others, and the currently hovered list item is fully opaque.

View Demo

And yes, old you-know-who browsers don’t do :hover on anything but anchor links. If it’s mission critical, use JavaScript to detect mouseenter events on them and apply/remove class names.

The wages of sin: Proper and improper usage of abstracting an OR/M

Originally posted at 3/11/2011

This time, this is a review of the Sharp Commerce application. Again, I have stumbled upon the application by pure chance, and I have very little notion about who wrote it.

In this case, I want to focus on the ProductRepository:

image

In particular, those methods also participate in Useless Abstraction For The Sake Of Abstraction Anti Pattern. Here is how they are implemented:

public AttributeItem GetAttributeItem(int attributeItemId)
{
    return Session.Get<AttributeItem>(attributeItemId);
}

public Attribute GetAttribute(int attrbuteId)
{
    return Session.Get<Attribute>(attrbuteId);
}

public IEnumerable<Attribute> GetAllAttributes()
{
    return Session.QueryOver<Attribute>()
        .Future<Attribute>();
}

public void SaveOrUpdate(Attribute attribute)
{
    Session.SaveOrUpdate(attribute);
}

And here is how they are called (from ProductService):

public AttributeItem GetAttributeItem(int attributeItemId)
{
    return productRepository.GetAttributeItem(attributeItemId);
}

public Attribute GetAttribute(int attrbuteId)
{
    return productRepository.GetAttribute(attrbuteId);
}

public void SaveAttribute(Attribute attribute)
{
    productRepository.SaveOrUpdate(attribute);
}

 public IList<Product> GetProducts()
 {
     return productRepository.GetAll();
 }

 public Product GetProduct(int id)
 {
     return productRepository.Get(id);
 }

 public void SaveOrUpdate(Product product)
 {
     productRepository.SaveOrUpdate(product);
 }

 public void Delete(Product product)
 {
     productRepository.Delete(product);
 }

 public IEnumerable<Attribute> GetAllAttributes()
 {
     return productRepository.GetAllAttributes();
 }

Um… why exactly?

But as I mentioned, this post is also about the proper usage of abstracting the OR/M. A repository was originally conceived as a to abstract away messy data access code into nicer to use code. The product repository have one method that actually do something meaningful, the Search method:

public IEnumerable<Product> Search(IProductSearchCriteria searchParameters, out int count)
{
    string query = string.Empty;
    if (searchParameters.CategoryId.HasValue && searchParameters.CategoryId.Value > 0)
    {
        var categoryIds = (from c in Session.Query<Category>()
                           from a in c.Descendants
                           where c.Id == searchParameters.CategoryId
                           select a.Id).ToList();

        query = "Categories.Id :" + searchParameters.CategoryId;
        foreach (int categoryId in categoryIds)
        {
            query += " OR Categories.Id :" + categoryId;
        }
    }

    if (!string.IsNullOrEmpty(searchParameters.Keywords))
    {
        if (query.Length > 0)
            query += " AND ";

        query += string.Format("Name :{0} OR Description :{0}", searchParameters.Keywords);
    }

    if (query.Length > 0)
    {
        query += string.Format(" AND IsLive :{0} AND IsDeleted :{1}", true, false);

        var countQuery = global::NHibernate.Search.Search.CreateFullTextSession(Session)
            .CreateFullTextQuery<Product>(query);

        var fullTextQuery = global::NHibernate.Search.Search.CreateFullTextSession(Session)
            .CreateFullTextQuery<Product>(query)
            .SetFetchSize(searchParameters.MaxResults)
            .SetFirstResult(searchParameters.PageIndex * searchParameters.MaxResults);

        count = countQuery.ResultSize;

        return fullTextQuery.List<Product>();
    }
    else
    {
        var results = Session.CreateCriteria<Product>()
            .Add(Restrictions.Eq("IsLive", true))
            .Add(Restrictions.Eq("IsDeleted", false))
            .SetFetchSize(searchParameters.MaxResults)
            .SetFirstResult(searchParameters.PageIndex * searchParameters.MaxResults)
            .Future<Product>();

        count = Session.CreateCriteria<Product>()
            .Add(Restrictions.Eq("IsLive", true))
            .Add(Restrictions.Eq("IsDeleted", false))
            .SetProjection(Projections.Count(Projections.Id()))
            .FutureValue<int>().Value;

        return results;
    }
}

I would quibble about whatever this is the best way to actually implement this method, but there is little doubt that something like this is messy. I would want to put this in a very distant corner of my code base, but it does provides a useful abstraction. I wouldn’t put it in a repository, though. I would probably put it in a Search Service instead, but that isn’t that important.

What is important is to understand where there is actually a big distinction between code that merely wrap code for the sake of increasing the abstraction level and code that provide some useful abstraction over an operation.

HTML5 Boilerplate MVC 3 Websites with AppHarbor in 3 Easy Steps

Here’s a quick way to get a new .Net MVC 3 site up that incorporates HTML5 Boilerplate patterns and practices.

Step 0: Get Git (If you don’t have it)

Git for Windows is available from the msysgit repository on Google Code; this guide was written for the 1.7.4 preview version.

There’s even a guide for installing on windows if you need some help.

Step 1:  Create Your AppHarbor Project

Go to the AppHarbor home page and create a new account if you haven’t done so yet.  Then click the Create New link on the Applications tab to get started.

Newapp

Once you’ve got your application created, copy the Repository URL so you can push your source up to your new site.

Gitlink

Step 2:  Create Your MotherEffin HTML5 MVC 3 Site Project

I’ve created a super easy HTML5 Boilerplate MVC 3 template project that can deploy to AppHarbor with no modifications.  You can get it from the Visual Studio Extension gallery, or through the new project dialog by clicking the Online Templates tab item on the left and searching for “HTML5?.

Html5projecttemplate

Make a note of your project location so we can use the Git Bash shell to push our source.

Step 3: Push it to AppHarbor with Git

Once you’ve got your project all set up and ready to deploy, navigate to your project’s location, right click on the root directory and select “Git Bash Here”.

Enter the following commands to initialize your new Git Repository
  1. git init
  2. git add .
  3. git commit -m "initial check in"

Once you have your files committed locally, you are ready to push up to the AppHarbor Git Repository Url.

Here are examples of the commands to do that:

  1. git remote add appharbor [YourSiteRepositoryUrl]
  2. git push appharbor master

Gitbashhere

Gitinitapp
Gitpushapp
Enjoy Your Site

Congratulations, you’ve just deployed your first HTML5 website.

Now all you have to do is navigate to your app’s url; i.e http://best-site-evar.apphb.com.

Next step, add a database and add the code first entity framework NuGet package for fast database scaffolding.  Hopefully I’ll get a tutorial up for that soon.

See the original post on my posterous blog
Page 1 of 612345...Last »