Questions tagged [code-quality]

Questions for best practices for writing high quality code.

Filter by
Sorted by
Tagged with
-1 votes
1 answer
2k views

HP openview servicedesk: looking for api information ? [closed]

Good day folks. I am very confused in this situation. I need to implement system which will be based on HP open view service desk 4.5 api. But this system are reached the end of supporting period. On ...
Dmitry Zagorulkin's user avatar
22 votes
9 answers
4k views

Are too many assertions code smell?

I've really fallen in love with unit testing and TDD - I am test infected. However, unit testing is normally used for public methods. Sometimes though I do have to test some assumptions-assertions ...
Flo's user avatar
  • 1,231
4 votes
6 answers
10k views

Setters or constructor for many variables? [duplicate]

Possible Duplicate: Are there guidelines on how many parameters a function should accept? I have got class with 30 variables (it is an application form), so I wonder what is the best practice to ...
Dracontis's user avatar
  • 211
31 votes
13 answers
14k views

Is 100% code coverage a pipe dream?

Is it feasible to expect 100% code coverage in heavy jquery/backbonejs web applications? Is it reasonable to fail a sprint due to 100% coverage not being met when actual code coverage hovers around ...
willz's user avatar
  • 429
2 votes
5 answers
2k views

Is automatically checking code quality via metrics possible?

For several years now I am a big fan of using static code analysis tools for checking the source code quality. We are mostly doing C# development so NDepend was the best way to go for me. Most of the ...
ollifant's user avatar
  • 241
3 votes
4 answers
347 views

Create new variable or make multiple chained calls?

What is the best way to get this attributes, thinking in performance and code quality? Using chained calls: name = this.product.getStock().getItems().get(index).getName(); id = this.product....
Rodrigo's user avatar
  • 1,077
7 votes
9 answers
1k views

Review quality of code [duplicate]

I have been asked to quality review two code bases. I've never done anything like that, and need advice on how to perform it and report it. Background There are two providers of code, one in VB and ...
magol's user avatar
  • 201
26 votes
5 answers
14k views

Is it bad coding practice to create something in a get if it does not exist?

So I have a webservice that has something like a getAccount where it would return an identifier to the account if it got it, else throw an exception. The client will always want to create an account ...
Mike's user avatar
  • 363
6 votes
6 answers
958 views

How to deal with over-complication?

I often catch myself doing code unnecessarily complicated (sad but true). Is there any set of rules, discipline, etc to help avoid that? (excluding the KISS principle, because I know it but often ...
tika's user avatar
  • 716
5 votes
4 answers
39k views

how to nicely use constant std::string in c++

In my current code project, there is an awful lot of constant strings I use to print out error messages. Hardcoding such strings is generally considered to be bad practice. Now I'm searching for a "...
stefan's user avatar
  • 213
21 votes
4 answers
5k views

Experiments correlating code metrics to bug density

I'm wondering if someone has done some experiments correlating code metrics (SLOC, Cyclomatic Complexity, etc) with bug density in Object Oriented applications. I'm not looking for experiments that ...
Augusto's user avatar
  • 1,012
38 votes
10 answers
27k views

Passing member variable as a method parameter

In a project, I've found a code like this: class SomeClass { private SomeType _someField; public SomeType SomeField { get { return _someField; } set { _someField = value; ...
tika's user avatar
  • 716
31 votes
5 answers
5k views

Is use of finally clause for doing work after return bad style/dangerous?

As part of writing an Iterator, I found myself writing the following piece of code (stripping error handling) public T next() { try { return next; } finally { next = fetcher.fetchNext(...
bisgardo's user avatar
  • 413
10 votes
7 answers
18k views

What is the difference between Static code analysis and code review?

I just wanted to know what the difference is between static code analysis and code review. How are each of these two done? More specifically, what are the tools available today for code review/static ...
user avatar
354 votes
19 answers
64k views

How would you know if you've written readable and easily maintainable code? [closed]

How would one know if the code one has created is easily readable, understandable, and maintainable? Of course from the author's point of view, the code is readable and maintainable, because the ...
12 votes
5 answers
7k views

Is it OK to repeat code for unit tests?

I wrote some sorting algorithms for a class assignment and I also wrote a few tests to make sure the algorithms were implemented correctly. My tests are only like 10 lines long and there are 3 of ...
Pete's user avatar
  • 766
2 votes
2 answers
3k views

Any Code Review tool with direct connection to CVS? [closed]

I've found many Code Review tools: Phabricator (by Facebook) - http://phabricator.org/ Rietveld (by Google) - http://code.google.com/appengine/articles/rietveld.html GitHub - https://github.com/ ...
Radek Simko's user avatar
13 votes
4 answers
1k views

How should code "Goal Tending" be handled by a Development Manager?

First allow me to coin a term: code goal-tending: Checking out code in the morning, then silently reviewing all of the changes made by the other developers the previous day file by file, (...
Kevin McCormick's user avatar
26 votes
4 answers
10k views

Are there any negative side effects of splitting up large modules? [closed]

I was browsing a github project and found this module which has more than 10 thousand lines. Is it a common practice to have that much code in a single module? It seems to me that this should be ...
Mahmoud Hossam's user avatar
0 votes
3 answers
1k views

What code smell best describes this code? [closed]

Suppose you have this code in a class: private DataContext _context; public Customer[] GetCustomers() { GetContext(); return _context.Customers.ToArray(); } public Order[] GetOrders() { ...
Paul Stovell's user avatar
  • 1,709
5 votes
6 answers
450 views

How to set up a one-man research in the difference between BDD and Waterfall?

Earlier, I asked a question about how to measure the quality of a project. The outcome of that question was that the quality of the project can be divided into two parts: Internal quality (code ...
Martijn van der Maas's user avatar
7 votes
4 answers
478 views

What quality level in the commit history can/should I expect/enforce?

I worked as a lone developer for a long time. During this time, I developed a way of formulating and ordering commit messages: Refactor first, describe exactly the reason for the commit in the message,...
krlmlr's user avatar
  • 793
6 votes
5 answers
4k views

Is it a bad practice to use inline styling with generated code?

If I'm using a technology like Grails. It's really easy to wind up with inline styling. Are there any downsides to auto-generating code with inline styling? Is this considered bad practice? Why?
josh-cain's user avatar
  • 223
30 votes
3 answers
13k views

What is the name for the idiom using method chaining to build an object?

I frequently use a pattern where I using method chaining to setup an object, similar to a Builder or Prototype pattern, but not creating new objects with each method call, instead modifying the ...
Garrett Hall's user avatar
  • 2,202
14 votes
3 answers
16k views

Should a method do one thing and be good at it? [duplicate]

"Extract Till You Drop" is someting I've read in Uncle Bob's blog, meaning that a method should do one thing alone be good at it. What is that one thing? When should you stop extracting methods? ...
KyelJmD's user avatar
  • 981
15 votes
14 answers
5k views

how to find out if spelling mistakes in source code are a serious issue or not? [closed]

I find very troubling amount of spelling mistakes I see everyday in our codebase, from which I will reproduce a very short but representative example: ArgumnetCount Timeount Gor message from queue ...
Andrei G's user avatar
  • 1,127
6 votes
5 answers
542 views

Splitting 1 large object into 2 tightly-coupled ones - good, bad?

I have a complex object (call it BusinessLogic) which provides an RPC interface to semi-trusted users. The functions in the RPC interface have to decide which procedure to call, check authorisation ...
Kylotan's user avatar
  • 181
13 votes
6 answers
9k views

What is considered best practice for printing usage / help (--help)?

When writing tools for the CLI of UNIX, how should I make the program print out help and/or usage? I usually use fprintf(stderr, "help text here");, but there are several issues with that. First, I'...
polemon's user avatar
  • 337
-6 votes
4 answers
374 views

What are good strategies in C for dealing with pointer errors of this type? [closed]

In C, I often come across errors with code like this prio_queue->head[index] = newEntry; Yields a " "Cannot assign Entry** to Entry* " How do you prevent/debug errors of this type, in general?
Caffeinated's user avatar
3 votes
2 answers
350 views

How to go about bring up the topic of bad programming practices with colleague [duplicate]

Possible Duplicate: How do I approach a coworker about his or her code quality? My development colleague is producing numerous blocks of code which I am a bit concerned doesn't really make for ...
dreza's user avatar
  • 3,476
2 votes
2 answers
285 views

How do you handle minor change in source code causing discontinuity in version tree?

For instance, I have a file with poor indentation (at least incoherant with the rest of the project). If I correct the indentation and commit, there will be a serious change in the file at a certain ...
BenjaminB's user avatar
  • 1,706
73 votes
12 answers
20k views

How can I quantify the amount of technical debt that exists in a project?

Does anyone know if there is some kind of tool to put a number on technical debt of a code base, as a kind of code metric? If not, is anyone aware of an algorithm or set of heuristics for it? If ...
Erik Dietrich's user avatar
66 votes
16 answers
5k views

Do We Have a Responsiblity to Improve Old Code?

I was looking over some old code that I wrote. It works, but it's not great code. I know more now than I did at the time, so I could improve it. It's not a current project, but it's current, ...
11 votes
6 answers
1k views

Need to make my code more readable to the other programers in my team

I am working a project in delphi and I am creating a installer for the application, there are Three main parts. PostgreSQL installation/uninstallation myapplication ( setup of myapplication is ...
PresleyDias's user avatar
25 votes
9 answers
6k views

Adding complexity to remove duplicate code

I have several classes that all inherit from a generic base class. The base class contains a collection of several objects of type T. Each child class needs to be able to calculate interpolated ...
Phil's user avatar
  • 3,660
1 vote
2 answers
3k views

What are the things that you consider in reviewing an iOS source code? [closed]

We're going to do some peer reviews for our iOS projects. We're kind of inexperienced at reviewing each other's codes. The iOS developers attending the reviews will be from other projects, since ...
aslı's user avatar
  • 757
22 votes
6 answers
2k views

Keep it simple now, or program with the future in mind?

I'm currently coding a new application for my company that is rather involved. To meet the deadline, the functionality has been toned down quite a bit so that we can have something ready to go for ...
Tyanna's user avatar
  • 9,528
5 votes
2 answers
595 views

Are there any opensource APIs that help analyze code?

As an example, let's say that I need to check for a certain usage of C# code and warn the user that that is a bad pratice. There are multiple usages that I want to detect, such as: Resource not being ...
George Silva's user avatar
0 votes
5 answers
197 views

Automatic sorting of class/module members and its possible impact on productivity and code quality [closed]

Recently I saw some possibilities of some IDEs (via plugins) to sort members of their classes/modules based on some criteria, sou you could have everything sorted automaticaly no matter where you ...
Jarek's user avatar
  • 241
48 votes
11 answers
8k views

How do I approach a coworker about his or her code quality? [duplicate]

I work on a new venture at a large enterprise software company (3000+ programmers). In my group, we have a bunch of projects and people usually work on several projects over the course of a year. I ...
daveslab's user avatar
  • 737
5 votes
5 answers
3k views

Example bad code project to motivate refactoring / good design [closed]

This is sort of the opposite of https://softwareengineering.stackexchange.com/questions/121571/is-there-an-open-source-project-that-can-be-an-example-of-well-written-code. I am teaching software ...
Alex Lo's user avatar
  • 159
38 votes
10 answers
8k views

What does a code review look like? [duplicate]

I'm writing a code review process document for our team; we've never had a formal process in place although we do do some code review. I've found lots of articles talking about how important code ...
GendoIkari's user avatar
7 votes
10 answers
3k views

Overcome clumsiness in writing code

I believe this is a little related with this question: How to be a zero-bug programmer?. But I believe this is more regarding clumsiness in programming because I know it is impossible to become a zero ...
junxiong's user avatar
  • 175
48 votes
4 answers
57k views

Why is #include <iostream.h> bad?

I was reading another thread where a guy asked about C++ books for beginners, and one of the programmers answering wrote this: Some warnings: avoid all books that present an "hello world" stating ...
Daniel Scocco's user avatar
8 votes
4 answers
242 views

Advice/Approach for distilling homogenous code and building common code for a team

I work for the State of California. Our programming team in my opinion is not really a 'team' in that we usually work solo on projects throughout the application/systems complete life-cycle. The end ...
one.beat.consumer's user avatar
28 votes
8 answers
17k views

Keep my classes and methods as small as possible?

A few days ago, I was talking to a Software Engineering PhD candidate and at some point she said to me: Keep your classes and methods as small as possible And I wonder if this is always a good ...
Flo's user avatar
  • 1,231
2 votes
2 answers
539 views

SONAR and DesignForExtensionCheck Rule

When enabling SONAR on an in-house Java project, there are a large number of violations being reported due to the rule DesignForExtensionCheck. Whilst I agree with the theory that all classes/methods ...
Brad's user avatar
  • 121
2 votes
3 answers
328 views

in doubt of using code generators

I am now entering the world of java ee 6. And I am supposed to used different technologies like jsf, jpa, different kinds of beans and all that stuff. I am learning using the netbeans IDE, which is, ...
chip's user avatar
  • 239
13 votes
3 answers
7k views

How can I define and measure simplicity in code?

There are many answers in my previous question about simplicity relating to readability that helped me see my definition and understanding of simplicity in code was, quite possibly, incorrect. How ...
Richard's user avatar
  • 1,739
33 votes
16 answers
4k views

Does simplicity always improve Readability?

Recently, I was developing a set of coding standards for our company. (We're a new team branching out into a new language for the company.) On my first draft, I set the purpose of our coding ...
Richard's user avatar
  • 1,739

1
8 9
10
11 12
14