Все вопросы: [refactoring]

610 вопросов

0
голосов
3ответов
316 просмотров

How to refactor this in J?

Here is a different approach for the Project Euler #1 solution: +/~.(3*i.>.1000%3),5*i.>.1000%5 How to refactor it?

2
голосов
2ответов
353 просмотров

How to refactor this in J?

My newbie solution to Project Euler #1 +/((0=3|1+i.1000-1) +. (0=5|1+i.1000-1)) * (1+i.1000-1) I know that this can be refactored, and transformed into a function, i don't know how to do it, and I would have to read all the labs to learn it.

0
голосов
1ответов
349 просмотров

Revision system - Help improve my code

A section of a site I am building needs some form of revision system and so decided to keep it simple and go with one similar to Stack Overflow. I quickly created the following which works although seems a little messy. I know I can use beforeSave and afterSave but I have no idea how I could im...

1
голосов
2ответов
1542 просмотров

How to best utilize jQuery to programmatically generate HTML elements

I have a bunch of Javascript functions that look like the following: function generateBusinessImage (business) { var business_image = document.createElement('img'); business_image.setAttribute('class','photo'); business_image.alt = business.name; business_image.title = business.name; b...

3
голосов
3ответов
6437 просмотров

File.ReadAllBytes Code Refactoring

I came across this piece of code today: public static byte[] ReadContentFromFile(String filePath) { FileInfo fi = new FileInfo(filePath); long numBytes = fi.Length; byte[] buffer = null; if (numBytes > 0) { try { FileStream fs = new FileStream(f...

3
голосов
1ответов
647 просмотров

Refactoring nasty legacy systems via AOP or other automated means?

I've recently been playing around with PostSharp, and it brought to mind a problem I faced a few years back: A client's developer had produced a web application, but they had not given a lot of thought to how they managed state information - storing it (don't ask me why) statically on the Applica...

0
голосов
1ответов
111 просмотров

Help porting javascript function to jQuery - learning tool

I am just learning jQuery and I wanted to see what I could do with the function below. This function adds or removes css classes to create a pull down menu (it is in fact Stu Nicholl's well known pull down menu). But I'm not getting very far (I've been learning jQuery for approximately an hoour...

0
голосов
1ответов
322 просмотров

WPF XAML namespace refactoring

Consider a ViewModel and a View that uses it, where the DataContext is set to the VM in the code behind file. When they are both at the project namespace, the view runs without exceptions with binding statements along the lines of: ItemsSource="{Binding Path=PrefixFilterChoices}" where Prefi...

1
голосов
9ответов
976 просмотров

PHP echo question?

Do I really need this many echo's or can I make it shorter? <?php if (!empty($url)) { echo '<p>Job: <span>' . $job .'</span></p>'; echo '<p>Skills: <span class="caps">' . $skills . '</span></p>'; echo '<p>Website: <a href="h...

3
голосов
2ответов
205 просмотров

Refactoring tool for Spring.NET

Currently I get to edit a lot of Spring.NET XML files, and I do find this work to quite repetitive and, frankly boring. Most of the stuff I do is sort of 'refactoring' - generalising XML declaration for instances and "inheriting" from those generalised structures to declare more specific ones. ...

7
голосов
1ответов
4655 просмотров

Oracle DB (PL/SQL) Refactoring Tools

I was wondering if there are any good refactoring tools for Oracle databases and especially for PL/SQL. I'm working on a project where half the developers are working with c# and the other half on the db where there is a large and complex schema and a large code base in pl/sql. We also use sql se...

0
голосов
2ответов
1996 просмотров

Help with a Refactoring: Introduce Parameter Object?

I have some code which is the same except that a certain sequence of assignments happen in slightly different orders. It is easy to factor this out into a method parameter of type int[], which denotes the order. However, I find it isn't the clearest. Another option was to factor them out in...

4
голосов
5ответов
391 просмотров

Refactoring and non-refactoring changes as separate check-ins?

Do you intermingle refactoring changes with feature development/bug fixing changes, or do you keep them separate? Large scale refactorings or reformatting of code that can be performed with a tool like Resharper should be kept separate from feature work or bug fixes because it is difficult to do ...

11
голосов
10ответов
1301 просмотров

Should I use Resharper to tidy up other peoples code?

I use Resharper at work. Some of my colleagues do not. When I open some code that has been written someone who doesn't, it is immediately obvious by the amount of orange on my screen. What I am unsure of is to what extent I should feel free to tidy up the messes the have unknowingly left. Wit...

0
голосов
1ответов
145 просмотров

Deciding when nibs should be subdivided in a Cocoa application

Apologies if this has been asked before. I searched and couldn't find it. In my application I have about 10 nib files, most of which hold a single significant view object and a number of subviews/controls. At what point would you consider breaking nibs into pieces? For example in one of my n...

1
голосов
3ответов
299 просмотров

Help finding the deepest Child Control for SpellChecking

I am trying to Refactor this code as it is repeated ad nauseum throughout my program. My problem has to do with the fact that on any given page(tabpage,panel,uc,etc) there are controls at multiple levels to spellcheck. i.e. --> foreach (Control control in tpgSystems.Controls) ...

4
голосов
2ответов
426 просмотров

How to refactor this code?

how can i refactor this code down to one method or something? if (!string.IsNullOrEmpty(_gridModel.Header)) _gridModel.Header += ","; if (item != null) _gridModel.Header += item.Header; if (!string.IsNullOrEmpty(_gridModel.Widt...

2
голосов
5ответов
1018 просмотров

PHP escaping error reporting with @

I am currently refactoring some code for work and I have come across some function calls prefixed by the "@" symbol. As I understand it, this is intended to escape PHP error reporting if the call fails. Is this type of thing good practice? I understand the rationale in a development environment...

3
голосов
6ответов
573 просмотров

How should I refactor a long chain of try-and-catch-wrapped speculative casting operations

I have some C# code that walks XML schemata using the Xml.Schema classes from the .NET framework. The various simple type restrictions are abstracted in the framework as a whole bunch of classes derived from Xml.Schema.XmlSchemaFacet. Unless there is something I've missed, the only way to know wh...

4
голосов
5ответов
1148 просмотров

How can I factor out the code duplication here?

So, I'd like to hear what you all think about this. I have a project where three different inheritance paths need to all implement another base class. This would be multiple inheritance and isn't allowed in C#. I am curious how I can implement this without code duplication. EDIT: I don't own ...

0
голосов
4ответов
68 просмотров

What Jquery Plugin or Extension could I use to construct a query string?

At this moment we construct our search query in our website with java script. We have an input box for keyword and another input box for name and so on. If a user enters keyword: test the query looks like: http://oursite.com/Search?keyword=test if they enter keyword: test and name: john the s...

0
голосов
1ответов
328 просмотров

How to fix and refactor this calculator script in JavaScript / JQuery

I decided to try and learn more JQuery and here is what I have come up with. It should be a simple enough job, but I can't get my head around it. I can add it up, but when I change a package, the price just keeps going up. I know I have to add some logic to decrement the counter, too, but I thi...

2
голосов
2ответов
122 просмотров

Can we make this snippet groovier?

are there any improvements where i can improve this code? Maybe there are some groovy language features? This snippet flattens a xml file to: node/node/node def root = new XmlParser().parse("src/your_xml.xml") root.depthFirst().each { n -> def name = n.name() while(n?.parent()){ ...

1
голосов
6ответов
4463 просмотров

How do I automatically clean up code in C++?

I'm working as a TA in an introductory programming class, and the students tend to submit their programs as either one line, or without any indentation. Is there any tool that allows me to insert indents and things like that automatically? (We're using C++ and VisualStudio)

8
голосов
2ответов
2845 просмотров

How to easyily find unused public methods/properties

I have a .Net(C#) solution. The solution contains bunch of projects. The projects were implemented not by me. It is not a framework, it means that I need to have amount of public methods/properties as less as possible. My task is to identify methods and properties which are not used, but exist in...

1
голосов
1ответов
50 просмотров

Are all Refactorings parameterized?

The question is about refactorings. Consider a rename method refactoring. This refactoring can be visualized as meta-method that takes old and new names, and changes the old method name to the new. so, for refactoring foo() { ......... ......... } to boo() { ......... ......... } the meta m...

6
голосов
6ответов
565 просмотров

Designing Constructors for Testability

I'm working with some existing code, trying to add to it and increase the unit tests for it. But running into some problems with getting the code testable. Original Constructor: public Info() throws Exception { _ServiceProperties = new ServiceProperties(); _SshProperties = new SshProperties...

1
голосов
3ответов
117 просмотров

Asp.net - Refactor action

I have this "problem" that i have code like this in many of my controller actions: var users = new List<SelectListItem>(); foreach(var user in userRepository.GetAll()) { var item = new SelectListItem { Text = user.FriendlyName, Value = user.UserId.ToString() }; if (User.Identity.Name ==...

2
голосов
1ответов
462 просмотров

Refactoring Linq to Sql

Is there a way to refactor linq to sql and take advantage of late evaluation? Is there a way to reuse object initilizer code? I have business objects that are persisted in a database and hydrated via a separate linq to sql layer. I would like to be able to reuse code from multiple queries that...

14
голосов
2ответов
5890 просмотров

Remove unused references (!= usings) in C# project without Resharper?

Is there any way of removing unused references to assemblies, in a C# project, without the help of Resharper? The MSDN documentation does outline something for Visual Basic, but I couldn't find the same dialogs for C#.