Win a copy of Rust Web Development this week in the Other Languages forum!

Esteban Herrera

author
+ Follow
since Dec 25, 2004
Esteban likes ...
Eclipse IDE Spring Java
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
24
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Esteban Herrera

Hello everyone,

After ten months of hard work (well six, I put the project aside for four months) I finally finished my OCP Java 8 study guide.

I decided to make it available so anyone can read it online at:

http://ocpj8.javastudyguide.com.

(Of course, if you want to support me, you can get it in paperback/Kindle format on Amazon or as an e-book in other stores)

Why?

Being a self-published author, I don't have many resources. I don't consider myself a good writer and I know that for many people, language can be a barrier.

So it occurred to me that if I open sourced the book, I could reach more people and maybe some of them would help to improve it or translate it in their own language so everyone can benefit.

The book's website is on Github:

https://github.com/eh3rrera/ocpj8-book

I hope you find it useful.
Of course I can tell you're passionate about coding with kids!

I totally agree, fun is the keyword.

You're such a great inspiration for all of us as parents, please keep releasing more stuff for kids. In the meantime, we'll be waiting for your Udemy course.

Best wishes!
Esteban
6 years ago
Hi Ganesh,

Sorry, I can't think of any way to get the child information directly, but if it's slow, maybe you can get the information when the application starts or cache it somewhere, depending how often it changes or how you use it.

Thanks for sharing the MySQL info.
Hi Bryson,

Congratulations on your book!

My oldest son is about to turn five and I want to start teaching him the basics of programming. But I'm curious to know how did you write this book. I mean, do your kids participated in some way? Have they gone through all the examples? What do they think about the book?

I saw your answers in other threads and in one you said your kids were always coming up with ways to make programs better so you started capturing their ideas to write the book. Could you tell us more about it?

Thank you.
6 years ago
Hi Claude,

This presentation by Arun Gupta seems very practical to me: Refactor your Java EE application using Microservices and Containers

I think it can be a good starting point.
6 years ago
The first file of the directory is processed and the rest is skipped. But see this for yourself. Execute the program above and play with it
Hi Ganesh,

DatabaseMetaData is one of the JDBC interfaces that must be implemented by the drivers, so this must be a driver problem. Try using the latest version. If there's still a problem, maybe you could share some code or the version you're using so we can help you more.

In theory, drivers must support the methods of this interface (like the ones you mention), but this is not always true in practice (or only in certain cases or with some special parameters). It's better if you try your program in each database to make sure it's working properly.
Hi Jhon,

If your column type is DATE, why are you using to_date? This function converts a string to a date.

Why don't you try getting my_date just with:

And then use the to_char function like this:


About your second question, I think it's the same problem. bigger_date and minor_date are dates, you don't need to use the to_date function in the if condition, compare them directly:

Hi Freiza,

If you use a reference to an object and you don't create a new object using that reference inside the lambda expression, you can do what you want.

You can even use an array if you don't want to create a class just for that, for example:
6 years ago
Hi Ertan,

I have the feeling your confusion is caused by a typo.

According to the image you posted, you wrote

It should be
6 years ago
Exactly Ahsan, that's the concept.

And you're right, this is a bad implementation.

Always check first if there's something in the API that you can use before using a custom solution. For example, a Deque can be used as a LIFO (Last-In-First-Out) stack.
6 years ago
Hi Ahsan. The reason is simple. When you call pop(), the last element is not removed from the stackValue list, only the pointer (stackPointer) to the index representing the current position of the list is updated.

If you add 1,000 objects to the list, the value of stackPointer will be 1,000. If you then call pop() 1,000 times, the value of stackPointer will be 0, but you'll still have the 1,000 objects in the list (in memory).
6 years ago
Yes Thomas, try this program (just change SKIP_SIBLINGS in each method each time you run it):



And:


In c:\temp (or any other directory you want) create a file structure like this for example:


And see the outcome.

From the java tutorials:
preVisitDirectory – Invoked before a directory's entries are visited.
postVisitDirectory – Invoked after all the entries in a directory are visited. If any errors are encountered, the specific exception is passed to the method.
visitFile – Invoked on the file being visited.
visitFileFailed – Invoked when the file cannot be accessed.

And:
SKIP_SIBLINGS – When preVisitDirectory returns this value, the specified directory is not visited, postVisitDirectory is not invoked, and no further unvisited siblings are visited. If returned from the postVisitDirectory method, no further siblings are visited. Essentially, nothing further happens in the specified directory.

Hope it helps.
I think this is what you're after:



In the case Paul mentions, the result would be either 4 or 5. It makes sense to my because I consider between inclusive. Hope it helps.
6 years ago
Your option number one (or a variation of this) seems to me the best one. These are my thoughts:

- I assume you have a Team class and a Player class (and maybe a Statistic class).
- I also assume that Team has a collection of Players and this class has a collection of Statistics.
- Design is not always white or black; it depends on the circumstances, but always prefer simple solutions (KISS principle). Is the abstract factory really justified? We shouldn't implement design patterns just for the sake of them. Is really worth to implement so many classes? Is the system going to implement more behaviors like these in the future?
- I don't think so. The modifications seem too simple that seems better to implement them with a method. I think you should use factory/strategy or whatever pattern only if you need flexibility for future changes.
- Behavior should be placed where it belongs:
1) Modify the description of the team. What class has the data of a team? This sound like a method of Team.
2) Modify the batting order of the team. What class has this information? Again, this sound like a method of Team.
3) Modify one player on the team. What class has this information? Again, this sound like a method of Team.
4) Modify one statistic for all of the players on the team. This seems a little more complex. What class has the statistic information? Sounds like Player has this info. So maybe Player should have one method to modify the statistics and another to get the players that belongs to a team (you can place this method on the Team class also, it depends how you want to access this information).
- If you want, you can use a Facade (like the TeamModifier class of your second option, but calling methods on the Team class) to protect your client code from changes of this new functionality.

Anyway, these are just my thoughts. As Tushar said, you should read about design principles and take into account your priorities (what do you want? Easy to understand, flexibility for change, easy of testing, etc.) to decide on one approach.
6 years ago