0
votes
1answer
59 views

should this code be structured into an event capture and a method or put the functionality in the event capturing

I have adopted some jQuery code that has like 20 event-captures that look like this // used on menu#edit $('.show-headers-only-toggle').on('click',function(){ ...
16
votes
11answers
1k views

Why are we supposed to use short functions to sectionalize our code? [duplicate]

I've seen an increasing trend in the programming world saying that it is good practice to separate code blocks into their own functions. Obviously, if that code block is reusable, you should do that. ...
10
votes
5answers
2k views

Is it considered Pythonic to have multiple classes defined in the same file?

In working with python for the first time, I've found that I end up writing multiple classes in the same file, which is opposed to other languages like Java, which uses one file per class. Usually, ...
2
votes
1answer
1k 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 ...
4
votes
2answers
549 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 ...
5
votes
3answers
498 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 ...
29
votes
10answers
3k views

Are flag variables an absolute evil?

Are flag variables evil? Are the following kind of variables profoundly immoral and is it wicked to use them? "boolean or integer variables that you assign a value in certain places then down ...
3
votes
3answers
438 views

Is there a limit on how many global consts are used before an application is considered bad programming?

Basically, I develop websites, some large with many crud operations, etc... However I've gotten into the habit of storing re-usable data as a constant in my PHP applications I currently have 44 ...
9
votes
2answers
660 views

Unit Testing: “It's a code smell if you're refactoring and there are no collaborators”?

I'm reading The Art of Unit Testing by Roy Osherove. I'm at section 7.2 Writing maintainable tests where the author has this note about code smell: NOTE: When you refactor internal state to be ...
17
votes
5answers
1k views

Is it OK for a function to modify a parameter

We have a data layer that wraps Linq To SQL. In this datalayer we have this method (simplified) int InsertReport(Report report) { db.Reports.InsertOnSubmit(report); db.SubmitChanges(); ...
16
votes
9answers
1k 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 ...
2
votes
4answers
638 views

What code smell best describes this code?

Suppose you have this code in a class: private DataContext _context; public Customer[] GetCustomers() { GetContext(); return _context.Customers.ToArray(); } public Order[] GetOrders() { ...
13
votes
10answers
2k views

About empty line of code

Why do my colleagues hate it when I add an empty line of code? Sometimes I add a few lines to see when a method ends and another one starts more easily.
2
votes
1answer
331 views

Is @staticmethod proliferation a code smell?

Consider a Python class with a number of @staticmethod methods and few instance methods. The static methods don't accept an instance of the defining class as parameters. Do you think that all these ...
8
votes
5answers
376 views

When developing on an old code base, should I use Best Practices or go for Consistency [duplicate]

Possible Duplicate: Code maintenance: keeping a bad pattern when extending new code for being consistent, or not ? As my experience in programming increases with each project, I look back ...
5
votes
6answers
306 views

How to keep a project easy to understand and intutive?

I am working on this project, which will soon contain loads of packages, projects etc. (Java). So, from the start I need to keep track of the high level package and class structure, monitor which ...
21
votes
5answers
2k views

Is code ownership a code smell?

This is something I've been thinking about ever since I read this answer in the controversial programming opinions thread: Your job is to put yourself out of work. When you're writing ...
46
votes
12answers
3k views

If your unit test code “smells” does it really matter?

Usually I just throw my unit tests together using copy and paste and all kind of other bad practices. The unit tests usually end up looking quite ugly, they're full of "code smell," but does this ...
14
votes
6answers
572 views

Do abstractions have to reduce code readability?

A good developer I work with told me recently about some difficulty he had in implementing a feature in some code we had inherited; he said the problem was that the code was difficult to follow. From ...
6
votes
3answers
537 views

Why it is not recommended to have set-only property?

Today at work one of my colleague reviewed my code, and suggested me to remove set-only property and use method insted. As we both were busy with other stuffs, he told me to look at Property Design ...
6
votes
6answers
286 views

Is code maintenance typically a special project, or is it considered part of daily work?

Earlier, I asked to find out which tools are commonly used to monitor methods and code bases, to find out whether the methods have been getting too long. Most of the responses there suggested that, ...
3
votes
9answers
371 views

What tools do you use to let you know that methods in your codebase are getting too long? [closed]

Most people seem to agree that long methods are a code smell - a sign something may not be quite right with the code contained in them. Which tools do you use to detect this smell? clarified title ...
18
votes
9answers
4k views

Is there any reason to use “plain old data” classes?

In legacy code I occasionally see classes that are nothing but wrappers for data. something like: class Bottle { int height; int diameter; Cap capType; getters/setters, maybe a ...
12
votes
8answers
1k views

What was the worst piece of code you fixed that you are proud of? [closed]

I have had a few that I am proud of and some of them were written by myself few years ago. It doesn't have to be necessarily buggy, just bad code.