code-review

Improving a simple JavaScript templating technique

I'm trying to develop a simple way of creating templates in JavaScript. The basic idea is that I've got HTML in a page that represents the UI of an object in JavaScript, and variables in that HTML that are replaced with properties of the JavaScript object. Think of it as technique for binding JavaScript objects to HTML presentations. A...

Reviewing 3rd Party code for security issues

I've been asked to oversee reviewing some 3rd party code (Freeware C# Sharepoint webpart in this case) before its inclusion on a internal corporate network. The big concerns are malicious code hidden in the webpart that will steal data/send information back to the webpart creator/etc, with a secondary concern being it will cause perform...

What to pass? Reference Object or Value Type?

Guys I have a "best practice question" For example I have this classes: class Person { public int age {get; set;} } class Computer { public void checkAge(Person p) // Which one is recommended THIS { // Do smthg with the AGE } public void checkAge(int p) // OR THIS { //Do smthg with the age. } }...

Critique – OO Design Flaws

Recently, I received some negative feedback about the design of a class that I had originally thought to be innovative. After reflection, however, I agree it is clearly more flawed than innovative. This post invited the community to join in the review and provide its thoughtful feedback on the design flaws and identify a fix. Backgr...

Put it or not? Modeling classes from DataBase tables.-

Guys I have another "best practice question" For example I have this tables on my Sql Server: -------------- Table: Client -------------- (PK) clientID long, clientName varchar(50) --------------- Table: Training --------------- (PK) trainingID long, (FK) clientID long, trainingName varchar(50) Now Im us...

Online code review tool with git integration

Hi all, For our dev team we need to conduct code reviews regularly. Our core requirements are: It is hosted somewhere so we don't have to bother with supporting the infrastructure for it It can integrate with our existing git repository It has simple and straightforward work flow: create a code review request based on the differences...

Refactor my ruby anagram solver?

I recently had to write an anagram solver for a job interview. Here is my code. class Anagram def self.resolves?(first_word, second_word) @letter_counts = {} # Assuming that anagrams aren't case sensitive. first_word.downcase! second_word.downcase! count_letters(first_word, 1) count_letters(second_word, -1)...

Inputs for Code Review Workshop.

What all aspects should be considered for conducting a code review workshop? It should be generic and 'C' Language based. Both experienced and junior programmers will form the audience. If a test or hands-on should be included, what can be the format for the same? ...

Generic Singleton<T>

Guys, I have a question, is this the correct approach to make a Generic Singleton? public class Singleton<T> where T : class, new() { private static T instance = null; private Singleton() { } public static T Instancia { get { if (instance == null) ...

Amateur C# Programmer: Code Critique

I did this once before and it was very helpful for me. I am an amateur programmer and don't have more seasoned programmers around me to assist and help me grow. Any feedback on this critique is greatly appreciated! What I've got is a C# class which takes some basic markup from a user (usually from a basic online textbox) and outputs a n...

MySQL: How can I condense this verbose query?

Here is my schema: Suppliers(sid: integer, sname: string, address string) Parts(pid: integer, pname: string, color: string) Catalog(sid: integer, pid: integer, cost: real) Primary keys in bold. Here is the MySQL query I'm working with: -- Find the sids of suppliers who supply every red part or supply every green part. -- this isn't...

Google Codejam 2009 Qualification problem: Watershed in C++

I tried out this Codejam problem and produced a valid solution in C++. There is a Python solution on the website. Was wondering if any C++ people would offer some improvements/optimizations to this solution. Thanks! BTW: In Codejam the goal is to write code as fast as possible (a reason why Python would have been a better language choic...

Code Reviews For offsite offshore and out of timezone developers

We have recently added offshore resources and are having trouble coming up with a successful strategy for core reviews. In the past a developer would grab another developer and walk though there changes while take notes of issues raised. The original developer would then reactor repeat. With our offshore partners we find the process l...

C# XNA: Optimizing Collision Detection?

I'm working on a simple demo for collision detection, which contains only a bunch of objects bouncing around in the window. (The goal is to see how many objects the game can handle at once without dropping frames.) There is gravity, so the objects are either moving or else colliding with a wall. The naive solution was O(n^2): foreach...

Given a number, which interval does it fit in?

I have a 2 sets of intervals, like: xCoords: (0, 60], (60, 120], (120, 180] ... yCoords: (0, 60], (60, 120], (120, 180] ... The size of each interval is guaranteed to be the same, but the size of an xCoord interval doesn't have to be the size of a yCoord interval. (I could make that sacrifice in generality if necessary for optimizatio...

What's wrong with my code?

void GasPump::dispense() { bool cont = true; char stop; do{ cout << "Press any key, or enter to dispense.\n" << "Or press 0 to stop: \n"; cin.get(stop); gasDispensed = gasDispensed + gasDispensedPerCycle; charges = costPerGallon*gasDispensed; displayGasNCharges()...

How to manage huge code changes between developers?

I am working with four developers on a compiler project. Our problem: we have yacc file (about 5000 line of code) , and every one of us has some changes on this big code so we need a method to merge our changes. What do we need to do that? How we can do that? ...

Is there software that can document source code with Rich Text or HTML without modifying the source file?

Is there software that can add rich text or HTML comments to specific lines and sections of text-based source code files without modifying the source file? I am looking to document some HP Basic software and the only program I can find is Microsoft Word. The Review pane allows me to tag comments to specific lines, but Word comments do ...

Google App Engine: How can I DRY this basic request handling?

I'm just getting started with Google App Engine. Currently, my app has two pages: one lists all the inventory currently in stock, and the other is a detail page for a given item. I feel that my coding could be much more DRY. (I'm making all the calls to print headers and footers twice, for instance.) Here is the code. How can I factor o...

code review: Is it subjective or objective(quantifiable) ?

I am putting together some guidelines for code reviews. We do not have one formal process yet, and trying to formalize it. And our team is geographically distributed We are using TFS for source control (used it for tasks/bug tracking/project management as well, but migrated that to JIRA) with VS2008 for development. What are the things...