code-quality

Quality of code, Dream Weaver Vs. Web studio

I built a site using webstudio 4.0, since I am a novice I figured this was an easy platform to get the job done. I recently had a more advanced programmer suggest that the code created in dream weaver would be far superior to that generated by web studio in regards to SEO. Is this true? ...

Groovy code analysis tool

Hi, Are there any good code analysis tools available for Groovy? I'm looking for something similar to FindBugs, PMD, CheckStyle, etc. I may even be able to use some of these tools directly if they work on Java byte code rather than source code. A feature that would be particularly useful is the ability to identify obsolete code, though ...

What's the point in hard coding values which may change?

Hi, When coding systems which use configuration information, it is always a best practice to soft code these on some medium like Xml so these values can be edited without recompiling the entire system. However, plenty of values like Urls are hard coded and these can change. What's the benefit in coding this way? This obviously reduces ...

is it a bad practice to declare objects as 'null'

So I just came back from a 'meting' about a fix that we had to do which would fix an issue we had in production. Before the code goes out, it has to be presented to all these bunch of people. hate it! Broken code (pseudo): SomeClassA object1 = null while loop { if (some condition){ // do something } else { objec...

When/how often to check whether object is null

I was writing some code and while unit testing I got a Null Pointer Exception...Now I'm wondering how often should we be checking that object is not null before doing get operations on it? For example, code was: HashMap paramMap = new HashMap(); getSqlMapClientTemplate().queryForObject("reexamination.isAuthorized", paramMap); return ((...

"Number line" style of comparisons

I recently read in Code Complete that the recommended way of handling expressions that involve numbers is to order them like a number line. The book has 2 examples: if ( (MIN_ELEMENTS <= i) && (i <= MAX_ELEMENTS) ) if ( (i < MIN_ELEMENTS) || (MAX_ELEMENTS < i ) ) With the first example showing that i is between the min and max elem...

Using Sparse to check C code

Does anyone have experience with Sparse? I seem unable to find any documentation, so the warnings and errors it produces are unclear to me. I tried checking the mailing list and man page but there really isn't much in either. For instance, I use INT_MAX in one of my files. This generates an error (undefined identifier) even though I #in...

Is fxcop a valuable/effective tool for improving code quality?

I have a large high quality c# framework codebase that I nevertheless want to try to improve. Is fxcop an effective tool for improving .NET frameworks? I know Microsoft uses the tool internally, but how do external users find it? Worthwhile? I already have a zillion lines of code and a well established style, can it be adapted to o...

Developers checking in non-conforming code

Consider a situation where a group of developers work independently(more or less) on projects. The dept. has a published standard to ensure code quality on issues like: no inline/embedded/dynamic SQL statements (hand coded by the developer) naming conventions more Question How would you set about enforcing the code quality rules? Ar...

Would you feel offended or upset if another developer ran a code beautifier on the code base?

I am working on a project which other developers work on. I would like the code to be standardized. I don't necessarily care what standard it is (K&R, GNU, 2 lines max, 1 line max, spacing between commas, etc..) just that it is consistent. I was thinking, that as a separate checkin, I could run a beautifier on the source code. What do ...

Is writing good code an asset or a liability? (maintenance contracts)

We all know that writing quality, well-factored code is an asset for code maintenance, ease of bug-fixing, and development of new features, but I would like to approach the subject from a different angle. If a piece of software is written well enough that it solves the client's problem(s) perfectly for their workflow, what is their ince...

JSLint: "Use the array literal notation []" for var os_map = {}

I don't understand why I get the error message when I run JSLint with a JavaScript file. I get the message var os_map = {}; Problem at line 28 character 36: Use the array literal notation []. if I run this code in JSLint. The options for the JSLint as the following. /*jslint onevar: true, browser: true, undef: true, nomen: true, eqeqeq...

Do I need to have meaningful names for loop control variables?

Code Complete book suggested, it is a good practice to use meaningful names for loop control variables. For example: for(int month=0; month < MONTHS_PER_YEAR; month++){ // processing } Instead of single letters for example for(int i=0; i < MONTHS_PER_YEAR; i++){ // processing } I follow this practice and use meanin...

How do you implement requirements traceability in practice?

I am currently examining the benefits and costs of introducing requirements traceability into the development process where I work. I can see the potential benefits to the stakeholders of traceability, but I'm unclear about how you can go about implementing the logistics to trace requirements back from code. Do you need to use special ...

Feedback on TOC Generation Code

Hi All I wrote a small code to generate ToC or Hierachical Bullets like one sees in a word document. Like the following set 1. 2 3 3.1 3.1.1 4 5 and so on so forth, the code is working but I am not happy with the code I have written, I would appreciate if you guys could shed some light on how I can improve my C# code. ...

'variable' was used before it was defined.

I am checking if a variable is defined or not, and if it is not defined explicitly I am going to define it by doing: if ( typeof(aVariable) == 'undefined' ) { var aVariable = value; } Because the variable is not defined JSLint warns that it is used before it is defined, and that is exactly what I want. What is the best practice to ...

Code quality criteria

Possible Duplicates: How do we define Code Quality? Software quality metrics What critera you use to determine quality of code? metrics or some other? ...

Is it worth creating a method if it is going to be called just from a single location?

A discussion I had today at work with one co worker. Is it worth creating a separate method, if it is going to be called just from a single location?. True, may be in the future you will have to call it from more places, but for the sake of the argument let's assume that it is known that it will never be called from any other place. If...

Why is bug count not a good measure of code quality?

Why is bug reports (unit testing, QA testing, etc.) not a good measure of code quality? And what is the best way to measure code quality? I believe code quality can be measured more during peer reviews rather than the number of bug reports during testing. Is this reasonable? UPDATE: Which quality metric should number of bug reports be ...

What's your worst bug that Findbugs found?

What's the trickiest bug that Findbugs (or similar static analysis tool) has found in your code that you wouldn't have caught without using such tools? Code snippets of offending code would be much appreciated. Has the effort from running such tools and dealing with the false positives been worth it or would alternative methods (code r...