Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Hauke Ingmar Schmidt

Rancher
+ Follow
since Nov 18, 2008
Cows and Likes
Cows
Total received
2
In last 30 days
0
Total given
0
Likes
Total received
44
Received in last 30 days
0
Total given
71
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Hauke Ingmar Schmidt

Sure, the Java tutorial can be found here: https://docs.oracle.com/javase/tutorial/

Most helpful for this would be "Learning the Java Language": https://docs.oracle.com/javase/tutorial/java/index.html

Formally everything is explained in the Java Language Specification: http://docs.oracle.com/javase/specs/jls/se8/html/index.html
4 years ago

Rob Spoor wrote:Since that compiles, you're not wrong

I knew that lambdas had precedence over casting, but never tried a lambda in a lambda. I am actually surprised that https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html still does not include the lambda operator, even after 18 months of Java 8.



JLS does ( http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.12 ) but omits instanceof which exists ... a little longer.
4 years ago
You need to understand the difference between an object and a reference.



defines a reference variable on the stack.

creates an A object on the heap.

assigns the object to the reference.

Every manipulation you do you do via the reference variable. The type of the reference variable defines the set of methods that you can use. You can't use B's or C's methods on an A.

Every manipulation you do is done to the object. An A is not an B or an C. You will never be able to use B's or C's methods on an A.

You can assign subclasses of a type to a variable of a supertype. You can assign B or C to a reference variable of type A.

You shouldn't set all those values externally but inside the constructor of the subclass.

Your code should look like:



If you absolutely must modify the object afterwards either think of a specifically typed variable:



or you can cast:



But a setup of an object outside the constructor is fishy in itself.
It is the -1 in Paul's answer. (Or you could iterate until j<arr.length; note the missing =).
6 years ago
You can stay with OO if it satisfies your needs.

When you export a slide from Impress (~ PPT) you can check "Selection" in the lower left of the file dialogue. If it is unchecked you export the whole slide which often results in white margins. If it is checked only the selected elements are exported (that you need to select, of course, easiest with CTRL-A). You enter the size of the exported image in pixels in the next dialogue. When you only export selected elements these will fit the whole image.
6 years ago
It is definitely not about Web Services - I don't see any connection there. But a specific Big Table forum exists: https://coderanch.com/forums/f-129/bigtable You use a ORM API provider but the problems seem to be specific about that product.

I am not sure about the problem itself, sorry. But this part sounds weird:

When I try to get an A object using its ID, I get the following error: You have just attempted to access field "bs" yet this field was not detached



So you get the error when you access the field but getting A itself succeeds? If this is true you need to show more of the transaction and access to the object.
Hibernate search and HQL/criteria API are for different use cases. You use Hibernate search when you need to index and search the content of objects, e.g. a full text search. HQL and the criteria API are for issuing queries against the database, queries on the fields.

Some databases offer support for indexing large clobs and would make a dedicated search engine superfluous. But in general database queries should not do and often can't do full text searches.

Hibernate search is not a faster replacement for query building in general. It has a special focus and learning it just because you want to get more proficient does not look very useful to me.

If your queries are too slowly executed but shouldn't (because they are "normal" queries) then it certainly would pay more to improve the knowledge there.
6 years ago

Billy Sclater wrote:or sword fighting as Hauke put it!!!



BTW, that was a reference to this XKCD.
6 years ago

Ulf Dittmer wrote:

Hauke Ingmar Schmidt wrote:Are the Java 8 additions for you too minor or not functional?


I didn't say Java had no functional elements, I said that I don't think many (more) will be added.



For me the additions of Java 8 are a sign that Oracle is willing to do so if needed or if a need is perceived (and that is what I wanted to express).

Ulf Dittmer wrote:but I think it would be a mistake to add everything people want to a language.



I fully agree. ("How cool would it be to have MySQL access without configuration? Let's add mysql_connect on language level."). There were reasons why certain possible capabilities were left out of Java deliberately. Probably we see the next language in a few years that reduces complexity and features and leaves only one way to do things to get most of developers productive (instead of satisfying a few from the top) - certainly with different focus in certain areas to adopt to shifting technology, development paradigms and preferences, and experience gained. And even now I can hear some people from the future cry how limited that language is, how certain features need to be included, and why that makes it a toy language only that never will gain traction. Or is that an echo of '95?
6 years ago

Ulf Dittmer wrote:I don't see Oracle putting many functional elements into Java.



Are the Java 8 additions for you too minor or not functional?

Let me quote from Richard Warburton, "Java 8 Lambdas":

Richard Warburton wrote:For many people, what Java 8 offers by way of functional programming is incredibly limited: no monads,[1] no language-level lazy evaluation, no additional support for immutability. As pragmatic programmers, this is fine; what we want is the ability to write library-level abstractions so we can write simple, clean code that solves business problems.

6 years ago

emjee man wrote:NOTE: Since the ad company AND the game's company shut down, THE GAME IS FREE TO USE.



That is probably a wrong, even if the legal owner doesn't use it or is not obvious it doesn't mean that he is non-existent. But that is not for us to judge here.

Do you have the source code?
6 years ago
I don't understand that. If you use hbm files for configuration then that is the place to do it. You need to change it there.

I guess some of the developers used eager fetching because it avoids session management. Yes, you will probably face some work in fixing this. But there is no real work around.

If your objects work in a "normal" use case and the eager fetching produces performance issues only in certain cases (e.g. report generating) you can either use SQL in parallel (Hibernate is not a complete replacement) or you can create lightweight objects that work on the same data; probably best if they are read only and are tailored to exactly the data you need.

Billy Sclater wrote:Are you saying that Jenkins can be configured to only allow code that builds successfully (and possibly passes sanity and unit tests) to be propogated to master?



No, I was thinking of the generated artefacts that you get from the repo. You don't check out and compile every dependency that you aren't working with, or do you?

Billy Sclater wrote:

Good luck with that!


As a new guy, and a new dev, I have no authority in the company to enforce these changes, I can only suggest them (feeling slightly inappropriate about it, as I'm sure my more experienced collegaues are probably well aware of these solutions!!);( So if my powers of persuasion don't work, I have a choice between being unable to work with a broken environment, or ... attempting a crude 'hack', and having a chance of getting some work done.



You are not in an easy situation. Of course you can't go to your team mates or the persons responsible for the process and tell them that everything is wrong and you refuse to work unless it is fixed. But it seems that there is at least some awareness for the problem even if the pressure seems not high enough to enforce a real solution.

Billy Sclater wrote:It sounds like nobody recommends any of the hacks mentioned in this thread! The list above contains 2 of those hacks! But including 'all' in the list above, if you were in my situation, which of the 5 would you choose?



#2. It is the least immerse, the variable that you need to work with is the one thing where your problems show (i.e. you don't need to recreate your whole development environment), it is the one that the superior who is responsible for that task recommends.

#5 is the Wally solution. Or you can do sword fighting.
6 years ago

Billy Sclater wrote:Wow! Thats certainly 'saying it how it is'! Actually, I'm a new starter and learning maven. Having broken jars in the repo and broken code on master has pretty much been the norm since I started at the comapny. I thought this was 'normal' and that 'maven was poor build tool'! From what you guys say, quite the reverse! You all seem to be saying:

#1 Building with maven should be a 2 step process S1:Pull the source code S2:mvn clean install.
#2 Using versions as opposed to snapshots is more stable.
#3 There are ways around broken repos but these are 'hacks'. The proper way to do things is not to have a broken repo in the first place (see #2).



Just for clarification: The repo is not broken. The code is broken which is a different problem. The problem with the missing version number is that you just can't reference a specific version of the code. If everything is always 0.0.1-SNAPSHOT (you ARE using version numbers, you don't set them) then you can't say: Always use the version from 2014-07-04 and switch only if the new version works. Even this I would consider a hack but at least you could define a working version.

IMHO your first step should be to ensure that the version in main is always working (in the sense of compiling). It is quite simple to set up a CI server like Jenkins for this. Even if you don't have extensive unit tests you could configure this to checkout the code at intervals (at least daily) and build it. At least you then know if it builds and can check in the version control who broke it. Only a working version should be propagated to the repository, and this should be done by the CI server.

In theory you could assign this task to some person to do it manually daily. But the set up is really simple, in my estimation it will pay out in less than a few days.

Billy Sclater wrote:I thought this was 'normal' and that 'maven was poor build tool'! From what you guys say, quite the reverse!



Maven is far from flawless but it has its benefits. But it has to be used right. One problem is that it is a little bit more than just a pure build tool, and if it is used purely to build you are not only leaving out some things; those things will even actually look and work like obstacles to you.

Billy Sclater wrote:For now looks like I have no choice but to 'hack'!



Good luck with that.
6 years ago