Skip to main content

Posts

Find mutual friends count from given relation ship array. Substantive Expertise

This is a good example of the “substantive expertise” aspect of data science. users = [     { "id": 0, "name": "Hero" },     { "id": 1, "name": "Dunn" },     { "id": 2, "name": "Sue" },     { "id": 3, "name": "Chi" },     { "id": 4, "name": "Thor" },     { "id": 5, "name": "Clive" },     { "id": 6, "name": "Hicks" },     { "id": 7, "name": "Devin" },     { "id": 8, "name": "Kate" },     { "id": 9, "name": "Klein" } ] friendship_pairs = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4),                     (4, 5), (5, 6), (5, 7), (6, 8), (7, 8), (8, 9)] # Initialize the dict with an empty list for each user id: friendships = {user["id"]: [] for user in users} # And ...

Authentication in MVC

using System; using System.Web; using System.Web.Http; using System.Web.Mvc; using System.Web.Routing; using System.Web.Optimization; using System.Web.Security; using System.Web.Script.Serialization; using DynamicProject.Utility.Security; using System.Configuration; namespace DynamicProject.Web {         public class MvcApplication : System.Web.HttpApplication     {         protected void Application_Start()         {             AreaRegistration.RegisterAllAreas();             WebApiConfig.Register(GlobalConfiguration.Configuration);             FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);             RouteConfig.RegisterRoutes(RouteTable.Routes);             BundleConfig.RegisterBundles(BundleTable.Bundles); ...

Abstract Factory Pattern

ABSTRACT FACTORY PATTERN           Provide an interface for creating families of related or dependent objects without specifying their concrete classes.                           Casual Implementation                               Factory Pattern Implementation  Usual Code Block   Factory Pattern Parent Class public class CheckBook {     protected decimal _Amount;     public decimal getExpense()     {       return _Amount;     } } These below child classes is derived from CheckBook base class. public class Health : CheckBook {     public Health()     {         _Amount = 5000;//Could be any logi...

SOLID Principle

SOLID PRINCIPLE Single Responsibility Principle Fully Loaded Single Responsibility Principle class Customer    {         public void Add()         {             try             {                // Database code goes here          }             catch (Exception ex)             {                          System.IO.File.WriteAllText(@"c:\Error.txt", ex.ToString());       ...