Introduction to Kotlin: Android Programming For Humans

In a perfect Android world, the main language of Java is really modern, clear, and elegant. You can write less by doing more, and whenever a new feature appears, developers can use it just by increasing version in Gradle. Then while creating a very nice app, it appears fully testable, extensible, and maintainable. Our activities are not too large and complicated, we can change data sources from database to web without tons of differences, and so on. Sounds great, right? Unfortunately, the Android world isn’t this ideal. Google is still striving for perfection, but we all know that ideal worlds don’t exist. Thus, we have to help ourselves in that great journey in the Android world.

Can Kotlin replace Java?

Kotlin is a popular new player in the Android world. But can it ever replace Java?

What Is Kotlin, and Why Should You Use It?

So, the first language. I think that Java isn’t the master of elegance or clarity, and it is neither modern nor expressive (and I’m guessing you agree). The disadvantage is that below Android N, we are still limited to Java 6 (including some small parts of Java 7). Developers can also attach RetroLambda to use lambda expressions in their code, which is very useful while using RxJava. Above Android N, we can use some of Java 8’s new functionalities, but it’s still that old, heavy Java. Very often I hear Android developers say “I wish Android supported a nicer language, like iOS does with Swift”. And what if I told you that you can use a very nice, simple language, with null safety, lambdas, and many other nice new features? Welcome to Kotlin.

What is Kotlin?

Kotlin is a new language (sometimes referred to as Swift for Android), developed by the JetBrains team, and is now in its 1.0.2 version. What makes it useful in Android development is that it compiles to JVM bytecode, and can be also compiled to JavaScript. It is fully compatible with Java, and Kotlin code can be simply converted to Java code and vice versa (there is a plugin from JetBrains). That means Kotlin can use any framework, library etc. written in Java. On Android, it integrates by Gradle. If you have an existing Android app and you want to implement a new feature in Kotlin without rewriting the whole app, just start writing in Kotlin, and it will work.

But what are the ‘great new features’? Let me list a few:

Optional and Named Function Parameters

fun createDate(day: Int, month: Int, year: Int, hour: Int = 0, minute: Int = 0, second: Int = 0) {
   print("TEST", "$day-$month-$year $hour:$minute:$second")
}

We Can Call Method createDate in Different Ways

createDate(1,2,2016) prints:  ‘1-2-2016 0:0:0’
createDate(1,2,2016, 12) prints: ‘1-2-2016 12:0:0’
createDate(1,2,2016, minute = 30) prints: ‘1-2-2016 0:30:0’

Null Safety

If a variable can be null, code will not compile unless we force them to make it. The following code will have an error – nullableVar may be null:

var nullableVar: String? = “”;
nullableVar.length;

To compile, we have to check if it’s not null:

if(nullableVar){
	nullableVar.length
}

Or, shorter:

nullableVar?.length

This way, if nullableVar is null, nothing happens. Otherwise, we can mark variable as not nullable, without a question mark after type:

var nonNullableVar: String = “”;
nonNullableVar.length;

This code compiles, and if we want to assign null to nonNullableVar, compiler will show an error.

There is also very useful Elvis operator:

var stringLength = nullableVar?.length ?: 0 

Then, when nullableVar is null (so nullableVar?.length returns null), stringLength will have value 0.

Mutable and Immutable Variables

In the example above, I use var when defining a variable. This is mutable, we can reassign it whenever we want. If we want that variable to be immutable (in many cases we should), we use val (as value, not variable):

val immutable: Int = 1

After that, the compiler will not allow us to reassign to immutable.

Lambdas

We all know what a lambda is, so here I will just show how we can use it in Kotlin:

button.setOnClickListener({ view -> Log.d("Kotlin","Click")})

Or if the function is the only or last argument:

button.setOnClickListener { Log.d("Kotlin","Click")}

Extensions

Extensions are a very helpful language feature, thanks to which we can “extend” existing classes, even when they are final or we don’t have access to their source code.

For example, to get a string value from edit text, instead of writing every time editText.text.toString() we can write the function:

fun EditText.textValue(): String{
   return text.toString()
}

Or shorter:

fun EditText.textValue() = text.toString()

And now, with every instance of EditText:

editText.textValue()

Or, we can add a property returning the same:

var EditText.textValue: String
   get() = text.toString()
   set(v) {setText(v)}

Operator Overloading

Sometimes useful if we want to add, multiply, or compare objects. Kotlin allows overloading of binary operators (plus, minus, plusAssign, range, etc.), array operators ( get, set, get range, set range), and equals and unary operations (+a, -a, etc.)

Data Class

How many lines of code do you need to implement a User class in Java with three properties: copy, equals, hashCode, and toString? In Kaotlin you need only one line:

data class User(val name: String, val surname: String, val age: Int)

This data class provides equals(), hashCode() and copy() methods, and also toString(), which prints User as:

User(name=John, surname=Doe, age=23)

Data classes also provide some other useful functions and properties, which you can see in Kotlin documentation.

Anko Extensions

You use Butterknife or Android extensions, don’t you? What if you don’t need to even use this library, and after declaring views in XML just use it from code by its ID (like with XAML in C#):

<Button
        android:id="@+id/loginBtn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
loginBtn.setOnClickListener{}

Kotlin has very useful Anko extensions, and with this you don’t need to tell your activity what is loginBtn, it knows it just by “importing” xml:

import kotlinx.android.synthetic.main.activity_main.*

There are many other useful things in Anko, including starting activities, showing toasts, and so on. This is not the main goal of Anko – it is designed for easily creating layouts from code. So if you need to create a layout programmatically, this is the best way.

This is only a short view of Kotlin. I recommend reading Antonio Leiva’s blog and his book – Kotlin for Android Developers, and of course the official Kotlin site.

What Is MVP and Why?

A nice, powerful, and clear language is not enough. It’s very easy to write messy apps with every language without good architecture. Android developers (mostly ones who are getting started, but also more advanced ones) often give Activity responsibility for everything around them. Activity (or Fragment, or other view) downloads data, sends to save, presents them, responds to user interactions, edits data, manages all child views . . . and often much more. It’s too much for such unstable objects like Activities or Fragments (it’s enough to rotate the screen and Activity says ‘Goodbye….’).

A very good idea is to isolate responsibilities from views and make them as stupid as possible. Views (Activities, Fragments, custom views, or whatever presents data on screen) should be only responsible for managing their subviews. Views should have presenters, who will communicate with model, and tell them what they should do. This, in short, is the Model-View-Presenter pattern (for me, it should be named Model-Presenter-View to show connections between layers).

MVC vs MVP

“Hey, I know something like that, and it’s called MVC!” – didn’t you think? No, MVP is not the same as MVC. In the MVC pattern, your view can communicate with model. While using MVP, you don’t allow any communication between these two layers – the only way View can communicate with Model is through Presenter. The only thing that View knows about Model can be the data structure. View knows how to, for example, display User, but doesn’t know when. Here’s a simple example:

View knows “I’m Activity, I have two EditTexts and one Button. When somebody clicks the button, I should tell it to my presenter, and pass him EditTexts’ values. And that’s all, I can sleep until next click or presenter tells me what to do.”

Presenter knows that somewhere is a View, and he knows what operations this View can perform. He also knows that when he receives two strings, he should create User from these two strings and send data to model to save, and if save is successful, tell the view ‘Show success info’.

Model just knows where data is, where they should be saved, and what operations should be performed on the data.

Applications written in MVP are easy to test, maintain, and reuse. A pure presenter should know nothing about the Android platform. It should be pure Java (or Kotlin, in our case) class. Thanks to this we can reuse our presenter in other projects. We can also easily write unit tests, testing separately Model, View and Presenter.

MVP pattern leads to better, less complex codebase by keeping user interface and business logic truly separate.

A little digression: MVP should be a part of Uncle Bob’s Clean Architecture to make applications even more flexible and nicely architectured. I’ll try to write about that next time.

Sample App with MVP and Kotlin

That’s enough theory, let’s see some code! Okay, let’s try to create a simple app. The main goal for this app is to create user. First screen will have two EditTexts (Name and Surname) and one Button (Save). After entering name and surname and clicking ‘Save’, the app should show ‘User is saved’ and go to the next screen, where saved name and surname is presented. When name or surname is empty, the app should not save user and show an error indicating what’s wrong.

The first thing after creating Android Studio project is to configure Kotlin. You should install Kotlin plugin, and, after restart, in Tools > Kotlin you can click ‘Configure Kotlin in Project’. IDE will add Kotlin dependencies to Gradle. If you have any existing code, you can easily convert it to Kotlin by (Ctrl+Shift+Alt+K or Code > Convert Java file to Kotlin). If something is wrong and the project does not compile, or Gradle does not see Kotlin, you can check code of the app available on GitHub.

Kotlin not only interoperates well with Java frameworks and libraries, it allows you to continue using most of the same tools that you are already familiar with.

Now that we have a project, let’s start by creating our first view – CreateUserView. This view should have the functionalities mentioned earlier, so we can write an interface for that:

interface CreateUserView : View {
   fun showEmptyNameError() /* show error when name is empty */
   fun showEmptySurnameError() /* show error when surname is empty */
   fun showUserSaved() /* show user saved info */
   fun showUserDetails(user: User) /* show user details */
}

As you can see, Kotlin is similar to Java in declaring functions. All of those are functions that return nothing, and the last have one parameter. This is the difference, parameter type comes after name. The View interface is not from Android – it’s our simple, empty interface:

interface View

Basic Presenter’s interface should have a property of View type, and at least on method (onDestroy for example), where this property will be set to null:

interface Presenter<T : View> {
   var view: T?

   fun onDestroy(){
       view = null
   }
}

Here you can see another Kotlin feature – you can declare properties in interfaces, and also implement methods there.

Our CreateUserView needs to communicate with CreateUserPresenter. The only additional function that this Presenter needs is saveUser with two string arguments:

interface CreateUserPresenter<T : View>: Presenter<T> {
   fun saveUser(name: String, surname: String)
}

We also need Model definition – it’s mentioned earlier data class:

data class User(val name: String, val surname: String)

After declaring all interfaces, we can start implementing.

CreateUserPresenter will be implemented in CreateUserPresenterImpl:

class CreateUserPresenterImpl(override var view: CreateUserView?): CreateUserPresenter<CreateUserView> {

   override fun saveUser(name: String, surname: String) {
   }
}

The first line, with class definition:

CreateUserPresenterImpl(override var view: CreateUserView?)

Is a constructor, we use it for assigning view property, defined in interface.

MainActivity, which is our CreateUserView implementation, needs a reference to CreateUserPresenter:

class MainActivity : AppCompatActivity(), CreateUserView {

   private val presenter: CreateUserPresenter<CreateUserView> by lazy {
       CreateUserPresenterImpl(this)
   }

   override fun onCreate(savedInstanceState: Bundle?) {
       super.onCreate(savedInstanceState)
       setContentView(R.layout.activity_main)

       saveUserBtn.setOnClickListener{
           presenter.saveUser(userName.textValue(), userSurname.textValue()) /*use of textValue() extension, mentioned earlier */


       }
   }

   override fun showEmptyNameError() {
       userName.error = getString(R.string.name_empty_error) /* it's equal to userName.setError() - Kotlin allows us to use property */

   }

   override fun showEmptySurnameError() {
       userSurname.error = getString(R.string.surname_empty_error)
   }

   override fun showUserSaved() {
       toast(R.string.user_saved) /* anko extension - equal to Toast.makeText(this, R.string.user_saved, Toast.LENGTH_LONG) */

   }

   override fun showUserDetails(user: User) {
      
   }

override fun onDestroy() {
   presenter.onDestroy()
}
}

At the beginning of the class, we defined our presenter:

private val presenter: CreateUserPresenter<CreateUserView> by lazy {
       CreateUserPresenterImpl(this)
}

It is defined as immutable (val), and is created by lazy delegate, which will be assigned the first time it is needed. Moreover, we are sure that it will not be null (no question mark after definition).

When the User clicks on the Save button, View sends information to Presenter with EditTexts values. When that happens, User should be saved, so we have to implement saveUser method in Presenter (and some of the Model’s functions):

override fun saveUser(name: String, surname: String) {
   val user = User(name, surname)
   when(UserValidator.validateUser(user)){
       UserError.EMPTY_NAME -> view?.showEmptyNameError()
       UserError.EMPTY_SURNAME -> view?.showEmptySurnameError()
       UserError.NO_ERROR -> {
           UserStore.saveUser(user)
view?.showUserSaved()
           view?.showUserDetails(user)
       }
   }
}

When a User is created, it is sent to UserValidator to check for validity. Then, according to the result of validation, proper method is called. The when() {} construct is same as switch/case in Java. But it is more powerful – Kotlin allows use of not only enum or int in ‘case’, but also ranges, strings or object types. It must contain all possibilities or have an else expression. Here, it covers all UserError values.

By using view?.showEmptyNameError() (with a question mark after view), we are protected from NullPointer. View can be nulled in onDestroy method, and with this construction, nothing will happen.

When a User model has no errors, it tells UserStore to save it, and then instruct View to show success and show details.

As mentioned earlier, we have to implement some model things:

enum class UserError {
   EMPTY_NAME,
   EMPTY_SURNAME,
   NO_ERROR
}

object UserStore {
   fun saveUser(user: User){
       //Save user somewhere: Database, SharedPreferences, send to web...
   }
}

object UserValidator {

   fun validateUser(user: User): UserError {
       with(user){
           if(name.isNullOrEmpty()) return UserError.EMPTY_NAME
           if(surname.isNullOrEmpty()) return UserError.EMPTY_SURNAME
       }

       return UserError.NO_ERROR
   }
}

The most interesting thing here is UserValidator. By using the object word, we can create a singleton class, with no worries about threads, private constructors and so on.

Next thing – in validateUser(user) method, there is with(user) {} expression. Code within such block is executed in context of object, passed in with name and surname are User’s properties.

There is also another little thing. All above code, from enum to UserValidator, definition is placed in one file (definition of User class is also here). Kotlin does not force you to have each public class in single file (or name class exactly as file). Thus, if you have some short pieces of related code (data classes, extensions, functions, constants – Kotlin doesn’t require class for function or constant), you can place it in one single file instead of spreading through all files in project.

When a user is saved, our app should display that. We need another View – it can be any Android view, custom View, Fragment or Activity. I chose Activity.

So, let’s define UserDetailsView interface. It can show user, but it should also show an error when user is not present:

interface UserDetailsView {
   fun showUserDetails(user: User)
   fun showNoUserError()
}

Next, UserDetailsPresenter. It should have a user property:

interface UserDetailsPresenter<T: View>: Presenter<T> {
   var user: User?
}

This interface will be implemented in UserDetailsPresenterImpl. It has to override user property. Every time this property is assigned, user should be refreshed on the view. We can use a property setter for this:

class UserDetailsPresenterImpl(override var view: UserDetailsView?): UserDetailsPresenter<UserDetailsView> {
   override var user: User? = null
       set(value) {
           field = value
           if(field != null){
               view?.showUserDetails(field!!)
           } else {
               view?.showNoUserError()
           }
       }

}

UserDetailsView implementation, UserDetailsActivity, is very simple. Just like before, we have a presenter object created by lazy loading. User to display should be passed via intent. There is one little problem with this for now, and we will solve it in a moment. When we have user from intent, View needs to assign it to their presenter. After that, user will be refreshed on the screen, or, if it is null, the error will appear (and activity will finish – but presenter doesn’t know about that):

class UserDetailsActivity: AppCompatActivity(), UserDetailsView {

   private val presenter: UserDetailsPresenter<UserDetailsView> by lazy {
       UserDetailsPresenterImpl(this)
   }

   override fun onCreate(savedInstanceState: Bundle?) {
       super.onCreate(savedInstanceState)
       setContentView(R.layout.activity_user_details)

       val user = intent.getParcelableExtra<User>(USER_KEY)
       presenter.user = user
   }

   override fun showUserDetails(user: User) {
       userFullName.text = "${user.name} ${user.surname}"
   }

   override fun showNoUserError() {
       toast(R.string.no_user_error)
       finish()
   }

override fun onDestroy() {
   presenter.onDestroy()
}

}

Passing objects via intents requires that this object implements Parcelable interface. This is very ‘dirty’ work. Personally, I hate doing this because of all of the CREATORs, properties, saving, restoring, and so on. Fortunately, there is proper plugin, Parcelable for Kotlin. After installing it, we can generate Parcelable just with one click.

The last thing to do is to implement showUserDetails(user: User) in our MainActivity:

override fun showUserDetails(user: User) {
   startActivity<UserDetailsActivity>(USER_KEY to user) /* anko extension - starts UserDetailsActivity and pass user as USER_KEY in intent */
}

And that’s all.

Demo Android app in Kotlin

We have a simple app that saves a User (actually, it is not saved, but we can add this functionality without touching presenter or view) and presents it on the screen. In the future, if we want to change the way user is presented on the screen, such as from two activities to two fragments in one activity, or two custom views, changes will be only in View classes. Of course, if we don’t change functionality or model’s structure. Presenter, who doesn’t know what exactly View is, won’t need any changes.

What’s Next?

In our app, Presenter is created every time an activity is created. This approach, or its opposite, if Presenter should persist across activity instances, is a subject of much discussion across the Internet. For me, it depends on the app, its needs, and the developer. Sometimes it’s better is to destroy presenter, sometimes not. If you decide to persist one, a very interesting technique is to use LoaderManager for that.

As mentioned before, MVP should be a part of Uncle Bob’s Clean architecture. Moreover, good developers should use Dagger to inject presenters dependencies to activities. It also helps maintain, test, and reuse code in future. Currently, Kotlin works very well with Dagger (before the official release it wasn’t so easy), and also with other helpful Android libraries.

Wrap Up

For me, Kotlin is a great language. It’s modern, clear, and expressive while still being developed by great people. And we can use any new release on any Android device and version. Whatever makes me angry at Java, Kotlin improves.

Of course, as I said nothing is ideal. Kotlin also have some disadvantages. The newest gradle plugin versions (mainly from alpha or beta) don’t work well with this language. Many people complain that build time is a bit longer than pure Java, and apks have some additional MB’s. But Android Studio and Gradle are still improving, and phones have more and more space for apps. That’s why I believe Kotlin can be a very nice language for every Android developer. Just give it a try, and share in the comments section below what you think.

Source code of the sample app is available on Github: github.com/tomaszczura/AndroidMVPKotlin

Original Post @ https://www.toptal.com/software/kotlin-android-language

Advertisements

Work Breakdown Tests

We think Test Driven Development is powerful and It can be used as a tool in a different way to get the distributed product development done.

So here is our experiment. This is how it will work. The idea is we will give you a set of Tests and you have to reply us with production source code by making the test pass. The problem statement will be from real world product.

So if you are interested than drop an email to confiablesolutions@gmail.com and we will share the Test file.

What’s in it for you?

That is a legit question, We are a firm believer in Agile methodology and Lean Principles.

We also believe that in today’s world of digital revolution we want to disrupt the most valuable assets of human being is TIME. Thus this initiative is to challenge your software development skills to solve this problem quickly and efficiently. Thus creating an alternative source of income without trading time for money.

Happy Coding!

Open Xml + Unable to create mutex

The error which took us a while to figure out to fix. As any mysterious error around this one also took a while to crack it. However the exception was IsolatedStorageException. We weren’t able to find the cause of the error.

Isolated Storage:  It is a disk location on server which is used when the processing of document size is bigger or a complex document structure, this was our interpretation. The definition says  “Isolated storage is a storage mechanism that provides isolation and safety by defining standardized ways of associating code with saved data.” You can find the details @ here

Then we got this stackoverflow link http://stackoverflow.com/questions/19465653/openxml-and-unable-to-create-mutex

We were not comfortable with accepted solution because It requires running IIS with elevated permissions which is a security weakness. May be we should have done further research on the Isolated storage and where the file location is created, however after going through the same link couple of weeks later we found another solution which mentioned something about to set Load User Profile to True. That solution worked for us.

Details on User Profile can be found here blogs.msdn.microsoft.com/vijaysk/2009/03/08/… and  iis.net/learn/manage/configuring-security/…

What we learned from this mistake is one has to go into the technical detail of an issue and read all available material related to  topic and do appropriate research before concluding the issue.

Technical Catalog

Teams which does IT Services, Application Development & Maintenance or Mobile development has one thing in common. They get stuck, hit a wall, a problem nags them. Often they come across research for a problems on unknown areas. We need to search about the topic, technical spec, domain, patterns and so on.

That’s where there are helps, forums, stack-overflow etc. The solution you get on internet will be generic. However if your software life cycle is more that one year and a you have a team working on it. Two thing will happen

  1. People will move in and out of the team.
  2. Software will keep evolving.

There will be small technical decision that will be every taken each day which will be specific to out software. which will be taken with the help of some reference link or help from internet. So on one kind of problem/issue the team will have to search all over again to get the background. The solution could be inside the code base, document wiki or over the internet. Below mentioned is a thought to take leverage of efforts already put by the team.

Technical Catalog: It is a simple list of reference links from internet, Small description specific to the software and reference in the software.

Problem Statement Solution Category
Sales report does not work in IE 8 http://someweb.url.com Reports

This will be help the team member starting to resolve any problem to check for the local catalog. which is created by the team with common purpose and goal. Thus helping them to get some initial inertia. Some time it help even the author because we don’t remember what we did six months ago when we stuck at the same problem.

 

 

Real experience of adding first sets of Tests to existing code base

I recently joined a team of very skilled and talented people. We wanted to put in Tests for an application which was running in production for quite some time. I cannot specify the details of the project but it had tens of thousands of line of code in it. It was developed in Microsoft Dot Net and SQL Server and a web application.

I would like to share some insight and recommendations:

  1. Long running tests and writing long dependency tests setups is the norm
  2. Adding technical debts in tests will be needed but keep it as clean as possible.
  3. Don’t worry of Unit Tests in the beginning. It will be lot harder to do it.(Add Integration tests, refactor code in smaller units, add unit tests later)
  4. Some types of test that will help you during this initial testing phase :
    1. Pinning Tests : http://c2.com/cgi/wiki?PinningTests
    2. Characterization Test : http://c2.com/cgi/wiki?CharacterizationTest

You must be thinking you already know all this stuff above. But the view point I want to share here is some real world numbers and facts. Firstly add  a automated code coverage to get the results of your tests with just one click. (a simple .bat file worked for me)

  1. I was working with the code for first time.
  2. It took me 16 hours to put in first 6 tests.
  3. These where clean, re factored and commit ready to Git.
  4. Code Coverage was 6% after 6 tests.
  5. When I added 5 more tests the code coverage was 15%
  6. Tests were covering different classes of different modules.

This stats may be controversial and its true that code coverage doesn’t signify that your code has 100% automated tests for all possible scenarios, However here are some reasons to go with it.

  1. It give some numbers to go for during initial stage of adding tests.
  2. It will help you to add test harness for different areas of applications.
  3. You can share reports with team and get feedback on what’s next.

Happy Coding!

Build Server Selection Influencing Factors Part 4

Read the third part of the series here.

Cruise Control .Net

How quick and easy it to get started?

Cruise control .Net is installed using windows installer. It is an open source project and has been around for quite a while now. It has a web dashboard displaying the configured projects and its details. The entire configuration is done via config file. It has an xml configuration. Since it is an open source product it is free use. Overall all the setup is easy but configuration is more manual.

Which source control system can be integrated out of the box?

Source Control Name Cruise Control .NET
AccuRev Yes
Alienbrain Yes
BitKeeper Yes
CA Software Change Manager No
ClearCase Yes
CMVC No
CVS Yes
Darcs No
Dimensions No
Git Yes
GNU arch No
GNU Bazaar No
Integrity Yes
Mercurial Yes
Perforce Yes
Plastic Yes
PVCS Yes
Sourceanywhere Yes
StarTeam Yes
Subversion Yes
Surround Yes
Synergy Yes
Team Concert No
Team Foundation Server Yes
Vault Yes
Visual SourceSafe Yes
Others File system, FTP, Robocopy

 

What about Test coverage?

Cruise Control .Net can be configured with MSTest, Nunit tests. Configurations is done using command line. Hence we have to be proficient with command line and Nant.

What is the medium of build result notification?

There is multiple notifications configuration in Cruise Control .Net. CCTray is known more commonly. CCTray is a system tray notification which gives an easy way to isolate all build related notification. CCTray can be used as notification center and it can be displayed on large screen or monitor for the development teams.

How easy can we find help to troubleshoot?

Cruise Control .Net is an open source project. It has a decent documentation. It is also used widely in the community so help can be found there too. So the major reliability is on community.

Summary on few other categories:

Name CruiseControl.NET
Platform Cross-platform
License BSD-style
Windows Builder MSBuild, NAnt, Visual Studio
Other builders Command Line
Notification E-mail, CCTray, RSS
IDE Integration Unknown
Other Integration Unknown

Conclusion:

Build Server for development team is definitely as good to have arsenal in your tool box. I can conclude two scenarios here:

  1. The first could be you are in a large organization with good Microsoft tools in hand like Visual Studio and Team Foundation Server. In this case you can take a call of having Team Foundation Build Server since it integrates well with the environment.
  2. Second could be a small team working for an open project with budgetary concerns on tools and need more customize options then going for Team City or CruiseControl.NET are a better option.

Hope this post helps you in your journey of Continuous Integration and Continuous Delivery.

Bibliography:

 

Build Server Selection Influencing Factors Part 3

Read the second part of the series here.

How quick and easy it to get started?

Team City is installed using windows installer. It needs java to be installed on the machine. Thus a web dashboard is used to configure a new build. The entire configuration is done by web dashboard. It has simple step by step configuration. It has both free and commercial version. For small teams and few projects free version works fine. Overall all the setup and configuration is easy.

Which source control system can be integrated out of the box?

Source Control Name Team City
AccuRev Yes
Alienbrain No
BitKeeper No
CA Software Change Manager No
ClearCase Yes
CMVC No
CVS Yes
Darcs No
Dimensions No
Git Yes
GNU arch No
GNU Bazaar No
Integrity No
Mercurial Yes
Perforce Yes
Plastic No
PVCS No
Sourceanywhere No
StarTeam Yes
Subversion Yes
Surround No
Synergy No
Team Concert No
Team Foundation Server Yes
Vault Yes
Visual SourceSafe Yes
Others

What about Test coverage?

Team City has out of the box configuration with MSTest, Nunit Tests. Configurations is done using web dashboard. The configuration is straight forward.

What is the medium of build result notification?

There is multiple notifications configuration in Team City. Email is one of them. It also has a system tray notification which gives an easy way to isolate all build related notification. Since the web dashboard also shows summary of builds. It can be displayed on large screen or monitor for the development teams.

How easy can we find help to troubleshoot?

Team city is a proprietary system of Jet brains. It has product specification documentation. The entire feature present in it is well documented. It is also used widely in the community so help can be found there too.

Summary on few other categories:

Category Team City
Platform Servlet Container
License Proprietary
Windows Builder MSBuild, NAnt, Visual Studio
Other builders Rake, FxCop, Command Line
Notification E-mail, XMPP, RSS, IDE, SysTray
IDE Integration Eclipse, Visual Studio, IntelliJ IDEA, RubyMine, PyCharm, PhpStorm, WebStorm
Other Integration Jetbrains Youtrack, JIRA, Bugzilla, FishEye, FindBugs, PMD, dotCover, NCover

Read about Cruise Control .Net here.

Build Server Selection Influencing Factors Part 2

Read the first part of the series here.

Team Foundation Build Server

How quick and easy it to get started?

Team Foundation Build Server has standard windows setup for build server. The installation needs administrative access and Team Foundation Server as a primary source control system. Configuration is done by build configuration wizard in Visual Studio. Configuration is starlight forward. Overall it the installation is quick and easy but tightly coupled with Microsoft Team Foundation Server and Visual studio.

Which source control system can be integrated out of the box?

Source Control Name Team Foundation Build Server
AccuRev No
Alienbrain No
BitKeeper No
CA Software Change Manager No
ClearCase No
CMVC No
CVS No
Darcs No
Dimensions No
Git Yes
GNU arch No
GNU Bazaar No
Integrity No
Mercurial No
Perforce No
Plastic No
PVCS No
Sourceanywhere No
StarTeam No
Subversion No
Surround No
Synergy No
Team Concert No
Team Foundation Server Yes
Vault No
Visual SourceSafe No
Others

 What about Test coverage?

Team Foundation Build Server has feature for configuring with Automatic Tests. Configurations are dependent on MS Build and command line. Hence we have to be proficient with command line tools and MS Build XML configuration.

What is the medium of build result notification?

The standard notification is email in Team Foundation Build Server. We can also add distribution list as an email for each pass and failed results. It also provides SOAP notifications.

How easy can we find help to troubleshoot?

Team Foundation Build Server is a proprietary system of Microsoft. It has product specification documentation. The entire feature present in it is well documented.

Summary on few other categories:

Category Team Foundation Build Server
Platform Windows, VSTM
License Proprietary
Windows Builder MSBuild
Other builders Custom script, Command line
Notification E-Mail, SOAP
IDE Integration Visual Studio, Eclipse
Other Integration Unknown

Read about Team City here.

Build Server Selection Influencing Factors Part 1

Build Server helps development team to do build automation. Build automation is the act of scripting or automating a wide variety of tasks that software developers do in their day-to-day activities including things like:

  1. Compiling computer source code into binary code
  2. Packaging binary code
  3. Running tests
  4. Deployment to production systems
  5. Creating documentation and/or release notes

Thus I felt it helps in following attributes of a project team:

  1. Increase Productivity
  2. Reduce development cost
  3. Increase development speed
  4. Reduce re-work
  5. Automate repeatable tasks.

In Microsoft Dot Net software development there are many Build server tools. Below mentioned are three tools on which I will do a comparative analysis:

  1. Team Foundation Build Server by Microsoft
  2. Team City by Jet brains
  3. Cruise Control .Net by Thought works

The objective of this paper is to make it easier for the development team to select the build server on Windows OS. This paper will help the team aware for the kind of questions to be asked before selections and the kind of trade off to be made during selection process. This paper is based on Dot Net platform & languages. It can be used for any other platforms or languages. We will try to classify them based on below mentioned Influencing questions.

  1. How quick and easy it to get started?
  2. Which source control system can be integrated out of the box?
  3. What about Test coverage?
  4. What is the medium of build result notification?
  5. How easy can we find help to troubleshoot?

In the future posts I will write about my findings on each tools. Read about Team Foundation Build Server here.

Bortosky google visualization Code update

You can find the library of Bortosky google visualization in here. As its home page states its a helper types to serialize System.Data.DataTable objects into Javascript Object Notation for use as a Google DataTable in the Google Visualization APIs.

When you go to one of its issue “JSON new Date output now fails parsing” solution provide by Sha…@babajob.com is correct but the source code mentioned in the download link is not updated with the fix.

So as mentioned in the fix please make below code changes in source code.

In file DateGoogleDataColumn.cs line 33

return string.Format("\"Date({0}, {1}, {2})\"",
 d.Year, d.Month - 1, d.Day);

In file DateTimeGoogleDataColumn.cs line 33

return string.Format("\"Date({0}, {1}, {2},
 {3}, {4}, {5})\"",
d.Year, d.Month - 1, d.Day,
 d.Hour, d.Minute, d.Second);

Enjoy Google Charts!