Thursday, July 12, 2012

A big wow!

So, the big wow is that I just rediscovered that I have a blog and can use it to post some of my recent crap. Oh.. and it seems like Google updated blogger.com UI, editors and it even looks nice!

Anyhow, I have nothing special to blog about today. OK. Maybe one thing, enjoy your life people, seriously!


You may find more charts like this one at http://chartporn.org/ (btw. great domain name)

Thursday, October 6, 2011

Hero who will never be forgotten

Today is a sad day. Steve Jobs passed away. He is and always will be an inspiration to me.

Thursday, September 1, 2011

Just passed the DKIM

Just one very short comment: I hate email!!!! (and anything related to it)

But now I am able to send some! ;-)

==========================================================
Summary of Results
==========================================================
SPF check:          pass
DomainKeys check:   neutral
DKIM check:         pass
DKIM check:         pass
Sender-ID check:    pass
SpamAssassin check: ham

Can your software do that good? Send an email to check-auth@verifier.port25.com and see for yourself.

Not sure what I'm talking about? See this: http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html

Wednesday, August 31, 2011

SOLID by Uncle Bob

I've spend a couple of minutes today on listening to the Hanselminutes podcast about SOLID principles. The principles presented and explained by Uncle Bob himself is something you totally need to hear if you're any kind of software developer.

It's really good stuff so make sure to take a couple minutes to relax and listen the podcast. It's here: http://www.hanselminutes.com/default.aspx?showID=163

I also summarized them quickly for future reference (but you may like the Wikipedia version better):
  • S (Single Responsibility) - Class and a method should have exactly one reason to change
  • O – Open-Close Principle - Module open for extension, closed for modification. Polymorphism. We use interfaces, extend functionality by using different implementations of that interface. We can add new features by adding new code, not modifying core of the application. Principle of attitude ;-)
  • L – Liskov substitution principle - The user of the interface should not be surprised by the implementation he's using. If you drive Chevrolet you should not be surprised by driving the VW. Square and Rectangle dilemma. No relationship between them. They are both a Shape, but in code, Square is not a Rectangle! (think about setHeight method.)
  • I – Interface segregation principle - Applies to very fat classes, classes that have hundreds of methods and many many clients. Populations of clients that use subsets of the methods of this class. Some of the clients use couple of methods there, the other clients use couple of methods somewhere else. If a signature of one of that methods changes, then you need to recompile the class for all the clients, even that ones who are not affected by the change. You don’t want to depend on something you don’t use.
  • D – Dependency Inversion Principle - Depend only at things that are abstract! Don’t depend at anything concrete, anything!!!! Never touch anything concrete! (In reality of course that never happens.. but there is a rule. The rule is that only those who are volatile can ignore the principle a bit. “The things that change frequently are volatile”, e.g. Main function. You need to instantiate come stuff there... but then depend only on abstractions!)

Monday, May 23, 2011

Say one big NO to all Office applications

Office like software is probably the most destructive, demotivating, demoralizing and unproductive tool ever used for documenting software projects. I get sick each time somebody asks me to edit some specification, design document, requirements, etc. It makes me go crazy when I need to find that documents somewhere on the file system or (as people here call it) a "global" share.

The days when companies were able to manage documentation written that way are long time gone. But why do we still do that? Come on, how crazy and irresponsible is that?

In the past (as I was told by couple of my older fellow colleagues) developers used to write their code and store it on an ftp server so that the other coders could take a look at the changes and continue with their updates. This meant conflicts, errors, inconsistency and other kind of bullshit making the released product a complete bullshit. People managed to solve this problem with version control systems and the nightmare was over.

The problem with documents is that they are not code and not being code has a lot of disadvantages these days.

First of all, there is no IDE which can help you find your stuff in seconds. There is no syntax highlighting, no auto-complete, no integrated API. The docs are also (in most cases) extremely long, specifically structured, contain lots of formatting errors, open slowly, contain useless information and the last but most important.. they are stored as files (one or more) and you never know where to put them when you're finished with the content.

C:\Documents\Hmm...
or maybe
C:\Documents and ...\..\My Documents\Hmm..
aaah... there is this share
\\someserver\Docs\... uppss... no, it does not quite fit here

Some companies use LiveLink (for document versioning) but you don't want to see the screenshot of the directory structure that our fellow managers have build. Maybe I am too dumb for that but I simply can't find anything there!

If you have a large project which requires documentation (e.g. medical apps do) you will be scrued very quickly if you don't find a good solution for this problems. Thousands of documents which are hard/impossible to find, nobody ever reads them or cares about, edits them only when it's a must. You end up with thousands of tools which are supposed to help you manage all that crap but what the tools do is make it even more complicated and confusing. Be careful, this may also lead to high peeks on your employee burndown chart (and the most precious employees will burn down first!).

So what to do to finally drop that "standard" document writing/managing crap? People often need to share a *.doc or *.pdf with others, don't they?

Yes they do, but first of all... think... think more... and more? Go on the net... read, think more... get interested in this subject and do not accept with status quo! Got it?

I'll give you the solution which has proven to be extremely successful for me. Get yourself a professional Wiki. I don't mean a TFS wiki (which is CRAP), or a 10kb wiki engine that you can start on your localhost. I mean A PROFESSIONAL WIKI!

Now what can a professional wiki do for you?

  1. It can manage you users so that each user:


    • has his personal account where he can put his private stuff

    • can edit, comment on, review documents (his changes will be visible in th history)

    • can blog (yes! blog) about the stuff that he e.g. just discovered, etc.

    • has a photo and personality on the wiki

    • can communicate directly via Wiki's web interface


  2. It can manage your documents so that:


    • the documents/wikis are searchable

    • the documents are easily editable and accessible

    • the documents have common structure (templating)

    • the documents can be exported to DOC or PDF

    • the documents reference the issues in ISSUE management app

    • the documents reference the requirements in the requirement management system

    • the documents can be easily versioned

    • the documents can handle images, movies and media well

    • the documents can contain tables, colors, quotes, code samples, charts, sketches, etc.


  3. It can manage your projects!

  4. Improves all the time!



Sounds non-realistic? Well, go on Google, type "Confluence" and see for yourself.



I personally LOVE this product. Atlassian did an extremely good job with their wiki and the book they have published. At the moment it is the tool of my choice for the project that I work on and I am more then happy to use it. It's actually fun to use it which is even cooler! So, say NO to Office apps!

Thursday, January 13, 2011

Three displays... pure luxury!

I just came back from my holidays and there it is, my third display waiting for me to power it up! Yes, probably as the first in the office I got to work with 3 monitors on the daily basis to proove the legendary "increase in efficiency when using more desktop space" concept.

Well, the setup itself was a bit tricky since I needed to get a special graphic card and a special adapter for one of my displays. Currently ATI supports three or more monitors with their FirePro graphic cards and Eyefinity technology. I ordered FirePro V4800 (the very basic and realatively cheap one) for my purposes. This professional card provides 2 DisplayPorts and 1 DVI port that can be used to plug-in 3 displays. But wath out, there is a trick! In order to enjoy your desktop on 3 screens, you would need at least one monitor with DiplayPort input. If you don't have one then there is an option to buy an expensive (~90-100EUR) active DisplayPort to DVI adapter for you VGA or DVI display. Since at my company they get crappy displays by default, I was forced to get one of those adapters for my setup. It works perfectly.. but it is just an uncecessary additional cost you would want to avoid when possible.

It's to early to say anything about my "performace imporvements" but I already feel great about having my development env in the center, docs on the left side and build results on the right ;-)

Tuesday, November 23, 2010

Do you speak the "programmer's language" well?

When you speak your language you usually do not ask yourself if you use it properly, what are it's strength and weakness or if you speak it better or worse than the other people. You simply use the words you know to communicate something. The communication may be faster or slower (read "more efficient" or "less efficient) independent of the communication medium. One may be able to use a rich dictionary to pass the same message using just a few properly put, sophisticated words. The other would describe the same thing with simple words. It would just take more time. Talking is natural to us and being faster or more sophisticated sometimes does not mean better. Why not? The problem with the "smart" speaker may be that there will be not to many listeners who will be able to understand him. It all depends on the environment you are in.

Now imagine what happens when a PhD. in whatever subject is put in a room with a person who did not even finish a primary school. Are they able to communicate? Well... Yes. Kind of. The problem is that the PhD. guy will use 5% of his communication skills, start building long sentences of simple words just to be explain the other guy some stuff that seems basic to him. I think you already know where I am going... :-)



The programmers are very much like usual people who instead of "speaking" the "normal, common language", "speak" programming languages, design patterns, recent technologies and some other funky stuff. (Well, at least the real programmers do.). We all know that programmers who know "the sophisticated words" can be much more efficient then those who "speak" the basics. That is mostly the reason why large companies try to hunt down the best to work for them. The problem with programmers however is that it's not that easy to verify their "spoken" skills. To do it correctly, the recruiter must actually be able to speak "the programmer's language" on at least the "considered as minimum of the best need to have" level. Why? Call back the PhD and primary school guy conversation. Accidental addition of a poorly skilled guy to your team of professionals, may (and will) lead to terrifying results. The overall team performance will go down because the communication between the developers will have a bottleneck. In the end paying big money for your experts will make no sense at all since their efficiency will be limited by other group members. The more "average" people are add, the worse the performance is. In the end the company would be better of hiring cheaper developers, as this would not make any difference for the project performance.



Just to illustrate this; imagine a group of developers who all know what a strategy pattern is. Since it's definition is obvious to them, they simply say, "we use the strategy pattern here, and we will use it also there". A guy who does not know what this term means will have no idea of what are they actually talking about.. and thus, can not contribute to the conversation. Asking for explanation is correct but.. it reduces the groups performance. Now instead of simply saying the "strategy pattern" they will need to explain the poor guy what it is what they actually mean step-by-step. Looks like unnecessary effort to me.

Now, why am I writing about all this well known stuff? It's actually very important to me :-) One of the hints that I'll try to keep in my mind at all times is to make sure I work with great people only! They are the source of the success, nothing else. Motivated, educated and experienced freaks who feel like they want to build something great. Get them, set the free and let them build together!

B.t.w. Today I learned that knowing "the language" good does not necessarily mean the ability of using it to "discus". You know... even if you knew all the names of the European poisonous mushrooms you would not be able to really discuss about them, right? This is however another subject. For now, just make sure your people know well "the thing" they are building. The fact that they know "how to build" does not mean that they are also able to use this skill to "understand and discuss about" whatever YOU are building. Know that they want to build it too!

Monday, July 12, 2010

The non-developing developers

What I totally like in a well prepared job interviews is that they, without any doubt, reveal the truth about the candiate. The truth which sometimes is unknown/unclear even to the candidate himself!

Last week the head of one of our development departments asked me to help him with interviewing three people for the Java development positions. The requirements were clear. The perfect candidates had to know what they are doing. Basicaly, they need to be able to think, understand what software development in Java (or any other OO) language is, are able to solve engineering problems, are Agile, etc. Clear stuff. I decided to help. Besides, this was a great oportunity to me as well as I have never interviewed people myself. Usualy it was "them" who interviewd me.

The interviewees

As I already mentioned, I received three CVs to review. Each of them was better then the other. On guy impressed me with his document so much that I felt like an incompetent person to ask him the questions. A whole lot of development expierience, tons of technologies, known programming languages, huge ammount of certifications, OOD, OOA, patterns, etc. Wow! This must be our guy, I thought!



The other two CV's were not worse. The candidates claimed great Java knowlege. (One guy even attached SCJP6 certificate to his documents.) They all could speek at min. 2 languages (important for the project we have) and of course dreamed of working at our company. One young lady attached her photo to the documents... a big, nice photo! ;-) What more do you need?

Preparation

Well, the candidates prepared themselves so I also had to. Since I did not have much time I decided to build a short list of most fundamental questions to verify the contents of their CVs. The idea was also to check if the candidates are able to think. Asking a question like "Describe Factory Pattern" does not mean that the candidate thinks. It just prooves that he knows what Factory pattern is, but does not proove that the guy will be able to use it when necessary. So, I've prepared my "Evil" question list. (I think I will publish it on this blog as well. It got really popular at our corporation so maybe you could slightly modify and use it too.)

The truth

So, what happend during the interviews? Certainly something I did not expect. I mean, I new that the candidates could overestimate their skills but I totaly did not expect them to have no software engineering skills at all!

None of the guys could answer a single question completely; some even partially.
The absolute "hit of the day" was the guy who's spoken with/through his nose. His mouth did not even open (maybe a little) and it was extremely hard to understand what he was saying. He's also spoken very fast and had to correct himself from time to time. OK.. a geek maybe, I thought. Let's test!

He has presentend his SCJP Certificate proudly. Since I also have one... what else could I do then ask a Java Certification question. This appeared to be too much. So I asked the guy to pick up a design pattern he likes (or rather knows best) and describe it. His reaction was: "Hehe.. Singleton". "Singleton... ok, describe it" I asked. So the guy started saying that Singleton is the simplest pattern of all. That this is useful when exactly one object is needed to coordinate actions across the system. This was acceptable answer... wikipedia like. But when I asked about potential problems with Singletons... the guy was gone. (Btw. SCJP6 includes question on threads and synchronization.) He was absolutely clueless! We asked about his other skills, like "How good is your English?". The answer was "Good". So we switched and started speaking english to him. BUM!!! The guy did not understand a word! We decided to finish.

The other beautiful part was when we asked the candidates if they know anything about the products our company builds. The answer was always "NO". No. How can this be? Why do you apply here then? "Yeah, because I know this corporation, its a well known company... bla bla". Amazing! :-)

I almost forgot to mention a female candidate. Young, good looking lady, right after her internship at one of our departments. We did not expect much but were interested in what she can do, if she's motivated, if there is any potential there. etc. She did not know what the difference between an interface and an abstract class is. She also could not explain what do we need interfaces for. Sorry. Oh.. and the only thing she could say in English was "Yes" with an extremely strong russian accent.

Conclusion

We should apply "Holywood" principle into the process of recruiting people. "Don't call us, we will call you!". Otherwise, in most of the cases, you only get developers who can't develop.

Tuesday, June 29, 2010

Quiet down the frustrating Open Space Office noises

I am and always will be the enemy of the "lets have an Open Space office" idea. From multiple articles, blog posts and research I know that Open Space makes us, software developers, sick. In the worst case, we have to share the Open Space office with guys from marketing, management, etc. and this makes us even more sick! I guess that to some guys it's simply not clear that developers need to work in peace if they are to build a good quality software. What talent do you need to have to concentrate on design of you component or some algorithm when 15 of your 50 neighbours run around, speak on the phone or simply talk with each other? If you are able to focus on your work in such an environment then you are either deaf or you have some supernatural skills of shuting down your ears while working. Most project managers can't understand that developers are humans too and can get frustrated from time to time. The fact that people are half effective at work does not seem to be a problem for the management as well. This results in developers changing their jobs... or simply geting crazy... but who cares anyway? The office must be cheap! (Btw. in reality it isn't, but this is differnt subject and probably even harder for the managers to understand.) Like Scott Ambler once said "Management people are insane!" ... and I agree completely.

Now, why do I write about it? Well, as you may have guessed, I acctualy work in an Open Space environment. However, instead of chaning my job (which I probably will do sooner or later) I decided to find some other solution to this "unfriendly development environment" problem.


The Head Phones with Noise Reduction system!

Short story

The Noise Reducing head phones were wandering around my mind for many years before I actually got them. I saw them for the first time when I was flying to US for my high school abroad year (quite a while ago). A small guy wearing the Bose phones was siting in front of me. I remember him reading his book. He looked relaxed and seemed to enjoy the music among all this airplane noise. After few weeks I decided to find out something about his phones on the Internet. (They really must have seemed special to me.) When I saw the description and the price, I understood that they are state-of-the-art technology which I can not afford at the moment.

The head phones reapeard in my life for the second time when my girlfriend joined the team working in a large Open Space office. She complained about the noise, was frustrated, couldn't concentrate on her work, (paste some other usual stuff here if you like,) etc. Frustration is not helping to build a good relationship so we sat down together and discussed about it... and
... finally... "do you think the noise reducing headphone could help?", "why don't we try it?"

The effect

You would be amazed how much noise this little toy is able to reduce. Just put them on your head, turn them on and wuala, the usual noises are reduced by 70-80% (or even more). Turn some music on at the minimal loudness level and you won't be able to hear anything from outside! Its simply amazing!

The headphones worked like a cure for the Open Space sickness. After few days there was no frustration anymore, no concentration problems as well. Everyone in the office wanted to check them out and everyone who tried them bought them after some time!

The only wonder was that the management guys at our corporation who actually were aware of the problem and have seen their employees solve it on their own, did not agree to sponsor this noise reducing head phones to them. The clear efficency gain per person, the low ammount of frustration, etc. were not good enough arguments. What can I say? Stupid.

Models

I don't want to recomment any particular product here. There are many on the market so you can choose whichever you want. They all work very good. My personal pick was Bose QuietComfort 15. My girlfriend has Bose QuietComfort 3 model and is also very satisfied with its performance.

Thursday, March 11, 2010

News - why always negative? why always dummy? It's boring!!!

Introduction

Since a very long time I am totally disgusted by the information broadcast by the public/non-public TV (or newspaper) news. Most of it concentrates on a very negative issues and I think it has a bad influence on people. I feel it has a bad influence on me. That's why I would like to share my opinion concerning this subject with you. Also, I want to share an idea on how this problem could be solved.

Common subjects that I see in the Internet news (and simply scroll over them) go like "A politician X said that politician Y is an idiot", "5 people died in a car accident .... bla bla..", "plain crashed.... somewhere near a country I never heard about" . Some of that news are real tragedies that we really need to be familiar with (so that they never happen again). On the other hand some of them are of really minor importance or even just a total bullshit.

Today I asked myself, why do people need to be informed almost only about this bad and dummy stuff? I don't like to read only about bad things all the time and would really appreciate something positive. Bad news make me feel sad, confused, unhappy ... just bad feelings there. Is there any particular reason why media do this? Why can't they simply balance positive with negative? Do all people simply like to read about bad stuff? If yes (which I don't believe), then why am I so different?

The problem with Media

The problem is that media see (btw. maybe that's what they want) a group of people as a single consumer. They do not filter their news and present them in the same way to all of us. It does not matter if you are a student, a cook or a Nobel price winner. You will all get to read the same news everybody does. This is a bad approach and I think here is where the problem appears. We all are different! The information presented to us must be personalized, otherwise it may be totally irrelevant and may affect our personality by pushing it out of its balance. This stuff is serious! Irrelevant information may affect our lives quite seriously. How? Keep reading.

Unique personalities

You see, every single one of us has a unique personality, different needs, desires, expectations, etc. What is interesting to one does not necessarily has to be interesting to the other. Of course, there are some behaviors which are more or less common to all of us. As an example, we all share the desire of staying up to date with the stuff that happens on our planet. The problem is that we are not able to consume all the information that is available to us. It is simply too much data out there and we are only able to process a small fraction of it. Since we consume the data through the process of reading, listening or through the vision, if we concentrate on unimportant data, we loose the time to get familiar with the important one. Therefore we would really appreciate if the information would be filtered according to our criteria an then presented to us so that we don't waste the time to do it ourselves.

Staying in balance with yourself

I stated before that irrelevant information may affect our lives quite seriously. Here's why I think so.

Lets imagine a simple guy who works all day long for some big company which pays him junk money for his hard job. When he comes back home and reads the news (the unfiltered, bad and dummy information) he probably feels happy! Yes, happy!!! Happy that he has a job, that he is alive, that he has a wife and kids and that they are alive and healthy. The news he just read force his brain to think about stuff he would never think otherwise. Mentally he needs to keep the "good" and the "bad" stuff in his life in balance, otherwise he would go crazy. Bad news he just read magnify the value of the stuff in his life that was not so bad to the levels where it can be accepted as good. The guy is happy with his bullshit salary, crappy job position, wife and kids he does not actually know that well. He's happy because he thinks, hey, there are people on this planet who don't even have what I do! That's something to be proud of. What I have is enough and makes me happy. His brain will stay in this balance until it receives the next portion of the some sort of data (e.g. a portion of "positive" news).

Crazy, but I can imagine that this is the main reason why people actually like to read this kind of stuff. The message "your life does not suck that much" seems to be very attractive to many of us. It is easier to balance yourself in the negative direction (that is to "make to bad look good"). The other case may require some extra effort (that is to actually "have the good"). People are lazy, we don't like extra effort.



Hmmm, and what would the guy think if he didn't read the news at all (I mean totally at all)? Yeah.. in many cases (not all of course) by seeing most of his colleges or neighbors having better live then he does he would think "Shit! Something is wrong here, I suck, those guys live better then I do, what can I do to become like they are.. to improve the quality of my life? They did it so I know I also can do it!". It would seem negative to the guy but in a sense it would also motivate him to do more (which on the other hand is extremely positive). As I said, the first feeling is negative because having to balance in the positive direction requires some extra work (like e.g. to learn smth, look for a new job, talk to the boss, etc.).

NOTE: The theoretical way of thinking in the above paragraph applies to members of non-communistic or post-communistic counties only. In such countries a guy would probably think more something like this: "What can I do to make the life of my neighbors suck as much as my life does". In this situation, the guy does not want to improve his qualities to reach his psychological balance ("have the good") but rather causes his neighbors (which were the actual cause of putting him in psychological imbalance) to degrade to his level. This also puts the guy in the desired, balanced position. The side effect is that the neighbors are then out of the balance (no longer "have the good"), but who cares anyway :-).

This was a very theoretical example of a single person being affected by the news. The problem with the "your life could suck more" message is that it affects all of the important people who surround us like a virus. Family members who could actually be good at motivating us to do more, do exactly the opposite, they believe in "the message" and force you to do the same. They don't believe in you, which makes you do the same too. Very negative stuff.

This is why I think that news have to be personalized. They may cause a lot of harm to people who do not filter them by themselves. A potentially smart and creative people can be wasted by the inappropriate information presented to them in the news. The solution to the "family virus" problem may be much harder to find.

My feelings about the news

Coming back to the news subject. When I see such a negative news, they generate only bad feelings in me! Only bad!! Why? I don't like the "your life does not suck so much" message at all because I differ extremely from the "common" consumer image. Most of you probably also do. This kind of news suck to all highly motivated people.
I would rather see the news saying "The cooperated work of Politician X and politician Y lead to improvement of the ... bla bla bla", "The genius student of our [some university name] invented a .... " or "Our local companies gain respect on the international market ...". Of course our world is not perfect. There is some bad stuff we need to be informed about (wars, serious accidents, ecological catastrophes, etc.) but I would be happy to see it mixed with some positive news simply to keep them in a healthy balance. I am creative guy and want to stay that way.

To all unhappy news consumers

To all of you who feel like they want to puke when they see the news. I guess, you're bettor of not reading the news at all. Instead try to talk to your friends, buy yourself magazines containing information that is really interesting to you. Also, throw your TV and Radio out of the window and see what happens in your live after the first month without it. You may be surprised.

To the media. How to make the news personalized?

Well, the idea is simple. Make your web app learn about the person clicking news links. Get to know this person's personality. In a simple scenario, simply mark your news as "positive" or "negative" ("optimistic" or "pessimistic") and count the clicks (yes, just like Google does). If the guy is more interested in positive news, show him more of the positive ones. If he likes to read about political affairs, mark that and show him more news about it. People will decide which news help them stay in their psychological balance and you will filter the news appropriately for them. It's that simple! Do it!

Monday, February 8, 2010

Better email validation with Tapestry

Recently I implemented a small form for creating user accounts with Tapestry. I used all the standard Validators available hoping that they will successfully pass the manual tests. Well, some of them did :-) except from one: The 'Email' Validator.

If you look at the sources of Tapestry (5.1.0.5) email validator, you may spot the problem.

//...
private static final String ATOM = "[^\\x00-\\x1F^\\(^\\)^\\<^\\>^\\@^\\,^\\;^\\:^\\\\^\\\"^\\.^\\[^\\]^\\s]";

private static final String DOMAIN = "(" + ATOM + "+(\\." + ATOM + "+)*";

private static final String IP_DOMAIN = "\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\]";

private static final Pattern PATTERN = Pattern
.compile("^" + ATOM + "+(\\." + ATOM + "+)*@" + DOMAIN + "|" + IP_DOMAIN + ")$", Pattern.CASE_INSENSITIVE);

//...

public void validate(Field field, Void constraintValue, MessageFormatter formatter, String value)
throws ValidationException
{
if (!PATTERN.matcher(value).matches()) throw new ValidationException(buildMessage(formatter, field));
}
//...


Can you see it?

What about the user "dajdajda" having account at "dhadadhahjad.edhadja.dads"? What about a Polish guy trying "adaś@ćma.pl" or German one checking out "thomas.müller@öäüß.de"? Are these really valid email addresses? Do you want to accept them? I would rather reject them right at the beginning.

To me full SMTP validation is a little overkill (because of performance, complexity and multiple additional problems that make your life complicated). However a hybrid of regex checks and DNS validation seems to be the acceptable solution.

I have created my custom Email Validator based on the simple DNS check code samples from http://www.rgagnon.com/javadetails/java-0452.html.
Also, for regex validation I used the org.apache.commons.validator.EmailValidator which in my opinion offers a better regex pattern than one defined in Tapestry 5.1.0.5 (see code above).

If you agree with me, then please feel free to use my code shown below (free of charge ;-)). You can create your DNSEmailValidator in any package you want, then contribute it in you AppModule.java and simply use it within your @Validate or <t:.. validate="dnsEmail"/> statements.


//...

import java.util.Hashtable;

import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;

import org.apache.commons.validator.EmailValidator;
import org.apache.tapestry5.Field;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ValidationException;
import org.apache.tapestry5.ioc.MessageFormatter;
import org.apache.tapestry5.services.FormSupport;
import org.apache.tapestry5.validator.AbstractValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DNSEmailValidator extends AbstractValidator<Void, String> {
private final static Logger _logger = LoggerFactory
.getLogger(DNSEmailValidator.class);

public DNSEmailValidator() {
super(null, String.class, "invalid-email");
}

public void validate(Field field, Void constraintValue,
MessageFormatter formatter, String value)
throws ValidationException {

// validate the syntax
final EmailValidator validator = EmailValidator.getInstance();
if (!validator.isValid(value))
throw new ValidationException(buildMessage(formatter, field));

// validate the DNS
final String[] tokens = value.split("@");
try {
int servers = doLookup(tokens[1]);
_logger.info(tokens[1] + " has " + servers + " mail servers.");
} catch (NamingException e) {
throw new ValidationException(buildMessage(formatter, field));
}
}

private String buildMessage(MessageFormatter formatter, Field field) {
return formatter.format(field.getLabel());
}

public void render(Field field, Void constraintValue,
MessageFormatter formatter, MarkupWriter writer,
FormSupport formSupport) {
formSupport.addValidation(field, "dnsEmail", buildMessage(formatter,
field), null);
}

static int doLookup(String hostName) throws NamingException {
Hashtable<String, String> env = new Hashtable<String, String>();
env.put("java.naming.factory.initial",
"com.sun.jndi.dns.DnsContextFactory");
DirContext ictx = new InitialDirContext(env);
Attributes attrs = ictx.getAttributes(hostName, new String[] { "MX" });
Attribute attr = attrs.get("MX");
if (attr == null)
return (0);
return (attr.size());
}
}


Contribution code:


//...
public static void contributeFieldValidatorSource(
MappedConfiguration<String, Validator<Void, String>>> configuration) {
configuration.add("dnsEmail", new DNSEmailValidator());
}
//...


Of course, this DNSMailValidator does not make sure that the mail account really exists. It proves that there are mail servers available at the given domain name. Checking the existence of mail account may take a little longer and sometimes fail (e.g. when greylisting is enabled). The cool thing is that Tapestry allows you to create any Validator you want, so you may implement both and use the one that satisfies current requirements of your project.

Wednesday, February 3, 2010

After interview

Yesterday I had a job interview for a Software Engineering (at least I thought so) position at one of the departments of my current company.

I am an interview newbie (who did like 5-6 of them in his life) but I think that's enough to notice the difference between a good and poorly prepared one.

Well, since the company I work for was never (and probably will never be) particularly good at interviewing software engineers, I kind of expected only pointless and stupid questions to be asked.

The fact that I usually like to read a lot on "what's the difference between a good and bad software professional", "how to filter people when you recruit them", etc. only made it only worse.

I think that the guy asking the questions didn't really know what he would like to hear and know about me. How would you answer a question going something like this:
"How much time do you think you would need to get up to speed with our project?". Well, it sounds like an important question, doesn't it? ... no doubts about it... but how the hell am I supposed to answer it if I know very little about the project, it's size, the code and documentation quality, the people (e.g. if they are helpful or not). I couldn't say that loud but I got really pissed off and thought ("This is the question you should ask yourself after getting to know me a little bit better!! That's why I am on the f.... interview, isn't it?"). Some people would probably give him an answer "As fast as it's possible", and I bet that this would satisfy that guy (who I bet loves "standard answers"). The problem is that I am a creative engineer and do not like routine too much. When interviewed I like to THINK.

I usually have nothing against dummy questions like "Describe Visitor Pattern" or "What's the difference between heap and stack?". They prove that I read books from time to time, or that I happened to work on a project where people actually used design patterns. On the other hand I do not favor this kind of "checks" because they do not prove if I am a "THINKING PERSON". I may be an idiot who knows patterns by heart but has no idea how to solve complex problems with or without them. Software Engineering is more like art. There is many ways to build software, nice and less elegant ones (but still correct). We can not say that the "Gang of four" defined the best ever solutions to design and implement applications. Patterns help to solve common problems and establish communication layer between developers who know what they are. However, they do not always solve our custom problems in the best possible way (there is no such thing like "the best way" anyway). That's why I would test people not on their knowledge but rather their ability of CREATIVE THINKING.

We will see if I get the job :-) The project is very interesting but one of the interviewers did a really good job in demotivating me.

At the end he also said something about my experience. That he does not like the fact that I did Java development for almost all my professional career (he would be really happy if it was C++ instead). I mean... honestly, he could hold it for himself because I personally, do not regret this fact AT ALL!! Language is just a tool, and as long as people do not get that it is JUST A TOOL, they will not be able to hire the real passionate software developers.

I think I suck, but my interviewer sucks much, much more! (and get's paid much, much better).

The guy did one good thing though. He motivated me to spend even more time on my own project. I can't wait to finally launch it. It would better be a success!

Tuesday, February 2, 2010

Want to learn C++ for free?

I found a very nice and free C++ tutorial (which kind of looks like a huge electronic book to me).

I find the section 7.9 — The stack and the heap particularly well written. The author uses simple analogies (e.g. the plate and the mailbox analogy) to explain how the stack and heap works. I always liked this kind of approach when learning new stuff. Unfortunately not many book authors use them in their works. Too bad!

1:0 for the free electronic book.

Monday, February 1, 2010

Can call myself a C++ programmer now!

Yeah, I've finally finished the "C++ from the ground up" book today (including the last appendix).

The author himself calls everyone who managed to go through all the chapters of the book a C++ programmer. I guess he is right. I totally feel like I am able to not only understand but also code some pretty advanced apps in this language. Of course, advanced does not mean perfect and bug free in this case. Every newbie has to start with some shitty code to become a master. The important point is to write the junk code at home and not contribute it to latest version of the application produced together with your colleges at work.

The book is really awesome and I highly recommend it to everyone willing to learn Standard C++.

The dark side of the book was that it did not cover some of the subjects commonly seen in the professionally written C++ applications. The author suggests his other book (isn't it funny? "... to know more about XXX refer to MY other book ...") to learn about e.g. "function objects" or some advanced STL data types and algorithms. Also, the author does not give any hints about how the C++ app should be structured (the ".h" files, dir structure of a project, dll's (or so's), etc.) which I think is a pity. I would expect at least a small, mini chapter covering this topic. I guess the book is good if you are willing to learn a new language (and only the language), but not the way to use it efficiently when building a large application.

Well, I am happy that I've read this book and will probably come back to it from time to time to refresh my knowledge on some certain language specific subjects.

Hmm... and maybe I will buy Herbert's second book "C++ The Complete Reference" to make sure I did not miss anything important. The templates, I definitely need to refresh my knowledge on templates right now! :-)

Wednesday, January 27, 2010

Coming back to the book

Well, I've had a small break from reading my C++ book. I was kind of "blocked" by some other tasks which required my attention.

Now I am back again and just finished reading about C++ I/0. It is nothing new, not very exciting either. The fact of adding some classes to C++ in order to make the standard C I/O methods "look better" was a good idea though. After few minutes of "playing" with the samples I was quite familiar with all the basics (and most useful) functionalities. The standard C I/O is not too bad as well but I will stick to the new OO implementation as I can already see how easy it is to write reusable components using the Standard C++ streams.

Next week I will continue with Run-Time Type ID and the Casting Operators. Now, it's time to go to Austria to snowboard a little ;-)

Wednesday, January 20, 2010

Half way through

Today I've reached page 300 of the great "C++ from the ground up" book. What can I say? Maybe "Java makes programmer's life easy, C++ does not!" would be a good summary sentence.

The concept of passing objects as parameters, returning or initializing them is much, much simpler in Java. Everything is passed by reference. C++, gives more flexibility on this subject, but it all comes with an enormous price - complex and bug-prone code! It feels like an overkill to implement a custom copy constructor everywhere the memory is dynamically allocated for the class members. It is however necessary, otherwise a serious errors may (and probably will) occur. Errors which are both, hard to find and not obvious for the beginners.

So what happens if you work in a team? Some guys are good, the other just regular. There is only one thing that come to my mind - buggy and ugly code full of memory leaks made by incompetent developers. Oh.. there is a second thing that comes to my mind now. Outsourcing your C++ project to India or somewhere else may be a really bad decision.

Also, all this makes me think that people at the university should not start with C++ as their primary language. It's far too complex. To be able to build a bug free apps with it is nearly impossible. How can you become a programmer if you never build a good and working app? Even a teacher may have problems with detecting those little bugs which may not scream "here I am" during every execution of the program.

Moreover, an average, professional programmer is typically a lazy, not-really-responsible human being. (Since a human is not a machine and may make mistakes, she will probably do that.) No, no, C++ is not a toy, it is a heavy weapon for which reading the manual is simply a must... which is actually good for me :-) I have some time to do that now. (Which probably won't stop me from writing a shitty, bug code in the future... just like all the other do.)

Oh my.

Tuesday, January 19, 2010

C++ is getting to be interesting (like never before)

The more I read my new C++ book, the more I understand how does expierience with Java (and probably the other languages like PHP or Perl) help me to simply "suck the knowlege" out of it. It is really amazing how much these languages have in common. It is also interesitng how professional expierience affects the way new knowlege gets absorbed. Now, when it's completely clear to me how a "typical" (not to overexaggerate), large scale application is build, it is far much easier for me to "detect" those "big" things about the tools (like C++) I use. I can see the value of both Java and C++ better. Also, I can now imagine (from the architectural point of view), how both of the languages can be mixed together in one project in order to achive maximum performance (e.g. web applications processing large ammounts of data).

It totaly amazed me that learning a new language (syntax... completely) may be the metter of only two/three weeks. I remember it beeing so painful at the university.

Today I got to the part with bitwise operations (not really needed when programming in Java or PHP) and I finally completely understood them (in terms of, why and when to use them, why do people need them, etc.). Cool stuff, I used the bitwise operators before... but I always underestimated their real power and tried to avoid them for the sake of code complexity. The same with extern, volatile and static variables. For some reason it was never well explained to me (at the university). Hmmm.. why, when and what for should I use them. Now I get it :-)

Tommorow I will start with the "Object-oriented programming" part of the book. I expect to see even more cool stuff.

Friday, January 15, 2010

The book is good

As I mentioned in my previous post, I started to read and now decided to review the "C++ from the groud up" book written by Herbert Schildt.

After reading the first 127 pages (and taking a quick look at the next 100) I must say that it is really well written. The author makes sure to present as many examples as possible to make the theory clear. The book is also rich in "professional programmer's adivces". There is not many, but the most important ones (very much simplifying them) go like e.g. "global variables are bad, try not to use them because your code will be messy and piss of your fellow programmers" or "know where your pointers are pointing all the time!" (which is kind of funny, but true). This is actually something that I would expect from such a book and the author did a good job delivering a C++ programming guide for all (beginners and professionals). The book kind of feels like Kathy Sierra's "SCJP 6 Certification" book. It is full of detailed information on most important aspects of the programming language, well organized and presented. (I guess no one can present the contents as good as Kathy, but Herbert did a good job too.) The book is not boring and also makes me feel like "I want to know more.. come on, give it to me!". I kind of like this feeling, so if my eyes did't say "Adam, enough for today", I wouldn't stop reading it.

Nice. So.. how many pages will I read tomorrow? I guess none :-) It's weekend!

Thursday, January 14, 2010

New Year - Old language

Since the software world would look much better if every professional programmer would read at least one book per year, I decided to start as quick as possible with upgrading myself. My pick for January is "C++ from the ground up" by Herbert Schildt (why this book... honestly, because my girlfriend already bought it. It seems to be well written.).



Why C++? I was always a Java guy! I even got certified! Well, the answer is easy.. I have to! .. and I kind of like the fact that I have to as well :-)

There is a slight chance for me to get a new, interesting job but C++ is a requirement.

The old, powerful, mother-of-all language came back to me like a boomerang I was always trying to get rid of. Re-learning C++ after so many years of experience with Java seems to be fun right now. (I am talking about Standard C++ without any MFC or self-made bullshit.) Well, some thing are finally clear to me. I understand the power of this language much better then before. I also see where it fails by giving developers too much freedom.

Hopefully, the fact that I always tried to program "into the language" instead of "in the language" will allow me to faster be able to work fluently with C++. What I am mostly afraid of is the fact that (if ever) I will probably be put into old, crappy, poorly designed and programmed project where I will have nor time neither freedom to make a change.

Anyway, C++ is the new skill that I want to put in my brand new 2010 profile.