Marcus Biel

Ranch Hand
+ Follow
since Jun 11, 2015
Marcus likes ...
IntelliJ IDE Mac OS X Windows
Munich, Germany
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

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.

5 days 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.
5 days 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
5 days 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;

3 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.
3 years ago
Spring in Action
3 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.
3 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.
3 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
3 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.
I am really not sure if I understand you correctly, you have a rather short description, and a rather lengthy code snippet.
However I have the feeling you fundamentally have not understood how Java works.
In short, String is an object, but it is also an immutable. Whenever you change a String, a new String Object will be created - you cannot change a String in one class
and expect that this will have the side effect of changing another String in another class (FORTUNATELY!!!)
What you need to do is create a String, and when you need this String in another class, you will have to create a method that returns this String to the other method.
If you have complex String concatenations going on like I can see in your case, have a look at the Java class "StringBuilder, which might do that more performant
and / or in a better readable way.

I have lately done two Java video tutorials which also talk about immutable Strings and StringBuilder:

Episode 19 - Object clone method -
Minute 30-35 - What is an Immutable / what does it mean for String to be immutable?
Object Clone Method

Episode 20 - Object toString method -
Minute 32-37 explaining class StringBuilder
Object toString method

3 years ago
To me your problem does not seem related to IntelliJ.

I think what you rather need is to use a build management tool like Maven or Gradle.