Tagged Questions
2
votes
1answer
99 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
436 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
431 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 ...
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 ...
3
votes
3answers
362 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 ...
8
votes
2answers
440 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
987 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();
...
15
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
3answers
416 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()
{
...
12
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
282 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
326 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
267 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 ...
14
votes
5answers
946 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. And it has been discussed a bit in other threads, such as this one, but I ...
43
votes
12answers
2k 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 ...