Posts

Showing posts with the label Programming

How to - Java Interfaces and Abstrac Classes

Today's topic - what is an interface? And what the hell does that have to do with abstract classes? As you can see, we introduce this program not as a class, but an interface. Inside the interface there are methods, which can or can not contain any kind of parameters but the bodies of these methods are empty.  But why would you want that .__. Look at the interface as a kind of blueprint. When you are a contractor and you are supposed to build a whole neighbourhood with 14 houses that look the same (kitchen, 2 bedrooms, 3 baths and a porch) you might not want to sit down at your desk 14 times and draw plans for every single house if they are going to look the same fucking way in the end ._. Sure, you might want to paint one green and the other red - but that can be added later on. So our interface is a blueprint for a type of class that should in the future be used over and over again, with the same kinds of methods in them. Note here: once you implement an interface int ...

How To - Java Methods

Let's begin with the basics.  In the first post we took a look at the small Program HelloWorld which printed the message Hello World out into our command line. This was a very simple program and with a basic command, but when we write scripts or programs that calculate values, or help sorting stuff we will need methods. We will write a program that calculates the middle value of two fixed values we give the method. Try to read the code and understand what part stands for what: - class name, main method, what is being called in the main method So here again in line 1 we have a public class with the class name MiddleVal for Middle Value, then open brackets to open the class body, line 2 contains the main method (which makes this class autonomous in itself) which also calls out method in the 3. line with 2 parameters that we give to the method. Now we can take a closer look into line 6 - what does the method in line 3 actually do? It's called public static int mid...

The ROSALIND Platform

Image
Hey guys, I was introduced to this fantastic platform a couple of days ago (probably would have been useful 2 years ago already). It's called the ROSALIND Platform and is a mainly bioinformatics exercise website, where you are challenged to engage real bioinformatics problems and brainbugs. I have started 2 days ago, and am very happy to say, I may not have made my Asian ancestors proud - but less ashamed^^ As you can see, the problems are organised in a Tree or List, from easy to tough and there is the possibility to add more problems if you come up with one yourself. You are not bound by the system to finish off the easy exercises before the hard ones, but I would advise you to start simple. I stumbled over a couple of silly mistakes in the beginning -_- so yeah. Go for it. The problems listed here, are form the section Bioinformatics Stronghold, but there are also others like Python Village (with an introduction on how to install and work it) and a more theoretic...

How To - Java Hello World

Hey guys, new year, new motivation, new yay. This is the start of my How To Java - so let's go :D When you start with any programming language and the additional self-t(orturing)eaching lecture, they will introduce you with this exercise public class HelloWorld{      public static void main(String[ ] args){           System.out.println("Hello World");      } } This non-humanity-threatening message is all cute 'n' shit but what exactly does it mean? This is already a fully functional program, so you deserve to be proud of yourself, but let's break this down: The first line in your code is usually gonna be your class name. Names are important, it is how you will later on find your program (or class) after you stored it away in your workspace somewhere, to incorporate it into a more complex program.  So class name here is HelloWorld . The curly bracket after your class name opens up to the body of your program -...

How To - CYK Algorithm

Image
In this quick post I try to explain the basics of the Cock-Younger-Kasami ( CYK ) Algorithm to you. This shouldn't take more than 15min for you to understand, since I am terrible at logic and math related studies - if I could do it so can you :D The CYK is a theoretical construct that can be used to find context free languages by feeding grammar and its production rules into a table and see wether a word from the language you wish to identify, matches up with these rules. To make this process run smooth, the production rules must be formatted in such way that it matches Chomsky Normal Form ( CNF ) standards; on the left hand side of a production rule stands a non-terminal symbol (a variable) on the right hand side of a production rule there can be maximal 2 non-terminals or 1 terminal symbol (a symbol that represents a constant value) but never non-terminals and terminals mixed For my course I worked through an example step by step, we started out with 3 production rules: A...