r/javahelp • u/[deleted] • Jul 08 '21
Node dev wants to understand spring
I've been building APIs for a while now and I would consider myself pretty component in Node.js and Express. As a result I know a lot about the Node.js ecosystem (tools, packages, yada yada). I want to transition into Spring Boot and carry over as much of my Node.js knowledge as possible. I've done some research, but the whole Java world is very foreign to me. Can anyone recommend resources that explain Spring concepts while giving examples in Node.js. Asking for a friend.
24
u/wsppan Jul 08 '21
I think you should learn Java first. Java and Javascript are vastly different languages despite having similar names. Once you have a strong grounding in Java I would only then tackle Spring. It is a very complex framework.
4
Jul 08 '21
I know the very basics of Java from when I used to do android development, but OOP has always been difficult for me (which is why I gravitated towards the functional style of node). How much java would you recommend I learn before jumping into Spring?
11
u/wsppan Jul 08 '21
Enough to be fluent in OO programming. Spring is a Java framework. You write Java code when using Spring. Java is an OO language.
1
Jul 08 '21
Yeah aight
3
u/ZukoBestGirl Jul 09 '21
The spring world of java looks a bit different from old JavaEE. With lombok, mapstruct, spring, jdbc and whatever else, the code is written in a much more declarative way.
But before getting into any of that, I'd suggest you get familiar with Java first. Like the other guy said, until you're comfortable with OOP, and maybe also lambdas. Java lambdas are bit clunky, IMHO. But once you get used to them, they're great.
After that, https://spring.io/guides
It's not extremly well organized, so you can skip some of them. Others do very strange things like direct DB access. How I'd describe them is: "Don't take the code as gospel. Just an example for how spring works".
However after you get through 80-90% of them, I'd say you'd have a good start at it.
0
Jul 08 '21
[deleted]
6
u/wsppan Jul 08 '21 edited Jul 08 '21
Java is an OO language with some FP enhancements. Try and write anything in Java without a Class. Spring is a framework written in Java that has some aspect oriented features. It is still Java and Java is OO at its core.
Edit:
"Java is a high-level, class-based, object-oriented programming language" - Wikipedia
"Your programming language is object oriented, yet it's still dead simple." - James Gosling white paper May 1996 The Java Language Environment
3
Jul 08 '21 edited Jul 08 '21
AOP, at least the way that it is done in normal Spring (and not crazy AspectJ), is a standard OOP implementation pattern, particularly the Decorator Pattern.
Spring itself is an IoC container, particularly implementing the "O" and "D" of the SOLID OOP programming principles, Open/Closed Principle and Dependency Inversion Principle. If you understand OCP and DIP, you will have a much better grasp of how Spring components actually work and how to customize their behavior.
For example,
RestTemplatecan use any HTTP client in existence, all because of DIP and OCP. Understand that, and you'll truly understand Spring.2
u/WikiSummarizerBot Jul 08 '21
In object-oriented programming, the decorator pattern is a design pattern that allows behavior to be added to an individual object, dynamically, without affecting the behavior of other objects from the same class. The decorator pattern is often useful for adhering to the Single Responsibility Principle, as it allows functionality to be divided between classes with unique areas of concern. Decorator use can be more efficient than subclassing, because an object's behavior can be augmented without defining an entirely new object.
[ F.A.Q | Opt Out | Opt Out Of Subreddit | GitHub ] Downvote to remove | v1.5
1
u/lookForProject Jul 08 '21 edited Jul 08 '21
Fair enough, I was incorrect. But as an aside, I do not try to make the claim that to understand Java en Spring, you don't need to understand OO. But I did not understand the strong singular focus on OO.
Until I reread the thread and noticed that OP had difficulty with OO. So the focus makes sense.
7
Jul 08 '21
Can anyone recommend resources that explain Spring concepts while giving examples in Node.js.
I'd say read the Spring documentation. It's quite extensive. There are a large number of guides.
I think you're asking a bit much if you want Spring explained in terms of Node, though. The Spring and Node languages, patterns and practices are completely different.
2
•
u/AutoModerator Jul 08 '21
Please ensure that:
Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
You include any and all error messages in full
You ask clear questions
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.