F
F
FastJony2020-08-18 13:47:50
C++ / C#
FastJony, 2020-08-18 13:47:50

Why is "the code quite hard to read" (test task)?

Sawing a test task for the position "Experienced C # Developer".

Task:
1. C# console application for block-by-block compression and decompression of files using "GzipStream".
2. We divide the source file into blocks of the same size, 1 meter each.
3. Each block is compressed and written to the output file independently of the other blocks.
4. The size of the files may exceed the size of the RAM.
5. Can be used: (Thread, Manual/AutoResetEvent, Monitor, Semaphor, Mutex)
6. Cannot be used: (async/await, ThreadPool, BackgroundWorker, TPL).
7. Start next. like this: GZipTest.exe compress/decompress [source file name] [output file name].
8. Archive format is not important, compliance with GZIP format is optional.

Decision:
https://yadi.sk/d/ZULN7SW1yWq6Tw

Why the solution is of poor quality (according to the reviewer):
1. The speed is good.
2. The code is quite hard to read.
3. For some reason, only a small part of the file remained after unpacking.

Question for experienced developers:
1. Looking at the project, is the code really unreadable?
2. Are there obvious jambs in it?
3. "only a small part of the file remained after unpacking"
- how much I tested, there were no problems. Does anyone see the jamb in the code?

I found the cant myself, thanks to everyone for the advice on the "beauty of the code" :*

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry Belyaev, 2020-08-18
@bingo347

First of all, I would mark the comments, it would be better if they didn’t exist than such ...
And okay, they are in Russian, but they tell what I should understand by reading the code.
A comment, if any, should answer not the question "what does the code do?", but the question "why is this code even needed here?". And if from the code itself it is not clear "what the code does" - then the code is bad.
Well, and so on trifles, like a single style and huge empty spaces ...

G
GavriKos, 2020-08-18
@GavriKos

Opened Main.cs. A bunch of incomprehensible indents. Some of the blocks under the condition are with curly braces, some are without. It's really hard to read. Some of the comments on the github even left the viewing area.

P
Peter, 2020-08-18
@petermzg

The code is readable, but it is clear that it was written by a beginner in programming.
From the simplest:

...
if ((uint)e.HResult == 0x80070002) actualException = "Ошибка : Не удается найти файл - " + ((FileNotFoundException)e).FileName + ".";
                        else if ((uint)e.HResult == 0x80070057) actualException = "Ошибка : Неверно задан путь к файлу или вы ссылаетесь на устройство нефайлового типа.";
                        else if ((uint)e.HResult == 0x80070003) actualException = "Ошибка : Неверно задан путь к файлу.";
                        else if ((uint)e.HResult == 0x80030003) actualException = "Ошибка : Неверно задан путь к файлу.";
...

What prevented:
1. use switch,
2. just write the text of the error and add "Error:" when outputting to the console

#
#, 2020-08-20
@mindtester

I found the cant myself, thanks to everyone for the advice on the "beauty of the code" :*
no no no .. where is the promised
PS. Who saws the same task, use: 3
return the turnip! .. or at least give me a copy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question