I'm new to javascript and was trying to refactor some code, clearly there's something I'm missing in javascript that I'd like to learn. This code produces a value once all 5 list boxes have something selected:
function GetTotal() {
//_listSeverity = document.getElementById("_listSeverity");
function ParseListBoxvalue(lis...
Can this be refactored into one LINQ statement? I feel like it can be but can't wrap my head around it. The mishmash of extension methods and LINQ just looks ugly to me.
(db is a DataContext.)
void AddToSeries(Series series, DateTime date)
{
foreach (var date in db.Ad.Select(ad => ad.DateTime.Date).Distinct())
{
var ph...
I program ActionScript for the FlashPlayer. This means compiling a set of ActionScript files into a SWF file (a bunch of bytecode that gets executed by the FlashPlayer in your browser). Anything that is not compiled into the SWF file must be requested. Examples of this would include ANY textual content, media, or graphical content that w...
I've recently seen some code similar to that outlined below.
public void someMethod() {
Lecture lect = createLecture();
...
lect.getLectureSeries().delete();
}
public Lecture createLecture() {
LectureSeries series = new Series();
Lecture lect = new Lecture(series);
...
return lect;
}
The point being that some objec...
What are the good ways to handle complicated business logic that from the first glance requires many nested if statements?
Example:
Discount Coupon. could be:
1a) Value discount
1b) Percentage discount
2a) Normal discount
2b) Progressive discount
3a) Requires access coupon
3b) Do not require access coupon
4a) Applied only to the ...
Hi. Is there a way I could point an Enum to another Enum? Here are the needs and details:
Currently:
I have a two public classes com.abcd.MyManager and com.abcd.data.MyObject.
MyObject class have pretty much everything is private except Types enum member.
MyManager class uses MyObject class
Notice MyObject class lives in a separate n...
so I have inherited an Access DB with different naming conventions applied to tables. It hurts my eyes, and I want to refactor. Code isn't a problem, but what about SQL embedded in the queries?
Going to answer my own question crudely now, but can anyone come up with a better method?
...
Hi guys:
I have been using ReSharper from before Visual Studio added Refactor. Then, it was inevitable to use ReSharper. Now that Visual Studio includes a few Refactor functions, I get to do projects where the client can do without paying for the ReSharper licence.
My problem is that I am so used to the ReSharper keymap that switching...
I am writing a simple XML file parser using LINQ to XML.
I want to have a TreeNode object (i.e a simple Tree structure) for each element in the XML. I want each element to be strongly typed.
It looks ugly and redundant compared to the simple looping approach I was using before (using System.XML). Is there a way to strip out the redund...
This seems to come up alot in my code, i'm wondering if there is some way of removing the switch statement, or if there is a more elegant way of doing it?
public class MetaData
{
public string AlbumArtist { get; set; }
public string AlbumTitle { get; set; }
public string Year { get; set; }
public string SongTitle { g...
These two functions have basically the same code. How can I factor it out?
public static String[] removeSuffix(String gA, String gB) {
String[] results = new String[2];
results[0] = gA;
results[1] = gB;
if (gA.equals("") || gB.equals("")) {
return results;
}
if (gA.charAt(gA.length() - 1) == gB.cha...
Hi,
I'm just starting to refactor my spaghetti code in xcode. I do the following:
select my class name in the header file
choose Refactor from the menu
pick "Create superclass of" from the dropdown
type in my superclass name
hit Preview
Then I get this big ugly error popup:
"Can't find @implementation for class 'MyUglyClass'"
... a...
I have a file - in a large legacy codebase - containing methods that access databases.
No classes are used, just a header file with the method declarations, and the source file with the implementation.
I want to override these methods to eliminate the DB access during unit testing.
I thought of the following options:
Make file into c...
I have a Perl codebase, and there are a lot of redundant functions and they are spread across many files.
Is there a convenient way to identify those redundant functions in the codebase?
Is there any simple tool that can verify my codebase for this?
...
I feel like there has to be a cleaner way to do somthing like this. I have 15 or so objects that list out with three on a row. Anyone know a better solutions.
<ul>
{% for object in object_list %}
<li
{% ifequal forloop.counter 1 %}class="first"{% endifequal %}
{% ifequal forloop.counter 4 %}class=...
I have an existing code base that is not packaged at all.
The code base is all minor Java programs designed to extend/enhance the functionality of a third party program. The current process is one jar per class, one class per file, no package.
I'd like to break out the code-base so each jar file is also a package; this eases my jar pro...
**EDIT: There are several options below that would work. Please vote/comment according to your views on the matter.
I'm working on cleaning up and adding functionality to a c# method with the following basic structure:
public void processStuff()
{
Status returnStatus = Status.Success;
try
{
...
Here is what I mean:
I need to be able to substitute this ugly looking C# code:
if (attribute.Name == "Name") machinePool.Name = attribute.Value;
else if (attribute.Name == "Capabilities") machinePool.Capabilities = attribute.Value;
else if (attribute.Name == "FillFactor") machinePool.FillFactor = attribute.Value;
into something like...
Hi All.
It's well known fact that hibernate work with indexes in a very strange way. It generate them only if you create a database schema from the scratch. But if you try to update the database schema hibernate will ignore new indexes.
My question is, does anybody find a solution how to ask hibernate generate SQL for new indexes durin...
I have a set of objects I'd like to do some operations on, in the order they're iterated. After that operation gets called on them, I'd like to perform other operations on them. Basically, the code will look sort of like this:
for(int i = 0;i < myobj.size();i++)
{
myobj.at(i).doSomething();
}
for(int i = 0;i < myobj.size();i++)
{
...