patterns-and-practices

Best approach for passing passwords to command line applications

What do you thing it will be the optimal method of passing passwords to different applications. Giving the password as a command line argument is not acceptable because this will be visible in logs - especially in an automation system. At this moment I'm considering two possibilities: providing the password in a file or temporary setti...

Group functions of similar functionality

Sometimes I come across this problem where you have a set of functions that obviously belong to the same group. Those functions are needed at several places, and often together. To give a specific example: consider the filemtime, fileatime and filectime functions. They all provide a similar functionality. If you are building something l...

Best practices for huge volumes of data load/unload?

My question applies to ETL scenarios, where transformation is performed outside of database (completely). If you were to Extract, Transform, and Load huge volumes of data (20+ million records or more) and the databases involved are : Oracle and MSSQL Server, what would be the best way to: Effectively read from the source database : I...

Design pattern for handling many parameters and business rules

I am working on a project that is responsible for creating a "job" which is composed of one or more "tasks" which are persisted to a database through a DAL. The job and task columns are composed of values that are set according to business rules. The class, as it exists now, is getting complicated and unwieldy because the business rules...

Recommended approach to merging two tables

I have a database schema like this: [Patients] [Referrals] | | [PatientInsuranceCarriers] [ReferralInsuranceCarriers] \ / [InsuranceCarriers] PatientInsuranceCarriers and ReferralInsuranceCarriers are identical, except for the fac...

Best practice for exposing multiple client-specific endpoints in a WCF service?

Moving forward with re-designing a web service architecture using WCF, our team has been discussing how we want to expose the endpoints. Example: I have a standard endpoint that all users could use with the proper token, but I also have some number of endpoints that will instead use certificate security. All endpoints will ultimately use...

Another way to use continue keyword in C++

Recently we found a "good way" to comment out lines of code by using continue: for(int i=0; i<MAX_NUM; i++){ .... .... //--> about 30 lines of code continue; ....//--> there is about 30 lines of code after continue .... } I scratch my head by asking why the previous developer put the continue keyword inside the intensive loo...

How and when to properly use *this pointer and argument matching?

When I go thru the code written by collegue, in certain place, they use: this->doSomething(); //-->case A doSomething(); //-->case B In fact I'm not sure about the great usage of *this pointer...:( Another question with argument matching: obj.doOperation(); //-->case C (&obj)->doOperation(); //-->case D In fact both cases are per...

When to sacrifice backwards compatibility?

Basically I am wondering about having this behavior in an app where the newer versions require the content created with the older version to be (automatically) converted to the newer version format, at the cost of backwards compatibility. Visual Studio does this for its .sln files. Are there any pros/cons to this practice? I guess in ...

Is it a bad practice to use the name of a type for a member function or variable?

If the answer is yes, can you tell me why? here is an example: namespace urx { struct reserved { }; struct side { urx::reserved reserved() { /*...*/ } }; } int main() { urx::side side; side.reserved(); } reserved is used for both a type name and a function name. side is used for both a type name and a variable name. b...

Call method directly, or Raise event to call the method (event handler)?

I just bumped into some kind of code and got quite a bit of shock: Code snippet 1: Class ABC Private Event Event123() Private Function ParentMethod() RaiseEvent Event123() End function Private Function ChildMethod() Handles Event123 ... code here End function End class (Note the functions and eve...

Nested(deep) iteration for loops ? Good or Bad Practice?

Hi All, I wanted to ask, If writing nested(deep) iteration loops (as shown in example) a bad practice (in OOPs)? For example : If i want to zip all files that in all Workspaces. Given example classes are Workspace, Project , File please ignore avoid syntax errors for each Workspace workspace in WorkSpaces { Pro...

Is there any good guide for gui programming?

Hi I am a web developer, writing complex widgets and managing their flow, sometimes I feel that I need to know some patterns and practices in GUI programming in general. I am aware of observer pattern, command pattern etc. But I want to know something more ... wondering how "facebook" manages their widgets controls. Suppose i will go thr...

For locale-sensitive functions, is it more common to pass the std::locale or the needed facet object(s)?

Recently I wrote a family of functions for trimming leading and trailing whitespace off of an input string. As the concept of "whitespace" is locale-dependent, I realized that I would need to either pass in a const std::ctype<char_t> reference or a const std::locale reference and call std::use_facet<std::ctype<char_t> > on the const std:...

Sorting results by 'most relevent' - MYSQL & PHP

I've never really considered this question before and wondered if anyone has any advice or input on best practices for achieving 'relevent results'. In my case I'm running a search query that includes full text searching across 5 fields, a geographic radial lookup and a number of basic comparisons. I can prioritise the fields I'm most ...

What is this type of copy called and is it bad pratice?

Shallow copy is when i write new List<List<ClassA>>(lsA) which just copies the member ls. So shallow copies the first list while the inner list is not. Since MyList has access to each T being put in (which its just piping through with C#'s List in this example) it can do a shallow copy each of those. So now all the members of MyList is b...

What is the name of this pattern or technique?

There are objects which need two other objects as parameters. This parameter objects may change during runtime. I use another object which holds the references to the parameter objects. These references are always up to date. All the other objects ask this objects for the current parameters. They don't have to be updated anymore. Onl...

How best to associate an Address to multiple models in rails?

This question on SO appears to be related to my question, but I'm not sure my question is answered by that. An address can belong to more than one model (UserProfile and Event) What's the correct way to implement this? The basic tables: user_profiles(id) events(id) Options for implementing the addresses table: addresses(id,user_pro...

Composite pattern in Swing

This is basically a architectural question. I want to implement composite pattern in handling Swing components; that is, I want to combine several components with their listeners and logic behind a single component for easier handling. Consider for example a simple directory browser; say, a JTree in JScrollPane with some logic which ha...

Running identical code on 2 objects

I have a test script that does something to one object then the same thing to a second object. This continues for quite a while. With so much predictable repetition that it seems ripe for automation but I can't figure out how. I wouldn't care so much except with so much repetition, it's easy to overlook using the wrong variable (ie: stag...