Showing posts with label Misc. Show all posts
Showing posts with label Misc. Show all posts

Wednesday, 13 March 2019

Three Rules of TDD


The Three Laws of TDD.


TDD (Test Driven Development) 's three simple rules:

  1. You are not allowed to write any production code unless it is to make a failing unit test pass.
  2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
  3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test.

Its good to follow these 3 rules to write quality, testable, readable, maintainable and production ready code.

Wednesday, 13 February 2019

Online free programming editors

Please find Online free programming editors

1. Ruby RegExp (Regular Expression) online free editor
    https://rubular.com/

2. C language online free editor
    https://www.onlinegdb.com/online_c_compiler
    https://repl.it/languages/c
    https://www.tutorialspoint.com/compile_c_online.php

3. Java language online free editor
    https://www.tutorialspoint.com/compile_java_online.php
    https://www.jdoodle.com/online-java-compiler

4. Scala language online free editor
    https://scastie.scala-lang.org/
    https://www.tutorialspoint.com/compile_scala_online.php

Friday, 1 December 2017

Know version in Ubuntu Linux: Java, Scala,Docker, Python, Sbt

In this post, we will discuss about how to know the current version of your installed software in Ubuntu Linux.

Let us discuss about the following softwares now:

To know Java Version:

ram:~$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)


To know Scala Version:

ram:~$ scala -version
Scala code runner version 2.11.7 -- Copyright 2002-2013, LAMP/EPFL


To know Python Version:

ram:~$ python --version
Python 2.7.12


To know Docker Version:


ram:~$ docker -v
Docker version 1.12.6, build 78d1802

To know SBT Version:

ram:~$ sbt sbtVersion
[info] Loading global plugins from /home/rambabuposa/.sbt/0.13/plugins
[info] Loading project definition from /home/rambabuposa/project
[info] Set current project to rambabuposa (in build file:/home/rambabuposa/)
[info] 0.13.16

To know Lightbend ConductR Sandbox Version:

ram:~$ sandbox version
1.2.25

Supported API version(s): 1, 2


Thank you for reading my tutorials. Please support my blog by clicking some ads in my posts.

Please let me know if you need any more commands to publish here.

Happy Learning!

Thursday, 16 November 2017

Github: How to keep Your Forked Repo Up-to-Date?

Sometimes, when we don't have "write" access to your working repository, we cannot create a new branch to apply your changes or we cannot push our changes to master.

We cannot create PR (Pull Request) to review your changes by peers.

In this case, we cannot use "Cloning", should use "Forking" concept.

Github Forking:

Forking is different from Cloning. Login to your github.com profile and click on "Forking" button or link available at top right corner.



It creates same repository into your github profile. Then fork it and work on changes.

Now we don't need to create a Branch as we are working on forked repository.

Just pull your changes to your forked master:   

$ git pull

Forking Problem:

Above procedure works as long as you don't see the following message:





Resolution:

Lets us ORIGINAL_REPO  is main repository and FORKED_REPO is our forked repo created from ORIGINAL_REPO.



1. Clone your fork:

git clone git@github.com:<user-name>/FORKED_REPO.git

2. Add remote from original repository in your forked repository:

cd FORKED_REPO_PATH
git remote add upstream git://github.com/<user-name>/ORIGINAL_REPO.git
git fetch upstream

3. Updating your fork from original repository to keep up-to-date changes:

git pull upstream master


4. Push changes to your forked repository:
git push


Thank you 










Wednesday, 8 November 2017

Install Firefox old version in Ubuntu (Linux)

Sometimes, we need to use old version to test some kind of testing like Acceptance tests, Performance tests, Browser Stack Testing etc.

My Linux system has default latest version of Firefox 55 and my automation tests required Firefox version 45.

In this case, we can NOT use our default latest version of browser.

I faced same issue with my current project with Firfox browser in Ubuntu (Linux) and fixed it by doing the following steps:

ram:~$ apt-cache show firefox | grep Version
Version: 55.0.2+build1-0ubuntu0.16.04.1
Version: 45.0.2+build1-0ubuntu1


It list out all available Firefox browser versions in your system.

To deploy the required version, please use this command:

ram:~$ sudo apt-get install firefox=45.0.2+build1-0ubuntu1


Now, we can continue our testing using firefox version 45.

Thank you so much for reading my tutorials.

PS:- Please support my blog by clicking some ads.


Thursday, 20 July 2017

Linux: Know PID running at a specific port number

To know the process id which is running on a specific port number


$ sudo netstat -nlp | grep :1212
   tcp6       0      0 :::1212        :::*   LISTEN      21341/java 


$ lsof -i 

It displays the information of all currently running process like PID, port number, user etc.


Example:-

$ lsof -i
COMMAND     PID    USER   FD   TYPE DEVICE      SIZE/OFF NODE NAME
java       60729   ram  7188u  IPv6  121212      0t0  TCP *:1291 (LISTEN)
java       60850   ram  7181u  IPv6  1212        0t0  TCP *:1195 (LISTEN)
java       60949   ram  8173u  IPv6  1212        0t0  TCP *:2272 (LISTEN)
java       70040   ram  1971u  IPv6  1213        0t0  TCP *:2230 (LISTEN)
java       70142   ram  9072u  IPv6  11111       0t0  TCP *:4449 (LISTEN)
java       70232   ram  1365u  IPv6  111         0t0  TCP *:5585 (LISTEN)
java       70318   ram  1476u  IPv6  111         0t0  TCP *:6514 (LISTEN)
python     70400   ram    43u  IPv4  2222        0t0  TCP *:1232 (LISTEN)
java      180595   ram  3402u  IPv6  22222       0t0  TCP *:3232 (LISTEN)



Then run kill command to kill it.

$kill -9 <PID>

Thanks you.

Tuesday, 14 February 2017

Tech News for Dev and QA

Introduction


Like Scala News, in this post, I'm going to update all Technology News useful for any IT Guys: IT, DEV and QA. Please check this post regularly to know more news.



Tech News

  • MongoDB Stitch
         Configure your application backend in the cloud
  • Convert Unix timestamp to Readable Date/time 
         Convert a Date/Time to a Unix timestamp
         http://www.onlineconversion.com/unix_time.htm
  • JSON Formatter Tool
         http://codebeautify.org/jsonviewer  
  • Gradle 3.5 now available! 
         https://docs.gradle.org/3.5/release-notes.html
  • Chrome DevTools  Free Tutorial 
          https://www.codeschool.com/courses/discover-devtools
  • Nice JSON Formater
         http://jsonformatter.org

  • JSON Validator or Formater

         http://jsonlint.com
  • To Create Regexpressions easily
          https://regex101.com
  • MongoDB UI Tool or Manager
         https://robomongo.org/
  • Another useful MongoDB Manager
         https://www.mongodbmanager.com/

  • ZAP Security (PEN) Testing Tool      
         https://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project

  • BigData Hadoop Softwares
BigData SoftwareOrganization
Apache HadoopApache Software
ClouderaCloudera Inc.
Microsoft AzureMicrosoft 
IBM BigInsights IBM
Google Cloud DataprocGoogle 
Oracle Big Data ApplianceOracle Corporation

  • Cloud Platform

BIGDATA SOFTWAREORGANIZATION
AWS (Amazon WebService)Amazon
GCP(Google Colud Platform)Google




Stay tuned for further updates to this post to know more news about Technology New.

I love your valuable comments please.


Thank you.

Wednesday, 20 May 2015

Favor Composition Over Inheritance

Composition Over Inheritance

What is Inheritance?
In Inheritance, one class can acquire all the members of another class except private members.
Inheritance means one class (Subclass) extends the functionality of another class (Super Class).

Inheritance is IS-A Relationship between two or more components

What is Composition?
Composition means a class (which wants to implement a functionality) uses other classes (that implement the desired functionality) as instance reference variables. Main candidate class does not implement that existing functionality. It uses and delegates to other classes (who are already implemented desired functionality and who are responsible to provide that functionality).

Composition is HAS-A Relationship between two or more components

Common Advantages of Inheritance and Composition:
1. Code Reusability.
2. Reduces code duplication.

Advantages of Inheritance:
1. Ease of code change with Dynamic Binding and Polymorphism
2. Ease to add new subclasses
3. As Inheritance uses single method call, it may have some performance improvement as compared to Composition uses delegation approach.

Advantages of Composition:
1. Easier-to-change code

Major Drawbacks of Inheritance:
1. Breaks Encapsulation principle
2. When Inheritance levels increases, it is very tough and hard to maintain 
    and create objects.

Major Drawbacks of Composition:
1. As Composition uses delegation approach, it may have a performance cost as compared to inheritance's single invocation of an inherited superclass method implementation.

What is Dynamic Binding?
JVM uses Dynamic Binding to decide which method should be invoked at runtime based on the class of the object.

What is Polymorphism?
Polymorphism is a technique of an object to take on many forms. 
Polymorphism means we can use a reference of a superclass to hold a reference to an object whose class is the subclass or any of its subclasses.


Reasons to Use "Favor Composition Over Inheritance" Design Principle:

1. Flexibility 
Inheritance resolves the required functionality at compile-time where as Composition does this at run-time. So we can write more flexibility code with Composition. Major Advantage of Composition is easier-to-change code

2. Ease of Testability
In Composition we use other dependent objects references as instance variables so that we can mock them and test our class functionality very easily.

3. Does NOT break Encapsulation
If we use inheritance to reuse and extend existing functionality, then there are some cases to break this functionality in future. 

For instance, our subclass method is reusing super class method to extend the functionality. If we change super class method behavior, then it will also change the subclass functionality. Inheritance provides weak encapsulation .

If we use Composition over Inheritance, there is no breakup of the functionality with future changes.

4.Java does NOT support Multiple Inheritance
As Java does not support Multiple Inheritance, it is better to use Composition to utilize more than one class functionality.

5. Well tested Design Patterns uses this Design Principle
Most of the well defined and tested Design Patterns follow this Design Principle.

The following design patterns follows this "Favor Composition Over Inheritance" Object-Oriented Design Principle
1. Strategy Design Pattern
2. Decorator Design Pattern
3. Bridge Design Pattern
4. Adapter Design Pattern
5. State Design Pattern
6. Delegate Design Pattern
7. Façade Design Pattern
8. Mediator Design Pattern
9. Manager Design Pattern
10. Operator Design Pattern
11. Command Design Pattern




Object Oriented Analysis and Design

OOAD(Object Oriented Analysis and Design)

Object Oriented Programming(OOPs) Concepts
1. Inheritance
2. Polymorphism
3. Encaspulation
4. Abstraction

They are known as Basic OOP or OOAD Principles. They are also known as Four Pillars of OOP or OOA&D. 

OOAD Principles: SOLID
S stands for SRP(Single Responsibility Principle)
O stands for OCP(Open Closed Principle)
L stands for LSP(Liskov Substitution Principle)
I stands for ISP(Interface Segregation Principle)
D stands for DIP(Dependency Inversion Principle)