Questions for best practices for writing high quality code.
2
votes
1answer
79 views
What does the “4” in LCOM4 mean?
I know that methods in a class should have high cohesion which roughly translates to having all the methods use all the instance variables directly or indirectly. I know that LCOM4 (Lack of ...
2
votes
2answers
83 views
Strategies for using a code metric evaluation tool
Should code quality metric evaluation tools like Sonar be integrated with IDE for running local analysis or should they be a part of the build process (like integrated with maven) for continuous ...
-1
votes
1answer
51 views
Code network metrics with UI events [closed]
There is a large body of literature regarding using network metrics (e.g. degree) for predicting defects. Something I'm running into is that a lot of my code is event-driven, so I have a large number ...
36
votes
8answers
1k views
What's the right balance between code consistency and code improvement?
Recently I had a discussion with a colleague regarding code style. He was arguing that your usage of APIs and the general patterns you are using should be as similar as possible with the surrounding ...
4
votes
2answers
397 views
How do I handle having so many SQL queries?
I have an MVC3 project that uses SQL Server.
I use data from the SQL database all the time and I often find that I'm reusing/duplicating some SQL queries. I thought I'd solve this problem by creating ...
0
votes
2answers
121 views
Code review practice in medium team [closed]
I'm looking for a way to organize code review process.
My inputs:
4-5 members in the team;
SVN/IntelliJ IDEA Community Edition.
Solution criteria:
Should support human review with ...
3
votes
5answers
232 views
Obsessed with finding most elegant solution [duplicate]
I find that at times I get obsessed with finding the most elegant solution to a problem or task.
I'll spend hours trawling the internet/texts for ideas and discussion on the right way to solve a ...
4
votes
1answer
103 views
Is there a modern replacement for a mutation testing tool like Jester for Java?
“Why just think your tests are good when you can know for sure?
Sometimes Jester tells me my tests are airtight, but sometimes the
changes it finds come as a bolt out of the blue. Highly ...
-1
votes
0answers
12 views
Fastest way to search for keywords in a array in Python? [migrated]
In Python, I have read in a file and am searching through it for a set of words.
I have the below test code which shows the fastest (so far) is set.intersection().
The question is, Are there other ...
16
votes
4answers
1k views
Why is test driven development missing from Joel's Test?
I was reading this blog by Joel Spolsky about 12 steps to better code. The absence of Test Driven Development really surprised me. So I want to throw the question to the Gurus. Is TDD not really worth ...
2
votes
1answer
121 views
Understanding high cohesion principle for methods in object oriented design
I know the idea of strong cohesion applies to methods as much it applies to classes. Just to be clear when I say strong cohesion of a method I mean a method which does only one task and does it well. ...
7
votes
2answers
359 views
How to deal with too much pragmatism in the project?
My team and I took over a medium sized codebase over a year ago when the previous tech lead left the company. Originating from the lack of man power I fear we favored pragmatic solutions over best ...
3
votes
4answers
419 views
What can I do to maintain respect for a poorly written codebase? [duplicate]
In my job I have to maintain a poorly written codebase which is both hard to understand, has tons of comments that are just plain wrong, has a bunch of weird decisionmaking going on in it and a whole ...
6
votes
3answers
125 views
Why would each widget need a reference to its parent in a simple widget system?
I'm working on a simple widget system (single window, fixed size). Each widget gets its parent (i.e. the widget containing it) passed into its constructor - except for the root widget, which I called ...
4
votes
2answers
196 views
code review with git-flow and github
With regular git and github I can do a code review by simply creating a pull request of the feature branch I'm working on to the master branch. How would I do code reviews with git-flow? With workflow ...
5
votes
1answer
172 views
Are there any empirical studies about the effects of commenting source code on software quality, maintainability and developer productivity?
I am an advocate of commenting on source code and documenting software products. It is my personal experience and observation that working on source code that is rigorously commented has helped me in ...
1
vote
3answers
323 views
Legitimate reasons for circular references in C++
I have project written in C++ that I am working on which has a parent-child relationship where each child has only one parent. I had previously decided after looking at this post that I would make the ...
-1
votes
3answers
131 views
Programming task to test for focus on maintainability [closed]
I am looking for a programming task, which shows whether the coder has maintainability in mind while programming. I imagine giving a task to fix a bug in a method. It should be clear to the programmer ...
1
vote
2answers
83 views
@Deprecated as of version x.y in JavaDoc
This question & its answers are useful but not sufficient for my problem.
My Question is if I want to add a javadoc as @Deprecated As of version x.y, replaced by {@link SomeClass} in my current ...
35
votes
15answers
3k views
How important is it to reduce the number of lines in code?
I am a Software developer who works on J2SE (core java).
Often during our code reviews we are asked to reduce the number of lines in our code.
It's not about removing redundant code, it's about ...
3
votes
4answers
264 views
Declaring functions in order to avoid explicit nested loops
My programming professor has told me that it is a good programming practice (at least in C/C++) to declare a function with the inner loop when nesting loops (not for loops, since when, i.e. looping ...
5
votes
3answers
301 views
Is 'using' appropriate in a context where there is nothing to dispose?
In C#, using statement is used to dispose in a deterministic manner the resources without waiting for garbage collector. For example, it may be used to:
Dispose SQL commands or connections,
Close ...
16
votes
5answers
959 views
Descriptive naming vs. 80 character lines [closed]
I frequently hear these two valuable programming practices: (1) lines of code should be 80 characters or less and (2) use descriptive names for variables, methods, classes, etc. I understand the ...
4
votes
7answers
403 views
Should I spend time prettifying unit tests? [closed]
The company I used to work for before we had automated unit tests to test our work. However the coding standards and architecture was not very important for tests. Of course you had to indent code ...
3
votes
1answer
203 views
Why Doesn't Java Allow Default Parameters/Arguments [closed]
Basically something like
public void jumpToRoom(String roomName = Rooms.DEFAULT_ROOM)
would be convenient.
Many languages nowadays seem to support it (Ruby, PHP, even C#).
What is Java's ...
55
votes
8answers
3k views
Recursion or while loops
I was reading about some development interview practices, specifically about the technical questions and tests asked at interviews and I've stumbled quite a few times over sayings of the genre "Ok you ...
8
votes
6answers
334 views
Is looking at random code snippets useful to quickly determine the quality of a project?
To get an idea of the quality of a project that I've never seen before (usually open source projects that I'm considering whether or not to use), I often start by opening random files and eyeballing ...
7
votes
5answers
806 views
Is code duplication a necessary evil in C?
I'm rather new to C, and I'm wondering if code duplication is a necessary evil when it comes to writing common data structures and C in general?
I could try to write a generic implementation for a ...
6
votes
5answers
353 views
Is a coder that 'quality checks' bug fixes and bugs raised by testers a recognised role?
I've recently found myself frequently in the position where I'm checking both bug fixes by other programmers, and bugs raised by the QA team.
Any bug fixes frequently end up having 'collateral ...
5
votes
2answers
180 views
what tools should I use for quality assurance and testing for front end javascript? [closed]
I am using jquery and HTML 5 techniques (like File API, HistoryAPI) extensively in a project I am working on.
I was wondering what tools I can use for
quality assurance my javascript and front ...
7
votes
6answers
356 views
what is the best way to ensure accountability in code checkins?
Note: after writing this I realize that this question is perhaps philosophical, but I'm interested in how the industry handles this scenario regardless.
I have recently been working with a code base ...
9
votes
5answers
320 views
Is adhering to one assert per test foolish consistency in this case?
I have a class that I'm testing. The class has a function: apply(List<IRule> rules, List<ITarget> targets);
In one test I want to ensure that each target has been passed to one rule, a ...
0
votes
2answers
135 views
Store image as logic file (in db by using binary format) or physical file (in the server) [duplicate]
Possible Duplicate:
what are the best tips for storing images in a database?
In those study cases of image storage,
An image that change only once in a while, if it changes at all (like ...
8
votes
8answers
716 views
How to evaluate code quality when you're not familiar with the language?
As a hypothetical, if I were to interview someone for a new PHP developer position when my experience is in .NET, how can I determine if the code sample they've provided me is efficient and of good ...
8
votes
5answers
524 views
Which is more maintainable — boolean assignment via if/else or boolean expression?
Which would be considered more maintainable?
if (a == b) c = true; else c = false;
or
c = (a == b);
I've tried looking in Code Complete, but can't find an answer.
I think the first is more ...
5
votes
3answers
424 views
At what point/range is a code file too big?
I'm finding lots of 2-3k line files, and it doesn't really feel like they should be that big.
What is a good criteria to objectively call a source code file "too big"?, is there such thing as a ...
1
vote
3answers
260 views
Programming language features that help to catch bugs early [closed]
Do you know any programming language features that help to detect bugs early in the software development process - ideally at compile-time or else as early as possible at run-time?
Examples of ...
45
votes
9answers
2k views
When does “proper” programming no longer matter?
I've been building an android game in my spare time. It's using the libgdx library so quite a bit of the heavy lifting is done for me.
While developing, I carelessly selected datatypes for some ...
3
votes
4answers
337 views
Duplication of code (backend and javascript - knockout)
We have a new developer on our team. He seems to be a smart guy (he just came in so I cannot really judge). He started with implementing some small enhancements on the project (MVC3 web application ...
2
votes
4answers
283 views
Can notes/to-dos in code comments sent to code-reviews result in an effective refactoring process?
I want to start/improve a culture of collective code ownership at my company but at a geographically distributed level... I'd say there is some current collective code-ownership mentality, but only at ...
20
votes
5answers
1k views
What is the politically correct way of refactoring other's code?
I'm currently working in a geographically distributed team in a big company. Everybody is just focused on today's tasks and getting things done, however this means sometimes things have to be done the ...
13
votes
2answers
577 views
What is the best approach for inline code comments?
We are doing some refactoring to a 20 years old legacy codebase, and I'm having a discussion with my colleague about the comments format in the code (plsql, java).
There is no a default format for ...
4
votes
1answer
73 views
Statistical Software Quality Control References
I'm looking for references about hypothesis testing in software management. For example, we might wonder whether "crunch time" leads to an increase in defect rate - this is a surprisingly difficult ...
6
votes
7answers
497 views
How to write good code with new stuff? [closed]
I always try to write easily readable code that is well structured.
I face a particular problem when I am messing around with something new. I keep changing the code, structure and so many other ...
20
votes
8answers
1k views
Should comments say WHY the program is doing what it is doing? (opinion on a dictum by the inventor of Forth)
The often provocative Chuck Moore (inventor of the Forth language) gave the following advice (paraphrasing):
"Use comments sparingly. Programs are self-documenting, with a
modicum of help from ...
23
votes
10answers
2k views
Are flag variables an absolute evil?
I remember doing a couple of projects where I totally neglected using flags and ended up with better architecture/code; however, it is a common practice in other projects I work at, and when code ...
7
votes
4answers
293 views
How can you get constructive criticism for your code?
My team rarely does code review, mainly because we don't have enough time and people lack the energy and will to do so. But I would really like to know what people think about my code when they read ...
4
votes
1answer
201 views
Distinguishing repetitive code with the same implementation
Given this sample code
import java.util.ArrayList;
import blackjack.model.items.Card;
public class BlackJackPlayer extends Player {
private double bet;
private Hand hand01 = new Hand();
...
6
votes
6answers
426 views
Should we exclude code for the code coverage analysis?
I'm working on several applications, mainly legacy ones.
Currently, their code coverage is quite low: generally between 10 and 50%.
Since several weeks, we have recurrent discussions with the ...
3
votes
4answers
367 views
Reusable VS clean code - where's the balance?
Let's say I have a data model for a blog posts and have two use-cases of that model - getting all blogposts and getting only blogposts which were written by specific author.
There are basically two ...