Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Jo
Jan 24, 2005

:allears:
Soiled Meat

The Laplace Demon posted:

I don't think it's possible to get around needing the index. This is the kind of thing I've written or seen for these problems:
Java code:
IntStream.range(0, data.length).forEach(i -> data[i] = op.apply(data[i]));

I like it. I'm left to wonder if this will incur less overhead than the data-copy version.

EDIT: gently caress YEAH. A nice performance boost with this. Thanks, all.

Jo fucked around with this message at 22:12 on Feb 4, 2017

Adbot
ADBOT LOVES YOU

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Wheany posted:

I have decided to use https://github.com/visad/visad/blob/master/core/src/visad/Delaunay.java, with its lovely 1998 vintage code.

It works and all, but holy poo poo this is the spaghettiest code I have seen ever.

There is no way of lifting just one class from out of that mess. By using the Delaunay class I suddenly need to have a dozen custom awt components and bespoke collections and :negative:

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Wheany posted:

There is no way of lifting just one class from out of that mess. By using the Delaunay class I suddenly need to have a dozen custom awt components and bespoke collections and :negative:

Success! I ran coverage on the class for the use case I have and then just deleted all branches and methods that were not touched :commissar:

3 Classes remain, one of them is a pointelss extension of Exception and I can easily combine the base Delaunay class and DelaunayWatson that extends it.

geeves
Sep 16, 2004

Having a problem with Maven. My code builds correctly on my main machine. But same codebase on other machines, I get a compilation error with HttpServletResponse. My company is JUST NOW getting to dependency management :sigh:

The code works as it is now for our application. It's just failing on build for my 2nd machine and for others.

There is an older version of javax.servlet:javax.servlet-api (we use 3.1, the dependency uses 2.3) that is used by another jar and I have tried adding it as an exclusion in the offending dependency, but that does not work

We're passing in:

method(HttpServletResponse res, ...)

and it fails on first line of the method: "res.setCharacterEncoding("UTF-8");"

Any thoughts? I've been stuck on this for over a day and really haven't been able to find an answer on Stackoverflow etc. (the exclusion one was promising, but ultimately didn't work)

code:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile 
        (default-compile) on project betaunit-common: Compilation failure: Compilation failure:
[ERROR] /Users/geeves/git/betaunit/common/src/main/java/betaunit/util/ICalUtil.java:[142,11] 
        error: cannot find symbol
[ERROR] symbol:   method setCharacterEncoding(String)
[ERROR] location: variable res of type HttpServletResponse
[ERROR] /Users/geeves/git/betaunit/common/src/main/java/betaunit/util/ICalUtil.java:[438,8] 
        error: cannot find symbol
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal 
org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project betaunit-common: Compilation failure
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
	at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:729)
	at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	... 20 more

CPColin
Sep 9, 2003

Big ol' smile.
Are you sure the older JAR went away when you were excluding it? And that no other dependencies were sneaking in old versions? (Whee, dependency hell!)

Carbon dioxide
Oct 9, 2012

Does either your local machine or the other one have a maven install with a customized settings.xml file in the maven conf directory? For instance, if they point to different remote repositories, things may fail. It's an easy to forget thing that can cause maven to fail managing your dependencies.

EDIT: If that's not it, this is how you can figure out version conflicts in maven dependencies: https://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html

Carbon dioxide fucked around with this message at 22:28 on Feb 8, 2017

geeves
Sep 16, 2004

It's weird. I commented out the dependency on a whim and ran mvn install. Build Successful. :v:

Uncommented the dependency and built. Build Successful. :v: It's some weird circular dependency.

The library causing the issue is some very old RSS lib (yarfraw) that's from 2008. I checked out the code to perhaps fix things, but everything fails to build. I've tried several tags and the main trunk. I don't know who thought using this was a good idea (it was our CTO). So I'm going to replace since it's only used in two small places. One place for parsing date time which java 8 can now do natively. The other is just basic reading.

Paul MaudDib
May 3, 2006

TEAM NVIDIA:
FORUM POLICE

geeves posted:

Having a problem with Maven. My code builds correctly on my main machine. But same codebase on other machines, I get a compilation error with HttpServletResponse. My company is JUST NOW getting to dependency management :sigh:

The code works as it is now for our application. It's just failing on build for my 2nd machine and for others.

There is an older version of javax.servlet:javax.servlet-api (we use 3.1, the dependency uses 2.3) that is used by another jar and I have tried adding it as an exclusion in the offending dependency, but that does not work

We're passing in:

method(HttpServletResponse res, ...)

and it fails on first line of the method: "res.setCharacterEncoding("UTF-8");"

Any thoughts? I've been stuck on this for over a day and really haven't been able to find an answer on Stackoverflow etc. (the exclusion one was promising, but ultimately didn't work)

geeves posted:

It's weird. I commented out the dependency on a whim and ran mvn install. Build Successful. :v:

Uncommented the dependency and built. Build Successful. :v: It's some weird circular dependency.

The library causing the issue is some very old RSS lib (yarfraw) that's from 2008. I checked out the code to perhaps fix things, but everything fails to build. I've tried several tags and the main trunk. I don't know who thought using this was a good idea (it was our CTO). So I'm going to replace since it's only used in two small places. One place for parsing date time which java 8 can now do natively. The other is just basic reading.

Usually this is exactly the problem and fix for me. You ran "mvn install" locally. Now you have a different version of the lib installed in your local Maven repository. Boom, compiles for you but nobody else. Or otherwise - somehow you have a different version of this lib in your Maven cache from everyone else, that's what it comes down to.

Dumb idea: you can set up a Maven reactor project. You have parent project A which compiles modules B and C and D. C depends on B, so the reactor will compile B and then sub it into C. Problem though - this means you are compiling everything every time, and if B's tests aren't insignificant that can potentially be a huge build time. Also, if D depends on C (B -> C -> D) then you have no way to build just C in isolation - your only unit you can build successfully by itself is "A" so compiling A will compile B and C and D too. This can also be a problem if D is huge.

Partial fix of this problem - you set up a local artifact repository inside the repo, and have Maven install to that repository when it does its thing. This is also how you replicate the traditional "libs" folder via Maven. Since it needs to know what each jar file actually is - so that it can manage your dependencies. There is no difference between Maven Central and something you install into a repo with "mvn install:install-file -DlocalRepositoryPath". One is accessible over http: //, one is accessible over file: //, that's the only distinction that Maven's abstraction will draw. https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

Now you get an additional problem, because Maven will "helpfully" set up a cache inside your homedir ("~/.m2" on Linux, "/Users/geeves/.m2/" on Windows). Somebody else pushes a new version of your custom-built dependency jarfile and some code changes. But Maven won't check the repositories until the cache expires - not even the local repositories. gently caress you Maven, this is a terrible coding decision. To fix it, delete your ".m2" folder and you will redownload everything.

Better fix of this problem - you really need to set up an artifact repository like Nexus or Artifactory. This is basically your own version of MavenCentral that holds your private jars and stuff. You can even have it cache stuff from MavenCentral so you don't have to redownload everything slowly from the internet every single time. https://www.sonatype.com/nexus-repository-sonatype https://www.jfrog.com/open-source/

Now we hit an additional additional problem. The "contract" of Maven dependencies is the groupId, artifactId, and version of the package matching if and only if the jar is exactly the same. As far as Maven is concerned, if those things match then the jars are interchangeable. Which is why Maven is deciding to cache poo poo in the first place. So now, every time some idiot compiles the jar with something that breaks the main code then it breaks for everyone who uses the artifact repository server.

Fix: if you are compiling every time then what you actually have is a "SNAPSHOT" build. For example, instead of building version target "2.0.0" you should use "2.0.0-SNAPSHOT". Also, set these config files to force them to always be rebuilt. http://stackoverflow.com/questions/2358965/maven-automatic-snapshot-update

Further tip: don't ever set your project up to compile configuration (DB server target, etc) into your jar files. You always always do something like JNDI instead of that. Otherwise, what happens when someone installs the jar and your production server suddenly boots up with test-server configuration?

I'm not going to say that I'm totally guilt-less here, but if you're going to do it, don't ever compile to the same jar-file target filename. Different filenames for different builds, it doesn't help the Maven problem but it will help your sanity. Deploying "myapp-prod.war" to Tomcat will only ever deploy to "webapps/myapp-prod/" unless you get frisky with the web.xml. And you always always do a "mvn clean package" or "mvn clean war:war" or something, you never never never do a "mvn clean install" on something that might produce a different output based on profiles/configuration/git branch/etc. Otherwise I guarantee you will get hosed by this down the road. It may be tomorrow, it may be 2 years, but your clock is ticking buddy. If your new guy does it then you get to have a long and productive explanation of the Maven lifecycle and how you will respect it.

Paul MaudDib fucked around with this message at 00:54 on Feb 9, 2017

geeves
Sep 16, 2004

Paul MaudDib posted:

Lots of good stuff.

Thank you for that reply. We actually did install Artifactory for this jar (and about 20 others) that have no MVN equivalent. I'll do the later mvn commands you suggested when the next developer tests this out (or I'll blow away my local mvn repo on the machine which I had trouble with and start from scratch again).

Does Gradle handle weird things like this any better?

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

geeves posted:

Thank you for that reply. We actually did install Artifactory for this jar (and about 20 others) that have no MVN equivalent. I'll do the later mvn commands you suggested when the next developer tests this out (or I'll blow away my local mvn repo on the machine which I had trouble with and start from scratch again).

Does Gradle handle weird things like this any better?

Like everything, it makes it's own tradeoffs and stupid loving decisions.

Boz0r
Sep 7, 2006
The Rocketship in action.
What library for conversion between DTO and Entity objects would you recommend?

FateFree
Nov 14, 2003

Boz0r posted:

What library for conversion between DTO and Entity objects would you recommend?

Not sure if anything better has come along but I previously used Orika without any problems: https://orika-mapper.github.io/orika-docs/

geeves
Sep 16, 2004

CPColin posted:

(Whee, dependency hell!)

I figured out most of this garbage. Unfortunately my company has a massive amounts of technical debt, including hibernate loving 3. Christ. I'm half tempted to quit than deal with
code:
Caused by: java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has interface org.objectweb.asm.ClassVisitor as super class
Which everyone, everywhere says is fixable with the right cglib. Which of course it's not.

:perfect:


Edit: figured it all out. So many exclusions - I've never really had to use those before, thankfully. Now struts isn't reading properties, but that's easier to deal with.

geeves fucked around with this message at 23:31 on Feb 15, 2017

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
Why does the GC log have to be so annoying to parse. I'm trying to write a logstash pattern for it, what a fuckin' pain!

I found an existing one online but god drat it is complicated: https://github.com/Mortinke/logstash-pattern/blob/master/logstash/etc/logstash/patterns/gc

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

fletcher posted:

Why does the GC log have to be so annoying to parse. I'm trying to write a logstash pattern for it, what a fuckin' pain!

I found an existing one online but god drat it is complicated: https://github.com/Mortinke/logstash-pattern/blob/master/logstash/etc/logstash/patterns/gc

They don't make monitoring applications for this sort of thing so you don't have to manually parse it all an then do something with results from logstash later?

Boz0r
Sep 7, 2006
The Rocketship in action.
I have some code that doesn't compile in IntelliJ, but our ant script works fine. I don't get it.

code:
public double someFunction(List<Pair<Long, Double>> parameter) { ... }

public BigDecimal someFunction(List<Pair<Integer, BigDecimal>> parameter) { ... }
As far as I can tell, it shouldn't compile. Why does it compile in ant?

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
That's odd. If you decompile the bytecode, what did it actually turn into?

TheresaJayne
Jul 1, 2011

Boz0r posted:

I have some code that doesn't compile in IntelliJ, but our ant script works fine. I don't get it.

code:
public double someFunction(List<Pair<Long, Double>> parameter) { ... }

public BigDecimal someFunction(List<Pair<Integer, BigDecimal>> parameter) { ... }
As far as I can tell, it shouldn't compile. Why does it compile in ant?

What java version are you using in the ide and what in the ant?

i have seen issues where ant is using java 6 or 7 and ide is using 8 (or vice versa)

Paul MaudDib
May 3, 2006

TEAM NVIDIA:
FORUM POLICE

Boz0r posted:

I have some code that doesn't compile in IntelliJ, but our ant script works fine. I don't get it.

code:
public double someFunction(List<Pair<Long, Double>> parameter) { ... }

public BigDecimal someFunction(List<Pair<Integer, BigDecimal>> parameter) { ... }
As far as I can tell, it shouldn't compile. Why does it compile in ant?

Your IntelliJ classpath isn't the same as your Ant classpath somehow. Unlike Maven, Ant build files are not a declarative "project" file, they are like a makefile and you need to keep your IDE's project file in sync with them. When you run "build" it's actually IntelliJ compiling it via its own build script - not running the Ant script.

Paul MaudDib
May 3, 2006

TEAM NVIDIA:
FORUM POLICE
Anyone used Lanterna before? Or any AWT/Swing stuff?

I'm just trying to dip my toes into Lanterna for a personal project, but the documentation is poo poo. I'm doing OK except I can't figure out how to make the font size change. Everything is super big (1/4 of my 1440p screen, so like 720p). What I'm trying is this:


code:

    public static void main( String[] args )
            throws Exception
    {
        Font font = new Font("DejaVu Sans Mono",Font.PLAIN, 4);
        TerminalSize size = new TerminalSize(80,20);
        Terminal terminal = new DefaultTerminalFactory()
                .setInitialTerminalSize(size)
                .setTerminalEmulatorFontConfiguration(AWTTerminalFontConfiguration.newInstance(font))
                .createTerminal();
        Screen screen = new TerminalScreen(terminal);
        screen.startScreen();

        Panel panel = new Panel();
        panel.setLayoutManager(new GridLayout(1));
        final CheckBoxList checkBoxList = new CheckBoxList();
        panel.addComponent(checkBoxList);

        for(int i = 0; i < 10; i++)
        {
            checkBoxList.addItem(Integer.toString(i));
        }


        final BasicWindow window = new BasicWindow();
        window.setHints(Arrays.asList(Window.Hint.EXPANDED));
        window.setComponent(panel);
        window.setTitle("title");

        panel.addComponent(new Button("Done", new Runnable() {
            public void run() {
                window.close();
            }
        }));

        MultiWindowTextGUI gui = new MultiWindowTextGUI(screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE));
        gui.addWindowAndWait(window);
        terminal.close();
        for(int i = 0; i < 10; i++)
        {
            if(checkBoxList.isChecked(i))
            {
                String txt = (String) checkBoxList.getItemAt(i);
                System.out.println("item " + Integer.toString(i) + ": checked");
            }
        }
    }
TerminalSize works... but it doesn't change the font size at all. Font doesn't seem to work at all. I've never worked directly with AWT before and I suspect that I may just be loving up the Font calls in some really obvious way.

Paul MaudDib fucked around with this message at 06:06 on Feb 21, 2017

CPColin
Sep 9, 2003

Big ol' smile.

Boz0r posted:

I have some code that doesn't compile in IntelliJ, but our ant script works fine. I don't get it.

code:
public double someFunction(List<Pair<Long, Double>> parameter) { ... }

public BigDecimal someFunction(List<Pair<Integer, BigDecimal>> parameter) { ... }
As far as I can tell, it shouldn't compile. Why does it compile in ant?

Yeah, that's weird. While the JVM spec allows methods to differ only by return type, Java definitely does not, so with the type erasure, those two should clash.

Paul MaudDib
May 3, 2006

TEAM NVIDIA:
FORUM POLICE
In unrelated news, at work I'm working on converting a legacy app that pre-generated database IDs at object creation, so basically Hibernate doesn't know what the gently caress because it sees everything as detached. saveOrUpdate is broken, persist is broken, one-to-many collections are broken, and we're piling more and more dirty hacks on top of the legacy dirty hacks because "what we had worked before!" and the tech lead doesn't want to touch anything because we have a big mass of spaghetti code and no tests.

I'm pushing hard for high-level integration testing using a container instance of the DB schema that we can set up and knock down almost instantly, and running tests by passing request parameters into the Struts actions and then parsing the output with something like TagSoup for targeted outputs. Like a form of Selenium testing that doesn't take hours to run. Then we can start delving down into the core code and cleaning it up into something testable.

Also, since it's Oracle-based, there's tons of DB quirks. Otherwise I'd propose SQLite.

The tech lead thinks it'll all just somehow work out with some bailing wire and lots of tester time. But I know we're gonna break everything all the time unless we get automated tests. Right now you have no idea what you'll be passed, every action is passing in a totally different mix of object states- transient, persistent, detached, illegal combinations thereof (detached objects that don't exist in the database!), or something that Hibernate shouldn't touch, and there's like 50 actions and several hundred views.

Paul MaudDib fucked around with this message at 06:20 on Feb 21, 2017

Boz0r
Sep 7, 2006
The Rocketship in action.

TheresaJayne posted:

What java version are you using in the ide and what in the ant?

i have seen issues where ant is using java 6 or 7 and ide is using 8 (or vice versa)

I think ant is using java 6, but I've tried using 6, 7 and 8 in IntelliJ, none of which compiles it.

FateFree
Nov 14, 2003

Paul MaudDib posted:

In unrelated news, at work I'm working on converting a legacy app that pre-generated database IDs at object creation, so basically Hibernate doesn't know what the gently caress because it sees everything as detached. saveOrUpdate is broken, persist is broken, one-to-many collections are broken, and we're piling more and more dirty hacks on top of the legacy dirty hacks because "what we had worked before!" and the tech lead doesn't want to touch anything because we have a big mass of spaghetti code and no tests.

I'm pushing hard for high-level integration testing using a container instance of the DB schema that we can set up and knock down almost instantly, and running tests by passing request parameters into the Struts actions and then parsing the output with something like TagSoup for targeted outputs. Like a form of Selenium testing that doesn't take hours to run. Then we can start delving down into the core code and cleaning it up into something testable.

Also, since it's Oracle-based, there's tons of DB quirks. Otherwise I'd propose SQLite.

The tech lead thinks it'll all just somehow work out with some bailing wire and lots of tester time. But I know we're gonna break everything all the time unless we get automated tests. Right now you have no idea what you'll be passed, every action is passing in a totally different mix of object states- transient, persistent, detached, illegal combinations thereof (detached objects that don't exist in the database!), or something that Hibernate shouldn't touch, and there's like 50 actions and several hundred views.

All of my domain objects have pre-generated ids because it solves a bunch of problems and allows you to use the id as the only field in equals/hashcode (My ids are UUIDs). But, I also use a version column that doubles as optimistic lock protection and a hint to hibernate whether the object has been saved before or not.

Volguus
Mar 3, 2009

FateFree posted:

All of my domain objects have pre-generated ids because it solves a bunch of problems and allows you to use the id as the only field in equals/hashcode (My ids are UUIDs). But, I also use a version column that doubles as optimistic lock protection and a hint to hibernate whether the object has been saved before or not.

There are times when UUIDs are required for ids, but usually an auto-incrementing number is perfectly fine. Plus, UUIDs only offer 99.99999999% guarantee of uniqueness, while the auto-incrementing number provides 100%. Plus, if you're using a sequence (and you're prefetching a bunch of numbers in advance), it is slightly faster than generating a new UUID for each object. Why would you go with UUID? What's the advantage that I'm missing here?

a witch
Jan 12, 2017

UUIDs can be generated offfline, make replication dead easy, and make keys truly unique, even between disparate applications. They should be your default choice for keys unless you're absolutely certain about the scope of your project.

Edit: this is assuming your database actually has a proper type for UUIDs and you're not just dropping them in a chat column.

smackfu
Jun 7, 2004

You don't need a single source of truth for the ID which can be useful in distributed contexts.

Snak
Oct 10, 2005

I myself will carry you to the Gates of Valhalla...
You will ride eternal,
shiny and chrome.
Grimey Drawer
I have no real experience with making GUIs, and I'm learning javaFX stuff in this class I'm taking. It seems simple enough at first, fxml make perfect sense from my experience with html. But I cannot figure out how to make elements center properly. Google just tells me to use the setAlignment(Pos.CENTER) method, and it doesn't do anything.

I've got a StackPane, which is coded in the fxml file, and in my code I create an AnchorPane and add it to the StackPane with stackPane.getChildren().add(anchorPane). But no matter what I do, anchorPane always just shows up in the top left of the stackPane. My understanding was that setAlignment(Pos) for containers set the alignment of the children, so I have stackPane.setAlignment(Pos.CENTER), but it doesn't help.

What stupidly obvious thing am I missing?

I have System.out.println telling me the size of stackPane, so I know that it's the width of the stage.

My appologies if there's a seperate thread for javaFX bullshit, I didn't see one.

edit: I have also tried StackPane.setAlignment(anchorPane, Pos.CENTER), which also does nothing.

edit2: Thanks for being my rubber ducky. I never figured out how to center an AnchorPane, but I did determine that using another StackPane was going to be more appropriate for what I am doing, and it works just fine. Thanks.

Snak fucked around with this message at 19:24 on Feb 21, 2017

Sedro
Dec 31, 2008
UUIDs can also be expensive to index, due to their size and being non-sequential

sarehu
Apr 20, 2007

(call/cc call/cc)

Sedro posted:

UUIDs can also be expensive to index, due to their size and being non-sequential

Sequential can be expensive to insert, because of locking and sharding. (Depending on the system of course.)

sarehu
Apr 20, 2007

(call/cc call/cc)

Volguus posted:

Plus, UUIDs only offer 99.99999999% guarantee of uniqueness,

If you generate 46 trillion of them.

Volguus
Mar 3, 2009

sarehu posted:

If you generate 46 trillion of them.

Heh, in theory that's correct. However, when you take into account the fact MAC addresses are not always unique, that system's time is not always in sync, that UUID generation algorithms are not always perfect, that number quickly shrinks to more earthly values.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
Well no true Scotsman generates UUIDs with a higher than 0,00000001% chance of collision after generating 46 trillion of them.

BabyFur Denny
Mar 18, 2003
Though I don't know anything that has better guarantees for uniqueness and is easy to come by.

Hughlander
May 11, 2005

BabyFur Denny posted:

Though I don't know anything that has better guarantees for uniqueness and is easy to come by.

Authoritative DB polled for each required unique value!

Mmo from the 00s I was on had a desktop under an engineers desk that would listen on a tcp socket, return an integer and update its internal count. Completely unique and ghetto af.

The tools would just ping it whenever they needed a unique Id that was unique across all designers and branches.

smackfu
Jun 7, 2004

Apparently if you have a one-to-one Hibernate relationship, and you define it as lazy, it doesn't actually make it lazy. Because there is no way to give you a pointer that might need to be null if the other side of the relationship doesn't exist. (I think that's the reason.) So every time you fetch the parent, it fetches the child in a separate query.

I feel like that deserves a warning or something. And there's no easy fix to it either.

Paul MaudDib
May 3, 2006

TEAM NVIDIA:
FORUM POLICE

smackfu posted:

Apparently if you have a one-to-one Hibernate relationship, and you define it as lazy, it doesn't actually make it lazy. Because there is no way to give you a pointer that might need to be null if the other side of the relationship doesn't exist. (I think that's the reason.) So every time you fetch the parent, it fetches the child in a separate query.

I feel like that deserves a warning or something. And there's no easy fix to it either.

What about defining it as many-to-one with "insert=false update=false" and the key column also being the ID column?

geeves
Sep 16, 2004

Paul MaudDib posted:

maven builds etc.

Wanted to thank you again for this and give a small update on this in case anyone else finds it helpful:

I basically wrote our own build script that incorporates all the options we may need for Maven and what each build needs. I wrote a script that uses the git log / status to find out what changed and what needs built with each build and took Maven out of the decision tree.

As for the caching issue mentioned, I've found that adding "-U" works 99% of the time, but with some random issue I downloaded an apache directory structure html file instead of a POM file from maven central in reference to sonatype. It was bizarre. But deleting /.m2/repostory/affected/path took care of it. (Didn't need to delete my whole .m2/repo)

After 99% of our problems were solved, we found one major one last week for which I don't have an answer of why, but a solution when it comes down to Environment vs. Gradle vs Maven.

We have our Common library (db connection, etc. shared among apps) and our Application WAR. Both the Common Lib and WAR have resources/package*.properties files. For the last 18+ months we've used an unholy alliance between Gradle and Ant and never used Gradle for full dependency management because reasons outside of my control and doing (ie: I wasn't involved).

During the cutover on Friday week we hit a snag. In our QA environment, with Maven builds promoted from Jenkins (running on Ubuntu 14), we started getting properties / ResourceBundle errors in our Application (from the WAR build) that were rooted in our Common Lib ("This property could not be found, etc.) causing all sorts of issues.

These didn't present themselves in builds locally on our own machines (MacOS). So we built a WAR from our local machines and uploaded that WAR file to QA directly from my laptop. It worked perfectly as we expected. But the build from Jenkins (on Ubuntu) did not.

Late Friday, my boss said with all other options exhausted at the moment, "Common and App both have the same file name structure when it comes to properties files, they're all 'package.properties'. - What IF something is going on in the classpath?" So in Common, I changed the properties file name from something like package_es.properties to common_es.properties (for each language) and it solved our issue.

It makes sense to me when I think about it: why "common/src/main/resources/package.properties" would interfere with "app/src/main/resources/package.properties" but why Gradle forgave this vs Maven (depending on environment) I do not. After working nearly nonstop on converting our app to Maven the last few weeks, I don't care as long as it works. But I would like to know if anyone has an answer.

tl:dr - in each of your libs, it might be a good idea to have a unique name for your properties files so you don't have collisions in your classpath.

Trick Question
Apr 9, 2007


Anyone here have experience working with CORBA?

I'm just starting out with it, and I'm having some trouble.

My program is a very, very basic auction house program that, ideally, allows users that are not the seller to bid on the item and the seller to sell it, as well as various functions to check the status of the auction.

My problem is that, while the program is successfully storing all of the information about the auction to the server, and I get the same information every time I access it across different clients, I'm getting weird false values whenever I try to check if the current user is the seller or the high bidder - which right now means just checking their name string against the auction.seller and auction.highBidder strings in the server. Anyone know what might be up?

These functions work:
code:
        public class Auction {
		public String seller = "";
		public String description = "";
		public float price = 0.0f;
		public String highBidder = "";
		
		//constructor
		public Auction(String newSeller, String item, float startPrice){
			seller = newSeller;
			description = item;
			price = startPrice;
			highBidder = seller;
		}
	}
	
	Auction currAuction = null;
	
	public boolean offerItem(String seller, String description, float startPrice){
		if(currAuction == null){
			currAuction = new Auction(seller, description, startPrice);
			return true;
		}
		else{
			return false;
		}
	}

        public void bid(String user, float bid) {
		if(bid > currAuction.price){
			currAuction.price = bid;
			currAuction.highBidder = user;
		}
	}

        public String getAuctionDescription() {
		NumberFormat formatter = NumberFormat.getCurrencyInstance();
		return currAuction.description + " is being bid on. Current high bid is " + formatter.format(currAuction.price) +
                           ". The seller is " + currAuction.seller + " and the high bidder is " + currAuction.highBidder;
	}
And these functions don't:
code:
	public int checkStatus(String userID){
		if(currAuction == null){
			return 0;
		}
		else if(currAuction.seller == userID){
			return 2;
		}
		else if(currAuction.highBidder == userID){
			return 3;
		}
		else{
			return 1;
		}
	}

	public boolean checkBidStatus(String bidder) {
		if(bidder == currAuction.highBidder){
			return true;
		}
		else{
			return false;
		}
	}

(well, checkStatus DOES give me a 1 if an auction exists, but it never returns a 2 or a 3.)

There's other functions that I haven't tested yet because they depend on the user being the seller.

Is this some specific property of CORBA that I'm running into, or is it more likely I've simply messed up the logic somewhere? Everything else is just helper files generated by idlj, a very simple server program to pass values to and back from these functions, and a very simple client function to let them put in a userID and access these functions.

Adbot
ADBOT LOVES YOU

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Does it work with currAuction.seller.equals(userID) instead?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply