Tag Info

New answers tagged

1

Ask yourself honestly why you want to refactor. That's really important. then think what you're doing at your company - are you hired to write nice code, or to create good product. I think too many developers get so caught up in the minutiae of the codebase that they forget what they're supposed to be doing - which is making something useful out of it. Its ...


0

I admit, I love refactoring code - but chose wisely what to refactor and why. Will the user of your code clearly benefit from the rewritten code? Will the user demand this new functional style code, or is it just a developer thing, to try coding with a different style? If there is no benefit for the user at all, except the code is now looking "nice", who is ...


1

You have a lot of duplicate code here, which defeats the DRY principle. This would be better: private function arrangeElementsLine(pElementSize:Dimensions):void { for (var i:uint = 0; i < target.numElements; i++) { var layoutElement:ILayoutElement = target.getElementAt(i); layoutElement.setLayoutBoundsSize(pElementSize.x, ...


0

I would go with negative logic. Well, you have something here... The issue is not with the ability to read it in a given language but in the process beneath. Going "negative logic" simplifies the process. If you have a single layered condition then the benefits are to be drawn from the names of the procedures, like isValid, isFound, as you pointed out. ...


1

I believe this is nothing but a matter of style - no "measure of readability" (which is always personal) can help you here. So before I go any further, let me say this: Whatever the style choice, if you're working in a team, define a clear standard that the whole team must comply with, because if there is one thing that everyone can agree on that makes ...


-1

In the specific example given this would work: if ( abs( foo() - 1.5 ) == 0.5 ) This works for two number values, but for the obvious reasons is not very easy to generalise


0

I'm going to take a different tact. Consistency in development is one of the most important features of software design, it's a critical tool in making applications extensible and maintainable but can be difficult to achieve when managing a team across multiple sites, languages and timezones. If achieved, consistency makes code much more accessible "once ...


3

There is nothing like that in PHP, however you can go for something like this -- even tho I'm not really recommending it: if ( in_array(foo(), array(1, 2), true) ) ... Please note that it's not gonna work on && conditions and you're limited only to == and ===.


0

Do as Defenestrator suggested, in leaving a blank line between the class declaration and the first member and also give a comment end braces: class ThisIsAClass { public void thisIsAFunction { // Do stuff }// end thisIsAFunction }// end class ThisIsAClass


3

Try setting a tab equal to two spaces. It cuts back on whitespace by a factor of 2.5x, yet it provides more than enough visual feedback.


1

You could leave a blank line between the class declaration and the class body, with the bracket at the end of the line, like so: class ThisIsAClass { public void thisIsAFunction { // Do stuff } }



Top 50 recent answers are included