patterns-and-practices

What is best practice on how to handle nulls

In you database and/or code. Do you avoid nulls or do you explicitly program to handle them in your logic? What is best practice on how to handle nulls? ...

Best practices for targetting a wide range of devices and screen sizes.

As you know android today is many versions many constructors, many screen sizes,... it's quite difficult for developers today to write programs that targets a big part of devices. What would be THE developer must-know practices for this ? tips for fluid layouts. "standards" for developing on any android version. ... Any other idea...

using wordpress for portfolio and posts

hi i started playing wordpress few months a go and a created a blog http://aurelkurtula.co.uk/blog/?page_id=2 currently there are no posts, but it will look similar to the link above.anyway, now i started to develop a portfolio theme using word-press, (i can only post one link) the two themes are similar, so i was wondering if you co...

Ternary operator in foreach

Hi there. I am currently struggling with about 5 nested if-statements and its becoming quite confusing to look over all of them. So, I thought about adding ternary operators instead of ifs for simple checks, see foreach (String control in controls) { if (!control.Equals(String.Empty)) { // Do some stuff foreach (Int32 someStuff...

When and how should one use project roles instead of groups within JIRA?

I am having a little difficulty understanding when a person should configure JIRA permissions using groups and when they should use project roles. I have read the online documentation, however, the difference between the two seems subtle. A group seems simple enough. Group users into a named bucket. Assign the group to one or more per...

Are QUndoCommands supposed to be tied to a view or a model?

In Qt's undo framework, you can have a stack of QUndoCommand instances. Each of these describes an action in the user interface. In our application, we have a set of views working on a set of models, some in combination, and we often have more than one view working on the same set of models. I'm now looking at the ability to undo acti...

SQL View Question

Are there any negative affects of creating Views, specifically large ones (50+ columns) on the database? ...

Best practice to monitor program life.

Hi guys! I want to hear your opinion about program life monitoring. This is the scenario. You have a simple program which normally works, that means that it's well written, exception are handled and so on. How will you operate if you want to ensure that this program works FOREVER? No external tools like crontab are available, but any...

How to shard existing key-value storage?

Hello, Let's suppose that we have 3Gb key-value storage on server A. I'm starting to feel that we need another server (server B). So, I have to separate server A data over shards (server A, server B), but... All keys on server A currently represented as is (for example, comment_ids:user_id:10). Question #1: What is the best practice to...

Where to find really good code examples

I am a new web programmer and am always looking to improve my knowledge and skills. As such I have read countless times on stackoverflow that a good way to do this is to read other peoples code. This is all fine and well but where can i find some good examples of really well written code? Im thinking specifically php here since this i...

Best practice for a recursive console tool in Python

What is the best practice (interface and implementation) for a command line tool that processes selected files in a directory tree? I give an example that comes to my mind, but I am looking for a 'best practice': flipcase foo.txt foo2.txt could process foo.txt and save the result as foo2.txt. flipcase -rv *.txt could process all ...

Is there a better way to write this named_scope? [Rails]

I am using this named_scope to search for products that have a description matching any word the user inputs. E.g., Product.description_like_any("choc pret") Will return products with names like "Chocolate Bar" "Chocolate Covered Pretzels" "Miniature Chocolate Ponies" Here's the named_scope I've written (which works) named_scope :...

How to handle optional parameters in SQL query?

Hi, guys. Say I have a sample table: id_pk value ------------ 1 a 2 b 3 c And I have a sample PL/SQL block, which has a query that currently selects a single row into an array: declare type t_table is table of myTable%rowtype; n_RequiredId myTable.id_pk%type := 1; t_Output t_table := t_table(); b...

Is it appropriate to use Microsoft.Practices.EnterpriseLibrary.Caching with ASP.NET?

Working on a legacy ASP.NET application we've found that ASP.NET session gets used for caching some objects, but for some objects Microsoft.Practices.EnterpriseLibrary.Caching gets used. Is there any reason to use Microsoft.Practices.EnterpriseLibrary.Caching over standard ASP.NET Session? Edit In my scenario, the Enterprise Library c...

JUnit best-practices - should I split methods for reuse?

Hi, I have the following JUnit test: @Test public final void testDivisors() { testDivisorsAux(1, new int[] { 1 }); testDivisorsAux(6, new int[] { 1, 2, 3, 6 }); testDivisorsAux(0, new int[] { }); ... } private final void testDivisorsAux(final int number, final int[] expected) { List<Integer> divisors = Util.diviso...

Proper order of Documentating, Testing, Coding

Hey all, I suppose this is more of an opinion than right / wrong. But I was wondering how you develop - I personally have tried coding before testing as well as test-driven development, and realized how much nicer test-driven development is, if you can hold your horses. But what I'm wondering is how do you develop? Also where does doc...

How to convince people that a single class with 11975 lines of code is bad? (isn't it?)

I have a dejavu feeling when reading [What to do about a 11000 lines C++ source file?] post, but I don't think I can start taking action on my own since I do not have the authority to take action. So I think the first step is to convince people in the organization that big lump of code is bad. I have a similar situation where there is a...

Best Practices - CSS Theming

Quite often when I design a website for a customer, I design his website with one (or multiple) CSS files that makes up the entire presentation layer. The thing is, usually, the customer's needs change drastically in terms of "website theming". He may end up asking to change from a blue/green color-based theme to a red/orange based one a...

Is it a good practice to have static variables to store global, changing information?

Is it a good OOP practice to have static variables to store global, changing information needed by different classes? as opposed to passing parameters around so that it can be accessed by the called classes. ...

Default value for function paramater?

So I've been doing this for as long as I can remember, but I'm curious if this is really what I should be doing. You write a function that takes a parameter, so you anticipate it to have a value, but if it doesn't, you have a good reason to default it, to say zero. What I currently do is write a helper function: function foo() { retur...