📜 ⬆️ ⬇️

Startup Game at Java Seminars


HttpSession illustration while working with cookies
This article owes its appearance to the new requirement for the “Advanced Java Programming” course, which I teach at the Mail.Ru Technopark at Moscow State Technical University. Bauman. This requirement was formulated at the beginning of the summer and sounded like this: “More practice!”.

Since the course was originally conceived as practical, and everything in it, as it seemed to me, is aimed at practical work, at the first moment I was confused. Even more practice could be achieved only in two ways.

The first is to bring all students to our Skyforge project and plant a server to write. I seriously did not consider such an option, of course, but it exactly corresponded to the new directive. I don’t know with what expression the project managers would look at me, if I came to them with a similar proposal, but it was fascinating to dream. Fortunately, I had a fallback.

I decided to change the course so that it, in addition to knowledge of writing a server in Java, contained more elements of the game in a game development startup. Practice orientation of this add-on seems to me obvious, and proximity to the “combat” conditions - too. I want to tell you about the beginning of this experiment.
Before proceeding directly to the description of changes in the curriculum and the first results, I would like to say a few words about the course and Technopark once again.
')
“In-depth Java programming” is the second semester course of Technopark . Students who successfully complete the first (of four) semesters of the program are admitted to the course. As part of the program, we are studying the server architecture of a browser game written in Java. Most of the students before this course have not studied the Java platform and do not have experience writing applications on it.

The course aims to write a scalable modular application. Server modules include work with the file system, database, web server (on Jetty) and game mechanics. All this lives in several streams and exchanges messages. All lecture materials are selected to serve as a foundation for practical work. We do not use JavaEE and work independently with threads and JDBC for educational purposes. To know how it works inside, and not just build a program from ready-made modules. The only exception is Jetty, so as not to begin your acquaintance with Java by writing your own web server. Read more about how the course was this spring, I wrote in my previous article .

Being inherently academic, the course “Advanced Java Programming” could not contain frontend development materials at all. But without this, its value, as well as the interest of students in it, would have been significantly lower. Writing a server without the ability to access it by a client is an exercise similar to developing a spherical horse in a vacuum. Therefore, we devote the first 2-3 lessons to setting up tools and developing a blank for the frontend.

A full-fledged work on the front-end of the game can be started only if you already know what game you will be writing. Ideally, it needs not only programmers, but also artists and designers. I cannot equip students with everything necessary for a full-fledged front end. This part of the project is more at their discretion.

So back to the motto “More practice!”. To get away from academicity towards greater practical value, I decided:
  1. strengthen the frontend part
  2. use more project management tools
  3. allow students to form groups themselves
  4. emulate intermediate control "investor acceptance".

Now more about each item.
The two previous semesters I started with a very simplified frontend part. For its delivery it was enough to download the Jetty library, connect to the project and write a successor from AbstractHandler (as in the basic example from the authors of the library). And send to the browser a page with a form containing the user session id created by the server, and a javascript that will post this form to the server once a second. Thus, we emulated communication between the server and the client.

From the point of view of server development, that was enough. The students themselves could push off and expand the capabilities of the system using servlets, http sessions, templating and ajax. Some have coped with this, some have not. I did not evaluate the richness of the frontend at the exam, everything was kept only on enthusiasm.

To achieve this new goal was clearly not enough. Therefore, we decided that it would be mandatory for everyone to use servlets, the HttpSession, and the mechanism of “giving away” static. In addition, we decided to use the library to generate pages. Fortunately for us, in the same semester, students had a front-end development course and for everyone who studies the “Java server”, it is not a problem to write asynchronous requests from the browser to the server.

As a result, at the first control lesson, almost all students had a server hooked to localhost: 8080, which returned index.html with a picture, a request to fill in a username and password (for the first time, all logs were hardcoded: o). In the case of a successful login, a transition was made to a page that regularly and asynchronously requested its area with the output of server time, greeting the logged in user, his userId and sessionId.

Of course, this is also not a gaming front-end, but, as it seems to me now, this example can be extended using the code already written as the basis. As far as I can imagine, the most valuable thing in our time is keywords. Knowing the names of libraries and technologies, anyone will be able to find a detailed description with examples and realize their plans with the help of someone already tested solutions. I repeat once again that the detailed development of the frontend is not included in the course, and if students want not just a server with a stub, but a server with a full-fledged website, then they should solve this problem on their own.

Now more about the tools. We have chosen IntelliJIDEA Community Edition as the IDE for this semester. To manage the build and external dependencies - maven. By this, we immediately achieved two goals - facilitated the process of downloading and connecting libraries and gave students the opportunity to master popular tools.

Students mastered the new development environment quickly, the “speed” of the Internet at MSTU was enough for maven to download the necessary libraries in minutes.

But, as it seems to me, the most significant and successful innovation was the use of github.com to host the source codes of projects. Before that we tried to raise our git, then our svn, but it turned out not very convenient and required a lot of manual configuration. This time we decided not to reinvent the wheel, but to use it ready.

Work on the practical task of the course is in groups of 3-4 people. Each group got an open repo on github. In addition, I reanimated my old account and put on it examples for classes and presentations. Now students can watch my materials, and I can follow the change of their codes. And again, there are two benefits from this solution: the ease of development and the study of popular tools.

Of course, when I offered to keep everything in open repos, they told me: "... after all, everyone will see our code !!!! 111". Yes, they will. And, as it seems to me, this is wonderful. Moreover, if you write a code that someone will watch and understand it, then this is your victory. And the one who can understand a strange example and on the basis of it write his own is a hero worthy of an excellent assessment.


My and student repos

One of the tasks of Technopark is to prepare students for work in a team. Very rarely does a new employee come to a team that already has friends and acquaintances. In order to emulate joining a team, we in previous semesters united students into groups ourselves.
This time we decided to do it differently, and I began the first lesson of the course with a proposal: “Imagine that you had a brilliant idea to create your own startup. And you decided to start writing browser games with your friends. ” As a result, at the very first lesson, 32 students united in 9 groups.


Teamwork Example

It is too early to talk about the benefits of this innovation, because we have excluded the training of the skill of coordinating work with strangers. But they definitely won in enthusiasm.

According to the rules of Technopark, knowledge is controlled not only at the exam at the end of the semester, but also at several intermediate exams. We have already conducted one of them. To get the maximum score, you had to upload your github code to my laptop connected to the projector, put together a project, show everyone how it works, and tell about the code.

The idea of ​​demonstrating the work of the application on the "hardware of the customer" has been very fruitful. Two of the projects prepared for delivery refused to run the first time. One did not work the way the authors planned. The argument “but everything is fine on my computer” I did not consider. Especially the delight delivered : “And now let's see how all this will look in Internet Explorer.”

Total. What is a lot of practice in the educational process? I answered this question for myself: this is an opportunity to try development in conditions close to production, solving problems similar to real ones, and using tools that are used for commercial development. We have already tested the first part of this formula (“tasks similar to real ones”). In this semester, we will try the second part.

After the publication of the previous article on the course in Technopark, I received many comments with the question: “Where can I see the course materials?” We recorded the course in SCORM format and now it can be found in the National Open University Intuit . Here is the video course "Advanced Java Programming." Examples of code that I talked about can be found on github .

Vitaly Chibrikov,
Allods team

Source: https://habr.com/ru/post/197902/


All Articles