An Introduction to Threads
I have found some really useful links for the SCJP Java 5 exam. This article is well written and covers quite a few of the tricky areas of the Java 5 SCJP Exam. Even if you aren’t studying for the exam these article’s might still be of interest to you because they cover topics like Autoboxing, serialization, printf and regular expressions.
This link has information on the Wrapper classes added in Java 5 and the very useful Autoboxing and unboxing now make them a lot easier to use with literal variables (int, double, char etc)
Concentrates on the Java.io packages and reading files and using the BufferedWriters and readers. This is can be quite a tricky area in the exam because you need to know what order you use the classes.
This is all about serialization. I found this very useful because I don’t use serialization in my daily programming life, so it was a completely new subject and the more information I could read about it the better.
Is about using the Java.text package and formatting number, dates and Strings. Learning how to use the locale class so it transforms the data into the correct locale.
One of the nightmare areas for the exam, the fearsome Regular Expressions section. It also talks about the C style printf, which allows you to format you System.outs.
I have recently been thinking of my code as a public API and being careful what I show to other classes using my classes. Viewing classes in this light also help to reduce coupling with other classes. The big benefit this has also is it hides the implementation of a classes methods from the users of the class.
The real benefit of this is that you can then change how the methods do what ever they are doing with the user worrying or knowing (assuming it still works the same way)This is where Interfaces come into play, where methods hide the implementation of one method, an interface can be used to hide numerous classes implementing that method.
The deadline for a customer project was brought forward by about a week and I had to write an initial version of the code in 2/3 days. They said hard code everything and just get it done. Knowing that I would have to write it properly a few days after I decided to hide the implementation of the hard coded values behind an interface. Basically there are a number of values that I have hard coded but I think the user would like to have the ability to change them in the next release.
So I created an interface called LLPGSearch and have initially then created a new version of the HardCodedClientValues class and then the rest of the code works using the values it gets from the interface. So now when I have some more time and improve the code, instead of using the HardCodedValues class I will collect the values from some property or xml files but fit them into a class which implements the LLPGSearch Interface which should hopefully mean the rest of the code will work not knowing that I have changed what's behind the interface. Basically showing that by hiding the implementation using an interface I have separated the things that change from the things that stay the same.I liked this code because firstly it seemed funny to me and other developers to see someone write a class called "HardCodedClientValues" and I don't think they understood what I was doing. It was also interesting for me because it was hiding the implementation but I wasn't thinking about that by name but realised that I had done that when I read this good explanation of Hiding the implementation from Thinking in Java 3rd
1. You release with known bugs because you care about quality so deeply that you know how to decide which bugs are acceptable and which ones are not.
2. You release with known bugs because it is better to ship a product with a quality level that is known than to ship a product which is full of surprises waiting to happen.
3. You release with bugs because the alternative is to fix them and risk introducing more bugs which are worse than the ones you have now.
When this bug happens, how bad is the impact?
How often does this bug happen?
How much effort would be required to fix this bug?
What is the risk of fixing this bug?
This is probably one of the easier topics on the Java 5 exam because if you are programming in Java then you will have had to use the flow control (IF and SWITCH statements etc).
The code also deals with the enum. This can be an exam nightmare because of all the extra things you can do with enums and the fact that it acts like a special class in many ways. It has the potential to provide some very tricky Java 5 exam questions so any information on this topic is welcome to me.
The Enum is also allowed in switch statements, this can be an exam gotcha because you might think that this isnÂt allowed and they are trying to catch you out, in fact they are using the double bluff.
Enums are one of the new features added in Java 5 that are both simple and complex at the same time. As soon as you see them you think cool, this is going to be really useful and then you see the examples or Exam questions on Enums and you think, oh my god look at all the possible syntax errors I could run into. Unlike some of the other features added into Java 5 Enums was done excellently and doesnÂt seem as much of a hack as the other features.
The tutorial also explains the new enhanced for loop which is a piece of cake but you have to make sure you understand what is on each side of the enhanced for loop.
Anyway here are the links, enjoy
another day, another bug put in the system which has halted what ever development I was doing. This is a classic case of putting a fix into solve one problem and in it's place is one if not more bugs.
This is a slightly interesting bug. Basically we have a Utils Static/helper class and it has a removeFraction function. The function itself is pretty dodgy but basically you pass a String into the function but you know the String is really a number but as a String. This isn't to bad because a lot of variables are passed around as String or a good example is that the main method in Java accepts an array of String but the variables could be anything waiting for you to convert them.
The function then finds the index of the "." fullstop and then takes what's on the left (no rounding here). Although it's a tad dodgy it's not to bad .......Except when you pass a null into it. Now it is difficult sometimes to know what to do if some code tries to pass a null into your method, a lot of the time you could just say, well if you are stupid enough to pass me a null I am going to throw an exception and this is fair play at least you are warning code that calls your function what you might do. I thought of catching the null and passing it back as null but then this is not a good thing to do and more than likely you are just passing the bug on, unless the class you are passing back to has better exception handling.
I was disappointed that this problem had occurred because for this class I had created a unit test, so the developer added this method he could have easily added in a test. A good reason why you should add unit tests (along with all the others) is that when you are testing a function/method when you think about how you should test the function you often think about what should happen if some fool passes in a null but often when you don't write a unit test you never think that anyone would pass in a null, why would they do that.
I have read in effective Java and by a presentation on API both by Joshua Bloch that you should validate the values passed into a method and I think this is a prime example. By validating and dealing with wrong values and nulls inside the method it means that you will only have to have this code in once instead of all the code calling the method having to validate it.
In this example I have chosen to put a try and catch block around the code which tries to remove the fullstop, so if it is a null an error gets thrown and I have decided to return a zero which seems a fair trade a null for a zero. The one problem I did have was I wasn't quite sure where this badboy got called and the effect returning zeros might have. I have tested it and all seems to be working but you never can tell.
I thought I would write a blog entry to big up the Java black belt. I passed my yellow belt the other day and you can choose to send the congratulations email to other people, so I sent it to my fellow developers.
If you want to know what Java black belt is, well a proper description rather than just my blog entry, they have a presentation here
but to be honest I think you can pretty much guess what it’s about. You have a load of tests and the more your pass the higher belt you get. They have recently been expanding the things you can test yourself with, Ant, JDBC, Struts, Spring and loads more.
For people studying for the SCJP 5 exam there actually have some beta tests on the Java 5 features as well as an exam on OO and your basic Java features. Which all add up to some good exam practise. I don’t think the level of difficulty is not as high as the proper Java 5 exam, so maybe it’s a good place to start.
The site says it’s
“With JavaBlackBelt, we want to give each Java developer an alternate way to measure and demonstrate his/her technical skills.”
Personally I see it as an interesting way to test your knowledge and get one over your fellow developers by being a higher grade. I don’t really see the belt grade as much value, I won’t be putting it on my CV (well I am only a lowly yellow belt). The other frustrating thing is that you have to contribute to gain points so you can take the tests. I know this isn’t in the spirit of things but I just want to take the tests, I don’t want to mark and suggest improvements, I’m sure there are many people who don’t mind helping, this is probably mean spirited of me but bah humbug
I have noticed that recently they have been putting a lot more adverts on the site but they are tucked away and quite a few for Amazon which has me tempted to click on them and buy those lovely developer books in a Homer Simpson after a donut way.
Anyway go and check them out and start getting your Java belts.
Another reason it appeals to me is because I attend a Taekwondo class (when not hung over) at Aston science university (no I’m not a student) like all things martial arts watching and doing. I am currently a red belt, which means
“danger – to myself and others”
This also probably sums up my coding style :-)
- Simple Design.
- "A program built with XP should be the simplest program that meets the current requirements. There is not much building "for the future". Instead, the focus is on providing business value. Of course it is necessary to ensure that you have a good design, and in XP this is brought about through "refactoring", discussed below."
Everyone has probably come across the actions the quote describes by accident. There have been times when for some reason I have lost the code I was writing, I had spent a week writing the code but when I found that it was gone it only took me a day to rewrite it and do it differently and more efficiently than before. The reason is when you tackle a coding problem the solution comes into investigating the problem, write some code that works and some code that doesn't and then refactoring it to be more usually more simple. All the knowledge is in your head through all the work you have done trying to solve the problem and knowing what you need to do to solve the problem.
In programming, a lot of simplicity comes from knowing what matters and what doesn't matter. A lot of times a program is made complicated because it's attending to details that aren't needed, or could have been avoided, or could have been relegated to something else.
I got my first comment Spam yesterday, well I think it was comment spam. The spam had one line of random sentence and then a link to some searching type site. It embarrassingly took me a while to understand that this was spam because they were very cunning and hide the spam amongst a compliment. Initially I was thinking, yeah people are digging the site, they just couldn't read the blog entry and not say how good the site was, you know what I don't blame them.
so the first message was
"Anonymous said... Interesting website with a lot of resources and detailed explanations."
I was thinking well it was okay, I could do better, well no perhaps he has a point and then this anonymous reader had to write another comment praising my blog
"Anonymous said... Your site is on top of my favourites - Great work I like it."
okay calm down old boy, you embarrassing me now, I'm English we don't compliments very well. Then this comment popped up
"Anonymous said...Nice! Where you get this guestbook? I want the same script.. Awesome content. thankyou."
What guest book, I haven't got a guest book. Could my secret admirer meant to put this comment on another website, the two timer. I was at this point a bit confused but my spidey sense was starting to tingle. The Anonymous started to add the same comments to other blogs and then double comment certain blog entries. I then noticed there was a little blue link and then realized that there wasn't really someone out there with big love for my blog, he was just a user, I felt used and dirty, my Mother had of course warned me about people like this but I thought this Anonymous commenter was the one. Bah.
So I had to rustle around and turn on the word verification do dah, which will hopefully stop this sort this flatterer.
Worse followed when I went to sleep I had nightmares about evil commentators attacking my blog.
Top Web sites in April 2006: Yahoo!, Microsoft.com, MSN, Google by ZDNet's ZDNet Research -- In April 2006 Yahoo!, Microsoft.com, MSN and Google received over 90 mln unique visitors. Yahoo! was the only one to break the 100 mln unique visitors barrier, according to Nielsen//NetRatings data.Top Web sites in April 2006Web siteAudience, 000Time spentYahoo!105,4443:10:02Microsoft95,7770:45:25MSN92,7861:38:53Google92,1200:52:48AOL70,4336:11:06eBay53,4651:53:00MapQuest40,8010:10:53MySpace38,3592:06:46Real.com38,1830:47:48Amazon37,8540:19:37Source: Nielsen//NetRatingsITFacts also published Web traffic findings for top sites in March 2006, top sites in February [...]the actual figures on the site our
Top Web sites in April 2006
|Web site||Audience, 000||Time spent|
"Unsubscribe from as many things as possible"
I found this brilliant link to basically a sample chapter on the topic of Declarations, Initization and Scoping. There are six articles so it is a fairly comprehensive on the topic. If you are thinking about doing the SCJP 5 Java Exam then reading this is a really good way to understand what is involved studying for the exam. You suddenly realise how many things you let your IDE just do and how tough the exam is going to be. So if you want help taming the Tiger and get prepared for the Java exam CX-310-055 (Sun Certified Programmer for the Java 2 Platform, Standard Edition 5.0) this article will set you on your way
I found this cheat sheet really interesting, especially as I am fixing a bug in some code which smelling stronger than someone who has just came back from Glastonbury
"From what I understand, it's basically audio RSS. Whereas before you could happily subscribe to a feed and read it at your leisure, skip the boring parts, scroll down to the conclusion, or simply copy and paste the useful bits elsewhere, the format does work."This can be true and you do have to listen to most of the podcast. They are also quite a few rubbish podcasts out there but there are also lots of crap blogs.
I had a very frustrating day at work today. Someone had only checked in half his code so I couldn't compile. It is really annoying because I was in two minds do I try and fudge the code I have got out so that it compiles and work or wait for them to check the rest in. In the end I half fudged it but then the code wasn't working, was it something I had done or was there a problem put in by someone else. In the end I decided to keep cursing them every half hour, I have to admit it did help quite a lot.
I'm not really sure what the policy should be because I think it is good that you check code in, so if your computer melted you know that the code would safely tucked away in source control but I don't think you should check in half the code so anyone who gets out the latest code can't compile the damn thing. I felt it was a bit of a poor show, it just gave me an unnessary headache.
In fact I think this is probably the reason why people have nightly builds to stop this kind of thing happening and to catch any bugs that your "enhancements" or code might have put in, side effect styleee.
You also don't want to get so you become a code hoarder, I have discussed why code hoarding is bad before
To cap this off even now we have most of the code checked in, now other parts of it don't work and I'm stuck wading around in the code to find out what is going on. I had a completely un productive day just treading water and going no where. By around 3pm I was beaten and didn't have the stomach to fight the code any longer and had to work on something. I hope to go in tomorrow with renewed vigour and give the code a right thrashing until it gives in and starts working.
• Hardly any software is maintained for its whole life by the original author.
• Code conventions improve the readability of the software, allowing engineers to
understand new code more quickly and thoroughly.
• If you ship your source code as a product, you need to make sure it is as well packaged
and clean as any other product you create.
a more important point about all using the same curly bracket convention is that it means when I look at the code I won't have to go through it putting the brackets in the right place, whilst my fellow programmer is putting them all back the other way in an evil catch 22 situation.