Let's take advantage of those new technologies provided by HTML5 to built impressive user-friendly WebSites and WebApps.
If you are a dev in your company who creates custom intranet or internet solutions this topic might be interesting for you. There are existing Desktop applications in need to be transformed into Rich Internet Applications, that's for Java, .Net, Python, C++, etc. based Apps alike.
Let's create a foundation of knowledge that helps you keeping track of what's happening out there and which purpose can be solved by those frameworks.
Follow me into a journey of developing solid Business Layers for your HTML5 needs!
From the point of view of a web developer, physics engine can give you a lot of cool features among which we can get for instance:
* Realistic simulation of basic shapes (Box, Sphere, compound, etc…)
* Simulation of friction and bounciness
* Link between objects (to simulate chains for instance)
* provide access to the entire Elasticsearch REST API * play nice with clusters * automatically discover nodes when desired * intelligently handle node failure * be easily extendable, so that you can really have it behave just the way you want
For our cloud auction project, we want to use web sockets to send price, availability and product updates from the server to all active clients. It’s important that these updates are synchronized as much as possible, so that every user sees the same price at the same time. We want to avoid users hammering our servers by refreshing the page in their browser, pressing F5 every second. We are starting from our ASP.NET MVC cloud auction website, a standard website based on the MVC Internet Website template. I described several parts of it in other posts in this series.
It really surprises me that there are people arguing that writing controller tests doesn’t make sense. Probably the most common argument is that actions are covered in acceptence tests along with checking if views are properly rendered. Right? Right…well that’s just wrong! Are you trying to say that your slow acceptance tests are covering every possible controller action scenario? Are you trying to say that, for instance, every redirect that should take place is tested within an acceptance test? Are you also checking every invalid request in acceptance tests? Are you telling me that your acceptance test suite takes 27 hours and 13 minutes to finish because you fully test your controllers there?! Oh I’m sure that your acceptance test suite runs faster and you probably cover only ‘the happy scenarios’ there…which basically means you miss A LOT of test coverage.
Part 1 ended with todos. The first one was to couple the server-side generated code with the client-side React, so that any updates past the initial page load will be handled by React's client JS, which is where React shines. Let's see how you can do just that.
This excerpt also includes some habits not necessarily related to the code itself, but more about the overall code creation process, including writing API documentation, conducting peer reviews, and running JSLint. These habits and best practices can help you write better, more understandable, and maintainable code—code to be proud of (and be able to figure out) when revisiting it months and years down the road.
The samples are now getting longer, and have more features in them. I’ve also posted some samples and explained some of the basic syntax. From here on out, I’m only going to extract small bits of the code, and explain the features that I haven’t yet explained. As always, the samples are online both as a working example and as code.
This sample has a simple TODOD checked list. You can see it running here. You can add new tasks. and mark any of those tasks as complete.
Browser add-ons are clearly an important web browser feature, at least on the desktop platform, and for a long time Firefox was the browser add-on authors’ preferred target. When Google launched Chrome, this trend on the desktop browsers domain was pretty clear, so their browser provides an add-on api as well.
Most of the Web DevTools we are used to are now directly integrated into our browser, but they were add-ons not so long time ago, and it’s not strange that new web developer tools are born as add-ons.
Web DevTools (integrated or add-ons) can motivate web developers to change their browser, and then web developers can push web users to change theirs. So, long story short, it would be interesting and useful to create cross-browser add-ons, especially web devtools add-ons (e.g. to preserve theweb neutrality).
With this goal in mind, I chose Ember Inspector as the target for my cross-browser devtool add-ons experiment, based on the following reasons: ...
This pro tip will guide you through the steps of implementing an end to end test using CasperJS. Although there's no code specific to Backbone in this tutorial, I do make assumptions on how an app will operate within the context of a Backbone app. This tutorial is therefore suitable for anyone who would like a 0 - 20 getting started guide to CasperJS.
CasperJS has its own handy test runner. Let's begin by writing a quick little script to get used to the boilerplate.
Backbone.js is a lightweight framework that let us create single page applications in a structured manner. It is based on the Model-View-Controller (MVC) pattern. It is best suited for creating single page applications using a RESTful service for persisting the data.
By default, Ember.js uses the hashchange event in the browser to change URLs. This is the most widely supported way but it feels like a hack and there is a better way, introduced in HTML5: the History API.
Bear in mind that the History API has a lower browser support rate than the hashchange event does (~70% vs. 89%), so there is a tradeoff involved that you should decide to make or not to make.
Ember.js makes it really easy to change the URL type. All you have to do is add the following lines to your client app:
Seems too good to be true (that is just the way Ember is), but provided you did not assemble any routes manually and only used Ember’s tools to transition between routes (e.g link-to, transitionTo, etc.), that is all the client-side code changes you had to make.
The server side needs to be adjusted, too, though, since the server now gets sent the client-side routes, too. How to do this can vary depending on the application server you use.
Jan Hesse's insight:
AngularJS has always had a Scope.$watch() function as means to observe [and react to] changes in a given value. With AngularJS 1.1.4, however, they added the Scope.$watchCollection() function as a means to observe changes in a collection (either as an Array or an Object). Between the two current functions, there are three unique ways to watch a value for changes. And to be honest, it can get a bit confusing. As such, I wanted to take a quick look at these three different watch-configurations and nail down what kind of changes each one will track.
However, writing an application that is testable, decoupled, and manageable, is a whole other beast. The typical approach to making Ajax requests in an application is to use jQuery's Ajax, pass a success callback and update the DOM with the response. That's great if you have some small application that doesn't need a lot of updates and manageability.
What happens in an enterprise environment when someone writes that kind of shortcut Ajax code, makes a mess of the DOM in the success callback? You've just coupled your DOM directly to your request. What if the new boss comes in and says, "I HATE TEH JQUERY!"? Well, at that point you have to find the code in the success callback that messed with the DOM, rip it out, rewrite your Ajax logic, etc... It's a mess.
If you are using Ember as your client-side web framework, I may just save you a lot of trouble. Ember is still being heavily developed, so I never expected it to work perfectly out of the box, but today's ordeal with setting up fixtures (using Ember Data) was impressively hair-pulling. I will be fair and preface that most of these issues arose from Ember Data itself and not Ember, but I don't consider that a valid excuse.
These were the main points that fucked me today:
* Not much documentation.
* Data store adapters handle data differently.
I'll walk you through a few of the pitfalls I faced: ...
Follow along in this two part series as we walk through the steps to test for bugs in AngularJS.
First, we will write unit tests that reflect the intended behavior and then fix the bug so these tests pass. The goal is to improve code maintainability and reduce regression bugs.Download or clone the repo to follow along – each step has a corresponding branch to checkout.
We are going to focus on the play/pause functionality of the player. By right-clicking on the video element, we can see that the video will play and pause.
We will write tests for both the controller and the directive for this button in order to make sure our tests are small, consistent and maintainable.
So, how can we combine these two immensely powerful libraries to do something interesting? Or at least vaguely interactive.
Let’s see if we can use D3 to draw some rectangles, described in a Knockout view-model, which we can modify using D3 or by altering the data itself.
There is some overlap in functionality here: KO enables us to generate DOM content based on data, as does D3. In theory we could use a KO template to generate fragments of SVG markup for each of our view models. But that would involve generating the elements long-hand and we wouldn’t have the association between view and view-model.
Now, we need a way of getting the KO data fed to D3 at the right time: when it’s updated.
One of the first things to notice is that if we observe the array of rects, we only see changes to the array, not to its elements. In other words, we only know when items are added or removed, not when elements properties are changed. Seeing as we need to know when a rectangle’s position changes, we’ll need to do some more work.
You may want to read this post if: * you want your URLs to look like /posts rather than /#/posts and to interact with browser history properly * you need to support browsers that do not support session history management * the Ember.AutoLocation feature is not yet available
If enough of that is true that you're still reading, then keep reading and I'll explain how to use History.js to make the pain go away.