<?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: Aryan Absalan</title>
    <description>The latest articles on DEV Community by Aryan Absalan (@aryanabsalan).</description>
    <link>https://dev.to/aryanabsalan</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%2F521349%2F158396fe-c2ad-47e5-b1ae-92add9394751.jpg</url>
      <title>DEV Community: Aryan Absalan</title>
      <link>https://dev.to/aryanabsalan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aryanabsalan"/>
    <language>en</language>
    <item>
      <title>Handling Passwords and Secret Keys using Environment Variables</title>
      <dc:creator>Aryan Absalan</dc:creator>
      <pubDate>Mon, 14 Feb 2022 20:50:47 +0000</pubDate>
      <link>https://dev.to/aryanabsalan/handling-passwords-and-secret-keys-using-environment-variables-32d7</link>
      <guid>https://dev.to/aryanabsalan/handling-passwords-and-secret-keys-using-environment-variables-32d7</guid>
      <description>&lt;p&gt;To save passwords and secret keys in environment variables on Windows, you will need to open Advance System Setting.&lt;/p&gt;

&lt;p&gt;You can navigate to control panel &amp;gt; System and Security &amp;gt; System &amp;gt; Advanced system Settings.&lt;br&gt;
Now in Advance System Setting click on Environment Variables.&lt;br&gt;
Here we can add new user variables and new system variables. We will add user variable by clicking New under user variables.&lt;/p&gt;

&lt;p&gt;In the new window you can add Variable name and Variable value and click ok.&lt;br&gt;
Now, click Ok on Environment Variables window to save changes.&lt;/p&gt;

&lt;p&gt;Access the environmental variables&lt;br&gt;
To access these variables in our python script, we need to import the os module.&lt;br&gt;
We can do that by using os.environ.get() method and passing the key we want to access.&lt;/p&gt;

&lt;p&gt;If you are using .python-dotenv method you need to add a couple of lines at the start of your application.&lt;/p&gt;

&lt;p&gt;from dotenv import load_dotenv&lt;br&gt;
load_dotenv()&lt;/p&gt;

&lt;p&gt;In case of Django project, you should add the above script at the top of wsgi.py and manage.py file.&lt;/p&gt;

&lt;p&gt;from dotenv import load_dotenv   #for python-dotenv method&lt;br&gt;
load_dotenv()                    #for python-dotenv method&lt;/p&gt;

&lt;p&gt;import os &lt;/p&gt;

&lt;p&gt;user_name = os.environ.get('USER')&lt;br&gt;
password = os.environ.get('password')&lt;/p&gt;

&lt;p&gt;print(user_name, password)&lt;/p&gt;

&lt;h6&gt;
  
  
  ###### output
&lt;/h6&gt;

&lt;p&gt;username password&lt;/p&gt;

</description>
      <category>python</category>
      <category>password</category>
      <category>environment</category>
      <category>variables</category>
    </item>
    <item>
      <title>Python’s Virtual Environments </title>
      <dc:creator>Aryan Absalan</dc:creator>
      <pubDate>Mon, 03 Jan 2022 08:10:05 +0000</pubDate>
      <link>https://dev.to/aryanabsalan/pythons-virtual-environments-1e0k</link>
      <guid>https://dev.to/aryanabsalan/pythons-virtual-environments-1e0k</guid>
      <description>&lt;p&gt;execute the venv module, which is part of the Python standard library.&lt;br&gt;
crating test-project folder&lt;br&gt;
% cd test-project/&lt;br&gt;
Creating an environment called venv&lt;br&gt;
% python3 -m venv venv/       &lt;/p&gt;

&lt;p&gt;For activating the venv on Windows:&lt;br&gt;
C:&amp;gt; \Scripts\activate.bat&lt;br&gt;
installing the requirements of the project with:&lt;br&gt;
pip install -r requirements.txt&lt;/p&gt;

&lt;p&gt;You can deactivate a virtual environment by typing “deactivate”&lt;br&gt;
you can Remove virtual environments using rm:&lt;br&gt;
rm -r  your_ENV&lt;/p&gt;

</description>
    </item>
    <item>
      <title>C#  Static Class</title>
      <dc:creator>Aryan Absalan</dc:creator>
      <pubDate>Thu, 26 Nov 2020 14:29:43 +0000</pubDate>
      <link>https://dev.to/aryanabsalan/c-static-class-5771</link>
      <guid>https://dev.to/aryanabsalan/c-static-class-5771</guid>
      <description>&lt;p&gt;In C#, static means something which cannot be instantiated. You cannot create an object of a static class and cannot access static members using an object.&lt;/p&gt;

&lt;p&gt;C# classes, variables, methods, properties, operators, events, and constructors can be defined as static using the static modifier keyword.&lt;/p&gt;

&lt;p&gt;Static Class&lt;/p&gt;

&lt;p&gt;A static class cannot be instantiated. All members of a static class are static and are accessed via the class name directly, without creating an instance of the class.&lt;/p&gt;

&lt;p&gt;The following code is an example of a static class, CSharpCorner. We know that all members of the class are static. &lt;br&gt;
public static class CSharpCorner&lt;br&gt;&lt;br&gt;
{&lt;br&gt;&lt;br&gt;
// Static fields&lt;br&gt;&lt;br&gt;
public static string Name = "C# Corner";&lt;br&gt;&lt;br&gt;
public static string Founder = "Mahesh Chand";&lt;br&gt;&lt;br&gt;
public static DateTime YearFounded = new DateTime(2000, 01, 01);&lt;br&gt;&lt;br&gt;
public static string Location = "Downingtown, PA";&lt;br&gt;&lt;br&gt;
public static string Description =&lt;br&gt;&lt;br&gt;
"Online community of software and data developers";&lt;br&gt;&lt;br&gt;
public static int GetAgeOfWebsite()&lt;br&gt;&lt;br&gt;
{&lt;br&gt;&lt;br&gt;
return 1;&lt;br&gt;&lt;br&gt;
}&lt;br&gt;&lt;br&gt;
}&lt;br&gt;&lt;br&gt;
Static classes have the following characteristics: &lt;br&gt;
Static classes cannot contain Instance Constructors.&lt;br&gt;
Static classes contain only static members.&lt;br&gt;
Static classes cannot be instantiated.&lt;br&gt;
Static classes are sealed. That means, you cannot inherit other classes from instance classes. &lt;br&gt;
You can learn more about static classes here: Static Class in C#&lt;/p&gt;

&lt;p&gt;Static Members&lt;/p&gt;

&lt;p&gt;A static or non-static class static constructors, properties, methods, fields, operators, and events. Static properties and static methods are the most-used static members.&lt;/p&gt;

&lt;p&gt;Static Constructor&lt;/p&gt;

&lt;p&gt;Static constructor can't be parameterized.&lt;br&gt;
Static constructor doesn't have any access modifier because it doesn't have message passing and is used during domain processing.&lt;br&gt;
Static Constructor is used to initialize static data members of the class.&lt;/p&gt;

&lt;p&gt;Static Field&lt;/p&gt;

&lt;p&gt;A field with the static keyword represents a static field. Static fields can be declared as follows by using the static keyword. &lt;br&gt;
public static class HistoryTeacher&lt;br&gt;&lt;br&gt;
{&lt;br&gt;&lt;br&gt;
// static field&lt;br&gt;&lt;br&gt;
public static string Subject = "History";&lt;br&gt;&lt;br&gt;
}&lt;br&gt;&lt;br&gt;
The following code calls a static field. &lt;br&gt;
Console.WriteLine(HistoryTeacher.Subject);&lt;br&gt;&lt;br&gt;
When we declare static data members inside a class, it can be initialized with a value as shown above. All un-initialized static fields automatically get initialized to their default values when the class is loaded for the first time.&lt;/p&gt;

&lt;p&gt;Static Property&lt;/p&gt;

&lt;p&gt;Static properties are used to get or set the value of static data members of a class. The following code example declares four static properties. &lt;br&gt;
public static class HistoryTeacher&lt;br&gt;&lt;br&gt;
{&lt;br&gt;&lt;br&gt;
// private fields&lt;br&gt;&lt;br&gt;
private static string name;&lt;br&gt;&lt;br&gt;
private static string school;&lt;br&gt;&lt;br&gt;
private static int rank;&lt;br&gt;&lt;br&gt;
private static int years;&lt;br&gt;&lt;br&gt;
// static properties&lt;br&gt;&lt;br&gt;
public static int Years { get =&amp;gt; years; set =&amp;gt; years = value; }&lt;br&gt;&lt;br&gt;
public static int Rank { get =&amp;gt; rank; set =&amp;gt; rank = value; }&lt;br&gt;&lt;br&gt;
public static string School { get =&amp;gt; school; set =&amp;gt; school = value; }&lt;br&gt;&lt;br&gt;
public static string Name { get =&amp;gt; name; set =&amp;gt; name = value; }&lt;br&gt;&lt;br&gt;
}&lt;br&gt;&lt;br&gt;
The following code example sets static property values. &lt;br&gt;
HistoryTeacher.Name = "Mahesh Chand";&lt;br&gt;&lt;br&gt;
HistoryTeacher.Rank = 2;&lt;br&gt;&lt;br&gt;
HistoryTeacher.School = "Garnet Valley High School";&lt;br&gt;&lt;br&gt;
HistoryTeacher.Years = 5;&lt;br&gt;&lt;br&gt;
In the same way, you can access a static property by using the class name. &lt;br&gt;
Console.WriteLine(HistoryTeacher.Name);&lt;br&gt;&lt;br&gt;
Static Method&lt;/p&gt;

&lt;p&gt;Static methods are shared methods. They can be called with the class name and static method name only. You cannot instantiate a static method.&lt;/p&gt;

&lt;p&gt;Static methods only use static data members to perform calculation or processing.&lt;/p&gt;

&lt;p&gt;The following code example declares a static method that takes two int values as method arguments. &lt;br&gt;
public static class HistoryTeacher&lt;br&gt;&lt;br&gt;
{&lt;br&gt;&lt;br&gt;
// static method&lt;br&gt;&lt;br&gt;
public static int CalculateScore(int rank, int years)&lt;br&gt;&lt;br&gt;
{&lt;br&gt;&lt;br&gt;
return rank * years;&lt;br&gt;&lt;br&gt;
}&lt;br&gt;&lt;br&gt;
}&lt;br&gt;&lt;br&gt;
The following code example calls a static method. &lt;br&gt;
Console.WriteLine(HistoryTeacher.CalculateScore(3, 5));&lt;br&gt;&lt;br&gt;
Why use static classes and static members?&lt;/p&gt;

&lt;p&gt;Static classes are used as containers for static members. Static methods and static properties are the most-used members of a static class. All static members are called directly using the class name. Static methods do a specific job and are called directly using a type name, rather than the instance of a type.&lt;/p&gt;

&lt;p&gt;Here is a list of few use cases of static classes. &lt;br&gt;
A Math class with all static methods. Static classes are useful and provide an easy way to access its members that does not need to work differently for different objects. &lt;br&gt;
Above listed CSharpCorner class. We know the value of CSharpCorner class members such as its founder, launch date, location, and description, will never change regardless of its objects. &lt;br&gt;
App Configuration class that has all static settings about an app and the values of settings don’t change based on the objects or users.&lt;br&gt;
A DatabaseConfig class that may have members such as database name, server name, port number, and even a connection string. We know that these values will not change for objects. &lt;br&gt;
Static classes and static members are useful because they do not require instances created for each new object. That means, they consume fewer resources and no duplication of the same class or member is needed in memory.&lt;/p&gt;

&lt;p&gt;Static members make code cleaner.&lt;/p&gt;

&lt;p&gt;In theory, a static should give better performance compare to an instance. However, it is unnoticeable.&lt;/p&gt;

&lt;p&gt;Complete Code Example&lt;/p&gt;

&lt;p&gt;Here is a complete program that shows how to use static class and static members. &lt;br&gt;
using System;&lt;br&gt;&lt;br&gt;
namespace StaticInCSharp&lt;br&gt;&lt;br&gt;
{&lt;br&gt;&lt;br&gt;
class Program&lt;br&gt;&lt;br&gt;
{&lt;br&gt;&lt;br&gt;
static void Main(string[] args)&lt;br&gt;&lt;br&gt;
{&lt;br&gt;&lt;br&gt;
Console.WriteLine(HistoryTeacher.Subject);&lt;br&gt;&lt;br&gt;
HistoryTeacher.Name = "Mahesh Chand";&lt;br&gt;&lt;br&gt;
HistoryTeacher.Rank = 2;&lt;br&gt;&lt;br&gt;
HistoryTeacher.School = "Garnet Valley High School";&lt;br&gt;&lt;br&gt;
HistoryTeacher.Years = 5;&lt;br&gt;&lt;br&gt;
Console.WriteLine(HistoryTeacher.Name);&lt;br&gt;&lt;br&gt;
Console.WriteLine(HistoryTeacher.CalculateScore(3, 5));&lt;br&gt;&lt;br&gt;
Console.ReadKey();&lt;br&gt;&lt;br&gt;
}&lt;br&gt;&lt;br&gt;
}&lt;br&gt;&lt;br&gt;
public static class HistoryTeacher&lt;br&gt;&lt;br&gt;
{&lt;br&gt;&lt;br&gt;
// static field&lt;br&gt;&lt;br&gt;
public static string Subject = "History";&lt;br&gt;&lt;br&gt;
// private fields&lt;br&gt;&lt;br&gt;
private static string name;&lt;br&gt;&lt;br&gt;
private static string school;&lt;br&gt;&lt;br&gt;
private static int rank;&lt;br&gt;&lt;br&gt;
private static int years;&lt;br&gt;&lt;br&gt;
// static properties&lt;br&gt;&lt;br&gt;
public static int Years { get =&amp;gt; years; set =&amp;gt; years = value; }&lt;br&gt;&lt;br&gt;
public static int Rank { get =&amp;gt; rank; set =&amp;gt; rank = value; }&lt;br&gt;&lt;br&gt;
public static string School { get =&amp;gt; school; set =&amp;gt; school = value; }&lt;br&gt;&lt;br&gt;
public static string Name { get =&amp;gt; name; set =&amp;gt; name = value; }&lt;br&gt;&lt;br&gt;
// static method&lt;br&gt;&lt;br&gt;
public static int CalculateScore(int rank, int years)&lt;br&gt;&lt;br&gt;
{&lt;br&gt;&lt;br&gt;
return rank * years;&lt;br&gt;&lt;br&gt;
}&lt;br&gt;&lt;br&gt;
}&lt;br&gt;&lt;br&gt;
} &lt;/p&gt;

</description>
    </item>
    <item>
      <title> The Object-Oriented Programming in C#</title>
      <dc:creator>Aryan Absalan</dc:creator>
      <pubDate>Thu, 26 Nov 2020 14:23:48 +0000</pubDate>
      <link>https://dev.to/aryanabsalan/the-object-oriented-programming-in-c-5999</link>
      <guid>https://dev.to/aryanabsalan/the-object-oriented-programming-in-c-5999</guid>
      <description>&lt;p&gt;The Object-Oriented Programming in C#&lt;/p&gt;

&lt;p&gt;The Object-Oriented Programming (OOPs) in C# is a design approach where we think in terms of real-world objects rather than functions or methods. Unlike procedural programming language, here in oops, programs are organized around objects and data rather than action and logic.&lt;/p&gt;

&lt;p&gt;OOPs, provide 4 principles. They are&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Encapsulation

Inheritance

Polymorphism

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

&lt;/div&gt;

&lt;p&gt;We will discuss all these principles in detail using some real-time examples.&lt;br&gt;
But first, we define some simple classes.&lt;/p&gt;

&lt;p&gt;Class and Objects from Layman Point of View.&lt;br&gt;
From the layman point of view, we can define a class as a blueprint of a specific object. Every living and non-living thing is considered as objects such as Car, People, Place, etc. Again, each and every object has some color, shape, properties, and functionalities.&lt;/p&gt;

&lt;p&gt;For example, consider the luxury car Ferrari. Here, Ferrari is an object of the luxury car type. The luxury car is a class that specifies some characteristics such as speed, color, shape, etc. So any car manufactures company that makes a car and if that car meets all those requirements, then it is an object of the luxury car type.&lt;/p&gt;

&lt;p&gt;If you take the example BMW, Lamborghini, and Cadillac, then all these cars are an object of the ‘Luxury Car’ class. Here, ‘Luxury Car’ is a class and every single car (BMW, Lamborghini, and Cadillac) is an object of the luxury car class. Now, let us understand what exactly class and objects from the programming point of view.&lt;/p&gt;

&lt;p&gt;Class and Objects from Programming Language Point of View.&lt;br&gt;
Here we are going to understand the class and objects from the C# programming language point of view. But this is also applicable to any object-oriented programming language like java and c++.&lt;/p&gt;

&lt;p&gt;Class:&lt;br&gt;
A class is simply a user-defined data type that represents both state and behavior. The state represents the properties and behavior is the action that objects can perform.&lt;/p&gt;

&lt;p&gt;In other words, we can say that a class is the blueprint/plan/template that describes the details of an object. A class is a blueprint from which the individual objects are created. In C#, a Class is composed of three things i.e. a name, attributes, and operations.&lt;/p&gt;

&lt;p&gt;Objects:&lt;br&gt;
It is an instance of a class. A class is brought live by creating objects. An object can be considered as a thing that can perform activities. The set of activities that the object performs defines the object’s behavior.&lt;/p&gt;

&lt;p&gt;All the members of a class can be accessed through the object. To access the class members, we need to use the dot (.) operator. The dot operator links the name of an object with the name of a member of a class.&lt;/p&gt;

&lt;p&gt;using System;&lt;/p&gt;

&lt;p&gt;using System.Collections.Generic;&lt;/p&gt;

&lt;p&gt;using System.Linq;&lt;/p&gt;

&lt;p&gt;using System.Text;&lt;/p&gt;

&lt;p&gt;using System.Threading.Tasks;&lt;/p&gt;

&lt;p&gt;namespace ClassDemo&lt;/p&gt;

&lt;p&gt;{&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Program

{

    static void Main(string[] args)

    {



        Console.WriteLine("Example of defining a class in C#, setting its properties and calling its method/s.");



        // defining the first object of student class as tim

        Student tim = new Student();

        // setting the poblic attributes for the first object

        tim.FirstName = "Tim";

        tim.LastName = "Timmabc";





        // defining the second object of student class as jim

        Student jim = new Student();

        // setting the poblic attributes for the second object

        jim.FirstName = "Jim";

        jim.LastName = "Jimmxyz";



        //Calling the Display method for both objects

        tim.Display();

        jim.Display();



        Console.ReadKey();

    }

}



class Student

{

    //Public properties

    public string FirstName { get; set; }

    public string LastName { get; set; }



    //Default constructor.

    public Student()

    {

    }



    //Public method

    public void Display()

    {

        Console.WriteLine("\t Student first name:  " + this.FirstName);

        Console.WriteLine("\t Student last name:  " + this.LastName);

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

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
