Friday, June 29, 2007

Fat Butt and Pancake Head

Sá þennan South Park þátt fyrr í vikunni í svona tuttugasta en örugglega ekki síðasta skipti. Cartman er einn af mínum uppáhalds sjónvarpspersónum allra tíma, hann svíkur aldrei rasista-fordóma sjálf sitt sem hann stendur fyrir.

Góðir þættir ef maður þolir húmorinn og fattar boðskapinn sem er oftar en ekki eitthvað taboo í þjóðfélaginu á hverjum tíma.

Friday, June 22, 2007

If Architects had to work like Web Designers

Já, ég veit, gott ef ekki flestir hafa séð þetta einhvern tímann en vinnufélagi sendi þetta út í morgun og ég varð bara að dreifa þessu til dyggra lesenda. Þetta hringir einhverjum óþægilegum bjöllum...

Dear Mr. Architect: Please design and build me a house. I am not quite sure of what I need, so you should use your discretion. My house should have somewhere between two and forty-five bedrooms. Just make sure the plans are such that the bedrooms can be easily added or deleted. When you bring the blueprints to me, I will make the final decision of what I want. Also, bring me the cost breakdown for each configuration so that I can arbitrarily pick one. Keep in mind that the house I ultimately choose must cost less than the one I am currently living in. Make sure, however, that you correct all the deficiencies that exist in my current house (the floor of my kitchen vibrates when I walk across it, and the walls don't have nearly enough insulation in them). As you design, also keep in mind that I want to keep yearly maintenance costs as low as possible. This should mean the incorporation of extra-cost features like aluminum, vinyl, or composite siding. (If you choose not to specify aluminum, be prepared to explain your decision in detail.) Please take care that modern design practices and the latest materials are used in construction of the house, as I want it to be a showplace for the most up-to-date ideas and methods. Be alerted, however, that kitchen should be designed to accommodate, among other things, my 1952 Gibson refrigerator. To insure that you are building the correct house for our entire family, make certain that you contact each of our children, and also our in-laws. My mother-in-law will have very strong feelings about how the house should be designed, since she visits us at least once a year. Make sure that you weigh all of these options carefully and come to the right decision. I, however, retain the right to overrule any choices that you make. Please don't bother me with small details right now. Your job is to develop the overall plans for the house: get the big picture. At this time, for example, it is not appropriate to be choosing the color of the carpet. However, keep in mind that my wife likes blue. Also, do not worry at this time about acquiring the resources to build the house itself. Your first priority is to develop detailed plans and specifications. Once I approve these plans, however, I would expect the house to be under roof within 48 hours. While you are designing this house specifically for me, keep in mind that sooner or later I will have to sell it to someone else. It therefore should have appeal to a wide variety of potential buyers. Please make sure before you finalize the plans that there is a consensus of the population in my area that they like the features this house has. I advise you to run up and look at my neighbor's house he constructed last year. We like it a great deal. It has many features that we would also like in our new home, particularly the 75-foot swimming pool. With careful engineering, I believe that you can design this into our new house without impacting the final cost. Please prepare a complete set of blueprints. It is not necessary at this time to do the real design, since they will be used only for construction bids. Be advised, however, that you will be held accountable for any increase of construction costs as a result of later design changes. You must be thrilled to be working on as an interesting project as this! To be able to use the latest techniques and materials and to be given such freedom in your designs is something that can't happen very often. Contact me as soon as possible with your complete ideas and plans. PS: My wife has just told me that she disagrees with many of the instructions I've given you in this letter. As architect, it is your responsibility to resolve these differences. I have tried in the past and have been unable to accomplish this. If you can't handle this responsibility, I will have to find another architect. PPS: Perhaps what I need is not a house at all, but a travel trailer. Please advise me as soon as possible if this is the case..

Monday, June 4, 2007

Good Times with Weapons

Hversu meiri snilld getur jmock verið?

final Folder folder = context.mock(Folder.class);
final Message message1 = context.mock(Message.class);
final Message message2 = context.mock(Message.class);
final Message[] mesages = new Message[]{ message1, message2 };
context.checking(new Expectations()
{
    {
        one(folder).getMessage();
        will(returnValue(messages));
    }
});

Segjum að við vildum sannreyna lógík sem við forrituðum gagnvart JavaMail API. Þá myndum við setja upp ákveðnar væntingar eins og hér að ofan og keyra síða forritið okkar m.t.t. væntinganna og staðfesta þær, t.d. með því að keyra forritið með junit og skilgreina nokkrar væntingar til útkomu á forritinu, en junit og jmock haldast nokkuð vel í hendur.

Við myndum þurfa að bæta við nokkrum skilgreiningum eins og t.d.

one(message1).getSubject();
will(returnValue("Lottery Winner"));

one(message2).getSubject();
will(returnValue("Vandræði með ruslpóst"));

Þá gæti ruslvörnin sem við vorum að skrifa ákvarðað að pósturinn geymdur í þessu pósthólfi innihéldi einn varhugaverðan póst. Það er að segja, ef við hefðum verið að skrifa alvöru ruslvörn og við hefðum gefið okkur gáfulegri forsendur fyrir því að finna ruslpóst heldur en bara subject reitinn í póstum.

Með þessum aðferðum getum við keyrt ruslvörnina gagnvart pósthólfi sem við byggjum upp í einingaprófunum, þ.e. án þess að vera með pósthólf með gögnum sérstaklega til að geta prófað forritið sem við erum að þróa.

Ég bendi áhugasömum á að kynna sér junit/jmock combo-ið í gegnum vefsíðurnar sem ég benti á fyrr í greininni og vona að þessi litla grein verði til þess að fólk fái áhuga fyrir því að skrifa og sannreyna forritin sín á sem skynsamlegastan máta sem umhverfin sem þeir eru að vinna í bjóða upp á. Það er síðan efni í aðra grein að útskýra mikilvægi allra prófana, ekki einungis einingaprófana.

Update: Gúndi greip villu í kóðadæmunum. Lagað eftir auganu.

About Me

Árni Hermann Reynisson
Ég nem hugbúnaðarverkfræði við Háskólann í Reykjavík. Ég vinn sem forritari hjá Hugsmiðjunni. Skoðanirnar sem birtast á síðunni eru mínar skoðanir og endurspegla ekki endilega skoðanir atvinnuveitanda míns. Takk fyrir innlitið.
View my complete profile

Greinar í tímaröð