IgorShare Thoughts and Ideas

Consulting and Training

Archive for the ‘Javascript’ Category

Roslyn: C# is cheating on me with JavaScript (or how to compile C# into JavaScript)

Posted by Igor Moochnick on 08/20/2012

imageWhile working extensively on development of the Single Page Applications (SPA) I was facing a fact that my server-side data models were evolving quicker than their JavaScript counterparts. Both the client-side and the server-side data models were getting quickly out of sync.

The brute force solution of using the T4 templating engine to emit both the client-side and the server side data models didn’t look that appealing to me. Primarily due to a simple fact that it’s not that easy to refactor the T4 templates. And, the ReSharper junkie like me, can’t tolerate this fact.

So I’ve decided to give the latest release of Roslyn compiler-as-a-service CTP another spin and use it as part of my build sequence and compile my C# models directly into the appropriate JavaScript ones. This was giving me the advantage of using the C# as a primary development environment and leaving the JavaScript to follow the “big-brother”.

Jinx C#-to-JavaScript compiler was created as a result of this exercise. You’re welcome to get the Jinx source from the GitHub. I’ll appreciate any collaboration on this project.

Note: all of the code is an intermediate solution that was answering my personal needs for the project I was running. It is in no-way represent the full fledge solution. If you want something bigger and more feature-reach, you can either contribute to my solution or look into projects like Script# or SharpKit.

Read the rest of this entry »

Posted in Architect, C#, Compiler, Javascript, Tutorials, Web | 3 Comments »

ASPConf 2012: Content for my presentations

Posted by Igor Moochnick on 07/20/2012

Building complex Single Page Application should be as enjoyable as visit to a SPA

You can watch the full Video on Channel9 and get the Source on the GitHub.

Check out the video

Video


Tips for Building Responsive Cloud Applications

You can watch the full Video on Channel9 and get the Source on the GitHub.

Video

Video


Posted in Azure, Cloud, Javascript, Presentations, Web | Leave a Comment »

ASPConf: Generating dynamic views, but Google Chrome was too smart for me

Posted by Igor Moochnick on 07/20/2012

I had a blast presenting for ASPConf 2012. I want to thank all the organizers, presenters and attendees. Without you it wouldn’t have been possible.

One of the questions from one of the attendees during my “Building complex Single Page Application should be as enjoyable as visit to a SPA” talk was:

Q: Is it possible to bring on-demand portions of the application that will be emitted by the Asp.Net MVC Views (aka: dynamic views generation)

A: Sure (see Picture #3).

But when, in fact, I’ve tried to demonstrate it right away – I hit a snag.

What happened is: my implementation was correct but Google Chrome was too smart for me to handle it and wrapped the partial HTML with the full “HEAD” and “BODY” tags [See Picture #1].

I’ve assumed that my server was returning more than the generated by the Raw view content itself. If I would’ve checked a network stream [See Picture #2] (or Fiddler) I would’ve seen another result – the correct one.

Picture #1

image

Picture #2

image

So, this is a simple example how you can import a dynamically generated content from an Asp.Net Mvc view into a SPA application:

1. Create a view

2. Create a Controller entry (when you’ll navigate to this view you should see a result on Picture #2)

3. Change a dependency path in your SPA view to point to the new content (and the final result should look like Picture #3)

Picture #3

image

Posted in ASP.NET, Javascript, Presentations, Web | Leave a Comment »

Tips for building Large-Scale rich Web sites and applications

Posted by Igor Moochnick on 06/09/2012

When you’re building a workflow-rich web site or application, you’re in a danger to get buried under piles of entangled JavaScript code, web pages, styles and other related artifacts.

It’s better to follow the best practices from the beginning to reduce the weight of the complexity and enable easy extensibility of your code. Here are a couple of links that may put you on a good path:

Here is an entry list of frameworks to know about:

I’m not afraid to admit that I’m not a web designer and I struggle with building good-looking sites, but there are a couple of tricks that I use to make sure that I’m not stuck:

Tips for VisualStudio–devoted crowd:

UPDATE:

Here are a couple of more helpful ones:

  • async.js – Async utilities for node and the browser

Posted in Architect, Javascript | 4 Comments »

NWT – .Net Web Toolkit

Posted by Igor Moochnick on 10/26/2011

Now, after waiting for quite some time, we finally can implement the real solution for .Net <-> javascript conversion and bridge the impedance gap in the projects that heavily rely on the powerful rich web UI.

Currently we have solutions like Script# and CofeeScript and others. The pros in cons of these systems have been discussed countless times (ex: HanselminutesJavaScript is Assembly Language for the Web: Semantic Markup is Dead! Clean vs. Machine-coded HTML).

With the recently released project Roslyn (or alternatively Mono Compiler Services) it is possible to have a clean solution to the problem:  I write my data and data model in a language and an environment that allow solid validation and refactoring.

I’m ironing out some kinks in my implementation and, as soon as it’ll be in a stable state, I’m going to release a NWT (NeWT) project that will provide a similar to GWT (Google Web Toolkit) functionality.

Posted in C#, GWT, Javascript, jQuery, Web | 1 Comment »

 
%d bloggers like this: