The tag has no wiki summary.

learn more… | top users | synonyms

2
votes
2answers
56 views

Method for all objects for checking conditions which also includes method chaining and avoiding variables

(I am currently using groovy but it should apply to most OO languages so I also put the langauge-agnostic tag) I try to program in a function style which also includes method chaining and avoiding ...
0
votes
1answer
46 views

Pretty splitting of lines?

<?php if (in_array(exec("pboxsvc pboxlib.bin DeterminarTipoSpool' $idJob"), ['IPP','PSFORM','PBSSFORM','PDF'])): ?> How would you refactor that line to be ...
0
votes
1answer
80 views

More appropriate to validate a dependency filter parameter by mock+stub or by expression compile?

My lead is enforcing TDD on our project. He says he's following Uncle Bob (Robert Martin) and SOLID principles. One of the rules he's reinforcing is what I call "the single cog rule"--there should be ...
0
votes
2answers
196 views

How to avoid spaghetti code when I have a lot of conditions? [duplicate]

I have the following problem: An user can withdraw money from 2 payment systems (but the number of payment systems can change anytime in the future). If user has a trusted account on either of ...
0
votes
2answers
76 views

How to improve code that has to handle list-objects in general and special cases?

I do have an implementation issue that I condensed to the following code snippet, because the real code is much more complicated. The core problem is that I do have a container object that has a mixed ...
2
votes
1answer
68 views

Erlang function naming conventions

I understand the general Erlang conventions for functions are using snake case or camel case, but what about exported functions? For example, say I have a gen_server module that defines a check to ...
-3
votes
0answers
29 views

How do you tidy up and maintain your code in JavaScript (jQuery)? [duplicate]

How do you tidy up and maintain your code in JavaScript (jQuery) while keeping it simple? I've been wanting to ask this for a while now but I never get around to it so I usually use websites like ...
8
votes
3answers
669 views

Clean Code and Hybrid Objects and Feature Envy

So I recently made some major refactorings to my code. One of the main things I tried to do was split out my classes into data objects and worker objects. This was inspired, among other things, by ...
0
votes
1answer
53 views

How to keep class parameters visible while using generic argument passing

After writing some classes where class initialization requires multiple options, instead of writing several parameters into constructors or setters, I started passing an associative array of ...
1
vote
1answer
259 views

Complexity vs simplicity? [closed]

Been a developer for over 7 years already. Not sure if I might be called a senior, but know one or two things. Last night was trying to solve some issues with Mockito and InjectMocks, and dig into ...
0
votes
5answers
217 views

Breaking a function into smaller ones is great… except for what about code-folding? [duplicate]

I'm currently reading Robert Martin's Clean Code book. So far I'm enjoying it. Martin talks a lot about separating long functions into short functions, each doing exactly one thing at one level of ...
15
votes
16answers
1k views

Do else blocks increase code complexity? [closed]

Here is a very simplified example. This isn't necessarily a language-specific question, and I ask that you ignore the many other ways the function can be written, and changes that can be made to it.. ...
0
votes
0answers
70 views

Better and cleanest way to bind a ICommand to a RelayCommand

By reading various source code, I see that there is different ways of binding an ICommand to a RelayCommand : From the constructor MyAwesomeViewModel() { this._fooCommand = new ...
8
votes
2answers
371 views

Applying the principles of Clean Code to functional languages

I'm currently reading Robert Martin's Clean Code. I think it's great, and when writing OO code I'm taking his lessons to heart. In particular, I think his advice to use small functions with meaningful ...
1
vote
2answers
182 views

How to know whether to create a general system or to hack a solution

I'm new to coding , learning it since last year actually. One of my worst habits is the following: Often I'm trying to create a solution that is too big , too complex and doesn't achieve what needs ...
3
votes
2answers
193 views

Should accessible members of an internal class be internal too?

I'm designing a set of APIs for some applications I'm working on. I want to keep the code style consistent in all the classes I write but I've found that there are a few inconsistencies that I'm ...
1
vote
0answers
71 views

MVC Controller - keeping methods small

I'm reading uncle Bob's Clean Code and it completely revolutionizes my programming style. In this book author claims that best methods are small methods. What about controller's action methods in ...
36
votes
14answers
5k views

How important is it to clean up someone else's code when faced with a tight deadline? [closed]

(I'm talking about HTML / CSS code (not programming languages) but I think we also face the same issue as with programmers.) I am the senior front-end designer in a team and I often have to re-work ...
1
vote
1answer
188 views

Equal or less than 15 lines per method(function) principle? [duplicate]

Some books or master told us this principle: Equal or less than 15 lines per method(function), and the perfect is under(or equal) 8 lines. Does the principle make sense for most conditions? There ...
6
votes
4answers
583 views

How do I introduce clean code?

My team has about 18 members and the code is generally good, using TDD and good specifications makes for working code. But I think they abuse comments in favor of writing cleaner, more readable code. ...
7
votes
2answers
277 views

How to hide AOP implementation dependency without breaking encapsulation?

I have the concept of a SlowLoading thing: public interface SlowLoading { boolean hasLoaded(); } I also have a component MyComponent: public interface myComponent{ void doSomething(); } My ...
2
votes
1answer
164 views

Will this “wireless” syntax for my framework make for good code structure / design?

I'm at the point where I'm getting into the freelance development of some complex web apps, and I would like to develop a light weight framework for my personal use, but I'd like to get some advice ...
0
votes
2answers
355 views

Can this code be made more concise? [closed]

I came across some code recently where in many, many places, expression evaluations were being assigned to different arrays one index at a time. A psuedo-code example: array[0] = item1[0] + item2[0]; ...
0
votes
1answer
58 views

Matching the superclass's constructor's parameter list, is treating a null default value as a non-null value within a constructor a violation of LSP? [duplicate]

I kind of ran into this when messing around with FlashPunk, and I'm going to use it as an example. Essentially the main sprite class is pretty much class Entity. Entity's constructor has four ...
2
votes
4answers
250 views

Is it normal needing time to understand code I wrote recently [closed]

By recently I mean some weeks ago. I am trying to continue a project I left 2 weeks ago and I need time to understand some functions I wrote (not copied from somewhere) and it takes me time. Normally ...
2
votes
1answer
155 views

How to handle passing multiple dependencies in a module hierarchy

So I have my application consisting of a number of modules in a module hierarchy. Furthermore let's also assume each module is a class and we have a tree of classes where the classes at the top are ...
0
votes
0answers
57 views

Import data and modify

I should build an importer in PHP. So below you can see how it should work or how it currently works. This is only a small example, the real importer is much bigger so the import() method is also ...
2
votes
1answer
239 views

Why does Java support brackets behind variables and even behind method signatures? [closed]

Java allows this: class X{ int i,j[]; // j is an array, i is not } and even worse, it allows this: class X{ int foo(String bar)[][][] // foo actually returns int[][][] { return null; } ...
3
votes
5answers
780 views

How should I handle exception that *should* never be thrown? [duplicate]

What is the best way to handle errors that shouldn't ever happen? My current way to do this is to throw an exception if the 'thing that shouldn't happen' does happen, like so: /* * Restoring from a ...
21
votes
18answers
2k views

Why write clean, refactored code? [duplicate]

This is a question I've been asking myself for a long time. Thought of throwing out it to you. From my experience of working on several Java based projects, I've seen tons of codes which we call ...
1
vote
2answers
287 views

ID properties on Domain objects in DDD

In my domain I have an Account object. e.g. class Account { public string Number; public string SortCode; } Within the context of DDD, should this account object have an ID property? The ...
4
votes
4answers
335 views

How to avoid excessive method overloading?

We have quite a lot of places in the source code of our application , where one class has many methods with same names and different parameters. Those methods always have all the parameters of a ...
21
votes
6answers
1k views

How do I prevent unknowningly duplicating code?

I work on a rather large code base. Hundreds of classes, tons of different files, lots of functionality, takes more than 15 minutes to pull down a fresh copy, etc. A big problem with such a large ...
6
votes
3answers
227 views

Dependency Injection vs Mixing Levels of Abstraction

I've been reading Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin. One point he makes: G34 Functions should descend only one level of abstraction However, I'm ...
3
votes
2answers
205 views

How to use the Decorator pattern to add little functionality to big objects?

This question regards the usage of the Decorator pattern to add little functionality to objects of large classes. Following the classic Decorator pattern, please consider the following class ...
1
vote
1answer
152 views

Further decoupling using static libraries

I've been thinking for a while about reasons that prevent a lot of programmers — myself first of all — from writing clean, modular and expressive code while developing, for example, CocoaTouch apps. ...
4
votes
4answers
374 views

Choosing value in SQL query vs (Java) code

I need to choose one of three values of an integer using the value of a column on a nullable column of a table. There are at least two approaches: 1) use SQL to do all the work: test null values, and ...
2
votes
2answers
570 views

“Clean Code”: How to organize named queries?

Few days ago I started to read Robert C. Martin "Clean Code" book and it encouraged me to look more detailed at my code. After I opened eclipse I saw this: ...
0
votes
1answer
269 views

The user interface in a clean architecture with client / server model [closed]

I have been reading (and watching presentations) about subjects like: DDD, TDD, BDD, SOLID (principles), design patterns, clean code, clean architecture, agile project methodologies. All in all I ...
9
votes
5answers
618 views

Can a pure-functional solution to this problem be as clean as the imperative?

I have an exercise in Python as follows: a polynomial is given as a tuple of coefficients such that the powers are determined by the indexes, e.g.: (9,7,5) means 9 + 7*x + 5*x^2 write a function to ...
5
votes
2answers
131 views

Should more than one function be used when they do similar, but not identical things?

For example, if I wanted to generate some HTML based on some input. Which is the preferred way out of: <?php function generate_html($type, $input){ switch($type){ case 'paragraph': ...
7
votes
4answers
411 views

What are good ways of balancing informative exceptions and clean code?

With our public SDK, we tend to want to give very informative messages about why an exception occurs. For example: if (interfaceInstance == null) { string errMsg = string.Format( ...
3
votes
3answers
926 views

Ordering if conditions for efficiency and clean code [closed]

This is purely a design question and the example is simple to illustrate what I am asking and there are too many permutations of more complex code to provide examples that would cover the topic. I am ...
107
votes
11answers
35k views

Why is Clean Code suggesting avoiding protected variables?

Clean Code suggests avoiding protected variables in the "Vertical Distance" section of the "Formatting" chapter: Concepts that are closely related should be kept vertically close to each other. ...
5
votes
2answers
662 views

Are “Clean Code” practices really that clean and useful? [closed]

I am currently doing an internship in a large corporation and they are undergoing many changes in software delivery structure (moving to Agile). In the past couple of months I have noticed this ...
0
votes
1answer
299 views

Good fix vs Quick fix [duplicate]

Let's start from this principle: quality is a feature that you can't add to a project in the middle of the development process. This is the scenario: two weeks to go live with my project and, one of ...
1
vote
1answer
142 views

Validating data to nest if or not within try and catch

I am validating data, in this case I want one of three ints. I am asking this question, as it is the fundamental principle I'm interested in. This is a basic example, but I am developing best ...
1
vote
1answer
128 views

Writing arguments in constructors

When creating constructors with multiple arguments, is ok to use the generic String[] args or is it better to list the arguments? Does it really make any significant difference as the coding becomes ...
1
vote
2answers
91 views

Whether to separate out methods or not

I am new to java and want to learn best coding practices and understand why one method is better than another, in terms of efficiency and as the coding becomes more complicated. This is just an ...
78
votes
23answers
7k views

Is fewer lines of code always better? [closed]

Which of these programming styles is better? var result = methodOne(methodTwo(a, methodThree(b)), c, d); or var result3 = methodThree(b); var result2 = methodTwo(a, result3); var result = ...