Lesson 3 – Directives (Angular 4)

Hi friends, in the last session we have learnt about how to setup in the local environment. In this session we will learn about Directives. Topics that are going to be covered in this session are

  1. Structural directives (Built-in Directives (ngIF, ngFor, ngSwitch)
  2. Style and Class Directives ( ngClass, ngStyle)
  3. Attribute directives
  4. Host Listener and Host Binding

 

Overview of Directives:

Directives are the classes that can change the behaviour or appearance of the components by using CSS Classes, CSS Styles and events.

There are three kinds of directives in Angular:

  1. Components—directives with a template.
  2. Structural directives—change the DOM layout by adding and removing DOM elements.
  3. Attribute directives—change the appearance or behavior of an element.

Components are the most common of the three directives. You saw a component for the first time in the QuickStart example.

Structural Directives change the structure of the view. Two examples are NgFor and NgIf in the Template Syntax page.

  • We use (*) before the structural directives, and when we use (*) before ngIf/ ngFor, angular actually recognizes that the current element as a template and it will read the current elements as <ng-template>. Where as in Angular 2.X it reads as <template>.

Attribute directives are used as attributes of elements. The built-in NgStyle directive in the Template Syntax page, for example, can change several element styles at the same time.

 

*ngIf:  This directive is used for conditional check on the HTML targeting elements. This will work similar to ng-if in Angular 1.X, where the elements will not get rendered into DOM until the condition satisfies. 

Step1: From the quick start example edit the component.ts

File: app.component.ts

Step2: Create a template.html in the app folder

File: template.html

Note: when use * before ngIf, angular treats it as <ng-template>

*ngIf else:  Angular 4  *ngIf has if/else syntax that make sense when you are making ajax calls we can show loading within the page. Where as else block is not existed in Angular 2.

From the above example, add the following html in the template

File: template.html

Angular compiler (JIT or AOT) transforms any <ng-template> elements and directives used with an asterisk (*) into views that are separate from the root component view.

Here when we use (*) before ngIF, angular actually recognizes that the current element as a template, and angular reads it as,

 

*ngIf then else: *ngIf directive can use two templates, one for If condition and the other for else condition. In the previous example we have seen using template for else condition, now for If condition we need to use then statement.

File: template.html

 

Lesson 2 – Setup for local environment in Visual Studio

Setting up Angular2/Angular4 is a quite complex, it needs a lot of work when compared with the installation for Angular1.X applications.

To setup with the quick start files follow these steps:

Step1: Install Node JS and npm

Step2: Install visual studio 2015 update3

Step3: Configuring External Web Tools.

Step4: Install Typescript

Step5: Download quick start files

Step6: Create ASP.NET Project

Step7: Copy the quick start files into your ASP.NET Project

Step8: Restore Packages

Step9: Build and Run

Install Node and NPM
  • Angular 2/4 is developed with compatible latest versions of Node, where you must have Node JS version 4.6.X or higher and npm 3.X.X or higher.
  • Older versions produce errors
  • Before installing make sure whether you have already installed Node JS before. For checking the Node JS and npm versions follow these commands in command prompt.

For Node JS: node –v

For npm: npm –v

  • If the PC don’t have Node JS installed it will show you like “node” is not recognized as an internal or external command, “npm” is not recognized as an internal or external command. Or if your PC has older version than the required please update to the latest versions.
  • For installing latest version of Node JS and npm go to https://nodejs.org/en/download/
  • Your first step will be completed if you have installed the required versions.

 

Install Visual Studio 2015 Update 3

Note: For studio 2017 versions can ignore this step

Minimum requirement for developing Angular2/ Angular4 applications is Visual Studio 2015 Update3 because the earlier versions do not follow the best practice for developing applications with Typescript.

  • To check the version of Visual Studio 2015

Open Visual Studio 2015    go to Help    click on About Microsoft Visual Studio

  • If you don’t have install Visual studio 2015 update 3

 

Configure External WebTools
  • We need to configure Visual Studio to use the global external web tools before the tools that ship with visual studio.
  • Go to Visual Studio    Click on Tools    Options    Expand Projects and Solutions    click on External Web Tools    now in the right hand side move $(PATH) entry above the $(DevEnvDir) This tells the visual studio to use the external tools like (npm) found in the global path before using its own version of the external tools.
  • Now click OK and restart the Visual Studio to reflect these changes. Visual Studio now looks first for external tools in the current workspace and if it doesn’t find them, it looks in the global path. If Visual Studio doesn’t find them in either location, it will use its own versions of the tools.

 

Install Typescript
  • To develop Angular applications we need Typescript 2.2.0 or its higher versions, as Visual studio Update3 doesn’t have such specifications we need to install it externally.
  • Before installation we can check our Typescript version in the Visual Studio

Open Visual Studio 2015    go to Help    click on About Microsoft Visual Studio

 

Download Quick start files

You can download the quick start files from Git hub https://github.com/angular/quickstart and then extract the files.

 

Create ASP.NET Project

Create ASP.NET 4.X or above project in the visual studio

Go to Visual Studio       File      New     Project    select Visual C# under Templates    click on ASP.NET Web Application     select Desired Templates    give the project name and click on OK.

 

Copy Quick start files into ASP project

Copy the quick start files into your project, but all the files are not necessary to be included into your project. So copy only selected files from the extracted folder.

Copy the following files into your .csproj

  • Src
  • Bs-config.json
  • json
  • json

 

Restore  Packages

Restore the packages required for your application

  • For restoring packages right click on json     select Restore Packages. This uses npm to install all the packages defined in package.json.
  • In between you can open the Output window to watch the npm commands that are executed. Simply we can ignore the warnings.
  • After you see the message Installing Packages Complete make sure that your project doesn’t includes node_modules

 

Build and Run

 File: /src/app/component.ts

In the above example that we have copied from the quick start files,

  1. In the first statement we are importing Component Package from angular/core package directory. After restoring package.json in /node_modules you can see all the packages that are downloaded using npm commands.
  2. In the second statement according to angular,
    1. @ is called –> decorator
    2. @Component  is called –> Component decorator
    3. selector –> xml tag / custom html tag
    4. template –> view for the component

Complete syntax of component, (Component decorator + class followed by the component decorator)

3. In the third statement we are exporting the component, to make it visible to other modules in our angular application.

  • After Installing packages build the Application.
  • To run the application open Command Prompt     go to your Project Directory       execute command npm start.
  • When this command is executed,
  • firstly it will launch typescript compiler and compiles the application with the following command tsc –p src/
  • Now it will start the lite-server and launches the browser where you can see the

Output: Hello Angular

  • But if you run the html by pressing F5 in visual studio it will not show the same output.

To Run in VS with F5 follow these steps

    1. In html, change base href from <base href=”/”>to <base href=”/src/”>.
    2. Also in html, change the scripts from node_modules to /node_modules with a slash
    3. In src/systemjs.config.js, near the top of the file, change the npm pathto /node_modules/ with a slash.
    4. After these changes npm start command no longer works, you must choose to configureeither for F5 with IIS or for npm start with the lite-server.
    5. Now run the application using F5

Tips to become Experienced Programmer

 “Experience is just a number”, in fact there is nothing difference between a Fresher and Experience. Every experience person also feels the same. When you are Fresher it doesn’t mean that you are less Intelligent / Skilled than Experience, you just need some time to stabilize your skills, intelligence, logical thinking and patience. Time will teach you everything. Most important difference is “Patience”, experience people will always show patience in any work. If you are a Fresher just keep some key points into your mind while coding, “That’s it”. Those key points will make you very closer to an Experience programmer/developer.

Key points to change you to an Experience programmer/developer:

  1. Learn how to Google
  2. Grip on OOPS
  3. Code Reuse
  4. Code comments
  5. Follow Standards

 

Learn how to Google:

  • Most of the Experience developers in IT sector are surviving because of If you know how to Google for a solution no doubt you can survive anywhere in IT sector. But need to remember is “Compromise nowhere until find the solution”.
  • Experience Developer:
    • Analyze the problem first
    • Google with the exact keywords
    • Picks up the popular forum sites like (stack overflow, Code project, Code Guru etc…)
    • start applying the up voted answers first
    • If not working, go for the all the other solutions and keep trying
    • if not working till, now he/she will start learning that new concept from technical content sites.

Note: As you have seen from the above process, “No where the person give up“. Just keep on trying till you find the solution, if not take your colleagues help.

Google API’s working formula

Minimum and simple words     Maximum results

For Example:

  • Who is the author of C (many words) gives few results
  • Author of C (few words)  good results

  • Prefer stack overflow first (Note: if it’s a known concept for you)
    • Some of the popular discussion forum sites (stack overflow, Code project, Code Guru etc…)
    • In the stack overflow the very first step search for the “Most up voted answer”.
    • “Read all the solutions”. Many solutions will work even if it’s not an up voted and vice versa.
  • Prefer site which has easy slang according to your terminology. If you pick the toughest slang of technical terminology you will never understand that topic in depth.

 

Grip on OOPS:

 

Strong in OOPS       you will argue with someone

Weak in OOPS         you will listen to someone

Confused wright!!

Yes when you are strong at something (For example: You know very well HTML). If your colleague doesn’t follow standards then what will be your reaction, sure you will argue with him and teach him the right way.

  1. Concentrate more and more on Loops (for, while, do while).
    1. If you are not confident on loops write every iteration on paper for some days.
    2. Iterate loops in your mind once you are confident.
  2. Use all oops concepts in every module if it’s not even required. So that you will not forget it.
  3. Teach someone who doesn’t know OOPS, teaching is the best-way to remember the basics all the time.
  4. Concentrate on unknown topics and learn at least one topic a day.

 

Code reuse

Most of the Experience Developers follow Code Reusing techniques all the time. Few techniques are using

  • Inheritance
  • Libraries (DLL’s)
  • Web Services & Web API’s

 

  1. Don’t ever write every piece of code in the same file
  2. Create libraries (or) Packages and Reuse them for Business Logics.
  3. Always prefer multi-layered architecture in all the Tiers of project. So that presentation of your code will be very clean.
  4. Create API’s for the Repositories (Repositories are noting but your Data Access Layer).
  5. Always try to maintain Loose coupling e., use Dependency Injection. This will be very helpful to test the application.
  6. Use Inheritance as much as you can.

 

Code Comments:

Few places where you should write comments:

  • File level / Class level comments
  • Method level comments
  • Code level comments

 

  1. Your code behind file (or) JavaScript file should look more green (or) red in color (color of comment depends on the language).
  2. Write a brief description on the top about complete file (Class file / script file) with Block Comment.
  3. Write XML comments on every method about the inputs, output, exception handling, date modified, and modified by.
  4. Write comments for every two or three lines, and for every code block in a function/ method.

Block Comment

XML comments

Follow Code Standards:

  1. Always use Pascal case (or) Camel case
  2. Don’t use names begin with numeric characters.
  3. Do not use Hungarian Notation!

Example: strName or nCount

  1. Don’t include the parent class name within a property name.

Example: Use Employee.Name NOT Employee.EmployeeName

  1. Give prefixes to Boolean variables using “IS”, “Has”, “Can”.
  2. Every developer has their own coding style.
  3. Don’t give more than one empty line in any piece of code
  4. Don’t write multiple classes in same file.

Connected and Disconnected Architectures in DotNet

  • NET (Active x Data Object) is mediator between front end and back end that interacts with client side application and server side application which supports two types of Data Accessing models, one is Connection oriented and Disconnected oriented.
  • NET leverages the power of XML for accessing data using disconnected architecture. It was completely designed with XML classes in .NET Framework.

 

Note: Before going into this article you should have a basic understanding on SQL queries on select, insert, update and delete commands.

Connection String

Connection string plays very crucial role in connecting your front end application and back end application. It’s a normal string which contains the information to establish the connection between backend Database and application and secured information such as user Id and password.

  • Usually Data Providers uses this connection string which contains parameters that are needed for establishing the connection.
  • Let’s have a look at Data Providers that are supported by .Net Framework.

List of Data providers which is supported by .Net Framework.

SQL server Provider connection string:

OLEDB Provider connection string:

ODBC Provider connection string:

 

Connection Oriented Architecture

 

The architecture which needs an open connection to access the data from database is known as Connection Oriented Architecture.

Following are the list of classes on which Connection Oriented Arch is built on:

  • ConnectionUsed to establish the connection between front end and back end.
  • CommandEnables access to database commands to return data, modify data, run stored procedures, and send or retrieve parameter information
  • Data Reader Used to read the data from Source. Provides high performance stream of data from data source.
  • Data Adapter
  1. Mediator between front end and back end which doesn’t have feature of containing data with in this , so it uses Dataset which is a result set.
  2. Also provides bridge between DataSet and data source.
  3. Use Command Objects to execute commands.

As Connected architecture needs connection for every transaction and creates much traffic to database since it do several trips. It shows very high impact on performance when the transaction has many commands i.e. for larger transactions. If it’s doing smaller transactions it is normally much faster.

Note:  In this Connected oriented arch the application stays connected even when it’s not doing any operations on database. To overcome this ADO.NET introduced a new component called DataSet which is a central component in Disconnected Architecture.

DataSet ds = new  DataSet( );

 

Disconnection Oriented Architecture

 

The architecture in which data can be retrieved from database even when the connection gets disconnected or closed is known as Disconnected Oriented Architecture.

Following are the list of classes on which disconnected arch is built on:

  • Connection
  • Command Builder Can generate insert, update and delete commands on single data base table for a data adapter.
  • Data Adapter
  • Data Set Contains the set of Data Tables (Data Table is set of Data Rows and Data Columns)

  • Data View It’s a view of table available in Can be used to perform insert, update and delete commands as in case of Data Set. Can be used to find, sort and filter the records.

  • Disconnected architecture is a method of retrieving the result set from database and giving the user ability to perform all CRUD operations like insert, update and delete. No traffic issues will get occurred because even though connection was gone data will be get already stored into dataset object.
  • By keeping connections open for only a minimum period of time, ADO .NET conserves system resources and provides maximum security for databases and also has less impact on system performance.
  • Any changes to data in DataSet doesn’t show effect on database directly, to save the changes need to use Update() method of Data Adapter.
  • Can be used with multiple and differing data sources, used with XML data, or used to manage data local to the application.

 

Da.Update(ds,”Table Name”);

 

Differences between Connection and Disconnection Oriented Architecture

 

 


 
 

Differences between Java and DotNet

  • Java and .Net are two incomparable guided, but by fact that .Net is Framework of simply platform and supports for almost 63 languages and java is just a programming language.
  • These two technologies have different syntax but gives the same result.
  • Let’s look at some basic imports and usings used in java and .Net.

  • Now let’s look at some application based differences.

  • Now let’s look at some basic differences.

How to Improve Coding Skills

 

The best way of improving your coding skills is firstly “Throw your fear on coding in the dustbin” and stop thinking about whether I’m doing correct (or) wrong. Because the best programmers are the people who makes lot of mistakes and wrong coding in the beginning. So if you are doing wrong coding now then you must feel great that you’re going to become the best programmer soon.

Everyone may have their own definitions on improving coding skills. In my definition following are the characteristics:

  1. Practice
  2. Analyse
  3. Optimize
  4. Share knowledge.

 

Practice:

  1. Practice all the basic programs like even-odd number, prime numbers, Fibonacci series etc.…..
  2. Don’t just copy and paste the code from your material that will never improve your logical thinking.
  3. Write program with your hands.
  4. Debug the code ‘N’ number of times until you understand the logic behind that program.
  5. Take own requirements and try to get expected outputs.
  6. Follow all the naming conventions.
  7. Write comments for every 3 line of code or for every block of code.
  8. Do hard work first smart work next.
  9. Think out of the bounds.

Analyse:

  1. Imagine picture of work before start programming.
  2. Proper planning is required before implementing the code.
  3. Choose tools which are required for your requirement.
  4. Think like an End User, to make your application more efficient.
  5. Commitment before starting the application and take a deadline, unless you take some deadlines you will never finish the program/ application.
  6. Understand the error before searching for solution.
  7. Don’t just copy and paste the unknown code from internet, understand the flow of the code first. And learn the unknown topics from that.

 

Optimizing:

  1. Think for the alternate ways for implementing the code.

Ex: Think like what is the fastest way to compute the Nth Fibonacci number. In the formal case there is a simple formula. In later case the recursive definition allows for an iterative approach which only requires an addition and variable shuffling at each stage.

Binet’s formula corresponding to the nth Fibonacci number,

  1. Take your friends or colleagues advice on how you can code in other way.
  2. Diagnose performance problems and measure the speed impact of your code changes.
  3. Remove unnecessary declarations.
  4. Avoid using nested iterations as many, instead try with other solution.

 

Sharing Knowledge:

  1. Participate in group discussions and Seminars or Webinars.
  2. Review others code so you can learn some new concepts and their way of writing.
  3. Read blogs, forums and articles regularly and try to answer their questions.

 

 

 

 

 

 

Manual Testing Syllabus

  1. SDLC and SDLC Phases
  • Requirements Phase
  • Analysis Phase
  • Design phase
  • Coding Phase
  • Testing phase
  • Installation

 

  1. SDLC Models
  • Waterfall Model.
  • V Model
  • Agile Model.
  • Prototype Model.
  • Spiral Model
  • Hybrid Model

 

  1. Software Testing Methodologies
  • White Box Testing
  • Black Box Testing
  • Grey Box Testing

 

  1. White Box Testing.
  • Path Testing
  • Loop Testing
  • Condition Testing
  • Performance Testing WBT
  • Memory Testing WBT

 

  1. Black Box Testing
    1. Functional Testing
      • Component Testing
      • Integration Testing
      • System Testing
      • User Acceptance Testing.
      • Sanity/Smoke Testing.
      • Regression Test.
    2. Non Functional Testing
      • Performance Testing.
      • Compatibility Testing.
      • Security Testing.
      • Recovery Testing.
      • Installation Testing.
      • Adhoc Testing.
    3. Globalization Testing
      • I18N Testing.
      • L1ON Testing.

 

  1. Software Testing Life Cycle
  • Understand the requirements/System study
  • Write Test Plan
  • Write Test Cases
  • Traceability Matrix
  • Test Execution
  • Defect Tracking
  • Prepare test execution report(TER)
  • Retrospect Meeting

 

  1. Testing Techniques
  • ECP
  • BVA
  • Error Guessing

 

  1. Defect Tracking Tools (Learn & Implement)
  • TFS

Edmunds Vehicle API with Jquery

Vehicle API

To get all Vehicle Details (New, Used, Future) using Jquery, Use the below code.

Step 1: Include the below code in your Html Body

 

Add this code in your HTML Header

Step 2: Sending Email with User selected car details.

Introduction to React JS

  1. What is React JS?
  2. What are the advantages of React?
  3. Limitations of React

 

What is React?

  • React is a front-end JavaScript library. Let me explain you in simple language with few key features of React.

Eliminating Redundancy:

  • While working on any application which uses HTML as Views, you might have a situations where you just copy and paste the same code at many places. Which is called as Code Redundancy.
  • So at this situation did you ever thought that how would if I can reuse this HTML code at multiple places.

Page1.html

Page2.html

If you are in this situation then how would if there is a common HTML for both page1 and page2.

Page1.html

Page2.html

How about this, awesome right!

Yes of course if we could do this there will be no more HTML code redundancies in the application.

 

Reuse UI Components:

  • If we can reduce the code redundancies using custom HTML tags, this is nothing but creating Reusable UI Components like <app-head></app-head>.
  • According to React documentation “React is a library for building reusable UI components which presents data that changes over time”.
  • Here the React Components comes into picture.
  • Component:
    • React application is all about components, the entire application will be divided into several Component segments.
    • One component can be nested with other component.
    • Components can be created in two ways,
      • Using var Component = CreateClass({ })
      • Using ES6 standards with Class keyword, class Component extends React.Component<{},{}>{  }

 

Ex:Using ES6 Syntax

Ex: Using ES5 Javascript Syntax

Easy Data-Binding:

  • This is one of the most important thing in React which is called as “Data-Binding”.
  • React can do only one-way binding using its interpolation “{ <expression> }”.
  • Here the JSX comes into picture, where JavaScript + XML = JSX.
  • JSX:
    • React used JavaScript expressions within curly braces “{ <expression> }”. We can put any type of JavaScript expression in the curly braces inside JSX.
    • Each React Element is like a real kind of javascript object which can be either stored in a variable or can be used throughout the program.
    • After coding in JSX pages no need to precompile the code, the JSX file will be automatically compiled and generates JavaScript syntax in the browser.

Example: Here I’ve used TSX instead of JSX, that’s why syntax while importing the libraries might look different.

Instead we can use, in JSX files

In TSX files,

 

 

Advantages of React:

  • Reusability of the UI code.
  • Eliminating code Redundancies (common code)
  • Familiar Syntax such as using class, extends, implements, interface keywords which are used for programming in most of the familiar languages like Java and .Net framework ,
  • The virtual DOM makes the testing simpler for the testers.
  • React can be used with most of the frameworks, because this is used only as a View Layer. Just we can replace the View Layer in any project with React UI Components. And it’s compatible with any Framework.
  • This is a light-weight library.
  • JSX syntax makes the developers feel free to use react i.e., Developers can use both javascript and HTML in a JS / JSX / TSX (typescript + XML) files with in a component. Where the developers will write the business logics in the component class, and the view part in the component’s templatee., with in the render ( ).
  • React can be written in
    • Javascript (.js) –   ES5 syntax
    • React’s recommended (.jsx) – Both ES5 and ES6 syntax
    • Typescript (.tsx) files. –  Both ES5 and ES6 syntax

 

Limitations:

  • React is just a library, because of that to develop an application React is just isn’t enough.
  • It doesn’t have its own routing, sevices etc… Because it is not a framework.
  • React has failed in competing with most of the advanced frameworks like Angular.
  • If someone asks why only React? There would be no perfect answer. Because Angular Framework can perform all the operations that React can do.

Differences between Angular JS and Angular 2

1.4 Differences between Angular JS and Angular 2

  • First thing we need to keep in mind is Angular 2 is not an upgrade version for Angular JS. Because Angular 2 is completely different compared to Angular JS architecture.
  • Architectures of Angular 2 has designed this as a new language which is no more uses MVC pattern. It’s a complete rewrite by the same Angular JS team.
  • Angular team announces that Angular 1.X is called as “AngularJS”, where Angular 2 will be called as just “Angular”
  • Let’s see the main differences between Angular JS and Angular 2