Errors that don’t make code behave wrong from user’s point of view – how would you call them?

var file_extension = 'txt';

if (file_extension === 'txt')
    alert('plain text');
else if (file_extension === 'md')
    alert('markdown');
var file_extension = 'txt';

if (file_extension === 'txt')
    alert('plain text');
if (file_extension === 'md')
    alert('markdown');

The second example is wrong: there is no need to use the second if. I would say the use of the second if is an error (since it should be else if instead), but this error doesn’t make the code behave wrong from the user’s point of view.

If you write documentation, how would you call such errors to differentiate them from those causing crashes, wrong messages, and so on?

5

Since there’s no unexpected or incorrect behavior, I’d consider it technical debt. It’s unclear why the code is the way it is, and this unclear structure can slow down the ability to maintain the system. This is a relatively simple example of technical debt, however.

1

Although everybody seems to believe that there is no problem with it, or no problem to worry about, I tend to disagree. Because this is about professionality.

First, as software developers we (should) strive for writing the best code we can. Even in this case, where the problem seems small, everybody will agree that this is not the best code possible – assumed “best” is defined in terms of

  1. correct
  2. performant
  3. maintainable

Second, even if the performance drop is minimal, one cannot decide without knowing the use case context whether it should be fixed sooner or later. If some piece of code is called a few thousand times in in a short time frame for some reason, every msec I can save per call will become seconds quickly. Last not least, if you are writing a library, one can’t even tell less, because you don’t know who is going to use it in which way and for what purpose.

Third, todays compilers do a lot of optimization work. New hardware we buy is usually faster than the old one. The average developer seems to use this as kind of an excuse. “Sure, my code is less efficient, but my brand new CPU can do it still faster than the old one, even without optimizations. So why bother?” Because the added hardware performance or the better compiler optimizations is not there for you to waste them! The idea is to get computations done quicker and with less resources, not as compensation for sloppy code.

As with everyhing, there are no fixed rules, because the mileage may vary with every piece of code and every project. But the OP just for thinking about it and asking that question he would deserve a double upvote.

PS: To qualify as an answer to the question: I’d call it “inefficient code”.

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật