Spring Boot Training Available

The Spring framework has been a highly popular framework for Java applications.  So popular in fact, it is pretty much the defacto standard of Java application frameworks.  One of the issues many projects run into though is just getting started with a new Spring project with all of the different features and configuration that might be required of a Spring project.

This is where the Spring Boot project can help.  Spring Boot makes it easy to create production-grade Spring applications that “just run”.  The following features taken from the Spring Boot site make it easy to get a Spring project going and focus more on the “What is this project supposed to do?” instead of the “How do we get this project setup?”

  • Create stand-alone Spring applications
  • Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
  • Provide opinionated ‘starter’ POMs to simplify your Maven configuration
  • Automatically configure Spring whenever possible
  • Get out of the way quickly as requirements start to diverge from the defaults
  • Provide production-ready features such as metrics, health checks and externalized configuration
  • Absolutely no code generation and no requirement for XML configuration

Since we have had many clients asking about Spring Boot recently we have added a 2-day Spring Boot training course that can help you start learning how to use this very useful project.  You can find the outline here:

WA2511 Spring Boot Training

Spring Boot is definitely one of the newer Spring features that prove this application framework isn’t going away anytime soon, it continues to grow!

,

No Comments

Angular 2 Programming Languages

Programming Languages for Angular Development

Angular 2 differs from Angular JS in regards to programming language support. With Angular JS you generally program in JavaScript. With Angular 2 the official site provides example code in several languages; JavaScript, TypeScript and Dart.

JavaScript is an implementation of the ECMAScript standard. Several versions exist including ES5 and ES6. Most current browsers fully support JavaScript ES5. This means that code compliant with ES5 will run on most most browsers without modification. ES6 on the other hand may not be supported and is typically converted to ES5 before it gets to the browser. The more recent version of JavaScript (ES6) adds features and makes certain tasks easier. It is not clear when browsers will be fully ES6 compliant.

TypeScript and Dart are language super sets of JavaScript. This means they include all the features of JavaScript but add many helpful features as well. But just like the ES6 version of JavaScript they don’t work on current browsers. To work around this limitation there are utilities to convert code written in their non-browser-compliant syntax back to JavaScript ES5. In this way they provide the developer with advanced features and still allow code to be run on existing browsers. The process of converting code from one language to another is referred to as ‘transpilation’. Technically this conversion is performed by a language pre-processor that, although it does not compile anything, is commonly referred to as a compiler.

TypeScript is an open source language that is developed and maintained by Microsoft. It provides type safety, advanced object oriented features, and simplified module loading. Angular 2 itself is built using TypeScript. The documentation support is better on the Angular 2 site for TypeScript than it is for the other options. So although you could write your Angular 2 apps in pure ES5 JavaScript you may find it more difficult and find less support if you get into trouble than if you bite the bullet and spends some time learning TypeScript.

Dart is another alternative for programming Angular 2 applications. It is similar in features to TypeScript and has its own loyal following. If your team is already versed in Dart and is looking to start developing in Angular 2 it could be a good choice. That being said,  in the rest of this post, we will be concentrating on TypeScript.

Code Example

A basic Angular 2 component coded in TypeScript:

import { Component } from '@angular/core';
@Component({
selector: 'hello-app',
template: '<h1>Hello Angular 2</h1>'
})
export class AppComponent { }

 

The same component coded in JavaScript ES5:

(function(app) {
app.AppComponent = ng.core.Component({
selector: 'hello-app',
template: '<h1>Hello Angular 2</h1>'
})
.Class({
constructor: function() {}
});
})(window.app || (window.app = {}));

 As you can see the TypeScript version is more concise and easy to read.

 

TypeScript Usage Basics

TypeScript support is provided by the Node.js ‘typescript’ package. To use typescript you first need to load Node.js and the Node Package Manager (npm). Once Node.js is installed on you system you would use the following command to install TypeScript support:

npm install -g typescript

This will install the TypeScript compiler and allow you to run it from the command line using the following command:

tsc

There are generally three methods to execute tsc. The first method involves passing the name of the TypeScript code file you want compiled on the command line:

tsc filename.ts

Here’s a simple TypeScript code file:

// app.ts
var msg:string = "Hello Typescript!";
function getMessage(message: string){
return message;
}
console.log(getMessage(msg));

Compiling this file produces a JavaScript file with the same name as the TypeScript file but with an extension of “.js”.

tsc app.ts
(produces app.js)

You can test the file by running it using Node.js like this:

node app.js

As your application gets more complex and you have multiple *.ts files in one or more directories you may want to take advantage of the second method of running tsc. To do this you will first need to set up a tsconfig.json config file. Among other things this file tells tsc which directories contain the files you wish to compile. After placing this file in the root of your project tsc will compile any *.ts files it finds whenever they are modified and saved. To use this method you launch tsc in a terminal window and then edit your *.ts files in any text editor. As you save your files they will automatically be converted to JavaScript.

The third method involves using a text editor plugin to determine when you have saved a *.ts file. When that happens the editor itself will call tsc to perform the conversion. This kind of plugin is available for the Atom text editor. Microsoft Visual Studio also includes this type of support. For those who don’t want to load the complete Visual Studio development system Microsoft’s Visual Studio Core text editor also includes TypeScript support.

Conclusion

Using TypeScript significantly simplifies the code you need to write when creating Angular 2 applications. Although TypeScript can’t be executed by browsers directly there are several ways to convert TypeScript into code that browsers can work with.

No Comments

Java 8 Example – Lambdas

A few months ago I wrote about how our core Java courses are being updated to Java 8.  Now that the updates are a little further along we also have a course map that can show which Java 8 courses we have might be appropriate for you.  You can find that here:

Java Course Map

I thought that it might be good to offer a quick example of some of the things in Java 8 on our blog.  Since you can’t really talk about Java 8 without discussing Lambda expressions I figured I would start there.

Read the rest of this entry »

No Comments

Creating custom HTML helper functions in ASP.NET MVC

ASP.NET MVC provides several  HTML helper functions that generates HTML automatically. E.g. Html.TextBox, Html.CheckBox etc. We can also create our own custom helper functions as well. For creating HTML functions following steps have to be performed:

1. Create a static class

2. Add a static method that returns either string or MvcHtmlString

3. First Parameter should use this and it should be of  type HtmlHelper. HtmlHelper is the class to which we are essentially adding an extension method for each helper function.

Here are a bunch of helper functions:

public static class SimpleCustomHtmlHelpers
{

  public static MvcHtmlString SubmitButton(this HtmlHelper helper, 
                                                 string id, 
                                                 string title)
 {
   string str = string.Format("<input type='submit' id='{0}'” +
                                “ value='{1}' />",  id, title);

   return MvcHtmlString.Create(str.ToString());
 }
 public static string MailTo(this HtmlHelper helper, 
                                    string emailAddress, 
                                    string textToDisplay)
{
   return String.Format("<a href='mailto:{0}'>{1}</a>", 
         emailAddress, textToDisplay);
}

public static string Image(this HtmlHelper helper, 
                                   string imageUrl, 
                                   string altText)
{
   return String.Format("<img src='{0}' alt='{1}' />", imageUrl, altText);
}
}
Using the above code will let us use following helper functions:
1. Html.SubmitButton(‘btnSubmit’, ‘Register’) 
2. Html.MailTo(‘abc@xyz.com’, ‘Email’)
3. Html.Image(‘/images/img.jpg’,’image’)

No Comments

SharePoint Server 2016 RC is now available

Both SharePoint 2016 and Project Server 2016 Release Candidate are not available. SharePoint 2016 RC is mostly feature complete and it’s now safe enough to evaluate it to get an overall picture of the final product. If you have older Beta 2 then it can be upgraded to RC.

If you have InfoPath 2013 and SharePoint Designer 2013 then they will continue to work with SharePoint 2016. Both will be supported for the duration of SharePoint 2016’s support lifecycle.

You can read about the prominent changes made to 2016 version in this blog post:

Permanent Link- Changes in SharePoint 2016

MinRole in SharePoint 2016

Permanent Link- Changes in SharePoint 2016 installation and deployment

No Comments

Exception handling in ASP.NET MVC applications

For exception handling we have been using try..catch..finally block since forever in various languages. In this blog we will see how to handle the unhandled exceptions in ASP.NET MVC. Unhandled exceptions are the exceptions that are not handled using try..catch..finally block. For handling unhandled exceptions or for creating a global exception handler we have to perform following steps:

1. In web.config add following line in the system.web section

<customErrors mode=”RemoteOnly”></customErrors>

2. Before each controller add following annotation:

[HandleError]

public ActionResult Index()

3. In Views folder create a sub-folder named Shared and create a file there named Error. Extension can be .cshtml (razor) or .aspx (web forms engine)

4. Optionally to the Error file add following code to display the actual error message:

@Model.Exception.Message

 

In case if you want to name the Error page something else then change the annotation before controller to [HandleError(View=”custom_name”)]. Replace custom_name with whatever your error page name is.

No Comments

New SharePoint CSOM version released for SharePoint Online

SharePoint supports two main development / deployment techniques for creating SharePoint projects: Server Object Model and Client-Side Object Model. If you plan on doing development for the hosted version of SharePoint, i.e. Office 365 / SharePoint Online, then you CSOM is the only option. A new SharePoint CSOM has been been released for SharePoint Online / Office 365. It also allows development for Project Online (hosted Project Server). It can be downloaded using “Manage NuGet Packages” option in Visual Studio. Just search for the id “Microsoft.SharePoitOnline.CSOM” and VS will download the required files.

No Comments

Microsoft has acquired Xamarin

Xamarin has been known for offering a native cross-platform development solution. It allows writing code using .NET and then running the same code on iOS, Android and WIndows devices. Microsoft has been supporting Xamarin tools in Visual Studio since VS 2013. But, now Microsoft has purchased Xamarin. It might boost Windows phone development and we might see more apps coming over to Windows. Even if Windows Phone apps don’t become popular it would still let .NET developers create cross-platform apps.

No Comments

Simple Algorithms for Effective Data Processing in Java

The needs of Big Data processing require specific tools which nowadays are, in many cases, represented by the Hadoop product ecosystem.

When I speak to people who work with Hadoop, they say that their deployments are usually pretty modest: about 20 machines, give or take. It may account for the fact that most companies are still in the technology adoption phase evaluating this Big Data platform and with time the number of machines in their Hadoop clusters would probably grow into 3- or even 4-digit ranges.

Development on Hadoop is becoming more agile with shorter execution cycles — Apache Tez, Cloudera’s Impala, Databricks’ Spark are some of the technologies that aid in the process along the way.

Read the rest of this entry »

No Comments

Java Courses Being Updated to Java 8

UPDATE – In order to provide clients a choice on which Java version they would like training on, we are releasing new course codes for Java 8.  Our current course codes will stay at Java 7 for those that need that version.

At Web Age Solutions it is important for us to make sure we are offering training that is relevant and appropriate for you.  Even though Java SE 8 was released some time ago, clients have taken a while to start using it since most Java environments they ran applications in had not yet added Java 8 support.  With the latest versions of all major Java EE application servers offering some type of Java 8 support that dynamic has changed.

We are updating our primary Java training courses to add Java 8 coverage.  The primary courses being updated are:

WA2494 Introduction to Java 8 Using Eclipse

WA2509 Advanced Java 8 Using Eclipse

The following courses will remain available using Java SE 7 for clients that need this version.

WA1278 Introduction to Java Using Eclipse

WA1449 Advanced Java using Eclipse

Since we know that there are also lots of Java programmers that do not need to take a “standard” course but simply need to learn what the changes are with this new version, we are also releasing a new course that covers the most recent changes.  This course covers the major changes of Java 8 that will have a significant impact on a wide range of Java applications in addition to a few important Java 7 features that are well known.

WA2493 What’s New in Java 8

So what is new in Java 8?  Will it impact your applications?  Java 8 is one of the most significant updates to Java in some time.  After Oracle bought out Sun, Java 6 was around for quite a while.  Oracle decided to release the "easy stuff" in Java 7 while working on some of the more significant changes for Java 8.

While the following is not an exhaustive list of Java 8 changes (you can go here for that) the following are some of the major features that are likely to impact a large cross-section of Java applications.

  • Lambda Expressions – This is by far the most impactful change in Java 8.  A “Lambda Expression” allows for the definition of an anonymous function that can be used as an object, for example being passed as a method parameter.  Besides simplifying code by replacing many usages of anonymous classes, a wide range of features are available as the rest of the Java platform was examined to use Lambda expressions where they made sense.
  • Collections Stream API – One place where Lambda expressions is leveraged is the Collections “Stream API”.  This lets you perform aggregate operations on a collection of objects.  For example, you might want to search through a set of CustomerProfile objects for all of the ones in a certain zip code and age range.
  • New Date/Time API – Although Java has always had the concept of ‘Date’ to represent a moment in time, many date and time related operations have been difficult.  Even answering the simple question “What was the date of the first Monday in November last year?” would be very complex.  The addition of the Date/Time API in Java 8 is meant to provide standard tools for these kinds of use cases.  This has long been a need in Java and now you won’t need third party libraries to address this need.
  • Concurrency changes – Although Java concurrency is not new, Java 5 and Java 7 introduced significant features in this area.  Java 8 continues to expand this area of Java programming, of particular importance since the impact of efficiently using multiple CPU processors, for example, can realize a significant improvement in performance.
  • Default methods – Currently, if you want to change the API of an interface, any implementing class is forced to implement the new functionality.  With Java 8 “default methods” you can add a new method to an interface along with a “default” implementation.  This implementation would be used for older classes that implement the interface but do not provide a unique implementation of the new method.  This could help you add new functionality to systems while minimizing the impact on existing, and already proven, libraries.

As I mentioned this is nowhere near absolutely all of the new changes in Java 8 but certainly most of the most significant. 

Besides the above courses that are being updated and released, we will also soon have a webinar that covers some of these changes as well.  Keep an eye on our webinar page for when that is scheduled.

No Comments