<3

Mys :)
Ännu en trevlig helg!
Då var ännu en mysig helg över, tyvärr får man väl säga! Visst är det skönt att behöva gå upp klockan 9.00 för att hjälpa studenter till ett roligare liv, men om jag får bestämma så får det gärna vara helg hela tiden och då skulle jag alltid vakna upp med en söt S vid min sida!
Helgen har varit händelserik, började med att flickvännen kom hem till mig i torsdags, hade lagat massa god mat, pepparbiff & potatisgratäng. Sedan kollade vi på trevlig film och så :) Fredags var det kalas för S kusin så där fick man träffa hela släkten, roliga & trevliga människor det där! Men inte nog med det, fick träffa hela drösen med folk en gång till, för på lördagen var det 75-årskalas för S morfar. Försökte hjälpa de få igång sitt internet, vet inte om det gick så bra, ringde tillslut ISPn och så fick de be nån tekniker kolla på det på deras sida. Så det löser sig nog! Sedan i går då så kollade vi på fam. S nya hus som verkar mycket tekniskt och coolt.
Idag väntar bara massa jobb på högskolan, imorgon blir det karlskrona-jobb och sedan resten av veckan får vi se hur mycket jobb det blir.
Mycket mysig helg i allafall och saknar redan S :)
Helgen har varit händelserik, började med att flickvännen kom hem till mig i torsdags, hade lagat massa god mat, pepparbiff & potatisgratäng. Sedan kollade vi på trevlig film och så :) Fredags var det kalas för S kusin så där fick man träffa hela släkten, roliga & trevliga människor det där! Men inte nog med det, fick träffa hela drösen med folk en gång till, för på lördagen var det 75-årskalas för S morfar. Försökte hjälpa de få igång sitt internet, vet inte om det gick så bra, ringde tillslut ISPn och så fick de be nån tekniker kolla på det på deras sida. Så det löser sig nog! Sedan i går då så kollade vi på fam. S nya hus som verkar mycket tekniskt och coolt.
Idag väntar bara massa jobb på högskolan, imorgon blir det karlskrona-jobb och sedan resten av veckan får vi se hur mycket jobb det blir.
Mycket mysig helg i allafall och saknar redan S :)
Lääängtar
Längtar hem nu, vill bara städa lägenheten, få tvätten avklarad och invänta morgondagen, för då kommer Sofie!
Ska börja hålla i Java-föreläsningarna på Creative Mobile Development-programmet nu, ska bli en intressant erfarenhet!
Men innan dess är det en mysig helg! Så ska man bjuda på mat imorgon med, förslag?
Ska börja hålla i Java-föreläsningarna på Creative Mobile Development-programmet nu, ska bli en intressant erfarenhet!
Men innan dess är det en mysig helg! Så ska man bjuda på mat imorgon med, förslag?
16 November!
Dagen då det blev officiellt! Ja, vad är det då som är så speciellt med denna dag? JO Då fick F sin S! :)
Har varit en helt underbart mysig helg med flickvännen, kollat film, käkat pizza, varit på fest, druckit vin och massa andra mysigheter som hör förhållande till!
Har varit en helt underbart mysig helg med flickvännen, kollat film, käkat pizza, varit på fest, druckit vin och massa andra mysigheter som hör förhållande till!
Snart är de helg!
Då är det snart helg, veckan går fort när man jobbar hela tiden, kommer väl tyvärr bli lite jobb i helgen med, men ska försöka bli klar innan fredag kväll.
Sedan får vi väl se vad som väntar för överraskningar i helgen? :)
Announcement - Moving a section to Wordpress
Blekinge Tekniska Högskola
Nu har äntligen intervjun med mig kommit upp på www.bth.se !
Use understandable variable names Dammit!
Is there anything more annoying than looking through code that has stupid variable names? Im currently tweaking a script that someone else once wrote, a couple of months back maybe and the variable names are like this:
ow, oh, wh, wi, nw, nh, sure i can understand ow = original width and nw being new width. But common?
Seriosuly, people that does this kind of programming should never, ever be working as programmers.
So what do i suggest instead of these riddicilus names? Well back in the time when we had a limit to how many characters we could use, there was a couple of conventions used, but i dont like any of these "short naming"-conventions. Use explaining variable names, such as: image_width, image_height, image_new_width, image_new_height or somewhat like this imageWidth, imageHeight, newImageHeight, newImageWidth. This will make code more understandable and readable.
ow, oh, wh, wi, nw, nh, sure i can understand ow = original width and nw being new width. But common?
Seriosuly, people that does this kind of programming should never, ever be working as programmers.
So what do i suggest instead of these riddicilus names? Well back in the time when we had a limit to how many characters we could use, there was a couple of conventions used, but i dont like any of these "short naming"-conventions. Use explaining variable names, such as: image_width, image_height, image_new_width, image_new_height or somewhat like this imageWidth, imageHeight, newImageHeight, newImageWidth. This will make code more understandable and readable.
Pointers & Double Pointers
Definitions
First off, we need to clearify what a some of the expressions i will use mean. These are the following expressions:
Stack
Assuming that you know about a computer having RAM ( Random Access Memory ) which allows you to store information and have this accessable faster than you would on a secondary memory like a harddrive and/or cd-rom.
When a program is executed there is a part in the memory reserved for this application to use, this "space" is called the Stack; The stack is always the same size and it's not possible to change it's size on any way.
Heap
The Heap is also a "space" on your memory, actually it's all the memory not allocated as a stack. So when your stack is defined, everything else can be expressed as the Heap.
Pointers
What is a pointer really? A pointer is a globally used expression to reference that your somewhat "point" to something. See the following illustration

On this image we have something that we point to, let's call A our Object. So having A as the actualy object, play with the thought that B and C isnt there, and there are no pointers to it.
This would infact mean that we had A allocated on the Stack. When does this become a problem? So play with the thought you have a really big information base such as a User Layer where you store a lot of data on each user. Then havnig a big register on all the people attending a course would take up somewhat a bigger space than we have free.
When is is an issue, we can use a pointer, to reference to this object. You can of course point to an object that you have on the stack, but that's not. afaik, what it's initially intended for.
So we tell our program that we want to create a Pointer, this pointer will in fact be stored on the stack, but a pointer only takes up 4 bytes so this wont be a problem.
After creating the pointer, we create the object itself and have the pointer B point to this.
Pointer, Objects s & Arrays
Assuming you know about some object orientation and how an object is constructed i will not go in to this very deeply. I.e. we have a class called Person and we want to create somewhat a register over students attending a course, what we initially want to do is create an object array, where we can store all our persons, using c++, as i will do in the following examples you would write something like this:
Person *attendingStudents = new Person[size];
Where size is equal to the max amount of students.
Running this code, the constructor of Person will be runned as many times as the size of the array attendingStudents. How is this a problem? This becomes a problem when we dont want to run the default constructor and allocate the object size as many times as the total array size, this has too much overhead.
First of all, how does this look in memory?

On adress 0 to adress 3 wnicn means 4 bytes; every memoy block is 4 bytes; the pointer attendingStudents is allocated and on that area a 4 byte long adress is stored which in our case is 84. The size of the given Person object is not given but just play with the thought that its 4 bytes and the size is 10 this would mean the total size of the Person array would be 10 * 4 = 40 Bytes going from the address 84 to 124.
However, let's say that the Person object takes up 4 times as much so it takes up 16 bytes per Person object, this would result in 16 * 10 = 160 bytes, going from address 84 to 244. Now, there is a big overhead if we dont use all the persons and it would be stupid to call the constructors twice.
So, how about, we just point to something that we know is a pointer, and then let this poitner take care of the rest? But we just initialize the first step?
Double pointers
Thjis is were double pointers comes in handy, look at the following code:
Person **attedningStudents = new Person*[size]:
This code is not as straight forward to look at, as the pervious one, but it basically means,
Person **attendingStudents = Create a reference, to a pointer, what is a pointer? A pointer is something that will in the end point to a data type, so what we do here is saying that Point to a Pointer, this pointer will eventually have the data type Person.
Just to clearify, a pointer to an array, initially points to the first index in that array. So after creating the Pointer to a Pointer we tell it to point to a new list of Pointers, the amount of pointers to create is the same as the digit in size.
This might not make any sense, but take a look at the following

Initally these pointers don't point to anything at all so what we can do is: attendingStudents[i] which will take us to the adress 84 and then create an object on this index by doing this: attendingStudents[i] = new Person();
Why is this method better than the one before? Well this assures that we Only have the 11 pointers which takes 4 bytes per pointer. 1 pointer on the stack, referencing 10 pointers on the stack. When does this give us overhead? This gives us a 4 byte overhead when we start creating our Persons. But the execution time saved and just given 4 bytes ovearhead per pointer, this is a preffered method by me.
First off, we need to clearify what a some of the expressions i will use mean. These are the following expressions:
Stack
Assuming that you know about a computer having RAM ( Random Access Memory ) which allows you to store information and have this accessable faster than you would on a secondary memory like a harddrive and/or cd-rom.
When a program is executed there is a part in the memory reserved for this application to use, this "space" is called the Stack; The stack is always the same size and it's not possible to change it's size on any way.
Heap
The Heap is also a "space" on your memory, actually it's all the memory not allocated as a stack. So when your stack is defined, everything else can be expressed as the Heap.
Pointers
What is a pointer really? A pointer is a globally used expression to reference that your somewhat "point" to something. See the following illustration

On this image we have something that we point to, let's call A our Object. So having A as the actualy object, play with the thought that B and C isnt there, and there are no pointers to it.
This would infact mean that we had A allocated on the Stack. When does this become a problem? So play with the thought you have a really big information base such as a User Layer where you store a lot of data on each user. Then havnig a big register on all the people attending a course would take up somewhat a bigger space than we have free.
When is is an issue, we can use a pointer, to reference to this object. You can of course point to an object that you have on the stack, but that's not. afaik, what it's initially intended for.
So we tell our program that we want to create a Pointer, this pointer will in fact be stored on the stack, but a pointer only takes up 4 bytes so this wont be a problem.
After creating the pointer, we create the object itself and have the pointer B point to this.
Pointer, Objects s & Arrays
Assuming you know about some object orientation and how an object is constructed i will not go in to this very deeply. I.e. we have a class called Person and we want to create somewhat a register over students attending a course, what we initially want to do is create an object array, where we can store all our persons, using c++, as i will do in the following examples you would write something like this:
Person *attendingStudents = new Person[size];
Where size is equal to the max amount of students.
Running this code, the constructor of Person will be runned as many times as the size of the array attendingStudents. How is this a problem? This becomes a problem when we dont want to run the default constructor and allocate the object size as many times as the total array size, this has too much overhead.
First of all, how does this look in memory?

On adress 0 to adress 3 wnicn means 4 bytes; every memoy block is 4 bytes; the pointer attendingStudents is allocated and on that area a 4 byte long adress is stored which in our case is 84. The size of the given Person object is not given but just play with the thought that its 4 bytes and the size is 10 this would mean the total size of the Person array would be 10 * 4 = 40 Bytes going from the address 84 to 124.
However, let's say that the Person object takes up 4 times as much so it takes up 16 bytes per Person object, this would result in 16 * 10 = 160 bytes, going from address 84 to 244. Now, there is a big overhead if we dont use all the persons and it would be stupid to call the constructors twice.
So, how about, we just point to something that we know is a pointer, and then let this poitner take care of the rest? But we just initialize the first step?
Double pointers
Thjis is were double pointers comes in handy, look at the following code:
Person **attedningStudents = new Person*[size]:
This code is not as straight forward to look at, as the pervious one, but it basically means,
Person **attendingStudents = Create a reference, to a pointer, what is a pointer? A pointer is something that will in the end point to a data type, so what we do here is saying that Point to a Pointer, this pointer will eventually have the data type Person.
Just to clearify, a pointer to an array, initially points to the first index in that array. So after creating the Pointer to a Pointer we tell it to point to a new list of Pointers, the amount of pointers to create is the same as the digit in size.
This might not make any sense, but take a look at the following

Initally these pointers don't point to anything at all so what we can do is: attendingStudents[i] which will take us to the adress 84 and then create an object on this index by doing this: attendingStudents[i] = new Person();
Why is this method better than the one before? Well this assures that we Only have the 11 pointers which takes 4 bytes per pointer. 1 pointer on the stack, referencing 10 pointers on the stack. When does this give us overhead? This gives us a 4 byte overhead when we start creating our Persons. But the execution time saved and just given 4 bytes ovearhead per pointer, this is a preffered method by me.
Mys
Helgen i halmstad har varit jättemysig! :)
Filmkväll i Fredags med Sofie, blev galen när jag inte fick igång sfanytime, visade sig vara en skitdålig film ändå så det gjrode väl inget. Lördags var det en 5:-s-krov på maxi ( ;) ) och sedan bio; såg Patrik 1,5, grymt bra film, i mina ögon en försvenskad version av Brokeback Mountain.
Sedan blev det partaj på kvällen; träffade massa nya människor och hade jätteroligt!
Idag är det Farsdag, köpte världsklass-whiskey till pappa, som kostar 15:- / cl, helt galet, får hoppas den är god och ger honom en trevlig upplevelse, mer än baksmällan då.
Senare ikväll blir det Hooockeeey, Halmstad - Kallainge Ronneby!
Filmkväll i Fredags med Sofie, blev galen när jag inte fick igång sfanytime, visade sig vara en skitdålig film ändå så det gjrode väl inget. Lördags var det en 5:-s-krov på maxi ( ;) ) och sedan bio; såg Patrik 1,5, grymt bra film, i mina ögon en försvenskad version av Brokeback Mountain.
Sedan blev det partaj på kvällen; träffade massa nya människor och hade jätteroligt!
Idag är det Farsdag, köpte världsklass-whiskey till pappa, som kostar 15:- / cl, helt galet, får hoppas den är god och ger honom en trevlig upplevelse, mer än baksmällan då.
Senare ikväll blir det Hooockeeey, Halmstad - Kallainge Ronneby!
VTC - Video Tutorials
Idag köpte jag konto på www.vtc.com kostar mig 250 dollar per år men det är de fan värt! Får tillgång till de bästa inlärningsvideona. Nu ska jag lära mig massa nya saker :D