code-maintainability

JQuery class selector vs id selector

泄露秘密 提交于 2019-11-29 06:11:54
I have 7 different buttons that all perform the same javascript function on click. should i use class selector or id selector. $("input.printing").on("click", function(event) { printPdf(event); }); or $("#package1Pdf").click(function(event) { printPdf(event); }); $("#package2Pdf").click(function(event) { printPdf(event); }); $("#package3Pdf").click(function(event) { printPdf(event); }); $("#package4Pdf").click(function(event) { printPdf(event); }); What are the advantage and disadvantage of each? Which is more preferred. BinaryTox1n You can use an ID filter without multiple selectors: $('[id^=

Is 100% code coverage a really good thing when doing unit tests? [closed]

与世无争的帅哥 提交于 2019-11-28 21:01:22
问题 I always learned that doing maximum code coverage with unit tests is good . I also hear developers from big companies such as Microsoft saying that they write more lines of testing code than the executable code itself. Now, is it really great? Doesn't it seem sometimes like a complete loss of time which has an only effect to making maintenance more difficult ? For example, let's say I have a method DisplayBooks() which populates a list of books from a database. The product requirements tell

Too many if statements

送分小仙女□ 提交于 2019-11-27 23:07:32
I have some topic to discuss. I have a fragment of code with 24 if s/ elif s. Operation is my own class that represents functionality similar to Enum . Here is a fragment of code: if operation == Operation.START: strategy = strategy_objects.StartObject() elif operation == Operation.STOP: strategy = strategy_objects.StopObject() elif operation == Operation.STATUS: strategy = strategy_objects.StatusObject() (...) I have concerns from readability point of view. Is is better to change it into 24 classes and use polymorphism ? I am not convinced that it will make my code maintainable... From one

Who wrote this programing saying? “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” [closed]

*爱你&永不变心* 提交于 2019-11-26 11:04:50
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. I found this at somebody's blog, and it introduces as Rick Osborne's. But I google this, and other people says: Martin Golding's, John Woods' and Damian Conway's... Yes, Damian Conway used this quote in " Perl Best Practices " (2005) but Damian doesn't mention who wrote it. Does anybody know who the real author of this aphorism is? I thought ChrisW's research was right, and I tried to confirm it by doing the same thing. I found John Woods' name in 1991 in this thread: Usage of

Who wrote this programing saying? “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” [closed]

泪湿孤枕 提交于 2019-11-26 03:27:40
问题 Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. I found this at somebody\'s blog, and it introduces as Rick Osborne\'s. But I google this, and other people says: Martin Golding\'s, John Woods\' and Damian Conway\'s... Yes, Damian Conway used this quote in \"Perl Best Practices\" (2005) but Damian doesn\'t mention who wrote it. Does anybody know who the real author of this aphorism is? 回答1: I thought ChrisW's research was right