<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Komal Singh</title>
    <description>The latest articles on DEV Community by Komal Singh (@komalsingh1).</description>
    <link>https://dev.to/komalsingh1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F373536%2F374fad73-51d0-4ae7-95d1-2b8683e00b33.jpg</url>
      <title>DEV Community: Komal Singh</title>
      <link>https://dev.to/komalsingh1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/komalsingh1"/>
    <language>en</language>
    <item>
      <title>C++ Interview Questions</title>
      <dc:creator>Komal Singh</dc:creator>
      <pubDate>Mon, 12 Oct 2020 13:24:24 +0000</pubDate>
      <link>https://dev.to/komalsingh1/common-c-interview-questions-2inj</link>
      <guid>https://dev.to/komalsingh1/common-c-interview-questions-2inj</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FhNDMwL3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u3pr3319wc3v8v2zw13p.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FhNDMwL3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u3pr3319wc3v8v2zw13p.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a constructor&lt;/strong&gt;&lt;br&gt;
A constructor is a member function of a class that initializes objects of a class. In C++, Constructor is automatically called when an object(instance of a class) is created.&lt;br&gt;
There are three types of constructors:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Default Constructor: Constructor with no parameters/arguments
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt; 
using namespace std; 
class A { 
public: 
    int a, b; 
    // Default Constructor 
    A() 
    { 
        a = 1; 
        b = 2; 
    } 
}; 

int main() 
{ 
    // Default constructor called automatically 
    // when the object is created 
    A obj; 
    cout &amp;lt;&amp;lt; "a: " &amp;lt;&amp;lt; obj.a &amp;lt;&amp;lt; endl 
         &amp;lt;&amp;lt; "b: " &amp;lt;&amp;lt; obj.b; 
    return 1; 
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
a: 1&lt;br&gt;
b: 2&lt;br&gt;
The compiler automatically provides a default constructor even if we do not initialize one.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Parameterized Constructor: Constructor with Parameter/Arguments
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;
class ParamA {
private:
int b, c;
public:
ParamA (int b1, int c1)
{
b = b1;
c = c1;
}
int getX ()
{
return b;
}
int getY ()
{
return c;
}
};
int main ()
{
ParamA p1(10, 15);
cout &amp;lt;&amp;lt; "p1.b = " &amp;lt;&amp;lt; p1. getX() &amp;lt;&amp;lt; ", p1.c = " &amp;lt;&amp;lt; p1.getY();
return 0;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: p1.b = 10, p1.c = 15&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Copy Constructor: A copy constructor is a member function that initializes an object using another object of the same class.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include&amp;lt;iostream&amp;gt;
using namespace std;
class test
{
private:
int x;
public:
test(int x1)
{
x = x1;
}
test(const test &amp;amp;t2)
{
x = t2.x;
}
int getX()
{
return x;
}
};
int main()
{
test t1(7); // Normal constructor is called here
test t2 = t1; // Copy constructor is called here
cout &amp;lt;&amp;lt; "t1.x = " &amp;lt;&amp;lt; t1.getX();
cout &amp;lt;&amp;lt; "t2.x = " &amp;lt;&amp;lt; t2.getX();
return 0;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;t1.x = 7&lt;br&gt;
t2.x = 7&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How constructors are different from a normal member function?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A constructor is different from normal functions in the following ways:&lt;/p&gt;

&lt;p&gt;A constructor has the same name as the class name&lt;br&gt;
Constructors don’t have a return type&lt;br&gt;
A constructor is automatically called when an object is created.&lt;br&gt;
If we do not specify a constructor, the C++ compiler generates a default constructor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constructor Overloading in C++&lt;/strong&gt;&lt;br&gt;
Two or more constructors in a class with the same name but a different list of arguments is known as Constructor Overloading.&lt;/p&gt;

&lt;p&gt;A constructor is called depending upon the number and type of arguments passed. While creating the object, arguments must be passed to let the compiler know the constructor that is needed to be called.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a destructor?&lt;/strong&gt;&lt;br&gt;
Destructor is a member function that destructs or deletes an object.&lt;br&gt;
A destructor function is called automatically when the object goes out of scope:&lt;br&gt;
(1) the function ends&lt;br&gt;
(2) the program ends&lt;br&gt;
(3) a block containing local variables ends&lt;br&gt;
(4) a delete operator is called &lt;/p&gt;

&lt;p&gt;Destructors have the same name as the class preceded by a tilde (~)&lt;br&gt;
Destructors don’t take any argument and don’t return anything.&lt;br&gt;
&lt;strong&gt;NOTE&lt;/strong&gt;&lt;br&gt;
The compiler creates a default destructor for us if we do not write our own destructor in class. The default destructor works fine unless we have dynamically allocated memory or pointer in class. When a class contains a pointer to memory allocated in class, we should write a destructor to release memory before the class instance is destroyed. This must be done to avoid Memory Leak. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/komalsingh1/c-common-interview-questions-7j1"&gt;Part 1: Series of C++ interview Questions&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Will be adding some more C++ based interview questions. Do suggest if you have come across some interesting C++ questions in interviews :)&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cpp</category>
    </item>
    <item>
      <title>C++ Common Interview Questions</title>
      <dc:creator>Komal Singh</dc:creator>
      <pubDate>Tue, 06 Oct 2020 04:05:32 +0000</pubDate>
      <link>https://dev.to/komalsingh1/c-common-interview-questions-7j1</link>
      <guid>https://dev.to/komalsingh1/c-common-interview-questions-7j1</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QloJBIQp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9cisf385un80ivdmkdq3.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QloJBIQp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9cisf385un80ivdmkdq3.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is this keyword and its use?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A very common concept used frequently in C++ Code. Let's see what are the use and what it is.&lt;br&gt;
Each object gets its own copy of data members and all objects share a single copy of member functions.&lt;br&gt;
Then now question is that if only one copy of each member function exists and is used by multiple objects, how are the proper data members are accessed and updated?&lt;br&gt;
The compiler supplies an implicit pointer along with the names of the functions as ‘this’.&lt;br&gt;
The ‘this’ pointer is passed as a hidden argument to all nonstatic member function calls and is available as a local variable within the body of all nonstatic functions. ‘this’ pointer is not available in static member functions as static member functions can be called without any object (with class name).&lt;br&gt;
The following are the uses of This Pointer:&lt;br&gt;
1) When local variable’s name is same as member’s name &lt;br&gt;
2) To return a reference to the calling object&lt;/p&gt;

&lt;p&gt;(Answer Credits: GFG)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are Serialization and Deserialization&lt;/strong&gt;&lt;br&gt;
Serialization is a mechanism to convert an object into a sequence of bytes so that it can be stored in memory. The byte stream, once created, also can be streamed across a communication link to a remote receiving end. The reverse of serialization is called deserialization, where the data in the byte stream is used to reconstruct it to its original object form. Apart from object persistence, this mechanism is particularly useful in transmitting object information in serialized form, say, to the server which, on receiving it, can deserialize and create the object format which is its original form.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are virtual functions – Write an example?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Virtual functions are used with inheritance, they are called according to the type of the object pointed or referred, not according to the type of pointer or reference. In other words, virtual functions are resolved at runtime. Virtual keyword is used to make a function virtual.&lt;br&gt;
Suppose we have the same function name in both the base and derive class and we want to access the derived class method, we can achieve this by making the base class method virtual.&lt;/p&gt;

&lt;p&gt;For example, in the following program, bp is a pointer of type Base, but a call to bp-&amp;gt;show() calls show() function of Derived class because bp points to an object of Derived class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include&amp;lt;iostream&amp;gt; 
using namespace std; 

class Base { 
public: 
    virtual void show() { cout&amp;lt;&amp;lt;" In Base \n"; } 
}; 

class Derived: public Base { 
public: 
    void show() { cout&amp;lt;&amp;lt;"In Derived \n"; }  
}; 

int main(void) {    
    Base *bp = new Derived;      
    bp-&amp;gt;show();  // RUN-TIME POLYMORPHISM 
    return 0; 
} 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;O/P: In Derived&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;What is Pure Virtual function? *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A pure virtual function (or abstract function) in C++ is a virtual function for which we don’t have an implementation, we only declare it. A pure virtual function is declared by assigning 0 in its declaration. See the following example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class virtualexample 
{    
    // Data members of class 
public: 
    // Pure Virtual Function 
    virtual void show() = 0; 

   /* Other members */
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Will be adding some more C++ based interview questions. Do suggest if you have come across some interesting C++ questions in  interviews.&lt;/p&gt;

</description>
      <category>cpp</category>
    </item>
    <item>
      <title>CI/CD and It's best Practices</title>
      <dc:creator>Komal Singh</dc:creator>
      <pubDate>Tue, 01 Sep 2020 13:17:45 +0000</pubDate>
      <link>https://dev.to/komalsingh1/cicd-and-it-s-best-practices-3k8p</link>
      <guid>https://dev.to/komalsingh1/cicd-and-it-s-best-practices-3k8p</guid>
      <description>&lt;p&gt;Continuous Integration, Delivery, and Deployment known collectively as CI/CD is a very common buzzword in IT Industry. It is an integral part of modern development intended to reduce errors during integration while increasing productivity.&lt;br&gt;
So now we know that CI/CD is so important let's understand what it is:&lt;br&gt;
&lt;strong&gt;CI (Continuous Integration)&lt;/strong&gt;&lt;br&gt;
This is a practice followed by the developers to merge their code changes in the master repository as often as possible. &lt;br&gt;
The change is then validated by automated build and Test Cases.  This avoids the integration blunder that usually happens when people wait for release day to merge their changes into the release branch.&lt;br&gt;
Continuous integration puts a great emphasis on Automation testing to check that the application is not broken whenever new commits are integrated into the main branch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Continuous Delivery&lt;/strong&gt;&lt;br&gt;
Continuous Delivery makes sure that the release can be made in Production after Testing. This means that Continuous delivery is not only about automated testing but also an automated release process that deploys your application at any point in time by clicking on a button.&lt;br&gt;
If you truly want to get the benefits of continuous delivery, you should deploy to production as early as possible to make sure that you release small batches that are easy to troubleshoot in case of a problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Continuous Deployment&lt;/strong&gt;&lt;br&gt;
Continuous Deployment is a step ahead of Continuos delivery. With this practice, every change that passes all stages of the production pipeline is released to the customers. every step is automated and only a failed test will prevent a new change to be deployed to production.&lt;br&gt;
The entire CI/CD process is a boon for business&lt;/p&gt;

&lt;p&gt;So now we know that CI/CD can help the developers a lot and they can now focus on important agenda instead of bugging on release day. Successful implementation of CI/CD is required to get the best out of it and hence it is important to follow the best CI/CD practices. &lt;/p&gt;

&lt;p&gt;Here are some of the mandatory practices to follow in CI/CD for the best result:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Securing and isolating the CI/CD environment&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this era where security threats can lead to a massive reputation and financial losses to businesses. Stressing on the importance of security is very important. Since the CI/CD system offers access to the codebase and credentials to deploy in various environments, it is often the prime target. Shielding all external access to the servers and tightly controlling the types of internal access allowed will help reduce the risk of your CI/CD system being compromised.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Commit daily and reduce branching in the Version Control&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Committing changes daily can make integration with the master branch really easier. This can save a massive amount of time invested in Version Control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Run Tests Locally Before Committing to the CI/CD Pipeline&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Discovering failures early is an important criterion. Changes must be tested in the Dev environment thoroughly before finally committing to the PROD environment. The local developer environment should have the entire test cases as in the production environment.&lt;/p&gt;

&lt;p&gt;To ensure that developers can test effectively on their own, the testing environment should be runnable with a single command that can be run from any environment. This is often achieved by providing a shell script or makefile to automate running the testing tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Keep the Pipelines Fast&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;CI/CD pipelines help changes through automated testing cycles, UAT environments, and finally to production. The testing Pipeline must be more comprehensive to avoid unforeseen situations in production deployment. Since all the change must go through this process, keeping the pipelines fast is incredibly important to not inhibit development speed.&lt;/p&gt;

&lt;p&gt;Now how can we speed up the process in the  Pipeline?&lt;br&gt;
Steps that you can take to improve speed are scaling CI/CD infrastructure and optimizing tests. &lt;/p&gt;

&lt;p&gt;Two broad categories of tests that can be automated are:&lt;/p&gt;

&lt;p&gt;Tests that are executed on a frequent basis &lt;br&gt;
If such tests are executed ‘manually’ by testers, it may be prone to errors since the productivity may reduce as the testers have to execute the same test multiple times in a day. Hence Automating these Test cases can definitely boost up the Deployment.&lt;/p&gt;

&lt;p&gt;Tests that require knowledge &amp;amp; have the dependency on a specific set of testers&lt;br&gt;
Dependency on a developers/testers that only have the domain knowledge required for test execution can be risky during a critical phase of the project. Their absence can impact the overall project deliverables. Such situations can be avoided by incorporating test automation in the CI/CD pipeline, so that project deadlines are not adversely affected&lt;/p&gt;

&lt;p&gt;There could be many other scenarios where automation testing can be used and the intent should be to make use of tools &amp;amp; test platforms (which are scalable) that can help you to achieve the required goal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Decide which processes and tests to automate first&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In many projects that when it comes to testing automation for CI/CD pipeline, we often forget to prioritize our test case in a systematic approach. Here is what I mean! As a best practice of CI/CD, it is always recommended to execute your smaller and simple test cases before your long and complex ones.&lt;/p&gt;

&lt;p&gt;This way you could be sure of individual test case coverage and performance with respect to functionality testing in an isolated manner. Complex test cases where you design test cases to check the interaction between multiple modules can come later!&lt;/p&gt;

&lt;p&gt;PS: Hope this article is useful. Feel free to add Valuable points! &lt;/p&gt;

</description>
      <category>devops</category>
      <category>jenkins</category>
      <category>agile</category>
      <category>cicd</category>
    </item>
  </channel>
</rss>
