Microsoft platform and web development

Microsoft, without doubt is the biggest and one of the best platform for enterprise developers . These were even more so compare to java . Visual Basic took the world by storm and everyone under the sun started writing one and have heard about the goodness, then came NGWS later became .net, seriously nobody could write a better language than c# team did. But the advent of mobile and better browser supports means a lot of Microsoft development shop spending their time and effort on building up and front end , and those who adopted asp.net(visual basic of the web) were all the rage with server controls and event, I was there, preaching about the goodness… Until one day.. And it happened to a lot people .. Ajax… JavaScript, why do we have to do everything on the server,…. And the classic case was there was this team of developers who claims … They are the new generation of web developers, know not a single line of HTML and JavaScript other alert. Oh well .. When jQuery was released to the world… They were all still sleeping and think it was some kind of stupid.. Php, un-object oriented, uncool stuff.

What they don’t realized or they just ignoring them is the fact that JavaScript is no longer , something that you slap in at the end of the day just to make that bit or this bit a little nicer, people have been developing in JavaScript from end to end, and they are still pre-occupied with asp.net,  “One asp.net”… who cares(well may be those VB6 programmers who just heard about asp.net). Entity framework and Web API are among the few things I will never allow my team to ever touch or learn, WHY would I need somebody to write me code that we don’t understand. EF makes it harder to apply SOLID principals in every way.

For the rest of us, we at Bespoke have been for at least 5/6 years , never have to do anything server control or Html.LabelFor or Html.EditorFor.. any more, if we want a label then we will write <label> this is my label</label>.

 

With the announcement of internet explorer 11, Microsoft finally has something to o against Chrome DevTools and FireBug except..

  • it’s too late – see what happen to Windows Phone
  • it doesn’t work everywhere  – it’s not like Chrome or Firebug

Is it really important, for the F12 to work every where, every one has their own opinion, but  in Microsoft case, they only care about their latest OS. If they intend to get really serious about winning developers mind and hard they get work harder.

I personally believed that a good developers tools should no be bundled from the main branch of the browser, what they should do is have a developer edition of the browser that come with very powerful tools for developers. May be based on Visual Studio shell, heck who cares if its 500MB, it’s only meant for developers and they won’t install it on their iPad/ table anyway.

These are the list of features they should have.

  • It’s completely blind to the server technology
  • Support for TypeScript debugging, (the only reason I write JavaScripts instead of TypeScript is debugging in codes that you don’t write is stupid)
  • Having workspaces and assets and version control built in(do a local Git repository) allowing us to do branching and experiment
  • Lots of override and emulation for touch, GelLocation , HTML5 platform and so forth

The closest i could get to this thing today is combination of Chrome DevTools and JetBrains WebStorm, with all the mock and requirejs, I hardly back in Visual Studio anymore.

 

 

 

 

 

 

 

 

DurandalJS with server side code

Those of you that do everything on the client side when using SPA framework are often writing a more complex code in order to cater for something such as authorization, and security related code. Writing these code on the client is often very tedious and error prone, not to mention that once everything gets in the browser , someone could always find a way to beat you.

It’s the best to control access on the server, but what if your views and view models are all .js files and .html files in ~/App/Views and ~/App/ViewModels directory, there’s going to be a lot of <location> tag in your web.config

The best way is always to do in using ASP.Net MVC controller and action and spit out these js and html accordingly and being able to use C# and Razor on the server.

DurandalJs default configuration is set to look for views and viewmodels in the default location in ~/App/Views/m.html and the view model in ~/App/ViewModels/<m>.js, and if the server find a disk file there, it will fetch it, but what is it’s not there. Well then the default router will try to find a controller with name AppController , and ViewModels action in it, your m.js will become the id parameter. So you could write this controller and the action for Views, ViewModels, config and what ever that’s directly under the ~/App folder.

 public partial class AppController
    {

        public ActionResult ConfigJs()
        {
            return View();
        }

        [ActionName("config.js")]
        public ActionResult Config(string id)
        {
            this.Response.ContentType = APPLICATION_JAVASCRIPT;
            var script = this.RenderScript("ConfigJs");
            return Content(script);
        }

    }

If you delete your config.js file then automatically this action will be executed and will render your ConfigJs view, where you could use server side C# and Razor to customize the output.

See, you can’t find config.js , neither is something.js in viewmodels or something.html in views

and yet the server responded well and DurandalJs didn’t care

Get the plumbings at https://github.com/erymuzuan/durandaljs-with-server-side-code.git

Building highly scaleable distributed application

Image

 

 

Developing an enterprise application is a bit of balancing act, when you have to juggle all different aspects in your development environment, things like the ease and speed of the development should be the number one priority and it’s all to easy to get carried away when you are so comfortable with one particular style of architecture and approached.

Building a distributed system might require you to change the way you think about certain things, as the first rule of building a distributed system is “don’t distribute”. We have been fed with the ease of classic Remote Procedure Call(RPC) treated as local call, the tool vendors are preaching their platform could easily take a remote call and wrap them in your favorite language object and method and make it look like a simple local method call without even worrying about the network and the plumbing behind it.

 

 

 

 

Windows 8 – So do I we need to upgrade now?

It’s been more than a week since I had my home workstation running Windows 8, It was originally running Windows 7 Pro. So what it is for us programmers.

No 1 , it’s nothing as far as our life as enterprise developers is concerned it will be years before everyone or significant numbers to move to Windows 8 to really embrace “Windows 8 UI”(aka Metro). 

No 2 its quite the opposite since there tons of related usability and navigation features introduced. Though many thousand hours were put in designing the great user interface and the new navigation system, they break 1 simple rule, “Don’t make me think”. It’s not like picking a new set of wheels and floor them to feel the benefit. You do really have to read the user manual and helps to get around. What you supposed to do when all these years you have “Start Menu” ( nor it I understand why we all should click Start menu to shutdown) and it’s been really good in Windows 7 and suddenly it’s gone and you have to learn the new things.

No 3, Do we really care about all these new features, most likely not, the number 1 reason for the upgrade for me as a programmer is usability and performance is the key indicator of usability. As Windows progress so is the performance only in this aspects that I were to consider to adopt the new OS. Then there are things like.. it just works and that what great piece software does.

No 4 Visual Studio 2012 rocks, the UI were different but it’s good enough for me, ReSharper 7 just works, it’s all that matter. 

 

Obviously this opinion is based on my everyday life as a developer building enterprise application. If you are a developer in web/mobile and what not. Then you might not agree with me.Especially those who think that being connected at all the time it the utmost important part of your life.

 

The more things change the more they stay the same. BTW what is so great about being connected all the time.

So how much time do you spend reading emails

Emails is the biggest productivity killer for programmers, so should you or not spend time reading your emails. All I’m saying is schedule your email. Don’t write much.

ASP.Net Membership add user & role utility

How many time do find you can’t easily add new user to your application when deploying. It’s ironic that you have built an asp.net application with a complete user management features but can’t get it to work because you need to login the first time around to access the features.

Or may be you can’t be bothered to create one, just want to create a few roles or users. We all know that we can’t  make ASP.Net web admin tools to work on a remote site.

This utility is meant to add a new user or roles to your newly create aspnet identity database.

to use just compile the source with .Net 4.0. the use this command line switchers

 

To add new user

  • -u username
  • -p password
  • -e email
  • -r role (if you have more than 1 role for the user, do it multiple times)
  • -c the path to the configuration file, i.e. your web.config

To add new roles

  • -r roles
  • -c the web.config file

This work by creating a new appdomain, and loading the config file , since there’s no programmatic way to access the Membership features(or I just can’t find it). See the source for details. You can safely delete the app.config

 

Download the source here

SQL Server Spatial

Learning SQL Server spatial.

Microsoft SQL Server, has had supported for spatial for quite sometime. It never really interest me until recently when we are working on mapping system. It’s all started when we were task to do project management consulting for LLM which is responsible for the country toll highways. It’s a pain to watch those guys working with spatial object in Oracle.

From then on we know, that we can’t ignore this. With the emergence of web mapping services such as Google Map and Microsoft Bing Map, couple with the affordability and ubiquity of GPS enabled devices. Microsoft SQL Server spatial is made easy if you are .Net developer and understand the concept of CLR and it’s hosting. From .Net developer point of view it’s just another class , another datatype, with a set of inheritance, properties and method.

Part 2