code-review

Python: How to refactor this simple list code?

I'm new to Python. Am I doing it right? The goal: Get a bunch of InCart objects from Google App Engine's datastore that corresponds to the current user. Each InCart item has two attributes: InCart.owner and InCart.item Provide the templating engine a set of items in any InCart.item The code: cartEntries = InCart.gql("WHERE ...

What is the best coding practice for if conditions?

Many years of coding have brought me to believe and try to reach this kind of if conditional coding: (demonstrated in C, but it's relevant almost to any language) if(a <= 0) return false; if(strlen(str) <= a) return false; if(str[a] == NULL) return false; return true; Which i think is much more readable than the ...

Code Review: How to stop programmers using specific namespaces / functionality

I am working on a project with ca. 20 developers. One thing we are finding is that it is difficult to keep up with code review. Somethings we automate, like checking code complexity, finding empty catch blocks etc. Other things are a bit more difficult. For example in our case no data should be stored in session state. Is it possible...

Make sure all changes are commented

As part of QA activities I need to make sure that all changes between the last tagged code and the proposed code are commented (At least have references to an issue ID). Is there a way of doing this instead of manually looking at diffs? Does anyone has a trick under his/her sleeve? I want to avoid making Code Review obseervations for ...

Code reviews for larger ASP.NET MVC team using TFS

I'm trying to find a good code review workflow for my team. Most questions similar to this on SO revolve around using shelved changes for the review, however I'm curious about how this works for people with larger teams. We usually have 2-3 people working a story (UI person, Domain/Repository person, sometimes DB person). I've recommen...

Using commit monitors as a form of code review

I'm working in a small company - four developers, working on a variety of projects. We've been looking at what we can do as cost-effective methods of process improvement, and an idea came up. Given what we do, we often have single developers working on parts of a system, independently of the other developers. This can have a number of...

Why should i depend on a tool for my code review?

I have done with my web application. Now I am into code review phase. I have looked for some tools for code review in StackOverflow. But my question is: Why should I depend on a tool for my code review? ...

Finding magic numbers using NDepend

Does anyone know how I could find magic numbers in the source code using the CQL queries in NDepend? This is the same problem as this question, but I don't want to use regex if possible. So I want to find all statements like Int32 someValue = 23; Double anotherValue = 1; but not for (int i = 0; i < array.length; i++) ...

Get a list of every value for a given key in a set of dictionaries?

How can I write this code more cleanly/concisely? /// <summary> /// Creates a set of valid URIs. /// </summary> /// <param name="levelVariantURIDicts">A collection of dictionaries of the form: /// dict["filePath"] == theFilePath </param> /// <returns></returns> private ICol...

Find unused import statements in Java source

Does anyone know of a tool (besides Eclipse or any other IDE) that I can use to find unused imports in a Java source file? I am looking for a command-line type of tool (to integrate in a larger script). Thank you. ...

What objects would get defined in a Bridge scoring app (Javascript)

I'm writing a Bridge (card game) scoring application as practice in javascript, and am looking for suggestions on how to set up my objects. I'm pretty new to OO in general, and would love a survey of how and why people would structure a program to do this (the "survey" begets the CW mark. Additionally, I'll happily close this if it's out...

Is this a good interface for persistent state?

I'm developing a game that maintains its information in a class called WorldState. Each GameObject in the world (trees, zombies, the player, health packs, etc) is composed of three objects: GameObjectController, GameObjectModel, and GameObjectView. (These classes may be extended if the GameObject requires additional functionality.) Worl...

c#: Clean way to fit a collection into a multidimensional array?

I have an ICollection<MapNode>. Each MapNode has a Position attribute, which is a Point. I want to sort these points first by Y value, then by X value, and put them in a multidimensional array (MapNode[,]). The collection would look something like this: (30, 20) (20, 20) (20, 30) (30, 10) (30, 30) (20, 10) And the final product: (20...

C#: Specify that a function arg must inherit from one class, and implement an interface?

I'm making a game where each Actor is represented by a GameObjectController. Game Objects that can partake in combat implement ICombatant. How can I specify that arguments to a combat function must inherit from GameObjectController and implement ICombatant? Or does this indicate that my code is structured poorly? public void ComputeAtta...

What's a good desktop-based code review tool?

Is there a desktop-based tool that's used for code reviews or do we just have to print out the code and mark it up by hand? ...

Code review - PHP syntax error unexpected $end

Hey guys! I keep getting a syntax error (unexpected $end), and I've isolated it to this chunk of code. I can't for the life of me see any closure issues. It's probably something obvious but I'm going nutty trying to find it. Would appreciate an additional set of eyes. function generate_pagination( $base_url, $num_items, $per...

Is there a best way to do this Linq query and function?

Im making this method retrieve records from the Data Base. As you can see i Want to return a List where ITieneID is an Interface defined on my business layer. AtlasWFM_Entities.Clases.Area implements that interface. It is pretty clear that this is not a good way to accomplishing it (even though it compiles correctly) public override L...

Initialization of components with interdependencies - possible antipattern?

I'm writing a game that has many components. Many of these are dependent upon one another. When creating them, I often get into catch-22 situations like "WorldState's constructor requires a PathPlanner, but PathPlanner's constructor requires WorldState." Originally, this was less of a problem, because references to everything needed wer...

Where should I exclude and select information BL or DL?

Hi guys; I have another conceptual question. Suppose I have a Data Layer and a Bussines Layer. I have on my data base for example Customers and those customers has an assigned Vendor: Customers(customerID, customerName, customerAddress, vendorID) Vendors(vendorID, vendorName, vendorAddress) Now suppose my Vendor logs into my web appl...

Is there a way to validate the presence of Javadoc and/or inline code comments?

We are trying to put quality code processes in place for a large project I am working on. Right now a lot of developers are not putting in Javadoc or in-line code comments into their code. Ok right now. But it will severely hurt us in the very near future. We are using Maven 2.0.9 as our build tool, as well as Hudson for Continuous In...