Sign in
Log inSign up

Should I avoid nest code as much as possible?

Đăng Tú's photo
Đăng Tú
·Oct 4, 2018

Yes

44%

No

13%

Depend (name one, or two...)

44%

16 votes · Closed

Pretending I have a code like this:
(Yes, it is my code. But let just never mind its function)

// Triple nest!!!
class DB
{
    static fetch(db, getRecord)
    {
        for (var i = 0; i < db.length; i++)
        {
            getRecord(db[i]);
        }
    }
}

Is it readable to you guy? Should I avoid nest of code? Does it take long time to compile and cost a lot computer (CPU) resource?