maintainability

Using Named Immediately-Invoked Function Expression (IIFE) instead of comments

家住魔仙堡 提交于 2019-11-29 18:28:30
问题 What are the pros and cons of utilizing Named IIFEs within JS code to describe and group related code? I've been using this "pattern" to lend structure to my more procedural code that gets executed only in one place. Example (function hideStuffOnInstantiaton(){ $('oneThing').hide().removeClass(); $('#somethign_else').slideUp(); $('.foo').fadeOut(); }()); I find this preferable to both: // hide Stuff on Instantiaton $('oneThing').hide().removeClass(); $('#somethign_else').slideUp(); $('.foo')

Best pattern for Constants in SQL?

纵然是瞬间 提交于 2019-11-28 23:46:21
I have seen several patterns used to 'overcome' the lack of constants in SQL Server, but none of them seem to satisfy both performance and readability / maintainability concerns. In the below example, assuming that we have an integral 'status' classification on our table, the options seem to be: Just to hard code it, and possibly just 'comment' the status -- StatusId 87 = Loaded SELECT ... FROM [Table] WHERE StatusId = 87; Using a lookup table for states, and then joining to this table so that the WHERE clause references the friendly name. SubQuery: SELECT ... FROM [Table] WHERE StatusId =

Array of objects vs Object of Objects

百般思念 提交于 2019-11-28 22:18:57
The issue is to decided the trade offs between following notations: JSON based : "users": { "id1": { "id": "id1", "firstname": "firstname1", "lastname": "lastname1" }, "id2": { "id": "id2", "firstaame": "firstname2", "lastname": "lastname2" } } Array Based : users: [ { "id": "id", "key2": "value2", "key3": "value3" }, { "id": "id", "key2": "value2", "key3": "value3" } ] Relating to this post on the same issue, I have decided (on front end) to use the JSON object notation instead of array of objects as it suits my requirements and better performance and less code in the browser. But the problem

Maintaining both free and pro versions of an application

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 17:05:27
I want to create a PRO version of my application for Android and was wondering how to structure my repository. For know I have a trunk and feature branches. I'd like to put a pro version in another branch but maybe there is a better way? For example, maybe I should create two branches - one for free version, the other for pro? Pro version will have additional features and will be ads-free, so eg. I don't want to include AdMob libraries in the pro version. Do you have any experience or suggestions as to what would be the best way to structure the repository in this case? EDIT: I think I've

Simplify Overriding Equals(), GetHashCode() in C# for Better Maintainability

心不动则不痛 提交于 2019-11-28 12:07:49
I find my self overriding Equals() and GetHashCode() frequently to implement the semantic that business objects with identical property values are equal. That leads to code that is repetitive to write and fragile to maintain (property gets added and one/both of the overrides are not updated). The code ends up looking something like this (comments on the implementation are welcome): public override bool Equals(object obj) { if (object.ReferenceEquals(this, obj)) return true; MyDerived other = obj as MyDerived; if (other == null) return false; bool baseEquals = base.Equals((MyBase)other); return

Angular directives - element or attribute?

时光总嘲笑我的痴心妄想 提交于 2019-11-28 06:25:47
I'm part of a team with about 6 UI devs, of varying quality and next to no Angular experience. Many are contractors, with little experience with the code base. The app has a very fancy (complicated) UI. It supports IE8+ (soon hopefully IE9+). We're introducing Angular for a major extension to the app, and I've been asked to write guidelines on the use of Angular for the team. We'll use directives to create fancy UI elements, all prefixed with "ipwr" to avoid name clashes. I'm trying to decide whether to mandate that devs give their directives the restriction "element" or "attribute". Mandating

What's the cleanest way to write a multiline string in JavaScript? [duplicate]

你说的曾经没有我的故事 提交于 2019-11-27 21:51:04
This question already has an answer here: Creating multiline strings in JavaScript 37 answers It doesn't really have to add newlines, just something readable. Anything better than this? str = "line 1" + "line 2" + "line 3"; Almost identical to NickFitz's answer: var str = ["" ,"line 1" ,"line 2" ,"line 3" ].join(""); // str will contain "line1line2line3" The difference, the code is slightly more maintainable because the lines can be re-ordered without regard to where the commas are. No syntax errors. I like this version (different than yours just in formatting of the code): var str = "line 1"

Best pattern for Constants in SQL?

柔情痞子 提交于 2019-11-27 15:03:46
问题 I have seen several patterns used to 'overcome' the lack of constants in SQL Server, but none of them seem to satisfy both performance and readability / maintainability concerns. In the below example, assuming that we have an integral 'status' classification on our table, the options seem to be: Just to hard code it, and possibly just 'comment' the status -- StatusId 87 = Loaded SELECT ... FROM [Table] WHERE StatusId = 87; Using a lookup table for states, and then joining to this table so

Simplify Overriding Equals(), GetHashCode() in C# for Better Maintainability

不打扰是莪最后的温柔 提交于 2019-11-27 06:48:19
问题 I find my self overriding Equals() and GetHashCode() frequently to implement the semantic that business objects with identical property values are equal. That leads to code that is repetitive to write and fragile to maintain (property gets added and one/both of the overrides are not updated). The code ends up looking something like this (comments on the implementation are welcome): public override bool Equals(object obj) { if (object.ReferenceEquals(this, obj)) return true; MyDerived other =

What should we do to prepare for 2038?

三世轮回 提交于 2019-11-26 22:05:43
I would like to think that some of the software I'm writing today will be used in 30 years. But I am also aware that a lot of it is based upon the UNIX tradition of exposing time as the number of seconds since 1970. #include <stdio.h> #include <time.h> #include <limits.h> void print(time_t rt) { struct tm * t = gmtime(&rt); puts(asctime(t)); } int main() { print(0); print(time(0)); print(LONG_MAX); print(LONG_MAX+1); } Execution results in: Thu Jan 1 00:00:00 1970 Sat Aug 30 18:37:08 2008 Tue Jan 19 03:14:07 2038 Fri Dec 13 20:45:52 1901 The functions ctime(), gmtime(), and localtime() all