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
RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Wheany posted:

Does anyone know of a fairly recent and up-to-date JavaFX tutorial/Introduction? I had a brief peek at some tutorials and they were incomplete and/or buggy, but I did notice that there were some pretty cool looking ideas like bindings(?)

I'd start here: http://docs.oracle.com/javase/8/javase-clienttechnologies.htm

I used the same info about a year and a half ago when I first started working with JavaFX. I'd install Netbeans, if you haven't, to go through the tutorials because anything IDE specific will most likely be referring to NetBeans. Once you're familiar with the basics of JavaFX it shouldn't be that hard to switch over to whatever IDE you're most familiar with. I had no problems transitioning to IntelliJ IDEA or just using those tutorials with it directly.

Adbot
ADBOT LOVES YOU

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Pedestrian Xing posted:

Anyone have strong opinions on Mac vs Windows for java dev? New job is asking which I want. I've always used Windows but if there's some tool that works better on Mac I'm not opposed to switching.

Really shouldn't matter if it's Mac, Windows or Linux. All the major Java dev tools are written in Java and run on all three platforms.

The only reason to prefer Windows over Mac or Linux is if you have other Windows apps you need to run.

e: Though if you do need to run some Windows apps you could just use Parallels or VMWare Fusion in Mac OS or VMWare Workstation in Linux. I've even used GPU passthrough with VMWare in Linux for gaming and it worked really well.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Volguus posted:

I have a strong opinion against Macs for the simple reason that I used one for 6 months (company issued laptop) and I have found that I am not able to use that UI. It is unix, once in the terminal pretty much everything is there, but the UI has been designed by drunken monkeys high on cocaine. During my 6 months of using it there haven't been 30 minutes going by without me screaming WTF in frustration to yet another dumb thing that OS did. And being a company issued laptop they didn't let me nuke MacOS and install linux on it. That's the UI. The hardware is good, except the keyboard. It hurts to have to type on that thing for too long (1 hour or so).

But, this has nothing to do with java development (or any development specifically). Just plain usage. I know people who love their macs and do development on it just fine. Mac is a thing that you either love or hate. Since it is very light on customization ability there's not much one can do to make it bend to your will. You have to bend to its will, something I am not willing to do (and never will), or it will just not work out.

My recommendation would be to try it out. It is the cheapest way to see if you like macs. If not, I presume you can always go back to a normal laptop.

Not sure if Pedestrian Xing has a preference for or against Mac OSX's UI but you could check out Elementary OS (https://elementary.io/) for a Linux distro that has a similar UI. On the Linux side I'd recommend going with OpenSUSE or Manjaro for dev work. They're generally much more current than Ubuntu based distros.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

benisntfunny posted:

Yuck. It's Frankenstein's monster.

WSL + OpenSUSE is the best thing to happen to Windows. It's a great SSH client, great for scripting, etc.. Just horrible if you need anything with a GUI. Yeah, you can use a local XServer but... Ugh.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider
Hey guys, I'm looking for the Java thread... I think I took a wrong turn and ended up in mid '90s usenet.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

FateFree posted:

Man I feel like I'm totally missing something. I've been forced to use IntelliJ at work and I'm having the complete opposite thoughts, it seems so clunky and crappy compared to eclipse (well, compared to STS which is what I have been using specifically). I don't get it!

In my experience it's more responsive than Eclipse and it has a working dark theme which helps with eye strain. Last I tried none of the dark theme options for Eclipse worked well in windows, they all had issues of some kind.

Ola posted:

The one thing that I struggled with in Intellij was Ctrl-Y is delete line, not redo. Lost a few chunks of code before I learned.

If you change the keymap to Visual Studio then ctrl+z & ctrl+y function as you'd expect, or you could just remap that command yourself.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider
People just pay money to Jetbrains for fun. I mean, that's why I do it.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider
I've been doing dev for a long time at a lot of companies from Fortune 100 down to a small <10 person company. You're going to run into most of those problems at any company and it will vary from project to project. I'm sure that there are companies that do it much better than others but they're rare and you likely won't know for sure until your hired and working on a project.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

NuclearEagleFox!!! posted:

I don't have a technical question, just a request for recommendations.

I learned basic Java way back in high school: methods, classes, objects. Since then, I've used it professionally and in my hobby projects effectively and encountered no issues. But now, my projects have gotten more complex and I've run into examples on Stack Overflow and even Oracle's Javadocs that seem completely foreign to me. They've hinted at features that I've only heard of in other languages: lambda functions, properties, list comprehension, etc. I'm familiar with these in other languages, but I didn't know they were available in Java and so never learned them there.

What's a good resource for learning "modern" Java for someone who's familiar with the language and these features in other languages? Part of the problem is that I don't know what I don't know, and so I can't just search for "X in Java".

Thanks in advance.

https://www.baeldung.com/ is a pretty good resource.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider
You're going to pick up a lot of outdated info and broken links reading Java posts from 10 years ago. I wouldn't recommend you approach it that way.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Rubellavator posted:

What's a good resource to learning all the stream api and other goodies added in java 8? Most of our codebase was written before java 8 was a thing and one of our new developers has taken it upon himself to refactor a huge chunk of the code using that stuff. Frankly I find it all unintuitive and confusing as hell to read, but I dont want to be that old man programmer just yet.

https://www.baeldung.com/java-8-streams

I'm not a fan of streams either. They're more difficult to read, meaning a higher cost of maintenance, and performance tests I've seen say they're slower than traditional methods in most cases. Still, it's good to learn regardless. Especially when you work with a streams happy dev.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Objective Action posted:

4)
Streams and flows only really shine when your code is a) parallelizable and b) results in an asynchronous callback/event notification or may actually never terminate for the life of the program. This is great because you can make your code run in parallel by just popping in 'existingStream.parallel().{rest of the ops}' but the caveat is that if you, today, threw that same code in a threadpool and it misbehaved you aren't magically going to be in any less trouble in a stream. You can get a fair amount done with traditional control flows that you might have done with an executor in 7 but some subtle architectural difficulties can pop up if you try to cram code that might not initially look tightly coupled into a flow and suddenly start hitting halting and communication problems you didn't know you had.

I will say that the one other place they are quite nice as a default option is the I/O stream enhancements, particularly for files, they made in 8 which have basically replaced 99% of my use cases for those modules.

Basically the benchmarks I've seen have shown that the only real place streams excel is in easily parallelized operations with a lot of data. Which is basically what you're saying here. Outside of that (and perhaps file I/O) they're both slower and more difficult to read and maintain than basic loops. I've seem a lot of streams code and none of it has fallen into either category. In my experience Java devs who love streams are mostly in love with "single line of code" solutions they consider elegant or clever with no consideration for either performance or maintainability. I agree that there are good places to use it but the vast majority of places I've seen it used in are to replace simple loops regardless of the amount of data or operations taking place.

I've been programming since the early 90's in Turbo Pascal, C, C++, Delphi, VB, C#, Java, JavaScript, Apex Code, SQL & PL/SQL, shell scripts etc... and generally have no problem looking at code in any language and understanding exactly what's going on and streams have been probably the first thing that that's made me have to research the code I'm reading. I've learned and can parse that poo poo fine now but it adds another barrier to entry for junior devs and it's hard enough finding junior devs that understand basic logic, let alone 5 operations chained on a single line with specialized knowledge required for things like map() vs. flatMap().

RandomBlue fucked around with this message at 06:32 on May 9, 2019

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Ola posted:

This is probably an old and tired topic, but I'm trying to wrap my head around null handling, hope I can get some good tips. So unhandled NullPointerExceptions are bad, that's fine. I've worked a little bit in a university project with Optionals and I felt that while it served as a post-it note that it might be null so you unwrapped it carefully, I had to do a lot more boilerplate, wrapping and unwrapping, instead of just remembering to null-check at some suitable point.

I'm getting into C# soon, I like x ?? y, but I don't if it magically alleviates the problems of 1) remembering to null check and 2) reducing boilerplate in null handling.

Did I do Optionals wrong? (it might have been a Maybe class come to think of it) Is there some pattern which is vastly better than others or is it just horses for courses? Seems to me that checking for an invalid state is pretty fundamental to a lot of human activity for completely fair reasons (Before I drive from the cargo terminal, did my truck get loaded? Before I go to the airport, is my passport with me?) so it's pretty odd that it seems to be shunned more than embraced in programming languages.

Your code should generally break down into 50% tests, 40% null checks/handling and 10% logic.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Volguus posted:

edit: And oh, forget that lombok thing. Really. It's not 1999, IDEs can do some stuff now.

Lombok is still useful because IDEs won't keep your hashCode(), equals() and toString() methods up to date. It also cuts dowb the amount of bullshit boilerplate you have to skim in PRs. Taking a DTO class from 200 lines of code to 30 (for however many DTO classes you've got) is nice.

Also not every team member uses the same IDE and has the same functionality/plugins available so if it can be handled by an annotation processor that can work for everyone.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Volguus posted:

Why do you need your equals/hashCode method to be kept up to date? How often do you change the equality criteria for an object? Add/remove fields, sure, but they usually are just fields that have no bearing on the uniqueness of the object. I don't remember the last time when I had a POJO where all the fields went in the equals/hashCode. Maybe for something really trivial with 2-3 members (Point with int x,y would qualify) but other than that an object is made unique by a few important members, not by all.

I would state that most likely is bad design and poor performance to include everything and the kitchen sink in equals/hashCode.

Maybe if you're only comparing objects after they've been persisted and have a unique ID. What about before that point? What if you're comparing a modified object versus an unmodified one or another modified instance?

If you want to customize those you still can with Lombok.

IMO, if you have a hashCode or equals implementation that doesn't check all publicly settable properties you should have a very good and well documented reason for that.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Jabor posted:

If your thing is mutable you shouldn't be overriding equals/hashcode at all, because object identity is more important.

If you have two immutable objects that are mostly the same but the Name field is different then yes they absolutely should not compare equal, seriously what the gently caress?

If you need specialized comparisons in some special context then write a comparator that compares things that way, don't junk up your general equality semantics.

Everything you've described is an unmaintainable shitpile and I hope you don't really consider it to be best practice.

Agreed.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Zaphod42 posted:

I'm not wild about val / var. I shy away from it in C# code too, that feels like something that should stay in javascript and interpreted languages.

Having strong types is good and knowing those types makes your code more readable. Don't make me guess based on your bad variable names. (Are we going to return to Hungarian Notation?)

var in c# is still strongly typed.

e: It takes on a type when the variable is initialized. It's implicitly typed: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/var

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

hooah posted:

We have a REST service that uses javax.validation.constraints.Pattern to ensure a path parameter is a UUID. Unfortunately, this annotation by default returns any invalid parameter to the client, which our security testing software has flagged a as cross-site accepting vulnerability. Is there any way to configure this annotation to not send the invalid string back?

If you're using Spring then add an exception handler for your REST controller: https://www.baeldung.com/exception-handling-for-rest-with-spring

e: Nevermind, looks like Pedestrian Xing's answer is the right one.

RandomBlue fucked around with this message at 22:11 on Dec 16, 2019

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

lifg posted:

So I’m team lead for a small project. All the devs know Java, so we’re using Java. Some of them know Spring Boot, and one of them used JHipster in their last project.

I don’t know any of these. I’ve been programming for 15 years, so I’m not totally hosed, but I do want to learn as much as I can. At one level, programming is programming, and syntax and semantics are easy enough to pick up. But I want to dig deeper and understand how it all works under the hood, and what the culture’s best practices are.

So what do I need to read or watch to start to really understand Java and Spring Boot?

JHipster is basically a project scaffolding that is based on Spring Boot with several other libraries included. It's a way of quickly bootstrapping a Spring Boot app with commonly used libraries.

Spring Boot is a framework that includes everything you need to host a database driven web app and/or web services.

There are probably better short descriptions of both. However, your biggest problem is probably going to be learning Java style programming, as that's very different from PHP, Perl, Ruby and (I believe) Python.

e: Some good places to start: https://www.baeldung.com/java-tutorial and https://www.baeldung.com/spring-boot - they have tutorials for beginners through advanced

Also, if you haven't worked with maven, gradle or whatever build tool is used for the project, you'll need to learn those as well. Maven is the most commonly used and uses an XML based file configuration (pom.xml by default).

RandomBlue fucked around with this message at 07:18 on Dec 21, 2019

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Volguus posted:

I strongly disagree with that assertion (that hibernate is trash). It can, however, generate in some cases sub-optimal queries. If that's 90% of your use case, then definitely hibernate (or probably any orm) is not appropriate for you and your app. But for 99% of the cases, of the apps out there, the dumb CRUD apps, hibernate saves a shitload of time as it really doesn't do anyone any favors to have to write "select bar from foo where id=5" 100 times.

Profile your app and replace those badly generated hibernate queries (with native sql if you have to) and you will come out on top in the end.

Yeah, it's super easy to use a native query with hibernate for one off stuff you need to optimize.

Also you guys are triggering my DBA PTSD with these pseudo-many-to-many relationships stored as an array converted to a string in a column. Please, for the love of god, don't do things like that.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

adaz posted:

JDK 14 is out officially.

I think I might have to play around with the new packaging tool for building native installers for jars. It's of moderate use especially for random console apps built to containers but still kind of cool. Only other thing that is of interest I saw is the new async JFR stuff which will be nice especially once it gets integrated into some of the APM toolsets out there.

JEP 358: Helpful null pointer exceptions.

The future is now!

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

adaz posted:

1. As other suggested lombok is the _easiest_ way around this and for pure POJOs i think it's fine. @requiredArgsConstructor handles _most_ of my validation concerns for simple pojos

2. You can break down the data model into a larger nested class but this does has performance penalties when hydrating your models if you're pulling from a datastore and relying on JPA. It's also not a terrible idea though if hte data model makes sense. However there are certainly valid entities that have more than 7 properties to them and furher decomposition would just ultimately hurt your understanding.

3. be like me and beg for kotlin style data classes in java

4. if you need ot do a lot of validation and complex logic builders are legit and you should do that.

Lombok also has an @Builder annotation that makes it super simple: https://projectlombok.org/features/Builder

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Hippie Hedgehog posted:

I would check in the generated code, yeah.

My team took the other route, which keeps the repo clean but gives us a slower build. Our product is micro-services in Dockers, and the Gradle build will spin up an instance of our Postgres docker and re-generate the DB classes every build. I really don't like it because it adds 7-12 seconds to every build which we didn't really need. (If you keep a "master database" running somewhere in your CI machinery, this would take just 1-2 seconds, but that would be one weird CI for a container based build...)

It is slightly safer though, because it won't fail in odd ways if someone changes the DB structure and forgets to re-run the jOOQ generation task and check in the new generated code.

Yeah, slowing down the build is annoying but wasting 30-60+ minutes trying to figure out why something is broken because someone forgot to update the generated code is worse.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Jabor posted:

No-one cares about your CI builds being ten seconds longer, and your developer incremental builds shouldn't be rebuilding the db classes anyway because it can see that you haven't changed the files that go into generating them.

Yeah, my poo poo takes at least 10 minutes right now. I'd easily tack on another 20 seconds to avoid poo poo failing from manual generation let alone having PRs including generated code changes.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

nakieon posted:

I... wow. That is a great post. I read this 3 days ago and something just felt off about it.

Less than a minute ago I just realized you structured your last sentence in the ternary operator pattern: boolean ? expression1 : expression2

Amazing.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

F_Shit_Fitzgerald posted:

I'm a C++ guy who wants to relearn Java. I've barely touched it since I took a community college course years ago (2008). Is there a good site, ideally not a pay one, where I can re-teach myself Java? Nearly every coding job I've ever seen requires Java and sticking with C++ is probably hurting me in the job market.

https://www.baeldung.com/java-tutorial

Lots of good, free tutorials on Java and Spring there.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

carry on then posted:

I also like how the Java thread is 99% nitpicking.

e: now that I have some time, if we want to get fully modern Java:

code:
var wordPages = new TreeMap<String, Set<Integer>>();

// populate your map of sets

// Then, you can access like this
Set<Integer> pages = wordPages.get(word);
boolean firstPage = pages.contains(1);

pages.stream().forEach(System.out::println);

// or just get the contents as an array
var pageNumbers = pages.toArray(new Integer[pages.size()]);
but you're looking at at least Java 11 required to run that.

That looks like basic Java 8 to me (doh missed the vars but come on), that introduced streams a long time ago and if you're just going to do:

code:
pages.stream().forEach(System.out::println);
then this would be simpler and faster:

code:
pages.forEach(System.out::println);
and a good IDE will tell you to change it to this because it's the same thing but usually faster:

code:
for (Integer page : pages) {
    System.out.println(page);
}
I hope this was sufficiently nitpicky and I can't wait to see 12 errors pointed out in my 4 lines of code.

e: Guess it's good that I'm so used to var now that I don't even notice it when reading code now.

RandomBlue fucked around with this message at 03:28 on Oct 28, 2020

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

carry on then posted:

I hope that student learned never to ask questions in the Java thread ever again because this was the opposite of helpful.

:same:

RandomBlue fucked around with this message at 06:39 on Oct 28, 2020

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Objective Action posted:

gently caress var forever. Take that poo poo back to Scala nerds!

Strongly typed local variable type inference is actually good most of the time unless you like repeating yourself on the same line:

OmgType varName = new OmgType();

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Objective Action posted:

Here is a nice Scala example that took fifteen minutes of my life yesterday:
code:
val filterFuncs = filters.map(filter => createFilterFunction(filter))
Strongly-typed right? So just ask the compiler or IDE!

Nope, that unrolls into six layers of three different interfaces and four traits. Time to slap a logpoint or debugger onto your code like some kind of goddamn caveman.

I agree that there are times like your example where you shouldn't use var. Any time the return type is non-obvious you shouldn't use it.

RandomBlue fucked around with this message at 15:16 on Oct 28, 2020

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Empress Brosephine posted:

hello0 java goons i've been going thorugh jetbrains academy which should be renamed brokebrain academy because I am enjoying Java alot, as it reminds me of C# compared to the javascript and php I write in.

That said, I am wondering if any of you know of a better learning resource preferably book form to learn this wonderful(?) language? I feel like i'm learning more about obtuse logic problems with jetbrains than the actual programming language itself

Thanks :)

https://www.baeldung.com/ is really good and has a lot of good basic tutorials and guides for "how do I do X". Start here for basic Java stuff: https://www.baeldung.com/java-tutorial

Effective Java is a good book that gets recommended a lot but it's less a java tutorial and more about specific solutions/patterns/best practices.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider
JavaFX is the current GUI framework for Java: https://openjfx.io/

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Objective Action posted:

I'm actually working on a project right now that uses JavaFX's WebView as an Electron alternative where the widgets are all Angular/HTML5 and bind back to Java processing code via the JSObject bindings. But then again I am a crazy person.

If you are interested in GWT there is a community maintained fork on GitHub but there is also a fork that still has free usage options and some more modern features in Vaadin that is maintained and used by a social network company in Germany.

Interesting. Why did you opt for this over Electron with a Java back-end? That's what I'm working on primarily right now.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

PierreTheMime posted:

Java code:
		if (csvLines.toString.getBytes().length > partSize) {

IIRC calling this repeatedly like this in a loop is very slow as it's converting the StringBuilder to a string, then to a byte array for every line you're processing in the input file. It'd be faster to get the size in bytes of each input line and increment a temp variable indicating how many bytes have been processed and then check to see if you're going to exceed your buffer size before adding more to the output.

Though the most likely culprit is the S3 transfer being slow. You might temporarily change the code so it loads that data into memory before any processing is done so you can separate the download from processing while trying to figure out why it's slow.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

PierreTheMime posted:

Edit: That absolutely was the issue. "calling this repeatedly like this in a loop is very slow" is an understatement of the century, the process runtime for 170MB of text is 43 seconds now.

Yup, I've had to solve this exact problem before (without S3 being involved) and that was our core issue originally as well.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Guildenstern Mother posted:

So I'm trying to write a spring controller that will add a recipe to my sql db. Ingredients are unique and don't contain a recipeId and its all tied together in a junction table that looks kinda like this:
code:
junction table

idJunction	idRecipe	idIngredient	idUnits	amount
1		1		1		3		1
2		1		2		2		16
3		2		3		2		8
4		1		3		2		4

Assuming I've got all my entities set up correctly how much of the work can I expect spring to do wrt to populating the junction table? Will I need to save to the junctionRepository?

edit: Of course I will, because the junction entry has the prep notes and quantities for the ingredients.

If each ingredient is coming back from the form with notes about measurement, quantity and prep notes could I make those transient properties in ingredients so that while they're there to be entered into the junction table they're not stored as part of the main ingredient entry or is that going to screw everything up?

edit edit: Doing that is giving me this error Inferred type 'S' for type parameter 'S' is not within its bound; should extend 'com.recipeproject.recipeproject.models.Junction'

My add junction row looks like this if its any help:

List<Ingredient> tempList = new ArrayList<>();
for (Ingredient ingredient: tempList) {Ingredient ingredient1 = new Ingredient();
junctionRepository.save(newRecipe, ingredient, ingredient.getMeasurement(), ingredient.getAmount(), ingredient.getPrepNotes() );

First, what you're calling a junction table isn't really, as a junction table just contains the ids of the two tables you're joining in a many to many relationship. Instead you have an entity with it's own properties that has many to one relationship with both Recipes and Ingredients and could be referred to a RecipeLineItem or something similar.

It does require it's own repository since it's not a junction table (which JPA could handle completely for you if it were via annotations, no repo needed) and the repo should have save methods that just take an instance of that entity as an argument, not individual properties as parameters. These properties all belong on the RecipeLineItem entity, where they will be saved, not as transient properties elsewhere.

In the code you linked you're trying to pass all those properties to your repo save method instead of passing an instance of the class to be saved.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

smackfu posted:

At least fighting with Spring and JPA is a real job skill.

Now try to make Spring Boot start up in an acceptable amount of time.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Hippie Hedgehog posted:

Use a library.

Here's the first google result, I haven't used it myself:
https://github.com/stateless4j/stateless4j

This one looks elegant, but is for Kotlin:
https://github.com/Tinder/StateMachine

Just want to say whenever you're trying to solve a problem you should always look for libraries first. The number of times I've seen poo poo like people rolling their own CSV parser is insane.

No you didn't think of everything and no it's not parsing the CSV correctly.

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

smackfu posted:

Of course, since it is Java, there is probably one library that everyone has used for ten years and that has a terrible API.

In my experience there are multiple library options for most common (and not so common) problems in Java.

For a lot of common problems, Apache Commons probably has a library for it and in my experience their libraries are decent.

Adbot
ADBOT LOVES YOU

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

chippy posted:

I work somewhere where we have 10 half-baked in-house versions of everything. It's an absolute nightmare. Early on in my time here I asked in Slack what our solution was for persisting data and got literally 7 different answers, and they were all bad.

It doesn't help that due to our weird processes, getting libraries added to the target platform is kind of a pain, but on top of that I think everyone just tries to write their own poo poo for a laugh. It's a scientific research facility, a very academic environment with very little process where everyone just kind does whatever they want a lot of the time. Our codebase is an insane labyrinth.

The worst one I ran into was someone rolling their own loving crypto and they got extremely mad when I told them they needed to be using one of the standard libraries, ESPECIALLY for crypto. They took that to mean I thought they were incompetent, which they were but that had nothing to do with whether or not I thought they could write a crypto library on their own.

IIRC it was a step above ROT13.

This was in the mid 2000's and it was a .NET app, AES (and several other ciphers of course) were built into the framework and easy to use.

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