Relative Content

Tag Archive for programming-practices

Custom error handling

I’m trying to figure out the best way to handle custom errors in my application.

How to create view models – Constructor, Factory Method, …?

I’m trying to lead a charge for re factoring our rather bloated controllers.
We currently have a BaseModel from which all our other models inherit. The BaseModel contains things common to all pages, such as the page title, css files needed, current user.

Is every number in the code considered a “magic number”?

So every number in the code that we are sending to a method as an argument is considered as a Magic Number?
To me, it shouldn’t. I think if some number is let’s say it is for minimum length of user name and we start using “6” in the code…then yeah we have a maintenance problem and here “6” is a magic number….but if we are calling a method that one of its arguments accept an integer for example as the ith member of a collection and then we pass “0” to that method call, in this case I don’t see that “0” as a magic number.
What do you think?