Friday Project–Request CV Series Part One

Hire Ravi Lodhiya for your next project

Right Folks!

I am creating a demonstration how I start or work in the greenfield project and build something very agile way to produce some valuable resource which generate an attention for the stack holders.

Now  I wanted to build something every week and release it and prove, If I could able to do it that means Scrum XP and single resource and most importantly show my portfolio which others may have not done before. Even I haven’t done this before but we will see.  


How to solve a seating arrangement in Airline–Part 2

Now continue to this project I have created a simple logic which allow to arrange a optimal points without panelising to split any combination or altered a consecutive arrangement as much as possible.

For that I have break down rows in group of 2. Let’s say 2 rows each rows has 6 seats and maximum number of allocation is 12. now we know by given fact that following combinations are possible:

  • 12 bookings which contains 1 ticket per booking.
  • 6 bookings which contains 2 ticket per booking.
  • 4 bookings which contains 3 tickets.
  • 3 bookings which contains 4 tickets.
  • 2 bookings which contains 5 tickets and 1 booking contains 2 tickets.
  • 2 bookings which contains 6 tickets per booking.
  • Now we know by rules if we have 2 booking of 6 tickets each than we have an optimal results which is far away from reality in the bookings. But at least it will give us a clue about the probability  of make a possible pair of tickets or combinations of various positions.
  • Suppose for example we have only 12 seats in other word 2 rows:
  • and we have bookings of 5 tickets, 4 tickets and 3 tickets respectively.

So here are following optimal arrangement


Which will generate around  (5 consecutive tickets = +2), for 3 tickets +1 but 4 tickets split therefore its –1 thus +2+1-1 = +2

but if we prioritise group of 4 first then we can have optimal value as given below


This will generate (+2 for 4 tickets, +1 for 5 tickets, +1 for 3 tickets), thus it has possibly 4 optimal points to gather.

So here we got a rough idea what are we dealing with. Obviously in logic terms we are still far far away from any coding at all. But that was the first condition for the challenge no need of any computer programming but simple logic of arrangement and make a common sense out of the arrangement.  

Next time I will go through combination of 2s and 3s and possible mix match of each with more and more rows, or may be lets keep it simple to 5 rows to generate an algorithm which give best optimal values from the various combinations.

Power of Google Analytics

I am so amazed by the statistics gathered by GA (Google Analytics). Recently I have set up my online resume and it gave me more insightful information about the location and new and returning users, which helps me to build something that useful.


It is good to see results which is working for you. I am really impress by the tracking yet so simple to use. Here I have attached some of the proof and still learning new skills to measure my sites coverage.

How to solve a seating arrangement in Airline – Part 1

As a software developer, I have been given many challenges or problems to solve and in fact, I love to get involved.

Here is problem statement:

The reputed airline named HardJet has announced that they are facing a criticism on deliberate efforts to allocate seats for their customers and more and more customer dissatisfaction fuelling to join  Hynair their biggest rivals thus HardJet has decided to reward on those who can help them to solve this puzzle.

First of all, this problem does not need any computer program or anything that generate complexity so first it should be just on paper mostly theory and general mathematics.

So my first approach was to research capacity of an aircraft and for example : according to this around 156 seats capacity. and 29 rows and each row has  2 sets of seats – 3 on each sides.  Thus, the best way to identify the problem of arrangement is to give best (optimal) arrangement positive points and  worst(minimum) arrangement negative points based on following criteria:

  • If booking has a single ticket than – window seat, aisle, or middle seat no points counted ( 0 point).
  • If booking has couple or pair (tickets) than if it has window seat or aisle seat (+1) (1window, 1middle or 1 middle 1 aisle), if same row and two aisle seat than 0. if split than –1.
  • If booking has three tickets booked than same side (+1) if same row but split in 2 (I.e. 2 aisles 1 middle) but consecutive seats then 0 otherwise again split to next row –1, if split all 3 tickets –3, if split in two groups –2.
  • If booking has four tickets than same row consecutive seats +2(however 1 windows 2 aisle 1 middle). if 2 windows and 2 middle than 1 point. if split different rows than –1, if all 4 seats are separated than –4. if two seats non consecutive than –2, any other possible non consecutive combination than  –1. 
  • If booking has five tickets than if same consecutive seats in same row +2 (2 windows, 2 middle and 1 aisle or 1 window 2 middle, 2 aisles). any split but follow couple and group of three still +1, any split non consecutive than per seat –1 , –2 , –3, –4 panelise.
  • If booking has Six tickets than if same consecutive seats in same row +3 (same row) if split to next row but same side (+2) split to next row other side (+1) any other combination with splits –2 and –4 points to consider.

Now from given rules we know that the best optimal combination is 29 bookings required each booking has 6 tickets which scores 87 (29 x 3 = 87) which I think is extreme case. But however for optimal value for each flight arrangement I am creating an algorithm which generate the optimal arrangement with calculated points and stored in the learning engine so that later best combination can be provided. I know it is quite a challenge to achieve but I think assuming that when you reach to a checkout you know that you will received best possible combination of seat, So far I haven’t add any other complexity such as let 50% seats to be filled by arrangement (which is completely different ball game).


Now this is just a beginning, I will keep posting this with my progress with this I know it is not that easy but with right mind-set and possibly knowledge how to build something which helpful to many. It is possible.

Airlines probed over ‘confusing’ seating policy

How software developer fails in two way

Software developer we are fail

As a software developers, we fail in two ways: we build the thing wrong, or we build the wrong thing. 

– Steve Smith

I was revising my knowledge on DDD(Domain Driven Development Not Developers Developers Developers ) and how I enlighten by few of my work starting from Unit Testing to Test Driven Development to Behaviour Driven Development and incorporate with Domain Driven Development. I think knowledge and know how helped me a lot but still sometime I felt doing too much of learning is not worth until you utilise your talent and find out its application and apply in a real life not for just fun but keep stack and build better software and application and solve some great problems of actual business complexity with great enthusiasm.

How long will it take to build a Personal CV site?

Recently I have set a challenge for myself. How long will it take to build a site from scratch and deploy completely. I thought it would be nice and easy 8 hours task but apparently my estimate was dead on the spot. 

So Let me go through the time line and explain you my estimation :

Task Description Estimated Time in Hours Actual Time in Hours
Story board my CV 1.0 1.0
Build a theme 1.5 1.75
Google Analytics setup 0.5 0.25
Keyword research 0.5 0.25
Get and validate external links 0.5 0.25
Generate Animation and Mobile first Screen 1.00 1.00
Get Feedback 1.00 0.75
Signup recaptcha and configure 0.5 0.5
Deploy on server 1.0 0.75
Release and write article 0.50 1.00

Now what is the proof.

Let me show you my proof.  Just visit the site and give your feedback. Love to hear that. Just feeling Awesome…. and awesomeness…….


Practical Implementation of in-memory Repository Patterns

Recently I have been given a task to demonstrate my key knowledge on OOP and Design Patterns and its practical implementation.

The Task

Create an in memory implementation of IRepository<T>

Hints:The solution should be developed in a Test Driven approach, we expect the code you write to have excellent unit test coverage.Keep the solution simple, we value simple architecture and SOLID principles, but we’re not looking for over engineered design.The code should be self-explanatory, documentation should not be required to understand the code.

I have create a solution for that but prior to that I would like to explain what is repository pattern and explain it in my own words and how I implemented by describing my thoughts.

Repository Pattern: what is it?

Repository pattern is a pattern for data access. This is a common design pattern inside of applications that need to perform data access.

Why do we use the Repository Pattern?

Because most of applications do need to access data from some Data source or perhaps multiple data sources, and for that we need to use data access code throughout Business Logic or Domain Model. It is true that data access code typically is very repetitive and it’s concerned with low-level infrastructure details such as opening SQL connection and managing parameters etc.

This pattern will help us to separate the data access code from business logic and increase the testability of an application without real data in the place. and we can simulate data access in unit tests and have a component that works with in-memory data instead of web service or against any database schema.This allows us to unit test to be very repeatable, very low friction and not much effort to set up and it has quick feedback cycle.

So Let us crack on.

A Repository is going to be a class that you build for your application and it’s going to exist somewhere between the Business Logic and the Data Source of your application. You might have multiple repositories inside of an application. You might have a repository for each type of entity that you need to store.

Here we have been given an opportunity to create a solution for in-memory Generic IRepository Implementation which allows us to Save, Delete, Retrieve all or Find data by Id. Because it is generic in nature it can be easily implemented for any other entities.  Likewise here we are talking very specific implementation for IStoreable which has a Property of IComparable. (You must have knowledge of how IComparable works and implements and further details can be found here


So let us get back to our original given problem statement:

Following interfaces has been given and we have to implement the concrete class for them.

The first file is IStoreable.cs as given below:

   1: using System;


   3: namespace RamInfosystems.Interview

   4: {

   5:     public interface IStoreable

   6:     {

   7:         IComparable Id { get; set; }

   8:     }


  10: }

Now next file is IRepository.cs as given below:

   1: using System;

   2: using System.Collections.Generic;


   4: namespace RamInfosystems.Interview

   5: {

   6:     // Please create an in memory implementation of IRepository<T> 


   8:     public interface IRepository<T> where T : IStoreable

   9:     {

  10:         IEnumerable<T> All();

  11:         void Delete(IComparable id);

  12:         void Save(T item);

  13:         T FindById(IComparable id);

  14:     }

  15: }


And we need to create some test in Unit Test file.

My approach to solve this is by applying Test first. Clearly here the implementation of an interface is generic type and has constraints of type Interface. And this will harness the element which we can compare and test against it. So far nothing unusual.

So when you implement the IRepository Class you also need to implement  IStoreable as well. Which I think first you need to figure it out what need to be achieved.

   1: public class TestStoreable : IStoreable

   2:     {

   3:         public string Name { get; set; }

   4:         public IComparable Id { get; set; }

   5:     }


So what we need to do here is Implement the IRepository interface and its 4 of Methods as such All, FindByID, Delete and Save. It was pretty obvious that implementation is a key for the each of operation required to be tested. I have to add a property call Name as string to attach.

I started with unit test and create my first test method named Test_Repository_List_Returns_IEnumberable_CorrectType as follows:

   1: [Test]

   2: public void Test_Repository_List_Returns_IEnumberable_CorrectType()

   3: {

   4:   repository = new Repository<TestStoreable>();

   5:   this.expected = repository.All();

   6:   Assert.IsInstanceOf<IEnumerable<TestStoreable>>(expected);

   7: }

Small explanation about the long name. I intend to do readable code as needed and what  my code does is reflect by its name for example test repository list returns when IEnumberable with correct type.

But I don’t have any implementation of Repository or any implementation of All(). Let’s implement it as below:

   1: using System;

   2: using System.Collections.Generic;

   3: using System.Linq;

   4: using System.Text;


   6: namespace RamInfosystems.Interview

   7: {

   8:     public class Repository<T> : IRepository<T> where T : IStoreable

   9:     {

  10:         private List<T> entities;


  12:         public Repository()

  13:         {

  14:             entities = new List<T>();

  15:         }


  17:         public IEnumerable<T> All()

  18:         {

  19:             return entities;

  20:         }

  21:         ///Not fully implemented. 


  23:     }

  24: }

so when we call repository.All() it expected to be IEnumberable of generic type and List<T> is a same of the type.  Trick here is a concrete implementation of IStoreable gives us a opportunity to test all() method’s implementation.

Further on Delete(IComparable id) and Save(T item) implementation also based on the writing test first approach, Arrange, Act and Assert is cycle for TDD and I follow the same.

   1: [Test]

   2: public void Test_Repository_Save_AddNewItem()

   3: {

   4:    repository = new Repository<TestStoreable>();

   5:    newItemToBeSaved = new TestStoreable { Id = 1, Name = "ItemToBeSaved" };

   6:    repository.Save(newItemToBeSaved);

   7:    expected = repository.All();

   8:    Assert.IsTrue(((IEnumerable<TestStoreable>)expected).Contains(newItemToBeSaved));

   9: }


  11: [Test]

  12: public void Test_Repository_Delete_An_Existing_Item()

  13: {

  14:    repository = new Repository<TestStoreable>();

  15:    anExistingItem = new TestStoreable { Id = 1, Name = "AnExistingItemToBeDeleted" };


  17:    repository.Save(anExistingItem);

  18:    repository.Delete(1);

  19:    expected = repository.All();


  21:    Assert.IsFalse(((IEnumerable<TestStoreable>)expected).Contains(anExistingItem));

  22: }


Now it is obvious for method Delete we are providing an ID (which is IComparable) and which leads to additional method to create as it requires Predicate of its type and we can fetch through the Id by lambda expression  as follows

   1: private Predicate<T> MatchedId(IComparable id)

   2: {

   3:   return match => match.Id.Equals(id);

   4: }


Alright. so it help to find an Id which provided in the Delete method. Also it add an advantage to avoid a duplicate id in the Save operation shown as follows

   1: public void Save(T item)

   2: {

   3:    Delete(item.Id); // Avoid Duplicate

   4:    entities.Add(item);

   5: }


Here it might get tricky as Lazy evaluation of Find as we are passing IComparable Id which lead us to do certain things.  

   1: [Test]

   2: public void Test_Repository_Find_By_Id()

   3: {

   4:     repository = new Repository<TestStoreable>();

   5:     someItem = new TestStoreable { Id = 2, Name = "SomeItem" };

   6:     anExistingItem = new TestStoreable { Id = 1, Name = "ExistingItem" };

   7:     newItemToBeSaved = new TestStoreable { Id = 3, Name = "NewItemToBeSaved" };

   8:     repository.Save(someItem);

   9:     repository.Save(anExistingItem);

  10:     repository.Save(newItemToBeSaved);


  12:     expected = repository.FindById(2);


  14:     Assert.AreEqual(someItem, expected);

  15: }

And finally Implementation of FindById.

   1: public T FindById(IComparable id)

   2: {

   3:     return entities.Find(MatchedId(id));

   4: }


This will harness all the uses of Predicates and Generic list to find and match equal ids. This technique will help to enhance in-memory sorting and searching very quickly. However I haven’t included any stress-test to generate let us say 100 Million records and measure performance against the memory load or anything as it was out of scope for me at this stage. But Later I am thinking to write a separate article for it.  

I have tried to implement and develop this task using my ability to provide demonstration about how to implement the Repository Pattern for in-memory. 


There are a couple consequences to using the Repository Design Pattern. First, you should have an increased level of abstraction inside your application. This is good because it should mean that you’ll have less duplicated code. It also means that you should have code that’s more maintainable, more flexible, and more testable, however, you do have some additional interfaces, some additional classes, some people who are not familiar with the design pattern might need to look at this and figure out exactly what’s going on before they can catch on. When you have data access logic buried right inside of your business code, sometimes it’s very easy to look at that and understand what’s going on, but it just doesn’t scale up well, and in complex applications, you really need this increased level of abstraction just to manage the complexity. Another consequence of the Repository Design Pattern is that you are one step further away from the data. Since the Repository is shielding you from the underlying infrastructure, sometimes it can also be more difficult to get hints into that infrastructure that can help it optimize some of the operations that it needs to perform against the Data Source.


Here I tried to explain the Repository Design Pattern and how we can use it to keep Business Logic and Domain Model free of data access code and away from infrastructure code and actual components that talk to the database.

Using the Repository Pattern, I was able to write more maintainable code and easily unit test code. And  I showed a specific example that implemented a generic repository in C# code, the IRepository<T> interface. Using the magic of Generics, I was able to provide a single concrete implementation of this interface that covers most of our needs in an application.

If you are looking for a code or repository you can get it from code project and stack overflow as link given below:

Introduction First Video Post

Hi all, my name is Ravi Lodhiya and I am a Full stack developer, this is my first video post. I am looking for a Contract opportunity in the Microsoft Technologies stack. I am available immediately for an interview. Please email me your Job Specification. Thanks for watching. I hope to speak you soon. Bye.

Simple can be harder than complex

Simple Can be harder than complex

Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it’s worth it in the end because once you get there, you can move mountains.

-Steve Jobs

Motivation make my day.

Do you need a resource to complete IT project/s? Yes. Then call me now…

Every company needs resources. Resources to complete projects where budget has been already allocated.  Now problem is with very little unemployment in the UK, companies are struggling to get hold of good resources and workforces, people are moving getting better wages and of course Brexit on the horizon and it has started its negotiation process. Yet all of this uncertainty, projects need to be carried out and delivered constantly, Pressure is mounting to make financial targets on Project Managers and Teams.

In this tough time, few things happening to the existing projects either project needs to keep on hold or hire more resources, or delegating projects/workloads to offshore or inland third-party (if it is safe to do so.) and on the top budget is limited and time is burning quickly.

Hire Ravi Lodhiya as a contractor

With this in mind, and as an experienced IT Contractor (trying to be Freelancer) I have few things to offer in this crucial time:

  • I can come to rescue your projects or workload if you delegate me.
  • I can help you/your company to find resource for your troubled IT projects.
  • I can help you to motivate your team and engaging them to better perform.
  • I can be honest to assess your estimates for the project and add value to it.
  • I can bring your project on track and if your budget is tight then find alternative resources for that.
  • As an independent entity, I  can be more resourceful to your enterprise by more cost-effective and reliable, affordable and promising.  While you are searching with your current recruitment agency to fill the gap in your team, I can surely add value to your projects and keep balls rolling till you find right candidate as a permanent staff or may be help your trainees to come up to speed.

So if you have a project going on trouble due to  lack of resources or new greenfield project on the horizon but not able to prove by recruiters or want to get an idea about how much it is actually going to cost. Just email me your details via contact page here.

I usually turn around your projects quickly and we can build long-term relationship as it grow.

p.s.: I am not a recruiter or neither representing them. I am an independent contractor work as a limited company and try to rescue enterprises and deliver value to their projects by offering my ability.

So if you reading this and feel that it is better to contact me here for further discussion. Believe me you won’t be disappointed.