Laboratory Works

Laboratory Work No.4

So far we’ve already got to the forth laboratory work. The task of the last laboratory work was to prototype program, using the MVC(Model-View-Controller) pattern. In order to do this I proceeded to the following steps:

Step 1:

Go to Rails Girls Chisinau and meet there the most WONDERFUL mentors:

Step 2:

Learn here great stuff, and don’t stop to their guide only, check whether they lie or not using the official Rails Documentation.

Step 3:

Wait for three months, and start emotionally preparing for the forth laboratory work at IDE course.

Step 4:

Procrastinate and let the whole work for the last week before deadline.

Step 5:

Star the actual work.

Work process

In the following lines I will explain the whole work flow of how the app was done.
The first step was making a new rails app. It took time to choose a name for it, but it seemed like “Green-Rainbow” is the guy I need. In order to create a new app I used the command $ $ rails new green-rainbow It generated a project which structure looks like this:

The following step, according to the tasks, was to simply add three static pages.

Screenshots of these pages can be found below.

Moreover, my site should keep all site data in a database.
In order to do that I used sqlite3 as database for Active Record. The table for the posts looks like this:

I AJAX Requests when adding a new post and when deleting one. Ajax (Asynchronous JavaScript and XML) is used as a mechanism for sending and retrieving data asynchronously (in the background). While XML can certainly be used with ajax, it is not limited to this format. The JSON format, for example, is more commonly used today, especially in the Rails community. There are significant advantages in using Ajax, which include better user interactivity. Ajax allows content on a page to be updated without having to re-render the entire page, making it a “seamless” experience. Thus, when pressing “Add new post” or “Delete” button the browser is not reloaded, but the newly created object is rendered.


You can visit my Github account to see the code. P.S. Ask me to show a demo!

Conclusion:

Basically, most of the things while performing this laboratory work were known. The interesting was the part with Ajax. I did’t know what this is and that was fine. I’ve got something to learn, that made the lab more enjoying. So far, the thing I liked the most is that by using Ajax you can update content on the page without rendering the entire page. I got stuck in the beginning, but after a couple of sites the things shaped themselves to be a bit more clear. I liked the way it worked in the case of creating a post, that’s why I decided add this feature to the “Delete” button. It was fun and I really enjoyed the lab.


While making a general description of the course - It was, imho, the most amazing course up to this moment. I really enjoyed doing labs, even if there were white nights. The word “enjoying” describes perfect my state while writing code for these labs. Keep hacking on and motivating others!

Laboratory Work No.3

The task for the third laboratory work was to create a pomodoro like app. In order to perform this laboratory work I had to deal with learnig the basic android concencepts, the life cycle of an application, ect. The hardest part was ingnoring all the facebook, twitter and telegram notifications. But in the end, I did it! Yey!
The first step in order to create a super fancy pomodoro app, was to learn, to get into what android is, and how to eat it. Here I met Advik Kabir:

No, not this, the other one:

The next step was to choose a fancy bakground for my app.
The background of my app, looks as serious as the name of my app: “SeriousPomodoro”.

In my project I have 2 classes - MainWindow and WorkingPomodoro. The first class is responsible for the main window screen and the second class is responsible for another Intent in which I actually created the progress bar and the timer.


For getting to the intent of the second screen I made a function :

To get the id of each UI object I used:

        relaxBar=(ProgressBar)findViewById(R.id.progressBar2);
        relaxBar.getProgressDrawable().setColorFilter(
                Color.RED, android.graphics.PorterDuff.Mode.SRC_IN);
        start_timer=(Button)findViewById(R.id.button);
        stop_timer=(Button)findViewById(R.id.button2);
        textView1 = (TextView) findViewById( R.id.textViewTimer );
        status = (TextView) findViewById(R.id.workingStatus);
public void onGetFocusedButtonClicked(View view) {
        Intent getWorkingPomodoroIntent = new Intent(this, WorkingPomodoro.class) ;
        final int result = 1;

        getWorkingPomodoroIntent.putExtra("callingActivity", "MainActivity");
        startActivityForResult(getWorkingPomodoroIntent, result);

    }

The funcion responsible for TextView setting time and progressBar setting proggress whith timer is the following:

@Override
             public void onTick(long millisUntilFinished) {
                     status.setText("Focus time");
                     textView1.setText(new SimpleDateFormat("mm:ss").format(new Date( millisUntilFinished)));
                     int progress = (int) (millisUntilFinished/1000);
                     progressBar.setProgress(progressBar.getMax()-progress);
             }

The full code can be found on Github (See the link below).

As you see, I downloaded 2 different fonts, in order to make the app look better, and to make every user feel excited about the app.


A new intend was created in the second activity, were the actual “focus mode” can be reached.

The source code of the laboratory work can be found here.

Conclusion:

In this laboratory work we developed(or better saying - initialised) our mobile programming skills. It was a great amount of information, for some of us maybe even challenging, but it was worth it. The things I liked the most was the project architecture. You’re splitting your UI with your bussines logic, without even thinking you are doing it, an that’s kinda cool. Another thing I got in touch with was multithreading. The first iteration my code contained multiple threads, but I decided I have to improve my threading experience first, and then present a lab with it inside. But anyway, I spend some days on trying to understand what this is for, how to use it, and I’m ready to try implementing. I still feel motivated to do tasks and to proceed to the next point in my laboratory work journey. =)
P.S. Ask me for an demo. :)

Laboratory Work No.2

In this laboratory work we had to create a travelling in time machine. To perform this laboratory work I used the following equipment:

Everything Is AWESOME

Actually,I’m kidding)) We had to make a calculator. The source code of the laboratory work can be found here.

How does my project look like?

Basically, the UI looks something like this:

This week I made it for the first time. I wrote JAVA!

Work process

Core

A “special” thing I would like to tolk about is the way I parsed the input string. In order to parse it, i worked with regular expressions. Here is an example of code I used:

String signRegex = "(\\+|\\-|\\*|\\/|sqrt|\\^)";
String floatingPointNumber = "(([-|+])?[0-9]+\\.?[0-9]*)";
String pattern = floatingPointNumber + signRegex + floatingPointNumber;

I created a pattern and used Matcher. Pattern r = Pattern.compile(pattern); Matcher m = r.matcher(string)[] I worked with groups. I can explain. :)

But most of all, I would like to talk about the project structure.
I decided to separate the project in two parts. One of the parts consists from “Business Logic”, which means the part which is related to the “smart” part of the program. The second part is UI. Here the visual part was implemented. Actually, that was done in the following way: I made an artefact(JAR) of the Logic part and icluded in the newly created project, where I implemented the UI. Moreover, same procedure was done for the lastly created project. Thus, I obtained a JAR file runnable on more platforms.

This week I did for the first time! I wrote JAVA!

The project structure looks like this: the Core and the Interface. The core contains the calculator logic. The Interface contains the UI - graphical/visual part of the calculator, with which the user will interract.

What about the work flow?

Actually, that was done in the following way: I made an artefact(JAR) of the Logic part and icluded in the newly created project, where I implemented the UI. Moreover, same procedure was done for the lastly created project. Thus, I obtained a JAR file runnable on more platforms.
Don’t forget to visit my github repository to see the code. ;)

Conclusion:

This laboratory work was really-really interesting. What made it so interesting to me? Of course writing the report and dividing the project in two parts - the gui and the logic tiers. This is my first java trial. I’ve never tried java, not even to write an app or something like that. At some point, I realized I’ve done bidlocode. So I decided I’ll rewrite it from scratch. It was painfully, but I did it. Of course in the end I still obtained bidlocode, but at least it’s less now(lines of code ) :D. It’s really nice that what we learn at the course helps us to perform the laboratory work. What’s really funny now is that now same task seems a lot more easier than it seemt two weeks ago, and that is, probably, a result. So what’s the difference btw now and two weeks ago? Lots of lines of bidlocode were written, some coffee in minus and… my pc probably hates me for so many

java -jar Core.jar 2^3+((3-4)^2) like-previous terminal commands, project creations and so on. Even stackoverflow must be surprised on frequency I visited their site with, considering the bunch of questions I had. Now I feel really motivated and challenged to proceed to the next laboratory work, and to do my best. :)

Laboratory Work No.1

In this laboratory work we had to deal with installing a normal operating system, Ubuntu (Server), in VirtualBox. Basically it was nothing difficult. I installed VirtualBox using

sudo apt-get install virtual-box

The next thing I’ve done was downloading the Ubuntu Server image and installing it in VirtualBox. Having the IP address I connected my machine to the virtual one, by using SSH. The following image describes my actions:

Basic Level


The next following 5 tasks describe the same image(addet below the tasks) .

To initialize a repository, I used the following commands:

git init

initializes a new repository.

echo "#midps" >> README.md

makes the README file.

git commit -m "Initial commit"

performs the first commit.

git remote add origin https://someorigin...

Normal Level

To create a new branch I used the command:

git branch branch-name

To commit from a different branch, one should move on dat branch, using the following command:

git checkout branch-name


After performing the modifications, I used :

git add
git commit -m "Some message"

Advanced Level

The next following 4 tasks describe the same image(addet below the tasks), from Advanced.

  git remote add origin blah blah...

To reset the branch to the previous commit I used the command:

  git reset --hard  3517831ce1

The “number” after the –hard is the commit SHA-1 key.

To commit two branches I used

  git merge branch-name-to-commit-with

command.

Opened the file, made some changes, saved it. Then used

   git add
   git commit -m "...."

Conclusion

Althought at the beginnig it seemed to be a quite difficult task, because I’ve never done it before, in the end I felt pretty comfortable to install Ubuntu on a virtual machine, to explore the VirtualBox itself, and to connect through SSH. Moreover, it somehow made me understand how different processes, with different meaning can run on the same machine without interrupting each other, without even knowing about each other.
The second part of the laboratory work was to play with some VCS. It is a very powerful tool for developers and not only. Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. It is widely used. Developers may wish to compare today’s version of some software with yesterday’s version or last year’s version. Since version control systems keep track of every version of the software, this becomes a straightforward task. Knowing the what, who, and when of changes will help with comparing the performance of particular versions, working out when bugs were introduced (or fixed), and so on. Any problems that arose from a change can then be followed up by an examination of who made the change and the reasons they gave for making the change.

I used git. Git - because I used it before. I thought I kinda look like this…

because I knew how to

git pull
git clone
git add .
git commit -m "Write somethig, otherwise you`ll enter VIM and you`ll never EXIT!!!!"
git push

and that`s all.

But… Umm, I then discovered

git cherry-pick

and

git rebase

and even more,

git hooks
and basically I got the point:

Well, so I decided to learn what $ git cherry-pick does. It is a very powerful feature. It allows us to choose a specific commit, to treat it as a cherry and to pick it. =))
So what have I done?
I made a new branch using the command:

git branch branch1

Switched to it. Made some commits and, on master, picked one of the commits I needed unsing the command:

git cherry-pick ue89fa456

For a better understanding, see the screenshots attached.

Screens and images on how I done git rebase will come soon. :)