Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!

Marcus Biel

Ranch Hand
+ Follow
since Jun 11, 2015
Marcus likes ...
Mac OS X IntelliJ IDE Windows
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Marcus Biel

Ok, sorry for the issues with the download... generally speaking it works -
over 6000 downloads so far! But for a few people it's not working -
I am using a profesional email service in the background, and it does some email validation in the background,
possible that it rejects some emails. We are still investigating the issue.
Long story short, please send me your email adress as a DM  on twitter:
or over my website:

and I will fix it for you...


2 years ago
Hooray! My book "Java for passionate developers" has finally been released!
Get it for free within the next few days:
2 years ago

Liutauras Vilda wrote:
What is missing in that video, that tests don't play any role in the refactoring process. You might wrote them and demonstrated how much confidence they add to refactoring?

Yes, I am planning to show/use tests... but, that is not really helping me at this point. First, I need a basis to start the refactoring from. I still think Sudoku could be a good use case - but
maybe the given C# code is too far away from Java, to hard to port. So now I am thinking about developing my own nasty procedural version of Sudoku.

2 years ago
I think you misunderstood me. Such a long method indeed is a nightmare - but it is perfect to demonstrate how to refactor it into nicely readable, object oriented code.
2 years ago

There is a video of a guy refactoring a complex c# method  (The game Sudoku).
(The Serbian video has English subtitles, so turn captions on)

And here is the code:

I want to do something similar in Java, so I aim to port this code to Java,
and trying to keep it as close to the original as possible - the good thing here is
that it consists of one method and one class only, so you can go from top to bottom through the code,
without having to click back and forth, which makes it a good fit for a live refactoring, I think.

I have ported most of the code, just the tough Linq bits are missing.
Lines 300-360 and 494-677  are specifically hard to port to Java.
Any help is greatly appreciated
2 years ago
OCA/OCP Java SE 7, Programmer I&II Study Guide

Page 595:

Map Interface:
Like Sets, Maps rely on the equals method to determine whether two keys are the same or different.

I am just looking into the source code of TreeMap. It uses the compareTo method to determine if two keys are equal or not.
The java.lang.Comparable interface states:
* <p>It is strongly recommended, but <i>not</i> strictly required that
* <tt>(x.compareTo(y)==0) == (x.equals(y))</tt>.

So the way I understand it, generally saying:
Maps rely on the equals method to determine whether two keys are the same or different.

is wrong.

What do you think?
I also once fought with tucket url rewriter, so I know how time consuming it can be to set up these rules.
Actually rewriting urls is VERY simple, so I have an alternative route for you to go without tuckey:

1. For the request mapping, write a javax.servlet.Filter that rewrites the incoming request to the real request
2. Declare your filter in web.xml
3. For the response mapping from the real response to the rewritten response,
extend the class javax.servlet.http.HttpServletResponseWrapper;

6 years ago
I would simply debug through the code.
The source could should be available and can be manually or automatically (e.g. Maven) attached to your project or your IDE might be able to decompile the source code.
6 years ago
Spring in Action
6 years ago
You are either in the wrong forum or the wrong IDE. This is a Java Forum and Visual studio is a .Net IDE.
Your classes are both in the same package. importing p1.*; does not compile.
Remove the import and it will work.

p.s.: protected is a complex beast. Try to avoid it. Try to avoid inheritance alltogether.
6 years ago
If the book is to though, you are to weak, sorry.

Start reading Head First Java then.

The exam is tough, the book condensed to the maximum. Make notes, read it several times.

Also, just thinking about it, my Free Java Beginner Video Course is based on all my knowledge I gained from Kathy's books and the certificate.
Whenever possible I go deep down into details which are also important for the certification. Might be helpful for you, too.
6 years ago

According to the website

I don't know which website you are talking about. I assume you are talking about the Oracle website, in this case, probably yes.
Additionally, you write "I have all the material". Well that might sound stupid, but more often then not people think possessing something is actually doing the trick - including me and myself ;-).
Really, be honest to yourself. Read Kathy's book, read every line of it. I once read the advice that you would be ready if you had a book full of colored highlighting that would fall apart you would be ready.
I did that. I was there. I even bought a new version (updated from Java 5 to 6) and that one in the end was just as colored and falling apart.
I did all mock exams I could get my hands on, and all simulators. I passed all of them above 90% or so as far as I can remember.
I have actually even now recently bought version 7 of the now called OCA/OCP book you probably have, I didn't yet have the time to read it, however mainly I just wanted to own it.
I love Kathy's books. And you can trust her. Everything that is in the book you will need. Everything that is not in the book, you will not need.
At the time in 2008 when I did my SCJP, I didn't even waste any time looking on any Oracle pages. Trust Kathy. That's all you need!

Was that clear enough?

p.s.: Yes, I am in love with her books
6 years ago
You spoke of a text file, not of System.out.println (which, generally speaking, you should avoid anyway).
How do you write to the file - this part you did not show us.
I would asume you have some kind of a FileWriter, and that should have a constructor or method to tell it the encoding you want.