V
V
Vlad1612014-01-22 14:39:15
Java
Vlad161, 2014-01-22 14:39:15

A few words about my Java code

After a long study of practice, I decided to write a program in Java. So tell me, experienced programmers, what does my code look like? Comment on mistakes, shortcomings. And is my code similar to OOP? Link to github
And my couple of questions:
1) Is it normal that almost every method had to attribute throws IOException? Because compiler requires. Or is it better to make 1 method there to shove everything that requires IOException and other classes to inherit from it?
2) Because first experience, then of course I googled a couple of pieces of code. The server transfers the whole file, and the client writes it in pieces, is that right?
P.s. the essence of the program is to transfer files from the server to the client

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Pomogaev, 2014-01-22
@Foror

All close() methods - it's good practice to add this to try {we use inout resources} finally {close()}, this will ensure that resources are closed
pklServer() - should be refactored into the Client constructor, otherwise this is crooked and unsafe, well, or call it connect() and check that if the socket is already legal then throw an exception
System.exit(0); - this is usually not done (it’s very crooked to take it like this and abruptly terminate the entire system in a banal method), it’s better to throw an exception, something like FileNotFoundException (such a class is probably even in standard lib), and the one who will catch it will decide - beautifully process this exception or stupidly throw a stack trace on the console without processing

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question