Taswar Bhatti
The synonyms of software simplicity
lg-p500-optimus-one

So Koodoo is having a deal on android phone LG Optimus One LGP500H and I couldnt resist and picked one up and unlocked it and wanted to start development on it. So here are some steps on LG Optimus One LGP500H installing usb driver.

So my first step is to get the USB driver working on my win7 machine.
I went to LG and downloaded their Mobile Support Tool to PC from http://www.lg.com/ca_en/support/product/support-product-profile-mobile-redux.jsp?customerModelCode=LGP500H&initialTab=drivers&targetPage=support-product-profile-mobile-redux

Once downloaded I launched the app.
Here is a step by step instructions of it.

One has to click on the Install USB Driver (yeah I know it looks grey out but one can click on it)

Next select the model of your phone and double click, which is LGP500H for us.

Then it will launch the install of the driver and select English

Click Next

And you will next see that the install is successful.

Now you can plug in your phone and it should try to update it but since its update to date there is nothing to install optionally one can install the mobile sync app and manual.

Hope this helps 🙂

automapper

In this last part of the series I wanted to talk about how to register automapper at startup of your web application, in doing so it would help speed things up with automapper.

There are many ways to do it, the easiest way is to just have a method inside Global.asax.cs file in your Application_Start like below

And if you are using an IoC container, than one can use the Command Pattern for a StartupTask, below is an example of using ServiceLocator for startup.

Note: one will need to remove all the CreateMap code in their controller to here, you do not need to call CreateMap anymore since the startup task takes care of it.

This concludes our final segment on Automapper, hopefully you will find this helpful 😛

Previous Post:
Part 1 (NullSubsitution)
Part 2 (Flattening by Convention)
Part 3 (Nested Mapping)
Part 4 (Projection)
Part 5 (CustomResolver)
Part 6 (CustomFormatter)

automapper

In this part I will show how we can use a customer value formatter (CustomFormatter) to format our mapped data into single “Number of Order:” and plural “Number of Orders:”.

First the Domain and Dto (data transfer object)

Now we will introduce a CustomResolver and Formatter, for the Formatter we are inheriting from IValueFormatter

For our mapping code we will use a block for options, so that after resolving the value, it would format it.

From the view we can see that the first order is displaying Order rather than Orders.

In the last part of the series I will show how to move all your mapping code to startup, so that it would speed things up.

Previous Post
Part 1 (NullSubsitution)
Part 2 (Flattening by Convention)
Part 3 (Nested Mapping)
Part 4 (Projection)
Part 5 (CustomResolver)

automapper

In Part 5, we will use a powerful feature that automapper allows us, which is CustomResolver.

Lets look at our Domain Object which contains a boolean field called ShipToHomeAddress, what we will do is map those boolean to a string value with “Yes” or “No”.

For our mapping code we will introduce CustomResolver class which inherits from ValueResolver and would map the boolean field to string

Now our mapping code would look like

The end result of the view looks like

In Part6, I will show how to use a CustomerFormatter with a Resolver to format the data in a certain way.

Previous Post:
Part 1 (NullSubsitution)
Part 2 (Flattening by Convention)
Part 3 (Nested Mapping)
Part 4 (Projection)

automapper

In Part 4 we will see how we can use projection to map inner objects for example a DateTime field.

Again our domain and Dto (Data Transfer Object) looks like

We will map the PurchaseDate in the Domain Object to our Dto PurchaseHour and Purchase Minute.

As you can see the View now contains the flatten Hour and Minute, from our previous posting we also see that the other way of nested projection/flattening is by CustomerName.

Here is how our view would display

In part 5, I will show how to use CustomerResolver to resolve and map values to different types.

Previous Post:
Part 1 (NullSubsitution)
Part 2 (Flattening by Convention)
Part 3 (Nested Mapping)

automapper

In this part we learn about Nested Mapping in Automapper and we will use the same OrderDto Object that we had previously but we will let Automapper to map the inner objects.

Once again here is the Domain Objects First

The Dto (Data Transfer Object) look like

This time when we map Order to OrderDto we will also provide the mapping of OrderItems to OrderItemsDto.

As you can see I have taught automapper about its inner child/object mapping before calling Map, thus it knows about the inner mapping, our result would show like

In the next part I will be showing projection in Automapper.

Previous Post:
Part 1 NullSubsitution
Part 2 Flattening by Convention

automapper

In this part I will be showing how Automapper uses flattening by convention.

If we look at our OrderDto we will see that it has a IEnumerable of OrderItemsDto and also something called OrderNumber. This is the type of object we want to send to our presentation layer.

Compare that to our domain object where it has a GetTotal method, OrderNo and a Customer Object

In Automapper there is a convention where it sees the method has a Get in front it. It will then auto flatten it by convention. See how in the OrderDto I have Total as a property and also CustomerName.

Our mapping code would look something like this where we are mapping OrderNo to OrderNumber

With this mapping will not get the inner mapping of OrderItems since we have told Automapper to Ignore those guys don’t map the OrderItems, as it stands OrderItemsDto would be null

This would produce a view looking like

As you can see Automapper automatically has pulled out GetTotal and populated Total Property and so is Customer object with GetName method with CustomerName. By using these simple conventions it automatically does the work for you without explicitly specifying it.

In next part we will talk about Nested mapping.

Previous Post:
Part 1 Null Subsitution

automapper

Recently I gave a talk on Automapper in Ottawa .Net Community, so I though I would post the main ideas of the presentation here also.

The demo was based on an Order System where there were just 3 tables/classes, “Order”, “Customer” and “OrderItems”

Object diagram

From the diagram we can see that a Customer has a Bio and if we pull out all the customer from a repository and display it, we may have some of them whom are missing the Bio.

Here is the code of how we are mapping our domain objects to a Dto or ViewModel, we are basically just passing the data to the View to render

Now lets say you want to replace the Null Bio with something like “N/A”, some people may go directly to the razor view code and add that but we can do better with automapper, we can tell automapper that when there is a Null just substitute (i.e NullSubsitution) it with something else, our code would then look like

In doing so we will use the same View but now we have “N/A” for “Uncle Leo” bio.

In part2 we will be talking about how to flatten objects by convention.

TEAM

Here are some recommendations to any team lead or development manager to have effective agile teams.

Note: these are just recommendations

  1. Get a white board for your Kanban or Scrum task and stick iteration tasks on the board publicly not in your office or cubicle
  2. Get every developer 2 monitors, that includes the QA since they should be part of your team. For team lead get them 3. One for monitoring the build or Nabaztag build bunny. Hold people accountable for breaking daily builds (buy donuts, pay a dollar into the pool for pizza, etc)
  3. Every developer machine should have 16G of ram or min 8G, anything less is unacceptable.
  4. Use a source control, bug tracker, and continuous build/integration
  5. Get a Powerful Build machine, install TeamCity or Hudson or CruiseControl or get TFS build agent running, or use the cloud to build.
  6. Get tools like Reflector, Resharper or CodeRush, Test Driver .Net, Code Coverage (dotCover, NCover) and “teach, guide” them how to use it effectively, shortcuts etc
  7. Get a wiki up and running for documentation of how to’s (local build, server build, etc )
  8. Teach the team proper unit testing, whichever framework you choose (NUnit, MbUnit, etc etc)
  9. Teach them mocking, whichever framework you choose (Rhino Mocks, Typemock Isolator, Moq, JustMock, etc) pick one and stick to it
  10. Teach the entire team how to debug effectively, using your IDE, teach them what pdb files are and how to remote debug if in .NET world, if you are in Java teach them how to debug a JVM, in Ruby just have them write unit test 🙂
  11. Have the entire team know about your build and document it on a wiki, don’t just have one person who is the build master due to the bus factor (If build master gets hit by a bus tomorrow who can take over the build?)
  12. Have only max 15 minutes daily stand-ups with format of “What I worked on yesterday, What I am working on today, and are there any impediments.”, there should be no sitting or resting or leaning on an object/wall. If there are extra things that come up, have those people with the team lead meet after the stand-up to resolve those issues.
  13. Provide an area for collaboration, pair programming
  14. Have a code clean up iteration for the team don’t just keep pushing features out. Let the team clean up the mess they have created.
  15. Use a runtime analyzer to see what features users are using, tools like Gibraltar or Runtime Intelligent Service definitely helps, or if you are cheap log things into a logging database with NLog or Log4Net.
  16. Automated! Automated! Automated!, builds, unit test, regression testing, performance testing, everyday there should be reports on what has build, passed and failed.
  17. Provide a learning atmosphere for the team have them showcase some technology, what they have learned, or create knowledge transfer brown bag lunches.
  18. Last but not least make it a fun learning environment for everyone involved, celebrate whenever milestones are reached, take the team out to eat to build trust. (There is something about breaking bread with someone, it builds trust.)

By the end you will have an Agile team that looks like the A Team 🙂

(hidden link in image)

javascript patterns

Over the holidays I read Javascript Patterns by Stoyan Stefanov.
Its a pretty light book consisting only of 240 pages, which is light in computer reading, where majority of the books are like yellow pages phone book over 1000 pages. It was quite enjoyable to have a concise book written by Stefanov, another highly recommended book is his Object Oriented Javascript.

Anywayz here is the low down.

Chapter 1. Introduction
This chapter is more of an introduction of using firebug (console.log), jslint, object orientation and prototypes in javascript.

Chapter 2 Essentials
This chapter talks about styles and coding standards, a must read for anyone doing javascript, patterns consisting of the single var variable and minimizing global variables, commenting code, api’s etc

Chapter 3 Literals and Constructors
Its about object literal notation, constructors functions using new, array notations, json, regular expressions and build in types e.g Error consturctor.

Chapter 4 Functions
Contains an indepth use of functions in javascript as first class objects, topics covered were API Patterns (Callback, Configuration objects, returning functions and currying), Initialization patterns (immediate functions, immediate object initalization, init-time branching) and last Performance patterns (Memorization and self-defining functions)

Chapter 5 Object Creation Patterns
One learns about the namespacing pattens, declaring dependencies, private, privileged method. The module patterns, sandbox pattern and last the object constants, static methods, chaining and lastly the method() method.

Chapter 6 Code Reuse Patterns
This chapter talks about inheritance by using borrowing methods, copying properties and mixin in javascript, it also covers classical inheritance but how there are more elegant ways in javascript rather than using the classical way.

Chapter 7 Design Patterns
This chapter goes through 9 GoF patterns and how to implement them in javascript namely Singleton, Factory, Iterator, Decorator, Strategy, Facade, Mediator, Proxy and lastly Observer. The author goes about to show how one can create these patterns in javascript in various ways, it takes a different mind set then the GoF book since javascript is dynamic and functions are first class (GoF was C++ examples in static languagues), if you are a GoF head u should read this chapter.

Chapter 8 DOM and Browser Patterns
The last chapter talks about using javascript in the browser, the author uses mostly YUI, although most of the things covered are already in jquery built in, I wish he covered more on jquery but ohh well. The bonus is he talks about loading javascript how to lazy load script tags and using setTimeOut for long running operations.

Conclusion
All in all I would definitely recommend this book, its not really a beginner book but if you are doing javascript its a definite read.

As I was writing this and finishing up the blog I also saw elegant code has posted a very good review of this books on their blog.

UA-4524639-2