I wrote this distructor one way, but the person who code reviewed it seems to think it's better and more readable the other way. I disagree. It's probably more a matter of preference, but what do you think...
RfPrinter::~RfPrinter()
{
if (!hub_.empty() && !name_.empty()) {
clearbuf(rfunitlock);
rul_hub = hub_;
rul_id = name_;
try {
read(rfunitlock);
clearbuf(rfunitlog);
rlog_hub = hub_;
rlog_id = name_;
rlog_indate = rul_date;
rlog_intime = rul_time;
GETTIME();
try {
read(rfunitlog);
rlog_outdate = date();
rlog_outtime = curtime;
write(rfunitlog);
} catch (nsr&) {
clearbuf(rfunitlog);
rlog_hub = hub_;
rlog_id = name_;
rlog_indate = date();
rlog_intime = curtime;
rlog_user = user();
rlog_outdate = rlog_indate;
rlog_outtime = curtime;
rlog_comm = "No IN-RECORD in Log.";
insert(rfunitlog);
}
rul_status = "Available";
rul_date = date();
rul_time = curtime;
write(rfunitlock);
} catch (nsr&) {
}
}
}
or...
RfPrinter::~RfPrinter()
{
if(hub_empty() || name_.empty())return;
clearbuf(rfunitlock);
rul_hub = hub_;
rul_id = name_;
try {
read(rfunitlock);
} catch (nsr&) {
return;
}
clearbuf(rfunitlog);
rlog_hub = hub_;
rlog_id = name_;
rlog_indate = rul_date;
rlog_intime = rul_time;
GETTIME();
try {
read(rfunitlog);
rlog_outdate = date();
rlog_outtime = curtime;
write(rfunitlog);
} catch (nsr&) {
clearbuf(rfunitlog);
rlog_hub = hub_;
rlog_id = name_;
rlog_indate = date();
rlog_intime = curtime;
rlog_user = user();
rlog_outdate = rlog_indate;
rlog_outtime = curtime;
rlog_comm = "No IN-RECORD in Log.";
insert(rfunitlog);
}
rul_status = "Available";
rul_date = date();
rul_time = curtime;
write(rfunitlock);
}
mostly i'd like thoughts on the single return vs the triple return.