Jul 17 2012

Brain overload

Category: TechnicalIuliana @ 12:32

If you are a developer and write error messages like these :

– Simple Error bla bla bla
– Small Malfunction bla bla bla

And I end up working with your code I have only this to say:

I don’t know who you are, I don’t know what you want, If you’re trying to be funny, I can tell you I don’t have a sense of humour, but what I do have are a very particular set of skills, skills that have acquired over a very long career. Skills that make me a nightmare for people like you. If you stop writing shit debug messages like these now, that will be the end of it. But if you don’t, I will look for you. I will find you and I will kill you.

Because when it comes to code, there is no such thing as a Simple ERROR, nor a Small MALFUNCTION.


Jun 19 2012

when you have an itch…

Category: TechnicalIuliana @ 10:34

… you gotta scratch it. And I had a serious itch caused by my Windows. Even if Windows has evolved so much, even if Windows 7 is the peak of greatness among all the Windowses before it, it still does not know how to manage 4 core processors. So I was seriously pissed about the fact that Windows 7 froze from time to time, making my super-laptop look like my first computer, an AMD K6, 500 MHz and 256 MB SRAM. Which was definitely not cool, considering the fact that my laptop’s configuration looks like this: Intel Quad Core i5-450M and 6 GB DDR3. The only reason I kept windows so far on my laptop was that my processor has a capability known as turbo boost, meaning that can over-clock itself when needed. But this won’t be needed that much if the tasks were efficiently distributed between the 4 cores, which were not.

So two days ago, I just snapped, decided to give up the possibility of playing games for a while and went on a search for the perfect Linux for my laptop. I am fond of Gentoo as you know, but compiling a full OS was not an option because it is a time-consuming operation and also because all that compiling would set my laptop on fire and it’s already hot in Romania right now (32 Celsius degrees). So I was left to choose between Archlinux and Mint. I did not even consider Ubuntu, it’s a Linux that looks and acts like Windows, the thing I was trying to get rid of. I had Archlinux before and I know in order to get the final result some time must be wasted on its configuration, so I went for Mint.

In less than 30 minutes I had a fully functional and compact Linux, oh well … fully for a normal user, not for me, a curios developer. So after this I went on and started installing the development software. The first one I wanted to install was the JDK. Mint uses open-jdk which Idea and STS refuse to go along with, so I went on a quest for installing the Oracle version. If on other Linux systems this was a piece of cake on Mint, it was not so, because Mint has all these symlinks pointing to open-jdk binaries, and even if you do everything right, set the JAVA_Home variable and add it to the path, when you will execute “java -version” in the console, the binary that will be executed will still be the one of the in the open-jdk. The only way to change this is to go to /usr/bin, see where the specific symlinks point to and change that. After that I installed Idea and STS and everything was flawless.

Then I wanted to add a second monitor and this is where all blew up in my face. But not because there was something wrong with Mint, but because one of the cables was not plugged in correctly in my monitor and the system did not see it. I did not even consider that the problem might come from a cable and went on and tried to install nVidia drivers in order to convince the system to see my external monitor. After the first restart I was left without an interface, because the nVidia drivers were not stable, of course. So I went old-school and installed lynx, a text based browser, and searched for a solution for my problem. I did so and tried different options for an hour, when finally it worked and I had my graphic interface back, but the external monitor still was invisible to Mint, so I considered the possibility of the monitor not actually being plugged in the laptop. I check the cables and … surprise. It detected it right away.

Conclusion: if you want to install a Linux on your laptop, I truly recommend Mint, it is small, smart, fast and it knows how to work the special buttons on your laptop, without any additional settings. And is also easy to install, if you are not an old-school developer who considers problems being caused by the software first :D , that is. :)

Tags: , , , ,


May 05 2012

What does a passionate developer do…

Category: TechnicalIuliana @ 22:35

… when is stuck in a hotel room because of the rain, bored out of his mind and with no mood to work? Well when that happens to me I start to reed my java feed reader and depending on what I find there I might write my own articles. So… yes, this article is today’s consequence of boredom.

1. What is the flaw with the Stack class?
Actually, there are two of them all being caused by the fact that java.util.Stack extends java.util.Vector:
I. Extending Vector methods insertElementAt and removeElementAt can be called and they actually work, so the stack definition is not respected (that part with only the last inserted element being accessible, the LIFO principle)
II. Extending Vector, Stack is also synchronized which makes it slow and when synchronization is not necessary this  is quite inefficient. This is not exactly a flaw, it’s more of a personal observation observation.

Then again in the api it is written that “It extends class Vector with five operations that allow a vector to be treated as a stack “, so I guess these are not flaws, the Stack class just works as intended. (Recommendation: use ArrayDeque)

2. Can an interface extend multiple interfaces?
There is no right answer to this question, because it depends of the point of view of the interviewer.
I. Yes, because you can define an interface like this:
public interface MultipleIntf extends List, Serializable {
}
II. No, extending means actually inheriting all functionality of the super-entity and  perhaps adding new functionality, in the case of interfaces there is nothing to inherit and no functionality to add. Except for the obligation to implement all abstract methods that will be enforced on the implementing class.

3. What is lazy loading?
Lazy loading is a name to describe the process of not loading something (object/class) until needing it. This question will surely take you to a ClassLoader discussion, so it is better to know and understand the Java Class Loading mechanism.
So:
– the java source files are compiled into executable code for the JVM, called bytecode, stored into *.class files.
– at start-up JVM has no loaded classes. When the first class is loaded, the classes on which its execution depends are searched and loaded too. So if I have a class which has imports statement for ArrayList and Serializable, the JVM will load my class, then it will search and load ArrayList.class and Serializable.class. Let’s imagine we have a big application with a lot of class files and one of them is missing. The application will run just fine, until we try to access a functionality implemented by that class, when the JVM will let us know that the class was not found by throwing a java.lang.ClassNotFoundException.
And this my darlings is lazy loading. A class is not loaded until used and there would be no point in doing that for efficiency reasons. Right? Anyway, if you want to have a deep understanding of the Java Class Loader, I recommend this article.

Tags: , , ,


Jan 16 2012

VirtualBox with Gentoo(4)

Category: Miscellaneous,TechnicalIuliana @ 13:58

This post is the not about the virtual machine or Gentoo, is more about setting up the tools that you will use to develop your applications and other good practices.

First, let’s talk more about environment variables. I mentioned in my previous post the JAVA_HOME variable. Most development tools need their environment variables too and they are not set up by Gentoo, so we will have to do this the way I like it, by hand. Every user has in it’s home directory – in /home/[username] (on my machine /home/jules) a file named .bashrc.The good practice is to edit this file by adding the necessary environment variables required by the tool that user will use.

1. Apache Ant

Apache Ant is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications. Ant supplies a number of built-in tasks allowing to compile, assemble, test and run Java applications.

It is easy to use, quite practical and I recommend it for small scale applications. The installation of Ant consists in unpacking the a

rchive, setting the ANT_HOME and adding the bin directory to the environment PATH variable of Gentoo. Also, the bin directory for Java should be added too, we’ll do that too.

To download ant, go to http://ant.apache.org and under Download menu item, there is a Binary Distributions link, click on that. On the frame on the right you will have a set of links which point to current versions of Ant. Download the tar.bz2 archive, you can use Firefox to do that or you can use wget:

# wget http://mirrors.hostingromania.ro/apache.org/ant/binaries/apache-ant-1.8.2-bin.tar.bz2

Then you have to unpack it:

# tar xpf apache-ant-1.8.2-bin.tar.bz2

After unpacking you will have a directory named apache-ant-1.8.2, usually I rename it to ant, because the version is not that important when the update is made by copying the new version content over the old one. You can copy it where you want, I usually leave it in the home directory for the current user. Then we have to set the ANT_HOME environment variable.

# cd ~ (gets you in /home/[username])
# nano -w .bashrc

Add the following lines:

# export ANT_HOME=/home/[username]/ant
# export PATH=${PATH}:${JAVA_HOME}/bin:${ANT_HOME}/bin

Save. (Ctrl+X,Y) Test the new environment variables:

# echo $ANT_HOME
# echo $PATH

Continue reading “VirtualBox with Gentoo(4)”

Tags: , ,


Dec 24 2011

VirtualBox with Gentoo(3)

Category: TechnicalIuliana @ 3:35

Well, we have a VM with Gentoo and an interface. Let’s make the virtual machine more flexible and more cooperative with the operating system on your computer. For this we have to install VirtualBox drivers on your Gentoo. After restarting your system upon setting up the interface you can log on to your desktop interface. But for installing other tools you will still  need the console. For the purpose of this tutorial we will use the Kde terminal named konsole.

To open a terminal: click the button on the left corner of the screen (the “K” button) and in the menu that is displayed at the top there is a text field. Type konsole and click on one of the results returned. (print-screen) Or press Alt +F2 and the same text field will appear at the top of your desktop. You can use it to start any application you want. You will be logged in with the normal user so in order to install things you need root access. So, in the terminal you need to use the su command:

# su -

You will be asked for the root password which you will type and then you can start installing. (By the way if any emerge process happens to fail, you can force to continue by using: # emerge –resume)
Continue reading “VirtualBox with Gentoo(3)”

Tags: , , , , ,


Dec 16 2011

VirtualBox with Gentoo(2)

Category: TechnicalIuliana @ 18:18

Step6.Configuring the Compile Options – this is the next step. The compilation options are kept in the /mnt/gentoo/etc/make.conf  file. You can edit this file by executing:

# nano -w /mnt/gentoo/etc/make.conf

Navigate using arrow keys to the end of the file and add line: MAKEOPTS=”-j2″.

Then add mirrors by executing:

# mirrorselect -i -o >> /mnt/gentoo/etc/make.conf
# mirrorselect -i -r -o >> /mnt/gentoo/etc/make.conf

A window will be displayed with a list of options. Navigate using up and down arrow keys and use to select a mirror you prefer (one in your country or next to your country). Then hit <Enter>.
Test the if the values have been added to make.conf: (Two new lines containing GENTOO_MIRRORS=”some link” and SYNC=”some link” should be added to the file)

# cat /mnt/gentoo/etc/make.conf 

Continue reading “VirtualBox with Gentoo(2)”

Tags: , ,


Dec 15 2011

VirtualBox with Gentoo(1)

Category: TechnicalIuliana @ 10:38

As I have no computer using Linux in my house right now and I kinda miss it I decided to create a virtual machine with a gentoo on it. And as I will have to write some posts about setting up a full java development  environment on Linux and Windows I will use it for that too. I will post all the steps I make, because I’m no guru, so If I can do it, anybody will be able to just by following my steps. So, good luck and you are welcome to use the comment section for any problems you might encounter or questions I might answer.

Step1. Download and install VirtualBox.

Step2. Create a virtual machine following the instructions on the site and select operating system Gentoo. Select at least 1,5 GB memory and aVDI hard drive  of minimum 20 GB.

Step3. Download a Gentoo image from here.  I recommend the x86 version because 64bit version is not stable and given the fact that we’re gonna do a lot of stuff by hand I recommend the minimal iso. (install-x86-minimal-<release>.iso)

Step4. Start your machine from the VirtualBox window and select your iso as a boot device. When the window with the black linux console is opened the actual work beggins.

Step5.  You will see written on your virtual machine screen  “boot: “. If nothing is written the default option will be used. I used the gentoo-nofb, which disables the framebuffer,which will make things go faster in text mode. You will also asked to press enter for some default option at some time. (If you want a complete installation guide with technical explanations look here, because this article just specifies the steps to execute simply and blindly). After a lot of text is scrolled on your window  and the last line just contains just the word livecd#, you start executing the following tasks in this order: (print the commands and insert required data)
Continue reading “VirtualBox with Gentoo(1)”

Tags: , ,