Useful Tools and Understanding Java Spring from a .NET Perspective

One of the first hurdles I ran across when trying to build a Java Spring application was how to transfer the basic Java language that I learned at Community College, with my knowledge of using .NET and C#. I know that C# is based loosely on .NET, but understanding the Spring framework was one of the first layers of the onion, and initially was fairly intimidating. I wanted to share some of my early learnings, but also the problems I ran into early on in the initial setup, the decisions I had to make, and how I arrived at the current state of understanding.

What is Spring

The first problem I had to overcome was the very basic understanding of what Spring does in Java, and how it interacts with applications. The way to think of Spring from a .NET perspective is that C# is a pretty basic language on its own. The power of C# comes from the IL to CLR and the full .NET suite of back-end supporting technologies. If we wanted to scaffold an ASP.NET Web API, we can use Visual Studio to scaffold out a basic project using decorators to mean various things and write less code that isn’t really that interesting. This out-of-the-box code lets you have a standard method to declare a controller and handle the HTTP request reliably in an industry-standard package.

Java Spring will help you be able to create projects such as Microservices, Reactive applications, Web Applications, Event-Driven Applications, and Batch applications. These can run on a variety of platforms such as a local desktop, a virtual unix server, or a serverless Cloud application. This flexibility is partially why Java has been preferred in some organizations because the toolset has supported more than just a Windows host. Microsoft did eventually compete with this by introducing .NET Core, and the latest iterations of .NET do support similar functionality, but Java built this idea first to be cross-platform and flexible.

Getting Started With Spring

One of the first ways I went and got started with my Spring project was I went to the Spring website and started reading how to set up a sample project using Gradle. The first project tutorial I used is available here Building Services with Spring. This gave me a pretty good understanding of how to get started and some of the basics on how I can do something I know how to do really well in with .NET. I also did some more research and found a really useful tool available for Spring Applications, which will help create a skeleton for a project using either Maven or Gradle and will build the basic dependencies and structure that you need based on the project type you select. The initializer can be found on the Spring site under initializer with a link here: Spring Initializer.

I used the combination of the documentation and initializer to build an application in my desired area and did run into some struggles. Most of my struggles were when I was starting to deviate from the basic items and needed to understand how to do some of the more complicated items. A pain point in this whole process is the language used in the MSDN .NET documentation has fairly different explanations than provided in the Java and Spring world because of the different controlling bodies for the languages. I needed a tool that would help span the gap, and I first started by doing the good old Stack Overflow and general Google search, however, I didn’t find a great site that translated things from Java to .NET or .NET to Java.

Introduction of ChatGPT and Co-pilot

I was talking to a co-worker one day, and I was talking through this problem, and he mentioned how he was trying to figure out separate problems, but wanted to try to learn React and was using ChatGPT and Co-pilot. He was having limited success but was slowly figuring things out. I took his initial idea and decided to one evening ask ChatGPT some very open-ended questions about translating .NET to Java Spring, and I did not get great results. This was disheartening because I too was having the same woes that the information just doesn’t exist out there, the Rosetta Stone of programming languages and frameworks.

Then I got the idea somewhere else one day and decided to get a trial for GitHub Co-pilot. I got this because it did include a chat and would at least help with building out some boring boilerplate code for me at the minimum. When I first used it, I learned quickly that the more specific and detailed you ask and prompt the question, the better the result. As I started to ask it questions, I struggled with describing my problem statement or question in a Java format and got back some interesting answers and suggestions. Only after switching the tactic to how can I build a Java Spring class that does x in .NET/C# did I start getting pretty good answers. I also learned how to better ask questions on explaining some of the early answers it gave, so that I not only could know how to prompt it for the right answer, but I would understand the result to figure out if it is correct or not.

I will say, that I am not scared of my AI overlords anymore, I am now seeing how I can incorporate them into my toolset so that I not only have two languages in my toolbox but now a way to expand my toolset even more by using Gen AI to help me learn additional frameworks by using a more natural language.

Leave a Comment

Discover more from harbargerdev Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading