Tuesday, July 30, 2019

SOLID Principles

S.O.L.I.D is an acronym for the first five object-oriented design(OOD) principles .These principles, when combined together, make it easy for a programmer to develop software that are easy to maintain and extend. They also make it easy for developers to avoid code smells, easily refactor code, and are also a part of the agile or adaptive software development.

  • SRP - Single Responsibility Principle
    • A class should have only one reason to change
  • OCP - Open/Close Principle
    • A class should be open to extension but close for modification
  • LSP - Liskov Substitution Principle
    •  If any module is using a Base class then the reference to that Base class can be replaced with a Derived class without affecting the functionality of the module.
    •  You should be able to replace a class with a subclass without the calling code knowing about the change
  • ISP - Interface Segregation Principle
    • that clients should not be forced to implement interfaces they don't use. Instead of one fat interface many small interfaces are preferred based on groups of methods, each one serving one sub module.
    • Many specific interfaces are better than a single
  • DIP - Dependency Inversion Principle
    • Code should depend upon abstractions, not concrete implementations

IoC - Inversion of Control
  • IoC is a design principle which recommends the inversion of different kinds of controls in object-oriented design to achieve loose coupling between application classes
  • Inversion of Control (IoC) is a design principle (although, some people refer to it as a pattern). As the name suggests, it is used to invert different kinds of controls in object-oriented design to achieve loose coupling. Here, controls refer to any additional responsibilities a class has, other than its main responsibility. This include control over the flow of an application, and control over the flow of an object creation or dependent object creation and binding. 
  • suppose you drive a car to your work place. This means you control the car. The IoC principle suggests to invert the control, meaning that instead of driving the car yourself, you hire a cab, where another person will drive the car. Thus, this is called inversion of the control - from you to the cab driver. You don't have to drive a car yourself and you can let the driver do the driving so that you can focus on your main work.
DI- Dependency Injection
  • It allows the creation of dependent objects outside of a class and provides those objects to a class through different ways. Using DI, we move the creation and binding of the dependent objects outside of the class that depends on them. 
  • The Dependency Injection pattern involves 3 types of classes.
    • Client Class: The client class (dependent class) is a class which depends on the service class
    • Service Class: The service class (dependency) is a class that provides service to the client class.
    • Injector Class: The injector class injects the service class object into the client class.

Sunday, July 28, 2019

What is JIRA Software?

JIRA software is a issue tracking product developed by Atlassian which allows bug tracking and agile project management.

Atlassian JIRA is an issue tracking and agile project management tool which allows us to track any project by following a proper workflow. Following are the reasons behind using JIRA.

  1. JIRA is a platform independent that could run anywhere
  2. JIRA can be run anywhere
  3. In JIRA, a workflow can be easily customized based on our requirement
  4. JIRA acts as an issue tracking as well as project management tool
  5. JIRA allows us to track the progress of a project from time to time

Epic -  An Epic can be defined as a big chunk of work that has one common objective. It could be a feature, customer request or business requirement.

When Product Owner writes a user story for a feature or customer request, that looks simple in the beginning but while covering all related work it expand to big user story which does not complete in a week or sprint time-frame. This big user story should be consider as Epic
Epics are large stories and span multiple sprints
Epics are not grouping of work items
Epics may contain stories, bugs and tasks withing team
Stories, bugs and tasks are all at the same level in JIRA

Story - Something actionable and small enough to fit in a sprint

OOP - Object Oriented Programming

  •  What is OOP
    • OOP stands for object oriented programming is a programming language in which programs organized around data or objects. An object can be defined as a data field which has unique attributes and behavior
  • Write concepts or principles of OOP
    • Abstraction
      •  Abstraction is one of the principle of object oriented programming. It is used to display only necessary and essential features of an object to outside the world
    • Encapsulation
      • Encapsulation binds together code and the data it manipulates and keeps them both safe inside a class from outside interference and misuse. Only public methods or functions can accessible form other objects
    • Inheritance
      • Inheritance means the ability to create new classes based on an existing class. so derived classes can access all the properties and methods of base class.
    • Polymorphism
      • Polymorphism provides the ability to a class to have multiple implementations with the same name.There are two types of polymorphism in C#
        •  Static/Compile Time Polymorphism
          • Method Overloading
            • In a class we have methods with same name but different parameters 
          • Operator Overloading 
            • You can redefine or overload most of the built-in operators available in C#. Thus a programmer can use operators with user-defined types as well.
        • Dynamic/Runtime Polymorphosm 
          • Virtual / Overriding Method
  •   What is Abstraction?
    • Abstraction is one of the principle of object oriented programming. It is used to display only necessary and essential features of an object to outside the world
    • Abstract Class in C#
      • An abstract class is a special type of class that cannot be instantiated 
      • An abstract class is designed to be inherited by sub-classes that either implement or override its methods
      • In other words, abstract classes are either partially implemented or not implemented at all
      • You can have functionality in your abstract class—the methods in an abstract class can be both abstract and concrete
      • An abstract class can have constructors—this is one major difference between an abstract class and an interface. 
    • Abstract Methods in C# 
      • An Abstract method is a method without a body. 
      • The implementation of an abstract method is done by a derived class. 
      • When the derived class inherits the abstract method from the abstract class, it must override the abstract method. This requirement is enforced at compile time and is also called dynamic polymorphism
  •  Constructors
    • Constructor is a method which has same name as class name
    • Constructors are class methods that are executed automatically when an object of a given type is created
  • Finalizers
    • It is used to dispose instances of classes 
    • In the .NET Framework, the garbage collector automatically manages the allocation and release of memory for the managed objects in your application. However, you may still need finalizers to clean up any unmanaged resources that your application creates. 
    • There can be only one finalizers for a class. 
  • Access Modifiers and Access Levels
    • We can specify access modifiers to methods and properties of the class to manage access level of it
    • public
      • The type or member can be accessed by any other code in the same assembly or another assembly that references it.
    • private
      • The type or member can only be accessed by code in the same class.
    • protected
      • The type or member can only be accessed by code in the same class or in a derived class from any assembly.
    • internal
      • The type or member can be accessed by any code in the same assembly, but not from another assembly.
    • protected internal
      • The type or member can be accessed by any code in the same assembly, or by any derived class in another assembly.
    • private protected 
      • The type or member can be accessed by code in the same class or in a derived class within the base class assembly
  • Virtual Keyword
    • Allows a class method to be overridden in a derived class. 
  •  Override Keyword
    • It is used to override a virtual or abstract method  defined in base class.
  • Abstract Method
    • We must override abstract methods in derived or base class
  •  new 
    • the new keyword explicitly hides a member that is inherited from a base class.
    • public class BaseC
      {
          public int x;
          public void Invoke() { }
      }
      public class DerivedC : BaseC
      {
          new public void Invoke() { }
      }
  • Interfaces
    •  Interface can have methods, properties, events, and indexers as its members. But interfaces will contain only the declaration of the members. The implementation of interface’s members will be given by class who implements the interface
    • Interfaces can’t have private members. 
    • By default all the members of Interface are public and abstract
    • We can implement multiple interfaces in a class
    • We must implement all methods of interface to the class who implements the interface
  • Partial Class
    • It provides a special ability to implement the functionality of a single class into multiple files
  • Generics
    • it enables us to create classes, interfaces, and methods that work with different data types without having to define the data type explicitly
  • Reflection
    • Dynamically know properties and methods in the object and also create code
  • Extension Methods 
    • Extension methods allow you to inject additional methods without modifying, deriving or recompiling the original class
  • Async
    • We can create async method, which calls asyncronously
  • Await 
    • When we create async method, we must add keyword await in the async method
    • The await operator is applied to a task in an asynchronous method to insert a suspension point in the execution of the method until the awaited task completes
  • Task
    • .NET framework provides Threading.Tasks class to let you create tasks and run them asynchronously.
    • A task is an object that represents some work that should be done. The task can tell you if the work is completed and if the operation returns a result, the task gives you the result.
    • It can be used whenever you want to execute something in parallel. Asynchronous implementation is easy in a task, using’ async’ and ‘await’ keywords. 
  • Delegates
    • the delegates in C# are the type-safe function pointer means they hold the reference of a method and then calls that method for execution
    • Single case delegate 
      • If a delegate is used for invoking a single method then it is called a single cast delegate or unicast delegate. In other words, we can say that the delegates that represent only a single function are known as single cast delegate.
      • If a delegate is used for invoking multiple methods then it is known as the multicast delegate. OR the delegates that represent more than one function are called Multicast delegate.
  • ArrayList vs List<>
    • List<T> is a generic class. It supports storing values of a specific type without casting to or from object (which would have incurred boxing/unboxing overhead when T is a value type in the ArrayList case).
    • ArrayList simply stores object
    • ArrayList belongs to the days that C# didn't have generics. It's deprecated in favor of List<T>. You shouldn't use ArrayList in new code that targets .NET >= 2.0 unless you have to interface with an old API that uses it.
  • IEnumerable Vs IQueryable
    • IEnumerable exists in the System.Collections namespace.
    • IEnumerable is suitable for querying data from in-memory collections like List, Array and so on.
    • While querying data from the database, IEnumerable executes "select query" on the server-side, loads data in-memory on the client-side and then filters the data.
    • IEnumerable is beneficial for LINQ to Object and LINQ to XML queries.
    • IQueryable exists in the System.Linq Namespace.
    • IQueryable is suitable for querying data from out-memory (like remote database, service) collections.
    • While querying data from a database, IQueryable executes a "select query" on server-side with all filters.
    • IQueryable is beneficial for LINQ to SQL queries.
  • Equals and ==
    • “==” does type checking during compile time
    • while “Equals” is more during runtime
    • “==” works with nulls but “Equals” crashes when you compare NULL values 
  • Task vs Thread
    • The Thread class is used for creating and manipulating a thread in Windows
    • A Task represents some asynchronous operation and is part of the Task Parallel Library, a set of APIs for running tasks asynchronously and in parallel
    • A task can have multiple processes happening at the same time. Threads can only have one task running at a time.
    • A Task is a higher level concept than Thread.

Tuesday, July 23, 2019

Design Patterns

1.      What is Design Patterns?
  • Design patterns are solutions, best practices to general problems that software developers faced during software development
2.      Types of Design Patterns
  • Creational Patterns
    • This type deals with the object creation and initialization. This pattern gives the program more flexibility in deciding which objects need to be created for a given case
  • Structural Patterns
    • This type deals with class and object composition. These pattern focuses on decoupling interfaces and implementation of classes and its objects.
  • Behavioral Patterns
    • This type deals with communications between classes and objects.
3.      Creational Patterns
  • Factory Method
    • Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
  • Abstract Factory
    • Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
  • Singleton
    • Ensure a class has only one instance and provide a global point of access to it.
  • Builder
    • Separate the construction of a complex object from its representation so that the same construction process can create different representations.
  • Prototype
    • Specify the kind of objects to create using a prototypical instance, and create new objects by copying this prototype.
4.       Structural Patterns

·         Adapter
·         Bridge
·         Composite
·         Decorator
·         Façade
·         Flyweight
·         Proxy

5.       Behavioral Patterns

·         Chain of Resp.
·         Command
·         Interpreter
·         Iterator
·         Mediator
·         Memento
·         Observer
·         State
·         Strategy
·         Template Method
·         Visitor

Tuesday, July 16, 2019

ASP.NET MVC - Action Filters

Some time we want to perform logic either before as action method is called or after an action method runs.
To support this, ASP.NET MVC provides filters

1. Action Filters

  • OutputCache − Caches the output of a controller action for a specified amount of time.
  • HandleError − Handles errors raised when a controller action is executed.
  • Authorize − Enables you to restrict access to a particular user or role.


2. Types of Filters

The ASP.NET MVC framework supports four different types of filters −
  • Authorization Filters − Implements the IAuthorizationFilter attribute.
  • Action Filters − Implements the IActionFilter attribute.
  • Result Filters − Implements the IResultFilter attribute.
  • Exception Filters − Implements the IExceptionFilter attribute.
Filters are executed in the order listed above. For example, authorization filters are always executed before action filters and exception filters are always executed after every other type of filter.

MVC - Types of Action

Types of Action

Actions basically return different types of action results. The ActionResult class is the base for all action results. Following is the list of different kind of action results and its behavior.
Sr.No. Name and Behavior
1 ContentResult
Returns a string
2 FileContentResult
Returns file content
3 FilePathResult
Returns file content
4 FileStreamResult
Returns file content
5 EmptyResult
Returns nothing
6 JavaScriptResult
Returns script for execution
7 JsonResult
Returns JSON formatted data
8 RedirectToResult
Redirects to the specified URL
9 HttpUnauthorizedResult
Returns 403 HTTP Status code
10 RedirectToRouteResult
Redirects to different action/different controller action
11 ViewResult
Received as a response for view engine
12 PartialViewResult
Received as a response for view engine

ASP.NET MVC - Life Cycle

MVC has two life cycles

1. Application Life Cycle
  • Application life cycle starts when application starts in IIS and end when it stops, we can handle start and stop events in startup file of the application

2. Request Life Cycle
  • Request life cycle starts with Routing
  • Controller initialization
  • Action Execution
  • Result Execution (View Engine)
  • Response

Secure ASP.NET MVC website

Below are some of the Security feature to secure ASP.NET MVC web application

1. Cross Site Scripting (XSS)
2. Cross site request forgery (CSRF)
3. Authentication
          Windows
           Forms


1. Cross Site Scripting (XSS)

  • XSS is a attack, where malicious user tries to inject scripts in input fields like a Textbox or TextArea like Hack
  •  To prevent this type of attack .Net framework has inbuilt functionality of ValidateRequest
  • But some time we have a requirement to allow script into the TextBox or TextArea to format input text, at that time we have to allow Scripts in TextBox or TextArea
  • In this situation we have a another option of Encode textbox input using Server.HtmlEncode(textbox) in aspx engine
  • for Razor View Engine, it will automatically handle XSS scripts
2. Cross site request forgery (CSRF)
  • CSRF is a attach, where malicious user tries to POST malicious data into URL Post request
  • to prevent this attach, there is inbuilt function of Html.AntiForgeryToken() which we need to call inside form

3. Authentication
  •  Windows Authentication - we need to config in Web.config authentication mode=Windows
  • Forms Authentication - we have to config in Web.config authentication mode=Forms and add custom code to Authenticate users
Once users are Authenticate, we will use Authorize Attribute on the Controller to verify user and Authorize them for the access of particular page

Project Management

  1. What Are The Different Phases Of SDLC?
SDLC stands for Software Development Life Cycle, It can be divided in to 7 phases
  • Planning and Requirement Analysis
    • Conduct product feasibility study in the economical, operational and technical areas
    • Identification of the risks associated with the project is also done in the planning stage
  • Defining Requirements 
    • Clearly define and document the product requirements and get them approved from the customer or the market analysts. This is done through an SRS (Software Requirement Specification) document which consists of all the product requirements to be designed and developed during the project life cycle.
  • Designing the Product Architecture
    • SRS is the reference for product architects to come out with the best architecture for the product to be developed
    • Create Design Document Specification
    • A design approach clearly defines all the architectural modules of the product along with its communication and data flow representation with the external and third party modules (if any). The internal design of all the modules of the proposed architecture should be clearly defined with the minutest of the details in DDS.
  • Building or Developing the Product
    • In this stage of SDLC the actual development starts and the product is built
  • Testing the Product
  • Deployment and Mainteance

  1. What is Agile Methodology?
  • It is a practice that promotes continuous iteration of development and testing 
  • Both development and testing activities are concurrent unlike waterfall model
  • The customer has early and frequent opportunities to look at the product and make decision and changes to the project
  • Development process is iterative, and the project is executed in short (2-4) weeks iterations. Planning is very less.
  • At the end of every sprint, user acceptance is performed
  • Speedy and continuous delivery of the software ensures customer satisfaction.

  1.  What are the different types of Agile Methodologies?
  • There are several types of agile development methodology. Scrum is one of the most popular and widely used agile methods. Other types of agile development methodology are; development like Crystal Methodology, DSDM(Dynamic Software Development Method), Feature-driven development(FDD), Lean software development and Extreme Programming(XP). 
  1. What is Scrum?
  • Scrum is an agile project management methodology or framework used primarily for software development projects with the goal of delivering new software capability every 2-4 weeks.

  1.  Who Uses Agile Scrum Methodology?
  • Scrum is widely used by software development teams. In fact it's the most popular agile methodology. According to the 12th annual State of Agile report, 70% of software teams use Scrum or a Scrum hybrid
  •  
  •  
  1. What are the Benefits Received from the Scrum Methodology?
  •  Organizations that have adopted agile Scrum have experienced:

        Higher productivity
        Better-quality products
        Reduced time to market
        Improved stakeholder satisfaction
        Better team dynamics
        Happier employees
     
  •  
  1. What Are the Components of Agile Scrum Development?
  • The Scrum Team

    Scrum teams are typically composed of 7 +/- 2 members and have no team leader to delegate tasks or decide how a problem is solved. The team as a unit decides how to address issues and solve problems. Each member of the Scrum team is an integral part of the solution and is expected to carry a product from inception to completion. There are three key roles in a Scrum team:

    The Product Owner

    The Product Owner is the project's key stakeholder - usually an internal or external customer, or a spokesperson for the customer. There is only one Product Owner who conveys the overall mission and vision of the product which the team is building. The Product Owner is ultimately accountable for managing the product backlog and accepting completed increments of work.

    The ScrumMaster

    The ScrumMaster is the servant leader to the Product Owner, Development Team and Organization. With no hierarchial authority over the team but rather more of a facilitator, the ScrumMaster ensures that the team adheres to Scrum theory, practices, and rules. The ScrumMaster protects the team by doing anything possible to help the team perform at the highest level. This may include removing impediments, facilitating meetings, and helping the Product Owner groom the backlog.

    The Development Team

    The Development Team is a self-organizing, cross-functional group armed with all of the skills to deliver shippable increments at the completion of each sprint. Scrum broadens the definition of the term "developer" beyond programmers to include anyone who participates in the creation of the delivered increment. There are no titles in the Development Team and no one, including the ScrumMaster, tells the Development Team how to turn product backlog items into potentially shippable increments

  •  Scrum Events (Ceremonies) 
  •  
  •  
  • The Sprint

  • A sprint is a time-boxed period during which specific work is completed and made ready for review. Sprints are usually 2-4 weeks long but can be as short as one week.

    Sprint Planning Sprint

    Planning team meetings are time-boxed events that determine which product backlog items will be delivered and how the work will be achieved.

    The Daily Stand-up

    The Daily Stand-up is a short communication meeting (no more than 15 minutes) in which each team member quickly and transparently covers progress since the last stand-up, planned work before the next meeting, and any impediments that may be blocking his or her progress.

    The Sprint Review

    The Sprint Review is the "show-and-tell" or demonstration event for the team to present the work completed during the sprint. The Product Owner checks the work against pre-defined acceptance criteria and either accepts or rejects the work. The stakeholders or clients give feedback to ensure that the delivered increment met the business need.

    The Retrospective

    The Retrospective, or Retro, is the final team meeting in the Sprint to determine what went well, what didn't go well, and how the team can improve in the next Sprint. Attended by the team and the ScrumMaster, the Retrospective is an important opportunity for the team to focus on its overall performance and identify strategies for continuous improvement on its processes. 
  • Scrum Artifacts
  • Product Backlog

    The product backlog is the single most important document that outlines every requirement for a system, project or product. The product backlog can be thought of as a to-do list consisting of work items, each of which produces a deliverable with business value. Backlog items are ordered in terms of business value by the Product Owner.

    Sprint Backlog

    A sprint backlog is the specific list of items taken from the product backlog which are to be completed in a sprint.

    Increment

    An Increment is the sum of all product backlog items that have been completed since the last software release. While it is up to the Product Owner to decide on when an increment is released, it is the team's responsibility to make sure everything that is included in an increment is ready to be released. This is also referred to as the Potentially Shippable Increment (PSI).


  • Risk Management
    • Resource Risk
    • Scope Risk
    • Schedule Risk
    • Four Method for Risk Management
      • Risk Identification
      • Risk Quantification
        • Risks can be evaluated based on quantity. Project managers need to analyze the likely chances of a risk occurring with the help of a matrix.
        • Using the matrix, the project manager can categorize the risk into four categories as Low, Medium, High and Critical.
      • Risk Response
        • Risks can be avoided 
        • Pass on the risk
        • Take corrective measures to reduce the impact of risks
        • Acknowledge the risk
      • Risk Monitoring and Control
        • Risks can be monitored on a continuous basis to check if any change is made. New risks can be identified through the constant monitoring and assessing mechanisms.
  • Gantt Chart
    • Gantt chart is a type of a bar chart that is used for illustrating project schedules. Gantt charts can be used in any projects that involve effort, resources, milestones and deliveries.
    • Gantt charts allow project managers to track the progress of the entire project. Through Gantt charts, the project manager can keep a track of the individual tasks as well as of the overall project progression.
    • Microsoft Project is one of the key Gantt chart tools used today
  • N-tier Architecture
    • N-tier architecture is a client-server architecture concept in software engineering where the presentation, processing and data management functions are both logically and physically separated. These functions are each running on a separate machine or separate clusters so that each is able to provide the services at top capacity since there is no resource sharing. This separation makes managing each separately easier since doing work on one does not affect the others, isolating any problems that might occur.  
    • Presentation layer (Client Tier)
    • Application layer (Business Tier)
    • Database layer (Data Tier)
  • SDD (Software Design Document)
    • The software design document (SDD) typically describes a software product's data design, architecture design, interface design, and procedural design
  • SAD (Software Architecture Document)
    • A software architecture document is a map of the software. We use it to see, at a glance, how the software is structured. It helps you understand the software’s modules and components without digging into the code. It’s a tool to communicate with others—developers and non-developers—about the software.
    • The software architecture document provides a comprehensive overview of the architecture of the software system. It serves as a communication medium between the software architect and other project team members regarding architecturally significant decisions which have been made on the project.
  • WBS (Work Breakdown Structure)
    • Dividing complex projects to simpler and manageable tasks is the process identified as Work Breakdown Structure (WBS)
    • In WBS, much larger tasks are broken down to manageable chunks of work. These chunks can be easily supervised and estimated.
    • Following are a few reasons for creating a WBS in a project:
      • Accurate and readable project organization.
      • Accurate assignment of responsibilities to the project team.
      • Indicates the project milestones and control points.
      • Helps to estimate the cost, time and risk.
      • Illustrate the project scope, so the stakeholders can have a better understanding of the same


 

Tuesday, July 9, 2019

How to change default start file 'server.js' to 'index.js' on windows Azure NodeJS AppService

In order to change default start file 'server.js' to 'index.js' on Windows Azure Node JS AppService, we have to change package.json file as below

"scripts": {
    "start": "node index.js"
}
 
 
 

Monday, July 1, 2019

ASP.NET Core

ASP.NET Core is a cross-paltform, high-performance, open-source framework for building modern, cloud-based, internet-connected applications.

ASP.NET Core is a redesign of ASP.NET 4.x

Benefits and Features of ASP.NET Core
1) ASP.NET Core applications can be developed and run across different platforms like
   Windows, macOS and Linux
2) ASP.NET Core applications can be hosted on
   IIS, Apache, Docker
3) One Unified Programming Model for MVC and Web API
4) Built-In support for Dependency Injection
5) Testability, Unit Test is Easy
6) Open-Source
7) ASP.NET Core provides Modularity with Middleware Components

  • What is Middleware Components
    • The Middleware components are the components which we use to set up the request processing pipeline in the ASP.NET Core application
    • Each middleware component in ASP.NET Core
      • Chooses whether to pass the HTTP Request to the next component in the pipeline.
      • Can perform work before and after the next component in the pipeline.
      • In ASP.NET Core there are so many built-in Middleware components are already available that you can directly use. If you want then you can also create your own Middleware components.  
    • Some of middleware components
      • Authenticating the user
      • Log the request and response
      • Handle the static files such as Images, Javascript or CSS Files etc
      • Authorize the users while accessing a specific resource
      • MVC Middleware