I have a whole slew of database access functions which assume a particular connection string. Within my application I call
myList = DB_MyTable.GetTableItems()
and within GetTableItems() I have something like
Dim connection As SqlConnection = MyDB.GetConnection
So the connection string is in one place in the code, and I call a meth...
This is intended to be more of a discussion than an outright question, hence I've made it community wiki.
When do you choose to break a method into smaller methods.
Say I have a method that has one purpose, i.e. to load a configuration file
public function configure($file){
$info = path_info(file);
$ext = $info['extension'];
...
I am playing with a toy project at home to better understand Test Driven Design. At first things seemed to be going well and I got into the swing of failing tests, code, passing test.
I then came to add a test and realised it would be difficult with my current structure and that furthermore I should split a particular class which had t...
I have a calendar application, and in that calendar application, there is a "mini view" of a calendar. That little widget only displays the days of the currently chosen month and when you click the number it opens a new page and sends GET data to that new page (to display MySQL info, etc.)
The point is: this little mini-calendar doesn'...
Hello, I seem to regularly write jQuery code of a pattern similar to this:
Fade Out ==> Do Something Behind the Scenes ==> Fade In
Illustrated below:
/// <reference path="jquery-1.4.2.js" />
/// <reference path="jquery-1.4.2-vsdoc.js" />
/// <reference path="jquery.validate-vsdoc.js" />
var fade = "slow";
$(document).ready(function ...
Can someone please show me how to do this basic thing using Zend Framework MVC?
I'm looping over the timestamp data and populating my table that way. i don't understand how I would pull my presentation HTML from this loop and stick it in the view? Any help would be greatly appreciated!
<table>
<?php
$day = date("j");
$month = d...
I have 2 methods which have almost the same content:
public string Method1(int someInt)
{
if(someBoolean)
return "test";
if(someOtherBoolean)
{
return "dfjakdsad";
}
else
{
string myStr = getString(someInt)
}
}
public string Method2(myEnum myenum)
{
if(someBoolean)
retu...
I am looking for a way to extract a nested inner class so that it is in a separate file. Is there an easy way to do this in Visual Studio 2008 (eg, using the refactor menu)?
EDIT
Maybe a refactoring menu option isn't necessary if manual refactoring is simple enough.
...
I'm currently working on a local application, which has access to a SQL Server 2008 Express. What I did was create a Class that manages all the access and actions over the database (e.g. INSERT,DELETE,etc) but the class is growing really large, and has at least 40 methods. So my question was: Is there a way to refactor this kind of class...
Hey, I currently have this method in my code:
public static DataSet PrepareDataSet(some params)
{
SqlConnection sqlConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlDataAdapter adapter = new SqlDataAdapter(Utils.EscapeProcedureName(...), sqlConnection);
adapter.SelectCommand.CommandTyp...
I'm principally interested in case studies on code metrics, relating code readability to defect reduction, that justify taking seriously cyclomatic complexity or some similar metric. Wikipedia has this example:
A number of studies have investigated
cyclomatic complexity's correlation to
the number of defects contained in a
mod...
On a related note to this question, which just came up:
I commonly follow the naming convention LibraryClass <-> LibraryClassTests for my unit tests. However, when renaming LibraryClass using the default rename/refactor functionality in either Visual Studio, R# or CodeRush (I have tested both) the test file is not renamed, meaning I mig...
Hi, I'd like to select multiple issues in Inspection Results and fix it automatically. Is there any way to do that?
EDIT:
I strongly encourage to vote for this feature here: http://youtrack.jetbrains.net/issue/RSRP-126551.
...
I must connect from my Rails app to a remote database on a Java application.
I have a query like this:
find_by_sql("select c_templateid, c_templateinfoid, c_startdate, c_enddate, c_active,
campaign, shortcode, prefix, c_descriptivename, c_description, c_templatename
from (active_services aser join activity a on aser.c_primaryprefixid ...
Instead of the normal IDE application icon, Delphi 2009 shows a small icon with a "T" in the "Search for Usages" dialog (see image below). What does this symbol mean?
...
Hi,
Consider that you have "System_A" which is a web application. And System_A has simply 3 layers: UI, BusinessLayer and Data-Layer.
And now you want to make a widespread refactoring of System_A (the UI and BusinessLayer only) meanwhile that is working as a live product.
What should be the safest strategy of refactoring System_A and ...
What is the fastest way to read from STDIN a number of 1000000 characters (integers), and split it into an array of one character integers (not strings) ?
123456 > [1,2,3,4,5,6]
...
I have to dive into a big chunk of legacy ASP code. What ressources would you recommend reading in order to grasp the best practices of this platform (object orientation, configuration for i18n, ..)
...
If I run it. It returns no errors. And in firebug it does in fact select the proper elements in the DOM.
If I break it apart and do something like this :
$('img[hspace]').css('marginLeft', ($('img[hspace]').attr('hspace') / 2) + 'px')
That works.
Here's the monster in its entirety.
$('img[hspace]').each(function(el){
var pixel...
I'm looking to write an efficient n-order Markov chain method to generate random text strings given a set of example text. I currently have a Java implementation that uses several layers of Maps, but it's clunky. A suffix array would be perfect for my needs, but I'm not clear if that can be efficiently implemented in Java.
In C I mig...