Questions tagged [code-maintainability]

61 questions
180
votes
4 answers

Can I create a named default constraint in an add column statement in SQL Server?

In SQL Server, I have a new column on a table: ALTER TABLE t_tableName ADD newColumn NOT NULL This fails because I specify NOT NULL without specifying a default constraint. The table should not have a default constraint. To get around this, I…
GlennS
  • 4,490
  • 4
  • 23
  • 30
162
votes
2 answers

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."

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…
beatak
  • 8,376
  • 9
  • 30
  • 41
28
votes
8 answers

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

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?…
Arseni Mourzenko
  • 45,791
  • 28
  • 101
  • 185
13
votes
5 answers

JQuery class selector vs id selector

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 …
Chun ping Wang
  • 3,619
  • 12
  • 39
  • 53
12
votes
6 answers

Too many if statements

I have some topic to discuss. I have a fragment of code with 24 ifs/elifs. Operation is my own class that represents functionality similar to Enum. Here is a fragment of code: if operation == Operation.START: strategy =…
9
votes
2 answers

MySQL Database design - Storing Images - Single table or multiple tables

I am currently working in a product where different types of images like product images, user profile pictures, logo etc. are there. I need a database with good query performance. I got two DB designs in mind. OPTION 1. - Storing all images in a…
7
votes
5 answers

java 1.5: Best practice to keep constants for column name of db tables?

Technology: - Java 1.5 or 1.6 - Hibernate 3.4 To avoid update of column name on multiple places on change of column name or tablename, i want to have a constant file for same. I have following queries? One possible solution is to maintain one…
Maddy.Shik
  • 6,241
  • 15
  • 62
  • 98
6
votes
3 answers

embedded software maintainability - configuration

I am developing a embedded software that is meant to run on two to three different family of micro controllers. For now we have makefiles that reads the configuration switches and does compilation. The process is getting more and more tedious for…
Kamath
  • 3,907
  • 5
  • 28
  • 52
4
votes
1 answer

Managing the list of workarounds in a long-lived project

We are creating a big project that will live and be improved for approximately 10 years. Already in our code base, there is a lot of code for specific browser incompatibilities, workarounds for different bugs in browsers, 3rd party tools and…
Mino
  • 785
  • 6
  • 13
4
votes
1 answer

What's the normal way of organising a header file in Objective-C?

I do start off organising my .h files with the best intentions but somehow they get disgustingly messy. Below is an example (which isn't that bad, but i've seen much worse!). I've tried grouping sections with #pragma mark but it seems to look even…
Jamie Chapman
  • 4,172
  • 5
  • 27
  • 47
4
votes
3 answers

Inputs for improving code debuggability apart from logs and error codes

Apart from error codes, error strings and logs, are there any other features which can be incorporated in the code to increase getting debug / trace information during code runtime which can help debug issues (or let us know what is going on) at…
Jay
  • 22,129
  • 23
  • 82
  • 131
4
votes
4 answers

How to implement and mantain multiple actionListener

Ok, I have one class (let's call it: MenuBarClass) that contain multiple Menu and MenuItem. I whant assign to every MenuItem an actionlistener, but.. instead of doing something like: menuitem_1.addActionListener(new ActionListener() { public void…
Andrea Rastelli
  • 577
  • 2
  • 10
  • 25
3
votes
1 answer

Does keeping cyclomatic complexity between 5-10 makes unit testing easier?

I'm planning to keep track of cyclomatic complexity for method and classes in between 5-10. Will it be easier to write unit tests if we keep it in that range? Does it help us write effective unit tests which can be valuable in long run? I know unit…
3
votes
3 answers

Using templates to avoid similar functions

Lets say I have 2 functions which perform the exact same operations on the arguments but use different sets of constants to do so. For an oversimplified example: int foo1(int x){ return 3+4*x } int foo2(int x){ return 6-4*x } In the real…
chessprogrammer
  • 708
  • 4
  • 11
3
votes
5 answers

Generic reflective helper method for equals and hashCode

I'm thinking about to create a reflective helper method for equals and hashCode. In case of equals the helper method looks over the reflection API to the fields of objectA and compares them with fields of objectB. In case of hashCode the helper…
eglobetrotter
  • 692
  • 4
  • 10
  • 23
1
2 3 4 5