Sunday, November 22, 2020

Python #001 - keywords, classes and instances

 

 

I wanna to get to the Google Drive API and JIRA and connect them together. In order to do that I've tried to prepare code in C#. I managed to do that... but if I want to deploy it online I need a server and more skill to that. I decided to switch to Python - there are people who will help me to deploy this kind of app.


So what is Python?

Python is an interpreted, high-level and general-purpose programming language. Python's design philosophy emphasizes code readability with its notable use of significant whitespace. Its language constructs and object-oriented approach aim to help programmers write clear, logical code for small and large-scale project.

Where to start?

I started with classes and instances. A great read over here: https://docs.python.org/3/tutorial/classes.html

There is "a little bit" different syntax than in JAVA (not so complex). This is my first class

The best example to explain how to use class variable shared by all instances and instance variable unique to each instance:

What about the keywords?

Keywords are special words which are reserved and have a specific meaning. Python has a set of keywords that cannot be used as variables in programs.

All keywords in Python are case sensitive.

Python Keywords Display Using Python Shell 

A quick shortcut to print the list of all the keywords:


 

Sunday, October 25, 2020

Unity #002 - PlayerController script (probably part #01)

There are many methods of coding a player movement. I wrote down two of them (the most convenient ones for my solution). Reminder here - I've been learning Unity for a short period of time so probably there are plenty better methods to do the PlayerController script for this solution :)

The first method is using Unity function AddForce

 

 to a myRigidbody I've added force by Vector2. It will move acc. to forceFactor value

A second method it is function MovePosition


Here there is no physics (no forces) added. I just added vector value to the current position.

Friday, October 23, 2020

Unity #001 - First blood

 All right I am back to blogging. This time it is a time for Unity and C#. I've done a 12 hour course with a fine teacher. Now I am trying to focus on game creation from the scratch and learn as much as possible.


The first game I will try to do is "Zeldish" style of game. I will build a simple player controler and few levels. I've already downloaded free assets for this one.

It will look like this: 


More to come. Let's go!

Monday, November 25, 2019

Time for JAVA #002 - constructor


Constructor is a block of code that initializes the newly created object. A constructor resembles an instance method in java but it’s not a method as it doesn’t have a return type.
This is how it looks like (the simplest declared constructor - no arg):


There are three types of constructors: Default, No-arg constructor and Parameterized.

1) If you do not implement any constructor in your class, Java compiler inserts a default constructor into your code on your behalf (it is invisible).

2) Constructor with no arguments is known as no-arg constructor. The signature is same as default constructor, however body can have any code unlike default constructor where the body of the constructor is empty.

3) Constructor with arguments(or you can say parameters) is known as Parameterized constructor.


Output will be:
Id: 00001 Name: Stalkerowaty
Id: 00002 Name: Stalkerowaty2

Although you may see some people claim that that default and no-arg constructor is same but in fact they are not, even if you write public Demo() { } in your class Demo it cannot be called default constructor since you have written the code of it.

Difference between Constructor and Method

The purpose of constructor is to initialize the object of a class while the purpose of a method is to perform a task by executing java code. Constructors cannot be abstract, final, static and synchronised while methods can be. Constructors do not have return types while methods do.

Quick Recap of all info:
1) Every class has a constructor whether it’s a normal class or a abstract class.
2) Constructors are not methods and they don’t have any return type.
3) Constructor name should match with class name.
4) Constructor can use any access specifier, they can be declared as private also. Private constructors are possible in java but there scope is within the class only.
5) Like constructors method can also have name same as class name, but still they have return type, though which we can identify them that they are methods not constructors.
6) If you don’t implement any constructor within the class, compiler will do it for.
7) this() and super() should be the first statement in the constructor code. If you don’t mention them, compiler does it for you accordingly.
8) Constructor overloading is possible but overriding is not possible. Which means we can have overloaded constructor in our class but we can’t override a constructor.
9) Constructors can not be inherited.
10) If Super class doesn’t have a no-arg(default) constructor then compiler would not insert a default constructor in child class as it does in normal scenario.
11) Interfaces do not have constructors.
12) Abstract class can have constructor and it gets invoked when a class, which implements interface, is instantiated. (i.e. object creation of concrete class).
13) A constructor can also invoke another constructor of the same class – By using this(). If you want to invoke a parameterized constructor then do it like this: this(parameter list).

Wednesday, November 6, 2019

Automation for JIRA #005 - How to set active link to @assignee in comment

The situation is like that:
There are two tasks. Task 1 and Task 2. Task 2 has a link set to "is blocked by" Task 1. Person who trasit Task 1 to status "Done" do not inform other person who is responsible for Task 2 (and can not work on it because it is blocked by Task 1).
I solved it with a simple automation:

What I could not find was a assignee name (but the active one) - there is a smart values like: {{assignee.displayName}} or {{assignee.key}} but those are displaying only the value. The correct instruction is [~accountid:{{assignee.accountId}}].
That displays like this:

Thursday, October 17, 2019

Time for JAVA #001

I want to learn. That is the first statement You have to understand to start. I found out a great site - exercism.io.
You can find there a lot of free exercises from many languages, and what is the most important You can consult your solution with a mentor.

Earlier today I finished one the execrises - named Reverse String.
The task was to write a code which will reverse a string for example: input: "cool" output: "looc".
Looks pretty easy but there are serveral ways to solve it.
In my opinion I found the simplest one:


The main issue of this problem is that String class does not have reverse() method, You need to convert the input string to StringBuilder, and after reversing You need to switch to String using toString().

I used gradle (please check it) for testing.


Back to Java is great!