my understanding of using asynchronous in c#

Exception handling need to be in control of developer in the code. For that the developer should have clarity in which layer the exception need to be handled.

Handling means:

  1. logging the error/exception
  2. exit the whole program
  3. return from the method
  4. let exception to continue to bubble up
  5. throw some other exception

Without try/catch, it is difficult to debug the program while developing when asynchronous code used.

unnecessary looping

To write a JavaScript function to return the given object with given keys

  • pick({a: 1}, ['a']) gives {a: 1}.
  • pick({a: 1, b: 2}, ['b']) gives {b: 2}.
  • pick({a: 1, b: 2}, ['b', 'a']) gives {a: 1, b: 2}.

My solution

function pick(obj, keys) {
  const result = {};
  for (const key in obj) {
    for (const ik of keys) {
      if (key === ik) {
        result[key] = obj[key];
      }
    }
  }
  return result;
}

better solution

function pick(obj, keys) {
  const result = {};
  for (const key of keys) {
    result[key] = obj[key];
  }
  return result;
}

Used Concepts

Mortgagebot LOS

  1. Dynamic Scaffolding – Dynamic UI Whole Page. Entire page will construct at runtime – Stallion Framework (In House)
    1. Reflection
  2. XML Databinding – serializable classes to write xml from business Objects( or any objects). usually to read also. but in our project we don’t need it
  3. Data Access Layer – _________________ – Entity Framework
  4. Business Model –                                    –  CSLA 4  V4.5.30
  5.                             –  Presentation Layer – MVC and VB ASP.net
  6.                           –                                      –  WCF and Web Services
  7. Continuous Integration Builds from TFS
  8. List of Object Creation Techniques Used in Project
    1. Static Factory Method (Not Gang of Four FactoryMethod)
  9. Loging
    1. The uncaught exception is logged . How ? I think in global.asax application level event

Determine the winning amount

Let us assume betting game in which the outcome or result will be purely random.

In our hypothetical game, we have a black pot. There are three balls in the black pot. Red, Green, Blue.

Three players can play the game. Each player can bet on a ball or a combination of two balls.

So there are following possibilities to bet

  1. Red
  2. Green
  3. Blue
  4. Red & Green
  5. Red & Blue
  6. Green & Blue

Let X be the amount a player bet on Red.
You are the host who is conducting this game.
How will you determine an amount win by the player bet on red ball ?
And how will you determine the winning amount for six bets (Green, Red & Green,  etc..,)

Naming is hard

There are only two hard things in Computer Science: cache invalidation and naming things. – Phil Karlton

When discussing Property mechanism(a language feature of c#.net), I have encountered a basic question. I was saying ‘. .. the code will be used(or reused)  .. ‘. To confirm his interpretation my friend rephrase it as ‘so it is shared’.

I am bit stuck by encountering his words. I said in programming context we call it as “Code Reuse” and sharing has a different meaning in the context. Actually at first I couldn’t articulate it. He argued why can’t we use the word “sharing” until I explained.

Actually it is fundamental that there are terms which have some special meaning in some contexts.This reflects the fact that the Indian society lacks the culture of critical thinking and other knowledge movements.

This discussion triggers me to think about naming the functions, concepts, data in source code. Giving a meaningful name is really a challenge as stated in this blog. I borrowed title for this blog post from Hanselman.

Two Programming Problems – Computing Fiscal / Academic Calendar Dates

In lot of institution they follow their official calendar year that may starts from April to next year’s March of Gregorian calendar . Each institution choose their start month and end month of their calendar year. Each calendar year should have 365 days (366 in case of leap year)

Here goes First Problem.

Financial Institutions follows April-March Calendar period. Some Academic Institutions follow June-July Period. The Problem is if Start&End months of Calendar Period for an Institution and a date is provided, To Find Calendar year’s Start Date and End Date for given date.

Sample input: Current Date = 25th December 2014
Start Month = April
End Month = March
Output: Current Calendar year’s Start Date = 1st April 2014
Current Calendar year’s End Date = 31st March 2015

Sample input: Current Date = 14th February 2015
Start Month = April
End Month = March
Output: Current Calendar year’s Start Date = 1st April 2014
Current Calendar year’s End Date = 31st March 2015

Second Problem:  A person can subscribe to a Daily NewsPaper Company a range of date. The Daily News Paper Company follows the April-March Fiscal calendar. Find what are the financial years and no of days in each financial year company needs to deliver paper to the person.

for example Mr.X is subscribed to a Daily NewsPaper Company from 15th November 2014 to  26 February 2016. Then Company need to deliver newspaper for

Sample Input:Date Range: 15th November 2014 to  26 February 2016                                                                                  Start&End months of a Fiscal year:   April to March

Output:136 days in financial year of 1st April 2014 – 31st March 2015                                                                          331 days in financial year of 1st April 2015 – 31st March 2016

The intention is to get various points of view in Problem decomposition and solving a problem. So share your code in jsfiddle or any thing  for this two Problem in what ever Programming Languages.

May be given data is redundant or insufficient !

 What name would you give to the method (OR function OR procedure OR subroutine)  you going to implement for these problems ? The third skill specified in this post
I want the code with function (or what ever is in your context)  returning the output for each problem not printf statement 😛
And same conditions that told for Given data is also  apply for Output.  i.e. redundant or insufficient.
So give it in optimal way.
Your code should be with the test code to prove  your implementation is correct in all scenarios. So that any one can verify the implementation by running your code
I am eager for your replies