Sergey Bylokhov

+ Follow
since Dec 21, 2009
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sergey Bylokhov

Yesterday after exactly 4 weeks I get my results for the test:

General Con: 100 91
Documentation: 70 70
OOD: 30 30
GUI: 40 31
Locking: 80 80
Data Store: 40 40
Network Server: 40 40
Total: 400 382

Really BIG thanks to Roel De Nijs and Roberto Perillo.

Write some info about my decisions later.

Thanks again for this amazing site!
10 years ago
Hello Everyone,
I aml preparing to the essay exams and get a small problem with providing adv and disadv for some choices.
For example in my choices.txt:
What you use RMI or sockets:
I used RMI because it is simply to understand.
And thats all. Why not? Its enough to answer the same questions on the essay exam with the same manner? Just because its simply?
Thanks Roel,
This is the same code which i used too.
Submit my program Try to take essay next week.
Hello Everyone.
Does somebody use setMinimumSize for the main application window?
I mean that if my windows below some size User cannot work with it.
Hello Everyone,

Wrote a lot of tests for may program and was bitten by this problem
Now i understand that I do not understand this

All text values, and all fields (which are text only), contain only 8 bit characters, null terminated if less than the maximum length for the field

What does it mean "null terminated if less than the maximum length for the field"??

For example i create a test which always fail in me Data class implementation

In error line i get an exception because I change all null fields to the empty String ("") befor save to the file And after save and reread field data changed
Probably its a bug? Its normal use case for creating or updating filed with null ?? Can i just throw an IAE in this situation?

Thanks for help

Hello Everyone,
Due some problems with assignments upload. I have a few additional days=)))

My DBMain interface have signature for unlock method

My Data class implement DBMain interface. And in Data implementation I do not throw RecordNotFoundException because its not necessary and I describe it in me choices.txt.
But i have a questions Should I change signature in the Data class to

Or should I set it the same DBMain.

Thanks for help.
Hello Everyone,
Probably this is my last questions because tomorrow my last day for submition my solution.=))

Have a quieston about utility class wich I created for converting Contrator class to-from String[6] and byte[]

This methods can be moved to the Contrator class(like Integer.valueOf(), etc) or can be stay at my ContratorConvertor(probably this is wrong name?) class in suncertify.util package;
Do you have any suggestions about it?

Thanks for any help.
Hello Everyone

Question about DTO object in the assignments, I create Contractor object and i have a few question about it:
1 recNo(record identifier) - is part of the Contractor object?
2 What is default values for dto objects? just empty strings?
3 DTO attributes recNo,name etc can be null ?


Roel De Nijs wrote:Hi Sergey,

According to your provided code samples you do understand my solution, because your code looks just fine. The data.setClientId(null); is not required (but I added them just to reset the value and add an extra validation: a client-id can't be overwritten by another client-id)

Kind regards,

Hi Roel,

Looks like i rewrite all the code which i show in the first post in this thread
But what about

Thanks for help again!!!

What about twice locking the same record by the same client. Can i throw IllegalStateException?

Roel De Nijs wrote:Hi Sergey,

How I can throw RecordNotFoundException from the find method?

For example when no record is matching the criteria (instead of returning an empty array or null).

Can I just write in javadoc its not necessary to unlock record after delete because it was unlocked inside delete method?

I used the search engine and someone had a similar question. Take a look here.

Kind regards,

Yes i know this approach when you extend sun interface and change only signature in this interface. But SUN try to test it in this way

Strange requirement=(
Hello Everyone,
I know that this theme was discussed early.

But i still do not understand how to implement this requirement:
My DBMain:

And i have this must option in assignment:

Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file.

All my methods has throws RecordNotFoundException; How I can throw RecordNotFoundException from the find method?

I was try to implement it but get strange results:
This code fails with RecordNotFoundException:

Can I just write in javadoc its not necessary to unlock record after delete because it was unlocked inside delete method?

Got a deadlock here because thread starting wait and there is no way to unlock it:

Can I lock one record twice from one client? In java doc i see only "Locks a record so that it can only be updated or deleted by this client."
there is no info about locking.

Thanks for help.

Roel De Nijs wrote:Hi Sergey,

According to your provided code samples you do understand my solution, because your code looks just fine.

Kind regards,

Hi Roel,Roberto
Thanks for your answers.
I look into it deeper (got code from Andrew's book) and think that Factory pattern more easy(do you know about disadvantages in this solution?).
But i still have a few questions about it:
1 Andrew in his book says that he do not want to make *Manager as a singleton but he make all field there as static. I look into this code and find this comments
* A structure that keeps track of the locked Dvd records. Note that we
* have not made this static, as doing so would mean that only one set
* of reservations could exist at any given time. We rely on the class
* which uses this ReservationManager to ensure that only one instance
* exists for any reservations.
private static Map<String, DvdDatabase> reservations
= new HashMap<String, DvdDatabase>();

In my implementation i made RecordLockManager and DataFileAccessManager as a singletons there is no static fields. Which uses only from my Data class.(I create Data objects for each network client).

2 What program should do if FileNotFoundException occured in RundomaAccessFile?(In this moment i wrap it in Data constructor and retrow DatabaseAccessException) But what next? should my application show the message and exit?

3 What should be done with InterruptedException in lock method? It should be retrow?

4 How to thow RecordNotFoundException in my lock,unlock,isLocked methods? Should I reimplement or just use read method before lock???
I mean some think like this(Note all methods in Data are synchronized)

5 What should do unlock method if the lock does not exists or if the lock exist but for another client?

6 What should be done if client lock the record and die after that?

7 What should be done with client if server die?

ps sorry for my english=)))


Roel De Nijs wrote:Hi Sergey,
Most important remark: Not using lock/unlock methods from the DBMain interface will result in automatic failure, because locking facility was implemented incorrectly (not according to the instructions and it is a must requirement).
Or you could use a unique client id (I used that one), more info about that could be found here.

Thanks for help Roel.
I replace ReadWriteLock in my business layer with my DBMain lock-unlock methods. But i still do not understand you solution with yours DB interface and setClientId() methods.

How I understand it:
On client side:

On the server side:

And in DB interface in each method: update,delete,read,lock,unlock i should check clientid
fo example(all methods synchronized):

map just store information about locks (CLIENT<-->RECNO)

So i should describe in my choice.txt that client of my class should implemented every methods in this way?:

How do you think can i use this approach in standalone mode too and just throw IllegalStateException if clientid == null?

Thanks for help again!!!
Hello Everyone,

First of all thanks for this forum.

Some information about my decisions:

I have a B&S assignments.
My DBMain looks like

So there is no information about client cookie.
The comments are:

Locks a record so that it can only be updated or deleted by this client.

How to ensure that only a particular client can perform a particular operation?
I want to avoid the entire challenge, and declare that I am only providing business logic methods to the client software - this is a valid design decision?

So I implement all my logic in bussness layer. I`ve got example here:

I have some questions:
1 Its normal that i aggregate DBMain in Services instead of inherit it?
2 I use ReadWriteLock instead of lock - unlock methods from my DBMain interface. It seems to me it works in my program. Is it ok?
3 As far i understand i must implement lock,unlock,delete,islocked methods even if i do not use it Because it can be checked by SUN. But how i can implement it with this requirement for lock method "Locks a record so that it can only be updated or deleted by this client." Do you have suggestions for it?