[JAVA] To write a user-oriented program (1)

What is a user-oriented program?

The system is still up and running today. Well, how about it? If I log in and operate a certain screen, I don't get a response ... If that happens.

There may be several implications for this.

--The program has not been processed --DB unresponsive, error due to memory exhaustion --Web server stopped due to the above cause --Hosting service failure, maintenance

And the worst is the pattern that was caused by the program I wrote.

Let's be able to write a user-oriented program so that it does not happen. That way, the program I wrote will always be alive. You can maintain a system that pleases your users.

(Private) Good program 3-piece set

--Short number of program lines --Processing time is short --Memory usage is optimized First of all, if you are aware of these three things, it will be a program that will not die in operation. Also when code review and refactoring I think that having this perspective will make the program better.

Shorten the processing time

Use StringBuilder instead of String when concatenating characters

When stringing with String


String name = "Quokka";
name += "Wallaby";
name += "Mr";

At compile time


String name = new StringBuilder("Quokka").toString();
name += new StringBuilder(name).append("Wallaby").toString();
name += new StringBuilder(name).append("Mr").toString();

As you can see, each object is created in vain. In other words, memory usage will increase temporarily.

Suddenly out of memory

Our battle is about to begin ...! I'll let you continue next week.

Recommended Posts

To write a user-oriented program (1)
[Introduction to Java] How to write a Java program
How to write a ternary operator
I want to write a nice build.gradle
[Basic] How to write a Dockerfile Self-learning ②
I want to write a unit test!
A program that calculates factorials from 2 to 100
[SpringBoot] How to write a controller test
Rails: How to write a rake task nicely
[Rails] How to write when making a subquery
Write a dockerfile to start jupyter-lab on ubuntu
Write to a file using ShiftJIS-Read a file (Kotlin / JVM)
I want to simply write a repeating string
How to write Rails
Created a menu program
How to write dockerfile
How to write docker-compose
How to write Mockito
How to write migrationfile
How to launch another command in a Ruby program
Program to determine if it is a leap year
How to write a core mod in Minecraft Forge 1.15.2
Java program to resize a photo into a square with margins
[1st] RSpec beginners tried to write ModelSpec as a beginner
How to write a migration from Rails datetime type to date type
Bit Tetris (how to write)
How to write java comments
How to leave a comment
[Beginner] I made a program to sell cakes in Java
[Refactoring] How to write routing
Great poor (how to write)
Pass a variable to Scope.
[Note] How to write Dockerfile/docker-compose.yml
What is this? Discover how anyone can write a program
How to write Rails validation
How to write Rails seed
[Ruby] How to write blocks
How to write Rails routing
[ruby] Creating a program that responds only to specific conditions
How to insert a video
How to create a method
I tried to generate a C language program source from cURL
[Reading impression] "How to learn Rails, how to write a book, and how to teach"
I got stuck trying to write a where in clause in ActiveRecord
Let's write a code that is easy to maintain (Part 2) Name
Vuze plugin to write and enjoy
Ruby: I made a FizzBuzz program!
How to add columns to a table
Write a Reactive server with Micronaut
[Rails] Two ways to write form_with
Precautions when writing a program: Part 3
Try to make a simple callback
Preparing to create a Rails application
Studying Java # 6 (How to write blocks)
Send a pull request to GitHub
[Rails] How to write in Japanese
How to make a Java container
How to make a JDBC driver
Baseball ball count (how to write)
Rails on Tiles (how to write)
[Rails] How to write exception handling?