Dienstag, 20. Oktober 2015

Why Angular when there is already ASP.NET MVC

This was a question I was asked by a colleague recently. He is new to the webstack, so it was interesting how new people see the things.

In ASP.NET MVC I have routing, view, controllers, ... and in Angular I have these thins again... why the redundancy?

So I tried to explain him that the frameworks are not the same.

First the main difference is that ASP.NET MVC is executed on the server-side and Angular is executed on the client-side. If you want a fancy, interactive and desktop-like webapplication you can not get around a framework like Angular.
At the moment you use Angular you mostly do not need the M and the V of ASP.NET MVC anymore and you end up with something like ASP.NET Web API. The M and the V moved to the clientside represented by Angular which is now responsible for the rendering of the UI. ASP.NET Web API is for providing and manipulating the data to and from the Angular UI.


Pros

  • no serverside rendering of HTML
  • no postbacks to the server and fullpage re-rendering
  • requests to the server with a small footprint using ajax
  • the full power of javascript
  • fast and responsible application
  • caching of static javascript and html templates


Conclusion

In a world of thousands of frameworks around it sometimes isn't clear which framework is responsible for which tasks. Back to the example you may realize that Angular replaces a part of ASP.NET MVC if you code a fully fledged webapplication.

Mittwoch, 22. Juli 2015

Creating a problemMatcher for gulp-tslint in Visual Studio Code

Recently I came up with the idea to parse the output of gulp-tslint to display it within Visual Studio Code to gather all errormessages at one single place. As Visual Studio Code does not provide an $tslint problemMatcher I created a custom one by adding a regular expression

Here you can see the regexp (line 18) to identify the lines in the console.log containing tslint messages. Line 19-22 are to map the capture-groups to the properties of Visual Studio Code error messages.


Its important to run tslint in full report-mode to capture the full path to the files. This enables Visual Studio Code to jump directly to the TypeScript files when clicking on the corresponding error messages.


You can find more information on this official page: Defining a problem matcher

Freitag, 4. Mai 2012

Radix was?

Schon mal etwas von einem Radix Parameter gehört? Ich zum ersten Mal als ich JSLint verwendet habe um meinen JavaScript Code zu überprüfen. Douglas Crockford empfielt nämlich bei Verwendung der parseInt(...) Funktion den Radix Parameter anzugeben.

Problem at line x character xy: Missing radix parameter.

Nun, ... er empfiehlt es nur, es ist nämlich nicht Pflicht da JavaScript in der Lage ist selbstständig zu erkennen in welchem Format der umzuwandelnde String vorliegt. JavaScript untersucht den Beginn des String darauf, ob er mit 0 oder 0x beginnt. Wenn nicht, dann nimmt es an dass es sich um das Dezimalsystem (10) handelt. Logisch, oder? Also lass ich ihn weg.

Einige Tage später....

Die parseInt(...) Funktion liefert 0, obwohl ich nicht "0" hereingebenen habe. Doch woran liegts? Kurze Recherche bringt mich auf diesen Artikel der das Problem beschreibt. In dem Moment kommt mir auch der Radix Parameter wieder in den Sinn und dessen Bedeutung. Da meine Eingabe zufälliger weise auch aus "09" bestand war das Problem klar. JavaScript nahm an es würde sich um das Octal-Zahlensystem handeln, doch da dort keine 9 existiert spukt es einfach eine 0 aus.

Korrekt schreibe ich nun also
parseInt("09", 10) //=> 9

Donnerstag, 19. April 2012

Funktionieren Extension Methoden auf Null-Referenzen?

Diese Frage hat sich mir heute gestellt und ich war nicht sicher. Die Lösung präsentiert Brad Wilson in seinem Blog. Mit Happy End ;-)

C# 3.0 Extension Methods and Null Instances

Donnerstag, 28. Juli 2011

JIRA fails to startup after first restart?

Every time I installed JIRA on one of my windows machines it just worked fine until the first restart. When booting up JIRA for the second time it fails showing up a JIRALockedError.

Diving into the file system resolves the problem. When JIRA starts up its locking for a file called .jira-home.lock in %ProgramFiles%\Atlassian\Application Data\JIRA folder to check if there is a second instance is running and using the files. If not it creates the file and proceeds to get executed. But naturally there is no second JIRA instance running on my machine, so why this error occure?


JIRA lacks of permissions to the database folder.
Windows 7 does not allow the current user and of course not an application to perform modifications within the %ProgramFiles% directories even if they belong to the application itself. So JIRA can not create the .jira-home.lock file an assumes that the directory is locked by an other instance.

So JIRA must be allowed to be able to create this file. To achieve this it needs Modify permission at least for the folder %ProgramFiles%\Atlassian\Application Data\JIRA. But if you startup JIRA again (and using the default in-memory database) it will stop working again because of another error. Thats because JIRA needs permissions for an additional folder containing the database stuff.

Finally the easiest way to get JIRA running is to grant Full Control for the MACHINE\Users group to the %ProgramFiles%\Atlassian folder. You should do this only for trial purposes.

Freitag, 1. Juli 2011

Windows Phone 7 - Touch reactivity

Since I have my Windows Phone 7 I encountered some differences on how controls react to contact with my fingers. There are a lot of places where I really like how the controls behavior. For example there is the call history containing my recent outgoing an incoming calls. If I touch one of the items it fades grey and gets a little bit smaller than before. To me this behavior seems very natural and I can see instantly that I hit the item with my finger. I think its very important to see instantly what the action I performed to the screen caused, especially in a touchscreen environment where it is a lot harder to hit a small control than in an environment where a mouse is used.

Things are getting a step further in the Windows Phone 7 e-mail client. In the e-mail client the "hitting-experience" feels even more natural since there is some 3-dimensional transform be performed to the item you are hitting. Depending on the location you are hitting the item it will rotate around a different axis. This feels more like you are physically hitting the item and pushing it down.

Both, the first and the second technique produce an instant visual feedback to the user before further actions e.g. a page transition follows. Because further actions sometimes has some lag due for example calling a web service the following page doesnt show up right after you touched the item. If the item does not support a transition when the user touchs it he may will be confused because he thinks something should happen, but actually nothing happens due lag. Maybe the user thinks he doesnt hit the button an tries again. So now, if the buttons reacts instantly to the user input, the user can notice the transform and know that the application received his input.

But thats exactly what some Apps including the Facebook App or Twitter App are doing wrong. Touching a tweet or hitting a friends Facebook status does not raise any visual feedback, followed by some lag before the page transition. Especially within the Facebook App with its many small links you dont actually know whats touchable due lack of visual feedback and you dont know if you hit the small link or if you have to try again. These Apps would be great if they are becoming more natural like the native "Apps".

Dienstag, 23. November 2010

Erstellen eines CommandLink in der WPF - Teil 1

Einleitung
Immer wieder bin ich auf der Suche nach einem Thema, über welches ich einen Blog-Post verfassen kann. Und so bin ich kürzlich wieder über das Thema CommandLink-Button gestolpert. Da dieser weder in WinForms, noch in der WPF out-of-the-box unterstützt wird, möchte ich ein kleines Tutorial über die Entwicklung eines CommandLink-Button als CustomControl in WPF erstellen. Nicht zuletzt dient dieses Tutorial auch dazu, Erlerntes weiter zu verfestigen. Bei der Entwicklung des Controls sollen die Windows User Experience Guidelines eingehalten werden. Damit der Beitrag nicht zu lange wird teile ich ihn in kleine Beiträge auf und werde von Zeit zu Zeit eine Fortsetzung posten.

Anforderungen an den CommandLink-Button
Bevor ich mit der Entwicklung des CommandLinks beginne, muss ich herausfinden wie der CommandLink ab Windows-Vista funktioniert. Dazu analysiere ich zunächst die unterschiedlichen Zustände die er Button einnehmen kann.
  • Normal
  • MouseOver
  • MouseOver + Focused
  • Focused
  • Pressed
Die fünf möglichen Zustände sind nun ermittelt. Als nächstes stellt sich die Frage welchen Inhalt ein solcher CommandLink anzeigen kann. Wer Windows-Vista oder Windows 7 kennt, weis, dass in den dortigen CommandLinks nicht nur Text vorkommt. Sie enthalten oft noch Details zur anstehenden Aktion, wie z.B. beim Überschreiben von Dateien. Dennoch sind ganz klare feste Bestandteile zu erkennen.
  • Icon oder grüner Pfeil / Schutzschild
  • Titel in grosser Schrift
  • Beschreibungstext unterhalb des Titels mit kleiner Schrift
  • (Details in unterschiedlichen Ausführungen)

CommandLink unter Windows 7

Fester Bestandteil des CommandLink sind, das Icon, Titel und Beschreibungstext. Details unterhalb des Beschreibungstextes sind optional und können je nach Scenario variieren. Der CommandLink soll als eigenständiges CustomControl erstellt werden. Dennoch möchte ich vermeiden sämtliche Logik von Grund auf neu schreiben zu müssen. Deshalb ziehe ich es vor, den CommandLink von einem bestehenden und funktional möglichst ähnlichem Control abzuleiten. Nichts liegt dabei näher, als das bereits im Framework vorhande Button-Control.

Fortsetzung folgt...