Wednesday, December 16, 2009

Optimize the time you live your life

Did you ever think about moving to some not-really-civilized-country and spending there the rest of your life?... just like that.

I'm trying to figure out, why oh why do I have to work for over 300 days per year just to get to go to such a country for 2 weeks for my holidays? Living in Europe is expensive, all people are in hurry and highly stressed. They smile rarely (I mean the REAL smile) and are limited by millions of artificial rules created by the government. Ok. They have the money to buy themselves a car, nice computer ... or a house. Do they really need that?

On the other hand, people who live e.g. in Bali (Indonesia), do not really have the money, but:
* The fruit grows all over the place (if you're hungry... just go to the jungle and get some)
* Rice prices are extremely low
* It's worm there all year around, no need to have the electricity (unless you feel better in air-conditioned rooms).
* People do not hurry, have no big work stress.. if they need money, they simply look for some dummy tourists and get some from them
* If you have skills like "scuba dive master", you may open your own business and have fun all year around (sometimes even get paid to guide some tourists underwater)
* No need to leave for holiday brake... you are on holidays.

Hmm... maybe I am wrong, but I think that people on Bali are happier then we are. Maybe they are poor but they live their lives more than we do!

So what do I do now... ? Get a visa and optimize my life? Maybe... when I am older ;-)

Thursday, October 29, 2009

Great day

I worked with MS Power Point the whole day today. This is how I feel now.



Isn't it funny? Even solving the most complex Java class loader and reflection related software bugs does not bring me to this state as fast as MS Office does. I have nothing against Power Point, it's probably just me. After a day spend on preparing a presentation I feel like I wasted 7 hours of my precious life!

Wednesday, October 7, 2009

Installing and using OSGi Deployment Admin Service

This is my first tutorial published on this blog. I hope you'll find it helpful and interesting.

In this tutorial you will:

  • Learn where to find and how to build and install an OSGi Deployment Admin Service implementation (well, at least partial implementation, but I guess you are welcome to contibute to it)

  • Get to know the structure of a standard "Deployment Package"

  • Learn how to use the Felix Web Console together with Deployment Admin to install and run a full OSGi based application (consisting of multiple bundles)



I assume that you are familiar with OSGi Service Compendium Release 4 specification (particularly section 114) so I will simply skip the introduction part to save myself some typing.

In this tutorial I will concentrate on one of the most essential responsibilities of a Deployment Admin Service. As described in Service Compendium the Deployment Admin "provides a Deployment Package concept to install and uninstall bundles and related resources on an OSGi Service Platform as an atomic unit"

Isn't it cool? We can package all our bundles (together with their configuration and permission information) into a single archive and then deploy it at once! Great!

Let's check it all out then.

Step 1: Starting the OSGi Container


In this tutorial I will use "Equinox 3.4". On the downloads page select the "eclipse-equinox-3.4.zip" and save it on your hard drive. While you're on the equinox downloads web site, take a look at the "Add-on Bundles"... do you see Deployment Admin there? No. Me neither :-) But don't worry, we will take care about it later.

Unpack Equinox (stuff inside the "eclipse" directory) to some meaningful directory (e.g. /opt/equinox or C:\Software\equinox). After you are done, cd to the instalation folder and start the container by issuing this command:

$ java -jar plugins/org.eclipse.osgi_3.4.0.v20080605-1900.jar -console


Great! It works. Now we need to customize the initial configuration a little bit to make sure that all required services are there before we begin with Deployment Admin and Felix Web Console.

Exit OSGi console (type "exit"). Go to you equinox/plugins/configuration directory. Create new file called "config.ini" and fill it with the following content:

osgi.bundles=org.eclipse.equinox.common_3.4.0.v20080421-2006@2:start,\
org.eclipse.osgi.util_3.1.300.v20080303.jar@2:start,\
org.eclipse.osgi.services_3.1.200.v20071203@2:start,\
org.eclipse.equinox.event_1.1.0.v20080225@2:start,\
org.eclipse.equinox.util_1.0.0.v20080414@2:start,\
org.eclipse.equinox.cm_1.0.0.v20080509-1800@2:start,\
org.eclipse.equinox.ds_1.0.0.v20080427-0830@2:start,\
org.eclipse.equinox.log_1.1.0.v20080414@2:start,\
javax.servlet_2.4.0.v200806031604@2:start,\
org.eclipse.equinox.http.servlet_1.0.100.v20080427-0830@2:start,\
org.apache.commons.logging_1.0.4.v20080605-1930@2:start,\
org.mortbay.jetty_5.1.14.v200806031611@2:start,\
org.eclipse.equinox.http.jetty_1.1.0.v20080425@2:start


Start the equinox again and type "ss" for status information. You should see this:



Great. Now lets play with the new stuff...

Step 2: Getting the Deployment Agent Implementation


I've spend some time googling to actually find a "half-functional" implementation of this service. I don't know, maybe the implementors thought that this service is kind of unimportant, but I find it quite useful... whatever. The only existing implementation (that I know to this point of time) comes from Apache Felix project. It is however not available yet in form of a stable, binary distribution. To use it you will need to download the sources and build it yourself. The good part of the story is that Apache guys used Maven as their "build tool" so getting the jar is just the matter of typing one simple command.

Here's what you do:

  1. Get the sources from the Felix SVN repository

  2. Build the project with "mvn clean install"

  3. Copy the newly created jars (org.apache.felix.deploymentadmin-0.9.0-SNAPSHOT.jar, and org.apache.felix.deployment.rp.autoconf-0.1.0-SNAPSHOT.jar) to your equinox/plugins directory.

  4. From the Felix downloads website get the Dependency Manager (version 2.0.1 and copy it to the equinox/plugins directory (required by Deployment Admin Service)

  5. Update the equinox/plugins/configuration/config.ini file adding the new bundles to the end of the list

    ...
    org.apache.felix.dependencymanager-2.0.1@2:start,\
    org.apache.felix.deployment.rp.autoconf-0.1.0-SNAPSHOT@2:start,\
    org.apache.felix.deploymentadmin-0.9.0-SNAPSHOT@2:start



Start Equinox. Type "ss". You should see all services as "ACTIVE".

Step 3: Creating the Deployment Package


Nice. The Deployment Admin seems to run just fine. It would be good to check out how it deals with a standard "Deployment Package".

What is a deployment package? Well, according to spec - "A Deployment Package is a set of related resources that need to be managed
as a unit rather than individual pieces. For example, a Deployment Package
can contain both a bundle and its configuration data. The resources of a
Deployment Package are tightly coupled to the Deployment Package and
cannot be shared with other Deployment Packages."


Let's create one then, a really simple one. First, lets take a look at the basic structure of a *.dp file (MIME type: application/vnd.osgi.dp).


deploymentpackage-0.0.1.dp
|
- org.nowaqblog.bundle1-0.0.1.jar
- org.nowaqblog.bundle2-0.0.1.jar
- META-INF
|- MANIFEST.MF


As you can see our deployment package is a simple jar/zip file (having "dp" extension) which consists of two bundles and a MANIFEST.MF file. The bundles are the complete application that we want to deploy using Deployment Agent. The MANIFEST.MF consists of specialy defined sections. The "global section" and multiple "name sections". The content of these sections is well described in OSGi Sevice Compendium (114.3.3).

For the purpose of this tutorial I created a simple deployment package MANIFEST.MF file like this:

Manifest-Version: 1.0
Created-By: 1.6.0_13 (Sun Microsystems Inc.)
Created-At: 1254918423406
DeploymentPackage-ManifestVersion: 1
Content-Type: application/vnd.osgi.dp
DeploymentPackage-SymbolicName: org.nowaqblog.deploymnetpackage
DeploymentPackage-Version: 0.0.1
DeploymentPackage-Copyright: Nowaq (c) 2009
DeploymentPackage-ContactAddress: mailto:your.email@host
DeploymentPackage-DocURL: http://host/doc

Name: org.nowaqblog.bundle1-0.0.1.jar
Bundle-SymbolicName: org.nowaqblog.bundle1
Bundle-Version: 0.0.1

Name: org.nowaqblog.bundle2-0.0.1.jar
Bundle-SymbolicName: org.nowaqblog.bundle2
Bundle-Version: 0.0.1


So, your job is simply to package all the bundles being the part of your application into dp file and add appropriate description in the MANIFEST.MF file. Simple, isn't it?

Step 4: Installing deployment packages via Deployment Admin Web UI (Felix Web Console)


Ok. Now we have all that we need. The deployment admin and the deployment package are ready to be used. How to do it then? Well, two options come to my mind. We could either extend the Equinox Management Console with a new command or use the Felix Web Console and deploy our package using web interface. You may find the first approach cooler (you learn how to use Deployment Agent API), but for the sake of simplicity I will stick with the second approach in this tutorial.

First we need the web console installed. Go ahead and download it from Felix web site (http://mirror.uoregon.edu/apache/felix/org.apache.felix.webconsole-1.2.10.jar).

Add this new bundle to your equinox startup configuration. (Add new entry in the config.ini file.)

...
org.apache.felix.webconsole-1.2.10@2:start


Start equinox and type "ss". All bundles should be "ACTIVE".

You may now check out the Felix Web Console at http://localhost/system/console. You will need to authenticate with "admin/admin". Play around a bit and go to the "Deployment packages" tab. This is the one of particular interest for us.



Step 5: Deploying the application to the OSGi Container


This is the easiest part of the story :-) In the Deployment Admn view of the Felix Web Management Console browse for your "dp" file and click on Install/Update button. Your package should deploy in a few seconds. The web interface will provide you will all the information you need.



Check out equinox console. The packages should be there indicating the "ACTIVE" state. Yeah! You just deployed your first "Deployment Package" using a "Deployment Admin Service". Congratulations!

Monday, September 28, 2009

Toshiba Satellite P100-102 - for Windows XP users only

Three years ago my girlfriend bought herself a notebook - The Toshiba P100-102. We've chosen it together as it's always better to have more critical points of view when it comes to buying such stuff. Our decision was based on multiple aspects. The critical ones were quality, performance and display size. My girlfriend upgraded this list with the additional one - "the looks". This notebook really rocked. Even today, after three years its performance would be totally satisfactory if not... the BIOS and the "f***n" graphic card cooling issue!

Toshiba mounted the "NVIDIA GeForce Go 7600" card into this great and whatsoever beautiful box. This was the largest mistake the company could ever make! Why? This chip has to be cooled down with a fan. After three years of what I would call "normal usage" the card simply DIED! And as you would expect, without the card the rest may be considered DEAD too!!! The funny part is, my girlfriend did not play any games, the chip did never work under extreme pressure. So how can that be?

Well, I always trusted Toshiba and believed that what they build will run for at least next 10-15 years (this was the case of my first notebook with Celeron 650MHz - it still simply runs!). What the hell did you guys do? Did you change your strategy from building quality products to building shit and forcing people to change their boxes every year?? I hope not, because if you did, I'll never buy a Toshiba again!!!

So what happened with the card? Did it overheat? Oh YES it did! Why? Well, this is what I found on nvidia Linux support forum after doing some research on "fan problems + P100 + geforce go". The guys explain how Toshiba controls the fan cooling the GPU. Here's what some said:

"... The modified Toshiba nvidia driver is constantly polling the MAX6659 sensor and then writing something into it's own embedded controller that is controlling the fan. So, I don't think it's a problem with the nvidia drivers but instead with Toshiba simply not telling nvidia how to control the fans they are using on their nvidia based laptops..."

This means:

  • you're stuck with old XP (note: not only windows! you are stuck with XP!)

  • you're stuck with old Toshiba modified NVIDIA drivers

  • you're possibly stuck with specific BIOS version too (at least you may hack it easily)

  • well... in other words, this notebook SUCKS!!! (as well as many other based on same idea and GeForce Go GPUs)

The whole cooling system story sounds a bit like a "big hack", immaturity and incompetence of the notebook manufacturer! So how do I see the Toshiba notebooks now? I will say just one thing. I am an OpenSource software fan... I don't like to be limited... and I absolutely HATE low quality components (including software of course) in my notebook!

So what am I going to buy now (apart from new, old GeForce 7600)?

Thursday, September 24, 2009

When should you reinvent the wheel?

You will be warned by so many software developers to not make this big mistake and reinvent the wheel again. They will say that this is purely just a waste of time. Your solution will be new, not properly tested and probably not efficient too. In other words "it will suck anyway!" Well... they are totally right! Well.. at least in most of the cases. There are however some buts... and this is going to be the subject of this short blog post.

There are cases when reinventing the wheel is exactly the thing that you want to do! This is connected with two very important subjects: education and evolution. Let's take Intel as an example. What would it be if they stuck with their i386 processor implementation and not reinvent it again in form of i486, then Pentium and finally Core 2? The technology changes... did you ask yourself why? Because people invent new things, often by reinventing the wheel. Those changes allow other people to go further by getting rid of old limitations (e.g. performance, functionalities, etc.). This leads us towards optimization of our existing solutions ("the old wheel") and creating new ones ("rocket powered multi-road moon wheel" - which is still a wheel, but a better one).



Also, if you are newbie in the IT world willing to become a "guru" in the future. How the hell will you get to know how stuff works if you have never looked inside of it? How can you make it better if you are not allowed to change the hearts of it?

If you have time and creative mind then go ahead and do it. Please, reinvent the wheel so that I can use it in my next large, time intensive project allowing me to make a lot of money ;-)

Wednesday, September 16, 2009

The wisdom of "Döner Kebab" consumers

I was pretty hungry yesterday in the evening so I decided to go to the city center to get me a "Döner". The plan was good, the only problem I had was that I didn't know which place to choose. The city of Munich has hundreds (or rather thousands) of them! Each place offers very similar product for the similar price. How do I choose the one offering a good quality and won't cause me stomach aches at night?

So what did I do? Well... I just relied on the instinct :-) Sounds easy, but as soon as I got what I wanted (a nice, fresh and tasty "Döner") I realized how complex and logical my decision making process was. (Tip: It has something to do with groups.)

Once I got to the city center I walked along the street for a while passing "Döner" bars. I didn't go to the first one, not even to the second one or third one. The one I've chosen was somewhere in the middle of the street. Just a typical "Döner" place (small and a bit dirty looking). There was however one significant difference if you compared this place to the other ones. In this bar there were people, many people. What's more, people who were waiting in a queue for their food to get prepared. Why did my brain told me to go there and wait with those guys? Illogical, isn't it?

No, it's not. It's rather really cool! This group actually "told" me which place to choose by simply being there and my instinct convinced me that I should rely on their wisdom.

The choice was perfect. I got myself a "Döner" having a very good "price/quality" ratio... just because I was relying on my instinct.



Interestingly, in my city I do not rely on the instinct anymore. I simply know where to go. I guess I learned which bars are the best from some other groups ;-)

Tuesday, September 15, 2009

Better controlling the Cloud

This is what I found on the web. Check it out:

http://link.brightcove.com/services/player/bcpid1753162278?bctid=17374112001

Seems to be an interesting idea. Waiting for some opensource product going this way.

Monday, September 14, 2009

I hate Mondays!

Last week I've booked my hotel and tickets to Munchen. I originally planed to stay there for three days (read two nights) and then come back to Erlangen and work remotely. Everything was great until today when I realized that I've made appointment for Thursday with a guy who substitutes my boss and comes to get some feedback info about me and my work. This fu... totally sucks! Booking another hotel just for one night in Munchen (it won't be cheap), re-booking the ticket (those guys at DB really know how to piss somebody off), etc. My girlfriend will be pissed of too (I promised to give her a ride to Nuernberg to the dentist on Thursday.) Why didn't I look at the calendar last week? It was all written there!! I don't get it! Oh.. I am such a... oh... no... I just hate these fu... Mondays!!!

Wednesday, August 26, 2009

Monkey see, monkey do

For the next two months I am going to work on a software project in Munich, Germany. Moving to a big city is quite a change for a guy like me. I am a person used to quiet, small and clean places the population of which does not exceed the size of 100.000 people. There are naturally many disadvantages of living in a small town but I personally think that the pros overtake the cons dramatically if you value the quality of your life the most.

I have been researching (reading about) the subject of "Groups" and "Behavior of individuals being a part of Groups" for a few weeks now. The last few days in Munich proved the theory I was familiar with and allowed me to experience some of those "wise statements" I've learned in practice.

The amount of people who unconsciously base their decision making on decision making of the group is extremely large. One of my observations (in the Munich subway) proves that when in a rush, many of our decisions are based on instincts. These instincts fire some behaviors which are proven to be "ok" or sometimes even "safe" or "normal". Consider this: What would you do if a group of people (let’s assume 10 people) surrounding you would suddenly start running in the opposite direction? Would you run with them? Would you at least think about it? Would you be scared? Or maybe you would decide to analyze the situation and make you decision based on "strict facts" concerning you?



I was on my way to get the train to my office. There was no rush. One of the digital displays showed that next train will arrive in approximately 5 minutes. I decided to slowly go to my destination. I've chosen the escalator because I am very, very lazy guy in the morning. There were about 6-7 people on the way in front of me too. Unexpectedly, two of the guys rushed of the escalator as if there was a train coming in a few seconds. There would be nothing special about it if not the fact that the rest of people who were standing in front of me rushed after them. (Interestingly, those behind me didn't.) When I reached the station, I saw the confused faces of those people. They were moving chaotically as if filled with some sort of energy generated by sudden jump of adrenaline level. Why did they react that way? Why did I feel like reacting the way the others did? That's crazy!

Being part of the completely different environment on day-to-day basis allowed me to "save my independence". I know however that if I was to stay in that city for a longer while I would become part of that "system/crowd" and my decisions would no longer be based on rational facts. They would be rather based on instincts taking over the decision making process for the boring part of my life.

Anyway, do not ever forget this:

Life moves pretty fast. If you don't stop to look
around once in a while you'll miss it.
-- Faris Beulers day off.

Monday, August 3, 2009

Why big hardware corporations can not write software?

I think one could write an entire Ph.D. thesis on this subject. Master's thesis could be to short and not cover all the aspects/problems the large corporations are dealing with.

I experience this sort of problems everyday since this is the kind of corporation I currently work for. It is extremely interesting to observe the behavior of people working here and it would be such a waste if I didn’t share some of my experience with you.

Why do they build software if they are hardware experts?


Well, the thing is that modern hardware has to go together with some sort of software. It needs it to function properly or/and to interact with the user. The devices the company produces are therefore useless without appropriate software package. Since the company builds the device itself, they are also the ones who understand it best. They simply know how the software should interact with their product. This knowledge is very seductive and makes them think: "Well, we've build the hardware, building software is just the formality then".

Since there is no way to go around this and some kind of software has to be build in the end, many companies choose to build it by themselves (and keep the implementation details "secret").

Why build it yourself, why not?


This is actually a very good question. If you have no experience with building software, then what do you do? Yes, you outsource it to someone who does! This idea is not that bad but only under one condition; you outsource the project entirely to the professionals who really know what they are doing! The problem of most hardware companies is that they want to go cheap. They simply outsource their projects to places where the so called "programmers" do not cost a lot. ("You know, the software is just this virtual piece of functionality that we need but is naturally of lower importance for the hardware itself, which our main product!"). This is the place where they are totally wrong and the "numbers" that management has seen at the beginning of the project turned out to grow up exponentially after delivery of the first working version of the new so called "software package".



So what do they do when they see the problem?


First of all they want the code back to their development centre. However, as soon as it’s there they realize there is no one who understands it. (I think that even the best software developers would have problem with it.) So what do they do next? Yes, they look for people who do (or at least say that they do). This is actually the place of their second failure. When they hire their new software developers they actually don’t know what kind of people they want. This problem may be well explained by the company’s lack of knowledge and experience related with building software. The group of their current hardware (or old software) engineers is simply not able to recruit good software developers since they themselves don’t know what the difference between "good" and "bad" is. So after asking the questions like: "How much experience with C++/ Java do you have?" or "Do you know what Ajax is?" they tend to recruit trashy people who have just a little idea about the art of software development.

But that's not all...


Hardware companies usually do not use, understand (or want to understand) the agile development methods. They stick with their waterfall models (or waterfall-like models) and think that something which was suitable for hardware can be also suitable for software. Well, it is not.

The typical problems they face:

  • Lack or badly defined requirements

  • Lack or bad architectural design. No "design for change". ("who needs architecture after all? We need to deliver soon so please start coding now!")

  • Lack of good software developers

  • Lack of unit, integration and system tests (no comments...)

  • [ ...write some yourself... ]


I was recently on a job interview at the typical, medium size "software company" in Berlin. These guys really impressed me with both, their professionalism and their recruitment process. I have spoken with the project manager and one of the lead developers. They knew absolutely everything about their product, developers, development methods they used and project management tools. They were even able to draw a simplified version of the architectural design of their application to explain me how it works and where they see me in that project. I didn't accept that job because of personal reasons and partially because they could not offer me the same or better financial conditions as I have at the moment. Now I kind of feel it was a bad decision.

Yesterday I was on a job interview for the other department at my current company (see, I am a "software engineer to rent"). The interviewers were totally different. They didn't know what they wanted from me, asked inappropriate questions, tried to convince me about how .NET is superior to Java technology without any reasonable arguments. They made me angry and in the end offered a JavaScript coding position for some sort of user interface they don't have requirements for. Can you imagine this? This was simply a waste of my (precious :-)) time. The funny part is that even though I don’t fit that position at all, they will probably accept me.

In the end I have one short message to all hardware developers. Guys, wake up! Software is a real deal! Be careful who you hire and don't forget to get rid of all that bad, useless and incompetent, so called architects, developers and most of all project (or product) managers!!! I want to be able relax when I am using my new digital TV receiver or get X-Rayed at the hospital, so please, get educated and do it right!

Tuesday, July 28, 2009

Tapestry 5.1 on JBoss 5.1

Well, today I tried this configuration and guess what... it didn't work! We all know who to blame (and this is not the Tapestry guys)! Now, what can we do about it?

The information on Tapestry wiki states that there is a workaround required for Tapestry to work on JBoss 5.0.x. The wiki says also that the workaround wouldn't work with JBoss 5.1. Hmmm... to bad, but why wouldn't it work?

I've decided to debug the code I got from the wiki and take a look at the behavior differences on both versions of JBoss. After an hour of debugging I found out that the URLs to the resources are build differently for jars which are packed inside of wars. There is however easy way to make them look the same.

Here's my patch for the original workaround at Tapestry Wiki.


...
public URL convert(URL url) {
if (url != null && url.getProtocol().startsWith("vfs")) {
// supports virtual filesystem used by JBoss 5.x
try {
URLConnection connection = url.openConnection();
Object virtualFile = invokerGetter(connection, "getContent");
Object zipEntryHandler = invokerGetter(virtualFile, "getHandler");
Object realUrl = invokerGetter(zipEntryHandler, "getRealURL");

// start of the patch (small fix for JBoss 5.1)
if (realUrl.toString().endsWith("jar")) {
Object localPath = invokerGetter(zipEntryHandler, "getLocalPathName");
Object context = invokerGetter(zipEntryHandler, "getZipEntryContext");
Object tempUrl = invokerGetter(context, "getRealURL");
realUrl = new URL(tempUrl + "" + localPath);
}
// end of the patch
return (URL) realUrl;
} catch (Exception e) {
log.info(e.getCause());
}
}
return url;
}
...


Now, you may enjoy having Tapestry on your favorite application server... and wait for a more professional workaround from Apache guys.

Twitter - isn't it just an observer pattern

It just occurred to me how great and powerful design patterns really are. Well, I must admit that I always thought about them as if there were just a tool that I can use to build great, exciting, flexible and maintainable applications. Well, after all that's totally true! However, it never occurred to me that I could take a design pattern and make an entire application out of it. Yes, I mean it! The pattern may be a great business idea! The business idea where the pattern implementation itself is all the software has to offer to its users. Sounds simple, doesn't it?

The concrete pattern that I am "secretly" thinking about is commonly known as an "Observer pattern". This "recipe" is extremely important to every good software developer who would like to build a flexible system which needs to deal with some sort of event handling… but you already know that. Now, take this pattern and map it to the real world. This is actually where it originally came from. What do you see?

I see e.g.:

  • newspaper companies and their subscribers

  • church and all the people who "subscribed" to it. They (typically) receive recent information about some sort of catholic events... etc. whatever...

  • the company which employs you and yourself. Well, you subscribed to get the money every month from them. The bad part is that you have to work to keep yourself on the list of subscribers.


As you can see our live is surrounded with observer pattern. It is natural that people love patterns. They make our lives easier. We don't have to think so much about that many things around us. Just this simple fact proves that a pattern itself can be a great business idea! How can we use it then to build our own business on the web using this common "routine"?

In my opinion, the best example is the Twitter. In Twitter you are acting as a Subject and Observer at the same time. The network of observers and subjects is therefore huge! Every time you post a message, all people who are your observers get informed about it. Every time the subject you subscribed to is posting an update you get informed about it too. Isn't it great!? Take a pattern and use it directly to make a lot of money. This is of course pure theory. The internal implementation of Twitter is probably not that simple, but this is not the point of this post.

So, when thinking about your next genius, innovative business idea, just make sure to take a closer look at the design patterns. Try to map them to the real world problems and use to build solutions nobody thought about yet.

I think that this approach will always lead you to a success. Here's why:

  1. This new thing of yours (whatever it is) will work for sure. Design patterns were tested by millions and proved to work correctly and efficiently.

  2. It will also be simple... and since people like it to be simple it makes a perfect match.

  3. We all probably will know this routine by our hearts. We just didn't suppose that you could use it this way. This means that the users will know how to use your software right away!

  4. There is more... and more... and more... but I am too lazy and too dumb to put them here.


Anyway, I will re-read my patterns book and look for some clues there.

Tuesday, July 21, 2009

Modern Web Design

If you are a guy who spends a lot of time on web application development, then check this out and tell me if you agree:

http://tapestryjava.blogspot.com/2008/06/time-breakdown-of-modern-web-design.html

Now.. this is so true, isn't it!

Monday, July 20, 2009

Do you own PT AX100 E/U?

For some time now, the device (which I personally love) kept misbehaving. Every 5min it turned itself of... very, very annoying when you watch e.g. an action movie.

If you too have this problem, this is what you should do to fix it:
http://www.youtube.com/watch?v=6jGwB05_gdk

Friday, July 17, 2009

Gmail-like text overflow

Today I've learned how to implement a nice gmail effect of text overflow. I was trying to build it for few hours with no good effect. I googled a bit and found the "correct" answer on this blog:

http://ajaxian.com/archives/learning-from-gmail

It's a very useful feature if you like to implement your web UI using liquid layout. The user may see more if he has a bigger screen (which is fine.. I like to know that having a big screen is actually a plus when I browse the net). Also, the effect allows your table to look more consistent independently on the screen resolution of the client viewing it. That's really nice!

Here's the style that I used:

...

.grid {
table-layout: fixed;
width: 100%;
}
.grid * td {
white-space: nowrap;
empty-cells: show;
overflow: hidden;
}

...

<table class="grid">
<col style="width:100px"/>
<col />
<col style="width:100px"/>
<tbody>
<tr>
<td style="padding-left:10px;">Other</td>
<td>
<a href="#">
Very long text.
</a>
</td>
<td style="padding-left:10px;">Other</td>
</tr>
</tbody>
</table>

...


And here's how it looks like:



I've dropped the "width:100%" property. It seems to be not necessary. Have a happy coding!

Tuesday, July 14, 2009

Impressed by Groovy and Grails

For the last few days I've been playing around with Grails framework just to get to know what it is about. I must say that I am really... no, that's to small for it... extremely impressed by its completeness, maturity and ease of use.

Building web applications is not an easy task. It involves many different subjects such as architectural deign, build process design and automation, database integration, user interface design, security, more and more stuff, etc. Grails covers all of those subjects within one, easy to understand framework. This stuff is really amazing!

Till now, I have been thinking that the only right technology for building web applications is Java. Well, I still think so, but now I would additionaly say... yes, it's Java but extended by Grails framework.

I really recommend you to take a look at the Apress'es book "The Definitive Guide to Grails 2nd Edition (2009)". Read a few chapters and discover what it means to quickly build complex web apps with an Agile framework.



Here's amazon link: The Definitive Guide to Grails 2nd Edition

Saturday, July 11, 2009

... } finally { certified = true; }

Yeah, I finally got certified!

It has been one of my TODOs for a few years now. The problem always was that I could never find time to prepare myself really well for this. There was this huge book to read, mock tests to do, etc. and lots of other task apart from that. I am happy that I didn't forget and finaly did what I planned to do.

I scored 84% and must say that I am pretty happy about it. Anything above 95% would probably mean that I am not a human beeing anymore but a Java compiler instead.

Some of the questinos were extremely hard but there were also no-brainers. Anyway, if you think that you could pass the SCJP exam without any preparation (because you have multiple years of expierience with Java) then you are totaly wrong! I screwed up mostly "Concurrency" questions even though I scored above 90% with Whizlabs Mock tests. It's just not predictable what kind of problems you may get to solve on the exam.

Now I may learn Groovy in piece :-)

Thursday, July 9, 2009

What's it gonna be?

Finally, THE TEST!

If everything goes well, I will get certified tommorow. After writing tons of code samples, reading the book, practicing with Mock test I am still not sure what's it gonna be!

Today I've learned something new! Would you expect something like this could print "true"?

Integer i = 18;
Integer j = 18;
System.out.println(i == j);


Interetingly, all samples shown below will print "false":

Integer i = 18;
Integer j = new Integer(18);
System.out.println(i == j);

...

Integer i = 128;
Integer j = 128;
System.out.println(i == j);

...

Integer i = new Integer(18);
Integer j = new Integer(18);
System.out.println(i == j);


Eeeh? Yes! Try it yourself! I'm not kidding! And there is more examples similar to the one shown above (e.g. Double.NaN == Double.NaN ... returns false).

Well, it's gonna be tough, that's for sure!

Wish me luck!

Friday, June 26, 2009

Getting certified with Wizlabs and Kathy Sierra’s book

Whizlabs did really good job with their “Examination Preparation Software”. I am really satisfied with their web based application (running on Google Gears) and the sample SCJP tests that they are providing. Part of the satisfaction is probably caused by the fact that I don’t have to pay for the software myself, but most importantly I feel that I get well prepared for the Sun’s exam. The cost is low… about $50 (like an average book, maybe two books) but I think it’s worth the money. Apart from the “Preparation Tests”, Whizlabs also provides possibility to review all your answers and generate a nice progress report for you (so that you can see where you are with your current knowledge).



Sample tests of course are not enough to get ready for the exam (even though Whizlabs seems to say they are). I recommend reading a book by Kathy Sierra and Bert Bates. It’s totally great. It is well written and I guarantee that you can learn a lot not only for the examination but also for the “real world” programming. It is also important to write tons of sample code just to burn the gathered knowledge into your brain.

Tuesday, May 12, 2009

Finally a good and simple UML editor

For a very long time I was looking for a simple and easy to use UML editor. I couldn't find any! Visio sucks, Together is too big and to complex for the simple diagrams and scenarios that I plan to draw in few minutes. What can I use then?

Today I finally found something that seems to be a tool that I was looking for. The "Violet UML Editor" is amazingly simple, portable and easy to use. It is well organized and even good looking. I was able to create simple and even more complex diagrams without having to think about return types and all other obsolete stuff (a least during architectural design phase). The fact that it is distributed as a single jar file is also a big plus - no installation required no matter what the operating system you work on.



Check it out: http://alexdp.free.fr/violetumleditor/page.php

Sunday, March 29, 2009

Pierwsze aplikacje

Dzis wyslalem moja pierwsza naprawde profesjonalnie przygotowana aplikacje o nowa prace. Polecialo do kanady do bardzo fajnej firmy robiacej software dla ecommerce. Specjalnie szukalem czegos co nie bedzie tak duze jak Siemens acz wystarczajaco spore i bogate by zatrudniac prawdziwych profesjonalistow od ktorych moznaby sie bylo czegos superanckiego nauczyc. Zobaczymy co z tego bedzie. Kanada jest daleko.. ale w sumie nigdy tam nie bylem wiec wypad na roczek lub dwa nic by nie zaszkodzil. Szkoda tylko ze placi sie tam w dolarach, jest zimno i blisko do hamburgerow. No ale.. czego to sie nie robi dla dobrej pracy i przygody.

Friday, March 27, 2009

Game over

No i stalo sie. Pod koniec kwietnia opuszczam MED GS (a moze HS... juz sam nie wiem, tak czesto zmieniaja sie tu nazwy dzialow ze za tym nie nadazam... hmm.. nie chce mi sie nawet nadazac). Kasa sie skonczyla i nie stac ich juz na pracownikow zewnetrznych.. zycie.

Prawdepowiedziawszy.. nie czuje w tym momencie nic. Spedzilem w tej firmie prawie trzy lata i jedyne czego bede zalowal to.. hmm.. to to ze nie znalazlem sobie ciekawej pracy zanim nastal tu kryzys (i nie mam tu na mysli kryzysu "globalnego").

No ale.. w sume to musze stwierdzic ze wiele sie tu nauczylem, np. jak nie programowac, jak nie testowac, jak nie tworzyc zlej architektury, jak nie powinien wygladac team work, jak nie powinno sie uzywac scrum'u, jak nie powinno sie obchodzic z ambitnymi ludzmi, jak nie zabijac dobrych pomyslow, jak nie przeprowadzac rekrutacji, jak i gdzie nie zaczynac swojego biznesu, itp, itd. To jest naprawde wiele! Co by bylo gdyby wszystko przebiegalo perfekcyjnie, gdyby pracowali tu ludzie super kompetentni, "guru", perfekcjonisci? Czulbym sie pewnie nie najlepiej jako poczatkujacy programista, nie mialbym pola manewru, kazdy wiedzialby lepiej i mial do tego racje... a tu, mimo ze kazdy wie lepiej to ja i tak wiem ze racji pewnie nie ma, moge to sprawdzic... oswiecic kogos.. nauczyc sie czegos... mile uczucie ;-) Tak wiec zaczalem lekko... nauczylem sie tego czego chcialem na przykladach z zycia wzietych na koszt firmy. Super, jestm happy i moge isc dalej... hmm... tylko gdzie. Przez te wszystkie doswiadczenia z "jak nie ..." mam teraz maly uraz psychiczny i "nieco mocniej" zdefiniowane wymagania co do pracodawcy. Wiem tez, ze moj obecny "employer" nie znajdzie mi pewnie niczego co odpowiadaloby moim zachciankom (java, open source, etc.). Biore sie wiec do roboty i szukam czegos superanckiego... moze znajde.

Wednesday, March 25, 2009

UNMOUNTABLE_BOOT_VOLUME - XP on vmware

I recently updated my Gentoo box to the latest version available (I tought "few hours compile time"... but no.. it actually took the whole night!). Since I also had the vmware-player im my "world" it got updated too. Unfortunately, I was unable to start the XP vmware after I rebooted my PC. I don't know what the reason was but all my stuff on that virtual machine seemed to be GONE! All I could see was just a blue screen (which happened to appear only for about 200ms.. which is long enough to take a screenshot).



If you happened to have the same problem, here is what I did:

  1. Took the XP installation CD and started vmware with it

  2. When the installation app asks you what to do, choose REPAIR (press 'R' key)

  3. run CHKDSK app (may take a while, depending on size of your disk)

  4. done. CHKDSK should print out smth about finding errors, etc.

  5. restart vmware.


It helped me, maybe it can also help you. Good luck!

Saturday, March 21, 2009

Jestem psycholem :-)

Czasami lubie patrzec na takie rzeczy...



Nie.. no powaznie, nie moge od tego czasami oderwac oczu. Podobnie jest zreszta z wszelkimi monitorami pracy komputera. Gapie sie w nie jak bezdomny zima w ogien. Szczegolnie kreca mnie xosview i gkrellm kiedy pokazuja obciazenie procesorow w trakcie kompresji, kompilacji czy linkowania. Czuje ze wykorzystuje w pelni moc mojej maszyny... hehe... czy jestem psycholem?

Tuesday, February 24, 2009

Co by bylo gdyby to mechanicy samochodowi tworzyli software?

Oczywiscie to pytanie to czysta abstrakcja. Ale.. no co by bylo?

Dwa tygodnie temu oddalem nasza Mazde do przegladu po 90K. Drogo bo drogo ale autko sobie na to zasluzylo. Nie sprawialo nawet najmniejszych problemow od momentu zakupu (choc to juz 8latek). Trzeba bylo zmienic pasek rozrzadu, wymienic olej i pare filtrow. Teoretycznie prosta sprawa dla kodos kto robi to na codzien, nie?

Co otrzymalem z powrotem?... piszczacego szrota! Autko chodzilo niby normalnie.. przez chwile... a potem zaczelo piszczec i swiszczec, jakby ktos paznokciami po czarnej tablicy szorowal.

Na szczescie mieszkam w niemczech i obowiazuje tu gwarancja na takie rzeczy, nikt nie proboje wciskac kitow itp. A co by bylo jakbym mieszkal w Polsce? (hmm.. pewnie ten post bylby na temat trojanow i robali)

Okazuje sie ze problem z pojeciem jakosci pracy i produktu pojawia sie w kazdym biznesie. Niestety, nie wszyscy mysla o tym ze cos nowo zbudowanego, przerobionego, "naprawionego" trzeba najpierw przetestowac zanim sie to przekaze klientowi. A przeciez to takie proste!! Test! Wsiadasz do fury i jedziesz.. raz szybciej, raz wolniej. Zakrecasz, wyjezdzasz na prosta i w gaz... itp. Sama zabawa i do tego nie wymaga az tyle czasu!

Doswiadczeni mechanicy czasami podobni sa do programistow pracujacych metoda "Kopiego-Pejsta". Kopiuja robote ktora pamietaja ze kiedys tam juz robili. A skoro tak zrobili i dzialalo to mysla ze jak zrobia to jeszcze raz tak samo to wszystko bedzie dobrze. Odpalaja aplikacje... chodzi. Yes! Niestety, po tygodniu, gdy kolega wciska przycisk w dolnym rogu aplikacji system pada, EXCEPTION! Chlopaki, testujcie!!

Zaraz wiaze fure do poprawki, juz sie ciesze na dzwiek kredy w garazu.. auuuc.

Thursday, February 5, 2009

Darmowe żarcie

Przegladajac niemieckie oferty pracy natknalem sie ostatnio na cos takiego (to tylko urywek tej oferty):

Senior Software Engineer (m/w)

Unser Kunde bietet Dir folgendes an:

- Flexible Arbeitszeiten
- Eigenes Budget für Bürobedarf und Fortbildung
- Garantierte Weiterbildung und keine leeren Versprechen
- Gratis Biofood und Getränke
- Unterstützung bei Wohnortswechsel
- Koordinierte Arbeitsabläufe und klare Trennung der Zuständigkeitsbereiche

Du bist fit in folgenden Bereichen:

- Erfahrung mit der Planung und Entwicklung einer Internet Plattform
- Erfahrung in objektorientierter Programmierung mit PHP5, MySQL
- Design und Implementierung eines neuen Datenbankschemas in MySQL
- Fundierte Kenntnisse mit Unit Testing in xUnit


Oferta ta, mimo ze ledwie przedstawia informacje na temat tego, czego tak na prawde pracodawca potrzebuje, wymaga i generalnie soba reprezentuje przyciagnela moja uwage. Byla to podswiadoma reakcja na ktorej sie zlapalem i postanowilem ja przeanalizowac. Oferta mierna wiec co to bylo do cholery? Dlaczego mysle, ze to moze byc dobra propozycja? Dlaczego, mimo ze nie mialem nic wspolnego z PHP od czasow uczelnianych, wciaz jest kuszaca? ... hmmm... no tak.. "Bio food"!

Nie zaregowalem tak z powodu tego ze bylem glodny albo ze mi "Bio" zarcia na codzien brakuje. Ten pracodawca pokazal mi po prostu ze swoj projekt a takze swoich pracownikow bierze na powaznie a nawet dodatkowo traktuje ich wyjatkowo (bo Bio zarcie nie jest przeciez dla mas :-)).

Wedlug Maslowa (see Model Abrahama Maslowa) zaspokajanie podstawowych potrzeb prowadzi do tego ze koncentrujemy sie na celach "wyzszych". Uczucie glodu, pragnienia itp. moze nas developerow lekko wytracic z kursu. Co by bylo gdyby np. w trakcie pracy nad jakims zajebiscie skomplikowanym algorytmem, miejsce mysli z rozwiazaniem zajela mysl o tym ze "za godzinke bedziesz w domu i zjesz w koncu ten obiad, batona czy cokolwiek zapychajacego".

Oczywiscie jest jeszcze druga strona medalu. A co jezeli pracodawcy chodzi o to zeby jego pracownicy wyprowali z siebie flaki i czesto zostawali po pracy zeby zdazyc z projektem na czas? To tez moze byc powodem "podrzucania" pozywienia do biora, nie? Hmm? Moze... ale wydaje mi sie ze wtedy nie byloby to bio zarcie... a poza tym, takie numery szybko koncza sie wypowiedzeniem.

Podsomowujac: Wydaje mi sie ze kazdy pracodawca liczy na to ze jego "podopieczni" beda dawac z siebie wiele. Idea umilenia pracy developerom np. Bio bananem czy Bio cola jest moim zdaniem bardzo dobra i na pewno wplywa pozytywnie na wydajnosc jak i motywacje pracownikow. Oby tak dalej!

Chcialem jeszcze dodac ze:
a) darmowa, super bajerancka kawa to podstawa! Nie musze tu chyba pisac dlaczego. Szkoda ze sa jeszcze pracodawcy ktorzy tego nie rozumieja (np. moj)
b) open space (Open-plan offices) - sami przeczytajcie

Wednesday, January 14, 2009

Polimorfizm vs. Polimorfizm (a.k.a. Strategy pattern)

Z cyklu "Bad practices"

Dzis zaskoczyl mnie nasz architekt ale niestety niezbyt pozytywnie. Jako ze facet ma jakies doswiadczenia zyciowe, wydawaloby sie ze sporo juz kodu w swoim zywocie widzial, a moze nawet napisal, nalezal mu sie do tej pory szacunek. Niestety, jak to juz w zyciu jest na szacunek ciezko jest zapracowac, za to stracic go mozna w jednej chwili... co tez kolega Berndt uczynil :-)

Grzebiac w kodzie naszego "wspanialego" systemu znalazlem gdzies taka metode:


public Something getSomethingNice(Something smth) throws Exception {
return smth;
}

prawda ze podejrzanie wyglada? hehe..

Przejrzalem historie zmian i okazalo sie ze metoda getSomething byla kiedys abstrakcyjna a klasa w ktorej obecnie sie znajduje byla kiedys interfejsem.
Jednym slowem niezle sie w systemie pozmienialo przez ostatnich pare lat. Najgorsze jednak bylo to ze ten bzdurny kawalek kodu przeszedl przez code review. Zadalem wiec architektowi pytanie. WHY???

Odpowiedz byla mniej wiecej taka:
Architekt: "Ahh!.. no bo to jest przeciez Strategy Pattern i tak juz musi zostac. Patrz, to sa np. klasy ktore dziedzicza od tej... bo w tej klasie ta metoda nie ma sensu wiec defaultowo zwraca to co przyjela."
Ja: "Ale.. ale... dlaczego ta klasa nie jest juz abstrakcyjna.. A po jakiego wala jest tam ten 'throws Exception'? Czy ktos kontroluje to co sie z kodem dzieje czy nie?"
Architekt: "Niech tak zostanie. Tak sie robi."

To ma byc Polimorfizm? No niby tak sie wlasnie ta cala konstrukcja zachowuje. Nie! Jak dla mnie to chuj nie polimorfizm! Liczy sie jeszce jakosc! - pomyslalem po czym polozylem glowe na klawiaturze, zamkalem oczy myslac o kawalku z "Code Complete" Steve'a McConnell'a o tym jak to zona gotowala kotleta wedle przepisu tesciowej. Nikt nie zastanowil sie nad tym dlaczgo w przepisie stalo "Posolic, popieprzyc i obciac dwa konce steku" (czyli standartowe "Bo tak sie robi"). Okazalo sie ze matka tesciowej lekko przycinala stek bo jej patelnia byla za mala :-) Tak wiec wydaje mi sie ze czasem wypada podrazyc temat troche glebiej by odkryc niepotrzebne bzdury, pozadnie przebudowac subsystem i ulatwic ludziom prace.

Shit, z takim architektem daleko nie zajdziemy.